这篇教程C++ IMIN函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中IMIN函数的典型用法代码示例。如果您正苦于以下问题:C++ IMIN函数的具体用法?C++ IMIN怎么用?C++ IMIN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了IMIN函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ec_laplace_encodevoid 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 {
开发者ID:CEPBEP,项目名称:onion-phone,代码行数:30,
示例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;}
开发者ID:ccowingzitron,项目名称:inla,代码行数:39,
示例3: run_analysisvoid 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);}
开发者ID:0culus,项目名称:ioq3,代码行数:27,
示例4: smoothvoid 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; }; };}
开发者ID:vvinuv,项目名称:pymorph,代码行数:27,
示例5: grab_pointer_positionvoid 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);}
开发者ID:ahqmhjk,项目名称:XScreenShot,代码行数:13,
示例6: fs_initstatic voidfs_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;}
开发者ID:JJCG,项目名称:gst-plugins-good,代码行数:51,
示例7: mpsqrtvoid 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; }}
开发者ID:contentsciences,项目名称:githubapitest,代码行数:50,
示例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 */
开发者ID:axelrod9,项目名称:ladr,代码行数:61,
示例9: getmvoid 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
开发者ID:goshng,项目名称:Peach,代码行数:33,
示例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);}
开发者ID:pmknutsen,项目名称:whiskertracker,代码行数:28,
示例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; }}
开发者ID:dJacomeWposs,项目名称:repoPrueba,代码行数:35,
示例12: opus_decodeint 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;}
开发者ID:biddyweb,项目名称:azfone-ios,代码行数:33,
示例13: sm_initOpusSM* 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;}
开发者ID:jzombi,项目名称:opus_sm,代码行数:27,
示例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);}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:59,
示例15: IMIN_VECTORint 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);}
开发者ID:KathleenLabrie,项目名称:KLlibc,代码行数:8,
示例16: procesoConsultaSaldoImpBOOLEAN procesoConsultaSaldoImp(void){ int costServ = 0; BYTE kbdbuff[10]; BYTE tmpPan[20 + 1]; //BYTE aux[10]; memset(kbdbuff, 0x00, sizeof(kbdbuff)); memset(tmpPan, 0x00, sizeof(tmpPan)); //memset(aux, 0x00, sizeof(aux)); costServ = RSP_DATA.dd_amount; DispClrBelowMW(MW_LINE2); DispLineMW( "Costo Servicio:", MW_LINE3, MW_LEFT|MW_SPFONT ); //split(aux, gToken_80.costoServicio, 2); //costServ = atoi(aux); DispAmnt( costServ, MW_LINE3, MW_SPFONT ); if( SiNo() != 2 ) { // 2 = Press Enter return FALSE; } DispLineMW( "DESLICE LA TARJETA", MW_LINE4, MW_SMFONT|MW_CENTER|MW_CLRDISP ); if( GetCard( FALSE, FALSE ) == FALSE ){ LongBeep(); DispLineMW( "CONSULTA DE SALDO", MW_LINE1, MW_CENTER|MW_REVERSE|MW_SMFONT|MW_CLRDISP ); DispLineMW( "TRANSACCION CANCELADA", MW_LINE3, MW_CENTER ); APM_WaitKey(200, 0); return FALSE; } do { DispLineMW( "CONSULTA DE SALDO", MW_LINE1, MW_CENTER|MW_REVERSE|MW_CLRDISP|MW_SMFONT ); DispLineMW( "INGRESE LOS ULTIMOS", MW_LINE3, MW_CENTER|MW_SPFONT ); DispLineMW( "CUATRO DIGITOS", MW_LINE4, MW_CENTER|MW_SPFONT ); DispLineMW( "DE LA TARJETA", MW_LINE5, MW_CENTER|MW_SPFONT ); memset(kbdbuff, 0x00, sizeof(kbdbuff)); APM_SetCol(7); // Set Columna for TextBox if (!APM_GetKbd(NUMERIC_INPUT + MW_SMFONT + MW_LINE7, IMIN(4) + IMAX(4), kbdbuff)){ return FALSE; } // Compara los ultimo 4 digitos del Pan memset( tmpPan, 0x00, sizeof(tmpPan) ); split( tmpPan, INPUT.sb_pan, 10 ); RTrim( tmpPan, 'F'); } while (memcmp(&kbdbuff[1], &tmpPan[strlen(tmpPan) - 4], 4) != 0); DispLineMW( "CONSULTA DE SALDO", MW_LINE1, MW_CENTER|MW_REVERSE|MW_SMFONT|MW_CLRDISP ); DispLineMW( "Costo Servicio:", MW_LINE3, MW_LEFT|MW_SPFONT ); DispAmnt(costServ, MW_LINE3, MW_SPFONT); if( !getPinblock() ) return FALSE; INPUT.dd_amount = costServ; // El costo del servicio debe viajar en el campo 4 en la proxima transaccion sprintf(gAmount, "%012d", INPUT.dd_amount); return TRUE;}
开发者ID:dJacomeWposs,项目名称:repoPrueba,代码行数:58,
示例17: GMRFLib_ged_add/** /brief Remove 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 remove the edge between /a node and /a nnode. If /a node equals /a nnode, then remove node /a node itself. Note that if node /a node is removed, then so are all edges where /a node is a part of. /sa GMRFLib_ged_add(), GMRFLib_ged_append_graph(), GMRFLib_ged_append_node()*/int GMRFLib_ged_remove(GMRFLib_ged_tp * ged, int node, int nnode){ /* * mark the edge between node and nnode as 'removed', or the node itself if they're equal */ spmatrix_set(&(ged->Q), IMIN(node, nnode), IMAX(node, nnode), 0.0); return GMRFLib_SUCCESS;}
开发者ID:ccowingzitron,项目名称:inla,代码行数:22,
示例18: mexFunctionvoid mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { /* Check number of input arguments */ if (nrhs != 4) { ERROR("Two input arguments are required."); } /* Check number of output arguments */ if (nlhs > 2) { ERROR("Too many output arguments."); } DOUBLE *X = (DOUBLE*) mxGetData(prhs[0]); DOUBLE *rp = (DOUBLE*) mxGetData(prhs[1]); INT M = (INT) * (DOUBLE *) mxGetData(prhs[2]); INT N = (INT) * (DOUBLE *) mxGetData(prhs[3]);// INT M = (INT) mxGetM(prhs[0]);// INT N = (INT) mxGetN(prhs[0]); plhs[0] = mxCreateNumericMatrix(1, 1, MXPRECISION_CLASS, mxREAL); DOUBLE *obj = (DOUBLE *) mxGetData(plhs[0]); DOUBLE *deriv; INT derivFlag; if (nlhs == 2) { plhs[1] = mxCreateNumericMatrix(M * N, 1, MXPRECISION_CLASS, mxREAL); deriv = (DOUBLE *) mxGetData(plhs[1]); derivFlag = 1; } else { deriv = NULL; derivFlag = 0; } INT MN = IMIN(M, N); DOUBLE *svdVec = (DOUBLE *) MALLOC(1 * MN * sizeof(DOUBLE)); DOUBLE *dataBuffer = (DOUBLE *) MALLOC(M * N * sizeof(DOUBLE)); DOUBLE *derivVec = NULL; DOUBLE *vtMat = NULL; if (derivFlag == 1) { derivVec = (DOUBLE *) MALLOC(1 * MN * sizeof(DOUBLE)); vtMat = (DOUBLE *) MALLOC(MN * N * sizeof(DOUBLE)); } nuclear_approx_obj_grad(obj, deriv, X, rp, M, N, derivFlag, svdVec, vtMat, / dataBuffer, derivVec, NULL, 0); FREE(svdVec); FREE(dataBuffer); if (derivFlag == 1) { FREE(derivVec); FREE(vtMat); }}
开发者ID:pfShawn,项目名称:sparse_linear_model,代码行数:53,
示例19: hxget// (size < 0) means hxhold: head is left locked on exit.// Usual usage is: hxhold(), modify record, hxput().inthxget(HXFILE * hp, char *rp, int size){ HXLOCAL loc, *locp = &loc; int leng, rpos, loops, junk; HXBUF *bufp; char *recp; if (!hp || !rp) return HXERR_BAD_REQUEST; if (hxdebug > 1) { char buf[25] = {}; hx_save(hp, rp, size<0 ? -size-1 : size, buf, sizeof buf); DEBUG2("%s('%s...')", size < 0 ? "hold" : "get", buf, size); } ENTER(locp, hp, rp, 1); if (size >= 0) { locp->mode = F_RDLCK; _hxlockset(locp, HEAD_LOCK); // just lock head } else { _hxlockset(locp, HIGH_LOCK); // lock head, +split if > head HOLD_HEAD(locp); } if (IS_MMAP(hp)) _hxremap(locp); leng = 0; loops = HX_MAX_CHAIN; bufp = &locp->buf[0]; bufp->next = locp->head; do { if (!--loops) LEAVE(locp, HXERR_BAD_FILE); _hxload(locp, bufp, bufp->next); rpos = _hxfind(locp, bufp, locp->hash, rp, &junk); } while (rpos < 0 && bufp->next); if (rpos < 0) LEAVE(locp, 0); recp = bufp->data + rpos; leng = RECLENG(recp); memcpy(rp, RECDATA(recp), IMIN(leng, size<0? -size-1 : size)); LEAVE(locp, leng);}
开发者ID:rsanaie,项目名称:hx,代码行数:51,
示例20: procesoConsultaSaldoCNBBOOLEAN procesoConsultaSaldoCNB(void){ BYTE kbdbuff[10]; BYTE tmpPan[20 + 1]; //BYTE aux[10]; memset(kbdbuff, 0x00, sizeof(kbdbuff)); memset(tmpPan, 0x00, sizeof(tmpPan)); //memset(aux, 0x00, sizeof(aux)); DispClrBelowMW(MW_LINE2); DispLineMW( "CONSULTA SALDO CNB", MW_LINE1, MW_CENTER|MW_REVERSE|MW_CLRDISP|MW_SMFONT ); DispLineMW( "DESLICE LA TARJETA", MW_LINE4, MW_SMFONT|MW_CENTER|MW_CLRDISP ); if( GetCard( FALSE, FALSE ) == FALSE ){ LongBeep(); DispLineMW( "CONSULTA SALDO CNB", MW_LINE1, MW_CENTER|MW_REVERSE|MW_SMFONT|MW_CLRDISP ); DispLineMW( "TRANSACCION CANCELADA", MW_LINE3, MW_CENTER ); APM_WaitKey(200, 0); return FALSE; } do { DispLineMW( "CONSULTA SALDO CNB", MW_LINE1, MW_CENTER|MW_REVERSE|MW_CLRDISP|MW_SMFONT ); DispLineMW( "INGRESE LOS ULTIMOS", MW_LINE3, MW_CENTER|MW_SPFONT ); DispLineMW( "CUATRO DIGITOS", MW_LINE4, MW_CENTER|MW_SPFONT ); DispLineMW( "DE LA TARJETA", MW_LINE5, MW_CENTER|MW_SPFONT ); memset(kbdbuff, 0x00, sizeof(kbdbuff)); APM_SetCol(7); // Set Columna for TextBox if (!APM_GetKbd(NUMERIC_INPUT + MW_SMFONT + MW_LINE7, IMIN(4) + IMAX(4), kbdbuff)){ return FALSE; } // Compara los ultimo 4 digitos del Pan memset( tmpPan, 0x00, sizeof(tmpPan) ); split( tmpPan, INPUT.sb_pan, 10 ); RTrim( tmpPan, 'F'); } while (memcmp(&kbdbuff[1], &tmpPan[strlen(tmpPan) - 4], 4) != 0); DispLineMW( "CONSULTA SALDO CNB", MW_LINE1, MW_CENTER|MW_REVERSE|MW_SMFONT|MW_CLRDISP ); if( !getPinblock() ) return FALSE; return TRUE;}
开发者ID:dJacomeWposs,项目名称:repoPrueba,代码行数:48,
示例21: mexFunctionvoid mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { /* Check number of input arguments */ if (nrhs != 4) { ERROR("Four input arguments are required."); } /* Check number of output arguments */ if (nlhs > 2) { ERROR("Too many output arguments."); } DOUBLE *Dc = (DOUBLE*) mxGetData(prhs[0]); INT rank = (INT) * (DOUBLE*) mxGetData(prhs[1]); INT M = (INT) * (DOUBLE*) mxGetData(prhs[2]); INT N = (INT) * (DOUBLE*) mxGetData(prhs[3]); INT K = (INT) mxGetN(prhs[0]); if ((INT) mxGetM(prhs[0]) != M * N) { ERROR("First dimension of Dc matrix does not match size of dictionary atoms."); } else if (rank > IMIN(M, N)) { ERROR("Input rank is larger than minimum dimension of signal matrix."); } plhs[0] = mxCreateNumericMatrix(M * N, K, MXPRECISION_CLASS, mxREAL); plhs[1] = mxCreateNumericMatrix(1, 1, MXPRECISION_CLASS, mxREAL); DOUBLE *Dcr = (DOUBLE *) mxGetData(plhs[0]); DOUBLE *norm = (DOUBLE *) mxGetData(plhs[1]); datacpy(Dcr, Dc, M * N * K);// INT MINMN = IMIN(M, N);// INT MAXMN = IMAX(M, N);// DOUBLE *sv = (DOUBLE *) MALLOC(MINMN * 1 * sizeof(DOUBLE));// DOUBLE *svecsmall = (DOUBLE *) MALLOC(MINMN * MINMN * sizeof(DOUBLE));// DOUBLE *sveclarge = (DOUBLE *) MALLOC(MAXMN * MINMN * sizeof(DOUBLE));// DOUBLE *normvec = (DOUBLE *) MALLOC(K * 1 * sizeof(DOUBLE));// INT lwork = 0;// matrix_dictionary_proximal(Dcr, norm, tau, M, N, K, sv, svecsmall, sveclarge, normvec, / NULL, lwork); matrix_dictionary_hard_thresholding_parallel(Dcr, norm, rank, M, N, K);// FREE(sv);// FREE(svecsmall);// FREE(sveclarge);// FREE(normvec);}
开发者ID:pfShawn,项目名称:sparse_linear_model,代码行数:48,
示例22: SetDhostIdx/****************************************************************************** * Function : SetDhostIdx * Description : Reset terminal DUKPT init key * Input : N/A * Return : TRUE; // key load ok * FALSE; // key load failed * Note : N/A * Globals Changed : N/A ****************************************************************************** */BOOLEAN SetDhostIdx(void){ BYTE kbdbuf[4]; kbdbuf[0] = 1; kbdbuf[1] = '0' + dhost_idx; while (1) { DispLineMW("DHost Idx(0-4):", MW_LINE5, MW_CLRDISP|MW_BIGFONT); if (!APM_GetKbd(NUMERIC_INPUT+ECHO+MW_LINE7+MW_BIGFONT+RIGHT_JUST, IMIN(1)+IMAX(1), kbdbuf)) return FALSE; if (kbdbuf[1] < '5') break; else LongBeep(); } dhost_idx = kbdbuf[1] - '0'; return TRUE;}
开发者ID:dJacomeWposs,项目名称:repoPrueba,代码行数:28,
示例23: MultiplyMatvoid MultiplyMat(register double *m1, register double *m2, register double *res, const int M1, const int N1, const int M2, const int N2) { int timesInner = IMIN( N1, M2 ); int timesRows = M1; int timesCols = N2; double sum; int row, col, inner; for( row = 0; row < timesRows; row++ ) { for( col = 0; col < timesCols; col++ ) { sum = 0; for( inner = 0; inner < timesInner; inner++ ) { sum += m1[row*N1 + inner] * m2[inner*N2 + col]; } *(res++) = sum; } }}
开发者ID:20SecondsToSun,项目名称:in-spirit,代码行数:20,
示例24: get_I_Conv/* ========================================================================== get_I_Conv Convulve I_Conv with oriented filter according to the whisker angle ========================================================================== */void get_I_Conv(int *w0_x,int *w0_y,int nwhisker_points, TMatrix2D image, int min_y, int max_y, TMatrix2D filters[], TMatrix2D *I_Conv_p){ int i,x_val; int *yy; int *angle_vec; int spline_len; int filt_size; int min_x, max_x; int nrows; nrows = Mat2D_getnRows(image); /* calculate spline of w0 */ min_x = IMAX(w0_x[0],0); max_x = IMIN(w0_x[nwhisker_points-1],nrows-1); filt_size = (Mat2D_getnRows(filters[0])-1)/2; get_spline(w0_x,w0_y,nwhisker_points,min_x-COL_WIDTH, max_x+COL_WIDTH, &yy); get_angle_vec(yy,min_x,max_x,COL_WIDTH,&angle_vec); /* for (i=0;i<nwhisker_points;i++) */ /* mexPrintf("w0[%d]: %d %d/n",i,w0_x[i],w0_y[i]); */ /* mexPrintf("/n"); */ /* for (x_val=min_x;x_val<=max_x;x_val++) */ /* mexPrintf("spline[%d]: %d angle = %d/n",x_val,yy[x_val],angle_vec[x_val]); */ /* mexPrintf("/n"); */ /* convolve each column of I_Conv with correct filter (according to angle) */ convolve_image_by_angle(image,filters,filt_size,angle_vec, min_x,max_x,min_y,max_y,I_Conv_p); free_ivector(yy,min_x-COL_WIDTH, max_x+COL_WIDTH); free_ivector(angle_vec,min_x,max_x); /* Mat2D_display(*I_Conv_p); */}
开发者ID:pmknutsen,项目名称:whiskertracker,代码行数:46,
示例25: simple_soft_render// TODO: need a "now" take it as an argumentvoid simple_soft_render(struct simple_soft_ctx *ctx, Pixbuf *out, int64_t now, int64_t tick0){ ctx->m = (ctx->m+1)&0x1; if(tick0+(ctx->maxfrms*1000)/ctx->maxsrc_rate - now > 1000/ctx->maxsrc_rate) { maxsrc_update(ctx->maxsrc, ctx->prev_buf, ctx->nr_samp/2); ctx->maxfrms++; } if(!ctx->rational_julia) { ctx->map_func(ctx->map_surf[ctx->m], ctx->map_surf[(ctx->m+1)&0x1], ctx->im_w, ctx->im_h, ctx->pd); maxblend(ctx->map_surf[ctx->m], maxsrc_get(ctx->maxsrc), ctx->im_w, ctx->im_h); } if(ctx->rational_julia) { maxblend(ctx->map_surf[(ctx->m+1)&0x1], maxsrc_get(ctx->maxsrc), ctx->im_w, ctx->im_h); ctx->map_func(ctx->map_surf[ctx->m], ctx->map_surf[(ctx->m+1)&0x1], ctx->im_w, ctx->im_h, ctx->pd); } // rather than just audio clock if((now - ctx->lastpalstep)*256/1024 >= 1) { // want pallet switch to take ~2 seconds pal_ctx_step(ctx->pal_ctx, IMIN((now - ctx->lastpalstep)*256/1024, 32)); ctx->lastpalstep = now; } pallet_blit_Pixbuf(out, ctx->map_surf[ctx->m], ctx->im_w, ctx->im_h, pal_ctx_get_active(ctx->pal_ctx)); //pallet_blit_Pixbuf(out, maxsrc_get(ctx->maxsrc), ctx->im_w, ctx->im_h, pal_ctx_get_active(ctx->pal_ctx)); int newbeat = beat_ctx_count(ctx->beat); if(newbeat != ctx->beats) pal_ctx_start_switch(ctx->pal_ctx, newbeat); if(newbeat != ctx->beats && now - ctx->last_beat_time > 1000) { ctx->last_beat_time = now; update_points(ctx->pd, (now - tick0), 1); } else update_points(ctx->pd, (now - tick0), 0); ctx->beats = newbeat;}
开发者ID:Spudd86,项目名称:julia-vis,代码行数:38,
示例26: printautoctablevoidprintautoctable (FILE * outto, int numautoc, struct autoc **ac, char **ac_str, const char *printacstring/*, int step*/){ int i, j; double **acvals; int numacprint; char numstr[20]; /* 4/9/09 change output for stdout so it only does tables for L[P] and split times, not tmrcas the total number of autoc tables for stdout will then be npops */ //numacprint = (outto == stdout) ? IMIN (numautoc, IFSTDOUTMAXSHOW) : numautoc; if (strcmp (printacstring, "Population Assignment Autocorrelations and Effective Sample Size Estimates") == 0) { numacprint = (outto == stdout) ? IMIN (nloci, IFSTDOUTMAXSHOW) : numautoc; } else { numacprint = (outto == stdout) ? IMIN (numautoc, IFSTDOUTMAXSHOW) : numautoc; } acvals = orig2d_alloc2Ddouble (numacprint, AUTOCTERMS); fprintf (outto, "/n%s/n", printacstring); for (i = 0; i < (int) strlen (printacstring); i++) fprintf (outto, "-"); fprintf (outto, "/n"); fprintf (outto, " # Steps Between Values and Autocorrelation Estimates /n"); fprintf (outto, "/tSteps "); for (j = 0; j < numacprint; j++) fprintf (outto, "/t %s", ac_str[j]); fprintf (outto, "/n"); for (i = 0; i < AUTOCTERMS; i++) { if (ac[0][i].cov.n > (AUTOCCUTOFF / AUTOCSTEPSCALAR)) { if (((float) autoc_checkstep[i] * AUTOCSTEPSCALAR) > 1e4) { sprintf (&numstr[0], "%.1e", (float) autoc_checkstep[i] * AUTOCSTEPSCALAR); fprintf (outto, "/t%s", shorten_e_num (&numstr[0])); //fprintf (outto, "/t%.1e", (float) autoc_checkstep[i]*AUTOCSTEPSCALAR); } else { fprintf (outto, "/t%d", autoc_checkstep[i] * AUTOCSTEPSCALAR); } for (j = 0; j < numacprint; j++) { acvals[j][i] = printautocvalue (outto, &ac[j][i]); } fprintf (outto, "/n"); } } fprintf (outto, "/tESS");/* integrate over autocorrelations values for values > 0.03 */ for (j = 0; j < numacprint; j++) integrate_autoc (outto, ac[j], acvals[j]/*, step*/); fprintf (outto, "/n"); orig2d_free2D ((void **) acvals, numacprint);} //printautoctable
开发者ID:arunsethuraman,项目名称:IMgui,代码行数:62,
示例27: swapchains/* CR 110929.4 get rid of extraneous args in declaration and remove several * variables not being used */intswapchains (int swaptries){ int ci, cj, i, swap0ok; double metropolishastingsterm; void *swapptr; int cjmin, cjrange;#define MINSWAP 0.1#define BETADJUST 1.414#define INCADJUST 1.414#define MINHEAT 0.0001#define MAXHEAT 0.2#define MAXINC 100#define MININC 0.1#define PAUSESWAP 1000#define SWAPDIST 7// 5/27/2010 removed HADAPT stuff for (i = 0, swap0ok = 0; i < swaptries; i++) { do { ci = (int) (uniform () * numchains); } while (ci < 0 || ci >= numchains); if (numchains < 2*SWAPDIST + 3) { cjmin = 0; cjrange = numchains; } else { cjmin = IMAX(0,ci-SWAPDIST); cjrange = IMIN(numchains, ci+SWAPDIST) -cjmin; } do { cj = cjmin + (int) (uniform () * cjrange); } while (cj == ci || cj < 0 || cj >= numchains); if (ci < cj) { swapcount[cj][ci]++; } else { swapcount[ci][cj]++; } metropolishastingsterm = swapweight (ci, cj); if (metropolishastingsterm >= 1.0 || metropolishastingsterm > uniform ()) { swapptr = C[ci]; C[ci] = C[cj]; C[cj] = static_cast<chain *> (swapptr); if (ci < cj) { swapcount[ci][cj]++; } else { swapcount[cj][ci]++; } if (ci == 0 || cj == 0) swap0ok |= 1; } } return swap0ok;} /* swapchains */
开发者ID:goshng,项目名称:cocoa,代码行数:74,
示例28: _mossNRsvdcmpint _mossNRsvdcmp(register double **a, const int m, const int n, double w[], register double **v){ int flag,i,its,j,jj,k,l,nm; double anorm,c,f,g,h,s,scale,x,y,z, rv11[n+1]; register double *rv1 = rv11; g = scale = anorm = 0.0; for (i=1;i<=n;i++) { l=i+1; rv1[i]=scale*g; g=s=scale=0.0; if (i <= m) { for (k=i;k<=m;k++) scale += fabs(a[k][i]); if (scale) { for (k=i; k<=m; k++) { a[k][i] /= scale; s += a[k][i]*a[k][i]; } f = a[i][i]; g = -SIGN(sqrt(s), f); h=f*g-s; a[i][i]=f-g; for (j=l;j<=n;j++) { for (s=0.0,k=i;k<=m;k++) s += a[k][i]*a[k][j]; f=s/h; for (k=i;k<=m;k++) a[k][j] += f*a[k][i]; } for (k=i;k<=m;k++) a[k][i] *= scale; } } w[i]=scale *g; g=s=scale=0.0; if (i <= m && i != n) { for (k=l;k<=n;k++) scale += fabs(a[i][k]); if (scale) { for (k=l;k<=n;k++) { a[i][k] /= scale; s += a[i][k]*a[i][k]; } f=a[i][l]; g = -SIGN(sqrt(s),f); h=f*g-s; a[i][l]=f-g; for (k=l;k<=n;k++) rv1[k]=a[i][k]/h; for (j=l;j<=m;j++) { for (s=0.0,k=l;k<=n;k++) s += a[j][k]*a[i][k]; for (k=l;k<=n;k++) a[j][k] += s*rv1[k]; } for (k=l;k<=n;k++) a[i][k] *= scale; } } anorm=FMAX(anorm,(fabs(w[i])+fabs(rv1[i]))); } for (i=n;i>=1;i--) { if (i < n) { if (g) { for (j=l;j<=n;j++) v[j][i]=(a[i][j]/a[i][l])/g; for (j=l;j<=n;j++) { for (s=0.0,k=l;k<=n;k++) s += a[i][k]*v[k][j]; for (k=l;k<=n;k++) v[k][j] += s*v[k][i]; } } for (j=l;j<=n;j++) v[i][j]=v[j][i]=0.0; } v[i][i]=1.0; g=rv1[i]; l=i; } for (i = IMIN(m,n); i>=1; i--) { l=i+1; g=w[i]; for (j=l;j<=n;j++) a[i][j]=0.0; if (g) { g=1.0/g; for (j=l;j<=n;j++) { for (s=0.0,k=l;k<=m;k++) s += a[k][i]*a[k][j]; f = (s/a[i][i])*g; for (k=i;k<=m;k++) a[k][j] += f*a[k][i]; } for (j=i;j<=m;j++) a[j][i] *= g; } else for (j=i;j<=m;j++) a[j][i]=0.0; ++a[i][i]; } for (k=n;k>=1;k--) { for (its=1;its<=30;its++) { flag=1; for (l=k;l>=1;l--) { nm=l-1; if ((double)(fabs(rv1[l])+anorm) == anorm) { flag=0; break; } if ((double)(fabs(w[nm])+anorm) == anorm) break; } if (flag) { c=0.0; s=1.0;//.........这里部分代码省略.........
开发者ID:20SecondsToSun,项目名称:in-spirit,代码行数:101,
注:本文中的IMIN函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ IMMBYTE函数代码示例 C++ IMG_REG_WRITE函数代码示例 |