本文整理汇总了C++中IMIN函数的典型用法代码示例。如果您正苦于以下问题:C++ IMIN函数的具体用法?C++ IMIN怎么用?C++ IMIN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IMIN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ec_laplace_encode
void ec_laplace_encode(ec_enc * enc, int *value, unsigned fs, int decay)
{
unsigned fl;
int val = *value;
fl = 0;
if (val) {
int s;
int i;
s = -(val < 0);
val = (val + s) ^ s;
fl = fs;
fs = ec_laplace_get_freq1(fs, decay);
/* Search the decaying part of the PDF. */
for (i = 1; fs > 0 && i < val; i++) {
fs *= 2;
fl += fs + 2 * LAPLACE_MINP;
fs = (fs * (int32_t) decay) >> 15;
}
/* Everything beyond that has probability LAPLACE_MINP. */
if (!fs) {
int di;
int ndi_max;
ndi_max =
(32768 - fl + LAPLACE_MINP - 1) >> LAPLACE_LOG_MINP;
ndi_max = (ndi_max - s) >> 1;
di = IMIN(val - i, ndi_max - 1);
fl += (2 * di + 1 + s) * LAPLACE_MINP;
fs = IMIN(LAPLACE_MINP, 32768 - fl);
*value = (i + di + s) ^ s;
} else {
示例2: GMRFLib_ged_remove
/**
\brief Add a node or an edge from an editable graph-object
\param[in,out] ged The editable graph-object.
\param[in] node First node
\param[in] nnode Second node
If \a node is different from \a nnode, then add the edge between \a node and \a nnode, and create node \a node and node \a
nnode if they do not exists. If \a node equals \a nnode, then add node \a node itself.
\sa GMRFLib_ged_remove(), GMRFLib_ged_append_node(), GMRFLib_ged_append_graph()
*/
int GMRFLib_ged_add(GMRFLib_ged_tp * ged, int node, int nnode)
{
/*
* add edge between node and nnode. add 'node' or 'nnode' to the set if not already present
*/
if (node == nnode) {
spmatrix_set(&(ged->Q), node, node, 1.0);
/*
* workaround for internal ``bug'' in hash.c
*/
spmatrix_value(&(ged->Q), node, node);
} else {
spmatrix_set(&(ged->Q), IMIN(node, nnode), IMAX(node, nnode), 1.0);
spmatrix_set(&(ged->Q), node, node, 1.0);
spmatrix_set(&(ged->Q), nnode, nnode, 1.0);
/*
* workaround for internal ``bug'' in hash.c
*/
spmatrix_value(&(ged->Q), IMIN(node, nnode), IMAX(node, nnode));
spmatrix_value(&(ged->Q), node, node);
spmatrix_value(&(ged->Q), nnode, nnode);
}
ged->max_node = IMAX(ged->max_node, IMAX(node, nnode));
return GMRFLib_SUCCESS;
}
示例3: run_analysis
void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, const void *analysis_pcm,
int analysis_frame_size, int frame_size, int c1, int c2, int C, opus_int32 Fs,
int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info)
{
int offset;
int pcm_len;
if (analysis_pcm != NULL)
{
/* Avoid overflow/wrap-around of the analysis buffer */
analysis_frame_size = IMIN((DETECT_SIZE-5)*Fs/100, analysis_frame_size);
pcm_len = analysis_frame_size - analysis->analysis_offset;
offset = analysis->analysis_offset;
do {
tonality_analysis(analysis, NULL, celt_mode, analysis_pcm, IMIN(480, pcm_len), offset, c1, c2, C, lsb_depth, downmix);
offset += 480;
pcm_len -= 480;
} while (pcm_len>0);
analysis->analysis_offset = analysis_frame_size;
analysis->analysis_offset -= frame_size;
}
analysis_info->valid = 0;
tonality_get_info(analysis, analysis_info, frame_size);
}
示例4: smooth
void smooth (float **in, float **out, long naxes[], float sigma, float radius)
{
int i, j, k, l, xmin, ymin, xmax, ymax;
float sumwt, sumflux, wt, rad;
for (j=1; j <= naxes[2]; j++) {
for (i=1; i <= naxes[1]; i++) {
xmin = IMAX (1, i - NINT(radius));
xmax = IMIN (i+NINT(radius), naxes[1]);
ymin = IMAX (1, j - NINT(radius));
ymax = IMIN (j+NINT(radius), naxes[2]);
sumwt = 0.;
sumflux = 0.;
for (l=ymin; l <= ymax; l++) {
for (k=xmin; k <= xmax; k++) {
rad = sqrt((k-i)*(k-i)+(l-j)*(l-j));
if (rad <= radius) {
wt = exp (-rad*rad/2/sigma/sigma);
sumwt += wt;
sumflux += in[l][k] * wt;
};
};
};
out[j][i] = sumflux / sumwt;
};
};
}
示例5: grab_pointer_position
void grab_pointer_position(int *src_x, int *src_y, int *width, int *height)
{
int dest_x, dest_y;
createWindow();
removeTile();
show_forever();
show_toplevel();
changeCursor(dpy, win);
showWindow();
window_main_loop(src_x, src_y, &dest_x, &dest_y);
*width = IMAX(*src_x, dest_x) - IMIN(*src_x, dest_x);
*height = IMAX(*src_y, dest_y) - IMIN(*src_y, dest_y);
}
示例6: fs_init
static void
fs_init (VisualFX * _this, PluginInfo * info)
{
FSData *data;
data = (FSData *) malloc (sizeof (FSData));
data->fx_mode = FIREWORKS_FX;
data->maxStars = 4096;
data->stars = (Star *) malloc (data->maxStars * sizeof (Star));
data->nbStars = 0;
data->max_age_p = secure_i_param ("Fireworks Smallest Bombs");
IVAL (data->max_age_p) = 80;
IMIN (data->max_age_p) = 0;
IMAX (data->max_age_p) = 100;
ISTEP (data->max_age_p) = 1;
data->min_age_p = secure_i_param ("Fireworks Largest Bombs");
IVAL (data->min_age_p) = 99;
IMIN (data->min_age_p) = 0;
IMAX (data->min_age_p) = 100;
ISTEP (data->min_age_p) = 1;
data->nbStars_limit_p = secure_i_param ("Max Number of Particules");
IVAL (data->nbStars_limit_p) = 512;
IMIN (data->nbStars_limit_p) = 0;
IMAX (data->nbStars_limit_p) = data->maxStars;
ISTEP (data->nbStars_limit_p) = 64;
data->fx_mode_p = secure_i_param ("FX Mode");
IVAL (data->fx_mode_p) = data->fx_mode;
IMIN (data->fx_mode_p) = 1;
IMAX (data->fx_mode_p) = 3;
ISTEP (data->fx_mode_p) = 1;
data->nbStars_p = secure_f_feedback ("Number of Particules (% of Max)");
data->params = plugin_parameters ("Particule System", 7);
data->params.params[0] = &data->fx_mode_p;
data->params.params[1] = &data->nbStars_limit_p;
data->params.params[2] = 0;
data->params.params[3] = &data->min_age_p;
data->params.params[4] = &data->max_age_p;
data->params.params[5] = 0;
data->params.params[6] = &data->nbStars_p;
_this->params = &data->params;
_this->fx_data = (void *) data;
}
示例7: mpsqrt
void mpsqrt(unsigned char w[], unsigned char u[], unsigned char v[], int n,
int m)
{
void mplsh(unsigned char u[], int n);
void mpmov(unsigned char u[], unsigned char v[], int n);
void mpmul(unsigned char w[], unsigned char u[], unsigned char v[], int n,
int m);
void mpneg(unsigned char u[], int n);
void mpsdv(unsigned char w[], unsigned char u[], int n, int iv, int *ir);
int i,ir,j,mm;
float fu,fv;
unsigned char *r,*s;
r=cvector(1,n<<1);
s=cvector(1,n<<1);
mm=IMIN(m,MF);
fv=(float) v[mm];
for (j=mm-1;j>=1;j--) {
fv *= BI;
fv += v[j];
}
fu=1.0/sqrt(fv);
for (j=1;j<=n;j++) {
i=(int) fu;
u[j]=(unsigned char) i;
fu=256.0*(fu-i);
}
for (;;) {
mpmul(r,u,u,n,n);
mplsh(r,n);
mpmul(s,r,v,n,IMIN(m,n));
mplsh(s,n);
mpneg(s,n);
s[1] -= 253;
mpsdv(s,s,n,2,&ir);
for (j=2;j<n;j++) {
if (s[j]) {
mpmul(r,s,u,n,n);
mpmov(u,&r[1],n);
break;
}
}
if (j<n) continue;
mpmul(r,u,v,n,IMIN(m,n));
mpmov(w,&r[1],n);
free_cvector(s,1,n<<1);
free_cvector(r,1,n<<1);
return;
}
}
示例8: arith_evaluate
/* PUBLIC */
int arith_evaluate(Term t, BOOL *evaluated)
{
if (!arith_term(t)) {
*evaluated = FALSE;
return 0;
}
if (VARIABLE(t))
return VARNUM(t);
else {
int sn = SYMNUM(t);
if (sn == Div_sn || sn == Mod_sn) {
int d = arith_evaluate(ARG(t,1), evaluated);
if (d == 0) {
*evaluated = FALSE;
return 0;
}
else if (sn == Div_sn)
return arith_evaluate(ARG(t,0), evaluated) / d;
else
return modulo(arith_evaluate(ARG(t,0), evaluated), d);
}
else if (sn == Sum_sn)
return arith_evaluate(ARG(t,0), evaluated) + arith_evaluate(ARG(t,1), evaluated);
else if (sn == Prod_sn)
return arith_evaluate(ARG(t,0), evaluated) * arith_evaluate(ARG(t,1), evaluated);
else if (sn == Neg_sn)
return -arith_evaluate(ARG(t,0), evaluated);
else if (sn == Abs_sn)
return abs(arith_evaluate(ARG(t,0), evaluated));
else if (sn == Domain_size_sn)
return Domain_size;
else if (sn == Min_sn) {
int a0 = arith_evaluate(ARG(t,0), evaluated);
int a1 = arith_evaluate(ARG(t,1), evaluated);
return IMIN(a0,a1);
}
else if (sn == Max_sn) {
int a0 = arith_evaluate(ARG(t,0), evaluated);
int a1 = arith_evaluate(ARG(t,1), evaluated);
return IMAX(a0,a1);
}
else if (sn == Lt_sn)
return arith_evaluate(ARG(t,0), evaluated) < arith_evaluate(ARG(t,1), evaluated);
else if (sn == Le_sn)
return arith_evaluate(ARG(t,0), evaluated) <= arith_evaluate(ARG(t,1), evaluated);
else if (sn == Gt_sn)
return arith_evaluate(ARG(t,0), evaluated) > arith_evaluate(ARG(t,1), evaluated);
else if (sn == Ge_sn)
return arith_evaluate(ARG(t,0), evaluated) >= arith_evaluate(ARG(t,1), evaluated);
else if (sn == Eq_sn)
return arith_evaluate(ARG(t,0), evaluated) == arith_evaluate(ARG(t,1), evaluated);
else {
fatal_error("arith_evaluate, operation not handled");
return INT_MIN;
}
}
} /* arith_evaluate */
示例9: getm
void getm (int ci,struct edgemiginfo *edgem,struct edgemiginfo *sisem, struct edgemiginfo *oldedgem,struct edgemiginfo *oldsisem)
{
int lastmigperiod;
// int i, ii;
/*for (ii = 0;ii<2;ii++)
for (i=0;i<5;i++)
{
checkptype[ii][i] = -100;
checkrr[ii][i] = 0;
} //8_30_10 */
lastmigperiod = IMIN(edgem->e,lastperiodnumber-1);
if ( sisem->edgeid == -1 /* sisem->mtall <= 0*/) // no sister edge, or sister edge not in a period where migration can occur
{
assert(sisem->mtimeavail[0] == 0);
edgem->mpall = mwork_single_edge (ci, edgem,oldedgem, lastmigperiod);
}
else
{
assert (edgem->e == sisem->e);
if (edgem->mtall <= 0) // edge has no length in a period with migration, so just do sister edge
{
assert(edgem->mtimeavail[0] == 0);
sisem->mpall = mwork_single_edge (ci, sisem,oldsisem, lastmigperiod);
}
else
{ // both edge and sis have length in periods with migration
mwork_two_edges(ci, edgem, sisem,oldedgem, oldsisem, lastmigperiod, &edgem->mpall, &sisem->mpall);
}
}
} //getm
示例10: get_score
/* ==========================================================================
get_score
========================================================================== */
float get_score(int w_x[],int w_y[],int nwhisker_points,TMatrix2D I_Conv)
{
float **conv_dat;
float score = 0;
int min_x,max_x;
int *yy, x;
int ncols, nrows;
conv_dat = Mat2D_getDataFloat(I_Conv);
ncols = Mat2D_getnCols(I_Conv);
nrows = Mat2D_getnRows(I_Conv);
min_x = IMAX(w_x[0],0);
max_x = IMIN(w_x[nwhisker_points-1],nrows-1);
get_spline(w_x,w_y,nwhisker_points,min_x, max_x, &yy);
for (x=min_x;x<=max_x;x++)
if (yy[x]>=0 && yy[x]<ncols)
score += conv_dat[x][yy[x]];
free_ivector(yy,min_x,max_x);
return(score);
}
示例11: SetMode
/******************************************************************************
* Function : SetMode
* Description : Set ECB/CBC mode for encryption/decryption
* Input : N/A
* Return : N/A
* Note : N/A
* Globals Changed : N/A
******************************************************************************
*/
void SetMode(void)
{
BYTE key;
BYTE kbdbuf[18];
memset(kbdbuf, 0, sizeof(kbdbuf));
DispLineMW("ENC/DEC Mode:", MW_LINE1, MW_CLRDISP|MW_BIGFONT);
DispLineMW("[ENTER] - ECB", MW_LINE3, MW_BIGFONT);
DispLineMW("[CLEAR] - CBC", MW_LINE5, MW_BIGFONT);
switch (key=APM_WaitKey(9000, 0)) {
case MWKEY_ENTER:
KDLL_SetOpMode(MODE_ECB, kbdbuf);
AcceptBeep();
break;
case MWKEY_CLR:
DispLineMW("Init Vector:", MW_LINE1, MW_CLRDISP|MW_BIGFONT);
if (!APM_GetKbd(HEX_INPUT+ECHO+MW_LINE3+RIGHT_JUST, IMIN(16)+IMAX(16), kbdbuf))
return;
compress(&kbdbuf[1], &kbdbuf[1], 8);
KDLL_SetOpMode(MODE_CBC, &kbdbuf[1]);
AcceptBeep();
break;
default:
break;
}
}
示例12: opus_decode
int opus_decode(OpusDecoder *st, const unsigned char *data,
opus_int32 len, opus_int16 *pcm, int frame_size, int decode_fec)
{
VARDECL(float, out);
int ret, i;
int nb_samples;
ALLOC_STACK;
if(frame_size<=0)
{
RESTORE_STACK;
return OPUS_BAD_ARG;
}
if (data != NULL && len > 0 && !decode_fec)
{
nb_samples = opus_decoder_get_nb_samples(st, data, len);
if (nb_samples>0)
frame_size = IMIN(frame_size, nb_samples);
else
return OPUS_INVALID_PACKET;
}
ALLOC(out, frame_size*st->channels, float);
ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL, 1);
if (ret > 0)
{
for (i=0; i<ret*st->channels; i++)
pcm[i] = FLOAT2INT16(out[i]);
}
RESTORE_STACK;
return ret;
}
示例13: sm_init
OpusSM* sm_init(int samplerate, int channels)
{
OpusSM* sm = (OpusSM*)malloc(sizeof(OpusSM));
sm->error = SM_OK;
if (samplerate != SM_SUPPORTED_SAMPLERATE) {
sm->error = SM_ERR_UNSUPPORTED_SAMPLERATE;
sm->opus_enc = NULL;
return sm;
}
/* application can be: (see opus_encoder_init() in src/opus_encoder.c)
OPUS_APPLICATION_VOIP
OPUS_APPLICATION_AUDIO
OPUS_APPLICATION_RESTRICTED_LOWDELAY */
int error;
sm->opus_enc = opus_encoder_create(samplerate, channels, OPUS_APPLICATION_VOIP, &error);
if (error != 0) {
sm->error = SM_ERR_OPUS_ENC_CREATE_FAILED;
return sm;
}
sm->celt_enc = (CELTEncoder*)((char*)sm->opus_enc + sm->opus_enc->celt_enc_offset);
celt_encoder_ctl(sm->celt_enc, CELT_GET_MODE(&sm->celt_mode));
sm->lsb_depth = IMIN(16, sm->opus_enc->lsb_depth);
sm->delay_compensation = 0;
if (sm->opus_enc->application != OPUS_APPLICATION_RESTRICTED_LOWDELAY) sm->delay_compensation = sm->opus_enc->delay_compensation;
return sm;
}
示例14: savgol
void savgol(double *c, int np, int nl, int nr, int ld, int m) {
/*-------------------------------------------------------------------------------------------
USES lubksb,ludcmp given below.
Returns in c(np), in wrap-around order (see reference) consistent with the argument respns
in routine convlv, a set of Savitzky-Golay filter coefficients. nl is the number of leftward
(past) data points used, while nr is the number of rightward (future) data points, making
the total number of data points used nl+nr+1. ld is the order of the derivative desired
(e.g., ld = 0 for smoothed function). m is the order of the smoothing polynomial, also
equal to the highest conserved moment; usual values are m = 2 or m = 4.
-------------------------------------------------------------------------------------------*/
int imj,ipj,j,k,kk,mm;
double d,fac,sum,**a,*b;
if (np < nl+nr+1 || nl < 0 || nr < 0 || ld > m || nl+nr < m)
nrerror("bad args in savgol");
int *indx= intvector(1,m+1);
a=matrix(1,m+1,1,m+1);
b=vector(1,m+1);
for (ipj=0;ipj<=(m << 1);ipj++)
{//Set up the normal equations of the desired least-squares fit
sum=(ipj ? 0.0 : 1.0);
for (k=1;k<=nr;k++)
sum += pow((double)k,(double)ipj);
for (k=1;k<=nl;k++)
sum += pow((double)-k,(double)ipj);
mm=IMIN(ipj,2*m-ipj);
for (imj = -mm;imj<=mm;imj+=2)
a[1+(ipj+imj)/2][1+(ipj-imj)/2]=sum;
}
ludcmp(a, m+1, indx, &d); //Solve them: LU decomposition.
for (j=1;j<=m+1;j++)
b[j]=0.0;
b[ld+1]=1.0; //Right-hand side vector is unit vector, depending on which derivative we want.
lubksb(a,m+1,indx,b); //Get one row of the inverse matrix.
for (kk=1;kk<=np;kk++)
c[kk]=0.0; //Zero the output array (it may be bigger than number of coefficients).
for (k = -nl;k<=nr;k++)
{
sum=b[1]; //Each Savitzky-Golay coefficient is the dot product
//of powers of an integer with the inverse matrix row.
fac=1.0;
for (mm=1;mm<=m;mm++)
sum += b[mm+1]*(fac *= k);
kk=((np-k) % np)+1; //Store in wrap-around order.
c[kk]=sum;
}
free_vector(b,1,m+1);
free_matrix(a,1,m+1,1,m+1);
free_intvector(indx,1,m+1);
}
示例15: IMIN_VECTOR
int IMIN_VECTOR(int v[], unsigned long l)
/* Find smallest value in v */
{
unsigned long i;
int m=v[0];
for (i=1;i<l;i++) m=IMIN(m,v[i]);
return(m);
}