/// <summary> /// Computes Brenner's focus measure (gradient based) /// </summary> /// <returns>The focus measure value</returns> double BasicFM::computeBREN() { if (checkInput()) { //this should be the faster version... cv::Mat FM(mSrcImg.rows - 2, mSrcImg.cols - 2, mSrcImg.type()); for (int rowIdx = 0; rowIdx < mSrcImg.rows - 2; rowIdx++) { const float *ptrSrc = mSrcImg.ptr<float>(rowIdx); const float *ptrSrc2 = mSrcImg.ptr<float>(rowIdx+2); float *ptrFm = FM.ptr<float>(rowIdx); for (int colIdx = 0; colIdx < mSrcImg.cols-2; colIdx++) { double diffH = ptrSrc[colIdx + 2] - ptrSrc[colIdx]; double diffV = ptrSrc2[colIdx] - ptrSrc[colIdx]; ptrFm[colIdx] = (float)cv::max(cv::abs(diffH), cv::abs(diffV)); ptrFm[colIdx] *= ptrFm[colIdx]; } } /* //old version cv::Mat dH = mSrcImg(cv::Range::all(), cv::Range(2, mSrcImg.cols)) - mSrcImg(cv::Range::all(), cv::Range(0, mSrcImg.cols - 2)); cv::Mat dV = mSrcImg(cv::Range(2, mSrcImg.rows), cv::Range::all()) - mSrcImg(cv::Range(0, mSrcImg.rows - 2), cv::Range::all()); dH = cv::abs(dH); dV = cv::abs(dV); cv::Mat FM = cv::max(dH(cv::Range(0, dH.rows - 2), cv::Range::all()), dV(cv::Range::all(), cv::Range(0, dV.cols - 2))); FM = FM.mul(FM); //end old version */ cv::Scalar fm = cv::mean(FM); //normalize //255*255 / 2 -> max value fm[0] = fm[0] / ((255.0*255.0)/2.0); mVal = fm[0]; } else { mVal = -1; } return mVal; }
void FontMetricsNode::inputsUpdated( qint64 pTimeStamp ) { NodeControlBase::inputsUpdated( pTimeStamp ); QFont Font = variant<QFont>( mPinInputFont ); QString String = variant<QString>( mPinInputText ); QFontMetricsF FM( Font ); QRectF Bounds = FM.boundingRect( String ); if( Bounds != mValOutputBounds->variant().value<QRectF>() ) { mValOutputBounds->setVariant( Bounds ); pinUpdated( mPinOutputBounds ); } }
int main (void) { int n; double tol = 1e-14; double **A, *b; for (n = 1; n <= 15; n++) { A = GMH (n); b = GV1 (n, A); gauss (n, A, b, tol); trisup (n, A, b, tol); printf ("%3d:\t%.30le\n", n, Norm (n, b)-1); FM (A, n, n); FV (b, n); } return 0; }
BOOL CNetRadioDlg::OnInitDialog() { CDialog::OnInitDialog(); // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 m_Browser.CreateFromStatic(IDC_BROWSER,this); CONFIG Config; ReadConfigFromIni(&Config); USES_CONVERSION; m_Proxy=T2A(Config.Proxy.GetBuffer(Config.Proxy.GetLength())); CString FM(Config.FM); TurnFM(FM); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE }
static int compare_nodes(NODE *n1, NODE *n2, char const *path) { int differs; if (n1 != NULL && n1->type == F_LINK) n1->flags &= ~F_MODE; if (n2 != NULL && n2->type == F_LINK) n2->flags &= ~F_MODE; differs = 0; if (n1 == NULL && n2 != NULL) { differs = n2->flags; mismatch(n1, n2, differs, path); return (1); } if (n1 != NULL && n2 == NULL) { differs = n1->flags; mismatch(n1, n2, differs, path); return (1); } if (n1->type != n2->type) { differs = 0; mismatch(n1, n2, differs, path); return (1); } if (FF(n1, n2, F_CKSUM, cksum)) differs |= F_CKSUM; if (FF(n1, n2, F_GID, st_gid)) differs |= F_GID; if (FF(n1, n2, F_GNAME, st_gid)) differs |= F_GNAME; if (FF(n1, n2, F_MODE, st_mode)) differs |= F_MODE; if (FF(n1, n2, F_NLINK, st_nlink)) differs |= F_NLINK; if (FF(n1, n2, F_SIZE, st_size)) differs |= F_SIZE; if (FS(n1, n2, F_SLINK, slink)) differs |= F_SLINK; if (FM(n1, n2, F_TIME, st_mtimespec)) differs |= F_TIME; if (FF(n1, n2, F_UID, st_uid)) differs |= F_UID; if (FF(n1, n2, F_UNAME, st_uid)) differs |= F_UNAME; if (FS(n1, n2, F_MD5, md5digest)) differs |= F_MD5; if (FS(n1, n2, F_SHA1, sha1digest)) differs |= F_SHA1; if (FS(n1, n2, F_RMD160, rmd160digest)) differs |= F_RMD160; if (FS(n1, n2, F_SHA256, sha256digest)) differs |= F_SHA256; if (FF(n1, n2, F_FLAGS, st_flags)) differs |= F_FLAGS; if (differs) { mismatch(n1, n2, differs, path); return (1); } return (0); }
void grans_perform64(t_grans *x, t_object *dsp64, double **ins, long numins, double **outs, long numouts, long sampleframes, long flags, void *userparam) { /* single evelope version: 0 trigger 1 car hz 2 harm (for all) 3 mod index (for all) 4 amp dur 5 x amp slope 6 y amp slope 7 amp enve type */ double *in1 = ins[0]; double *in2 = ins[1]; double *harm = ins[2]; double *modindex = ins[3]; double *in5 = ins[4]; double *in6 = ins[5]; double *in7 = ins[6]; double *in8 = ins[7]; double **outlets = outs; register double prev_trig = x->prev_in1; register double trigger; register double type; register double hz; register double dur; register double w_attack; register double w_slope; int j, i; double *sinetab = x->sinetab; //not sure if the const is helping me a lot? const double *cos_wind = x->wind_costab; const double *decaytab = x->expdecaytab; const double *dampedsinetab = x->dampedsinetab; const double *sinc_wind = x->sincwindow; const double **exptab = (const double **)x->exptab; const Boolean alwayson = x->always_on; //zero out samples, and check for new triggers for ( j = 0; j < sampleframes; j++) { for(i = 0; i < numouts; i++){ //might be able to move this into the main loop, and do the grain allocation there too... if that was the case the j offset could be removed also outlets[i][j] = 0.0; } trigger = *in1++; //trigger also used for chirp rate hz = *in2++; dur = *in5++; w_attack = *in6++; w_slope = *in7++; type = *in8++; if ( trigger != 0.0 && hz > 0.0 && dur > 0.0 && w_attack > 0.0 && w_slope > 0.0) { grans_setNewGrain( x, j, trigger, hz, dur, w_attack, w_slope, (int)type ); } prev_trig = trigger; } x->prev_in1 = prev_trig; t_osc *o = x->base; // t_osc *mod = x->modbase; //in case of individual grain envelopes const int maxoscillators = x->maxoscillators; const double tabSamp = 1.0 / STABSZ; const double halftab = 0.5 * STABSZ; const int shapetabscale = NSHAPINGTABS - 1; const int wtabscale = STABSZ - 1; register long tex_pc, xshapetab, yshapetab; register double pc, wpc, chirpdir; register double pi, wpi, att, slop, amp, tex, chirprate; register int w_type, outletnum; for( i = 0; i < maxoscillators; i++, o++) { pi = o->phase_inc; if( pi == 0.0 && !alwayson) continue; //<< if not always on, it's a little cheaper, but spiky //actually this is only one part of cpu cost, the other part is writing the windows, i'm not sure if I can reduced that... pc = o->phase_current; wpc = o->window_phase_curent; wpi = o->window_phase_inc; att = o->window_attack; slop = o->window_slope; xshapetab = (uint32_t)(att * shapetabscale); //could be in the grain struct yshapetab = (uint32_t)(slop * shapetabscale); //could be in the grain struct w_type = o->window_type; outletnum = o->outlet; j = o->offset; if( w_type == 0 ) //cos window { while(j < sampleframes && wpc < STABSZ) { //amp = pow( cos_wind[ (uint32_t)(pow( wpc * tabSamp, att ) * STABSZ) ], slop); amp = exptab[ yshapetab ][ (uint32_t)(cos_wind[(uint32_t)(exptab[ xshapetab ][ (uint32_t)wpc ] * wtabscale)] * wtabscale) ]; outlets[outletnum][j] += amp * FM(sinetab, STABSZ, pc, harm[j], modindex[j] ); pc = fmod((pc + pi), STABSZ); wpc += wpi; j++; } } else if( w_type == 1 ) //fof window { tex = o->tex; while(j < sampleframes && wpc < STABSZ) { tex_pc = (uint32_t)wrapPhase(wpc * tex, STABSZ); if( tex_pc <= halftab ) { //amp = pow( cos_wind[ tex_pc ], slop) * decaytab[ (uint32_t)wpc ]; amp = exptab[ yshapetab ][ (uint32_t)(cos_wind[ (uint32_t)tex_pc ] * wtabscale) ] * decaytab[ (uint32_t)wpc ]; } else { amp = decaytab[ (uint32_t)wpc ]; } outlets[outletnum][j] += amp * FM(sinetab, STABSZ, pc, harm[j], modindex[j] ); pc = fmod((pc + pi), STABSZ); wpc += wpi; j++; } } else if( w_type == 2 ) //dampedsine window { while(j < sampleframes && wpc < STABSZ) { //amp = pow( dampedsinetab[(uint32_t)( pow( wpc * tabSamp, att ) * STABSZ )], slop); amp = exptab[ yshapetab ][ (uint32_t)(dampedsinetab[(uint32_t)(exptab[ xshapetab ][ (uint32_t)wpc ] * wtabscale)] * wtabscale) ]; outlets[outletnum][j] += amp * FM(sinetab, STABSZ, pc, harm[j], modindex[j] ); pc = fmod((pc + pi), STABSZ); wpc += wpi; j++; } } else if( w_type == 3 ) //sinc window { while(j < sampleframes && wpc < STABSZ) { //amp = pow( sinc_wind[(uint32_t)( pow( wpc * tabSamp, att ) * STABSZ )], slop); amp = exptab[ yshapetab ][ (uint32_t)(sinc_wind[(uint32_t)(exptab[ xshapetab ][ (uint32_t)wpc ] * wtabscale)] * wtabscale) ]; outlets[outletnum][j] += amp * FM(sinetab, STABSZ, pc, harm[j], modindex[j] ); pc = fmod((pc + pi), STABSZ); wpc += wpi; j++; } } else if( w_type == 10 ) { chirprate = o->chirp_rate; chirpdir = o->chirp_direction; while(j < sampleframes && wpc < STABSZ) { //amp = pow( cos_wind[ (uint32_t)(pow( wpc * tabSamp, att ) * STABSZ) ], slop); amp = exptab[ yshapetab ][ (uint32_t)(cos_wind[(uint32_t)(exptab[ xshapetab ][ (uint32_t)wpc ] * wtabscale)] * wtabscale) ]; outlets[outletnum][j] += amp * FM(sinetab, STABSZ, pc, harm[j], modindex[j] ); pc = wrapPhase(pc + pi + (wpc * tabSamp * chirprate * chirpdir), STABSZ); wpc += wpi; j++; } } else if( w_type == 11 ) { chirprate = o->chirp_rate; chirpdir = o->chirp_direction; while(j < sampleframes && wpc < STABSZ) { //amp = pow( cos_wind[ (uint32_t)(pow( wpc * tabSamp, att ) * STABSZ) ], slop); amp = exptab[ yshapetab ][ (uint32_t)(cos_wind[(uint32_t)(exptab[ xshapetab ][ (uint32_t)wpc ] * wtabscale)] * wtabscale) ]; outlets[outletnum][j] += amp * FM(sinetab, STABSZ, pc, harm[j], modindex[j] ); pc = wrapPhase(pc + pi + (chirpdir * pow(chirprate, wpc * tabSamp)), STABSZ); wpc += wpi; j++; } } else { goto release; } o->offset = 0; if( wpc < STABSZ ) { o->window_phase_curent = wpc; o->phase_current = pc; } else { release: grans_releaseVoice(x, o); //this could probably be moved out of the osc loop, but seems ok if(x->nosc == 0 && !alwayson) break; } } }
#include <X11/XKBlib.h> #endif #define FLUSHKEYCACHE(ctx) \ bzero((char *)&ctx->keycache, sizeof(TMKeyCache)) /* * The following array reorders the modifier bits so that the most common ones * (used by a translator) are in the top-most bits with respect to the size of * the keycache. The array currently just reverses the bits as a good guess. * This might be more trouble than it is worth, but it seems to help. */ #define FM(i) i >> (8 - TMKEYCACHELOG2) static const unsigned char modmix[256] = { FM(0x0f), FM(0x8f), FM(0x4f), FM(0xcf), FM(0x2f), FM(0xaf), FM(0x6f), FM(0xef), FM(0x1f), FM(0x9f), FM(0x5f), FM(0xdf), FM(0x3f), FM(0xbf), FM(0x7f), FM(0xff), FM(0x07), FM(0x87), FM(0x47), FM(0xc7), FM(0x27), FM(0xa7), FM(0x67), FM(0xe7), FM(0x17), FM(0x97), FM(0x57), FM(0xd7), FM(0x37), FM(0xb7), FM(0x77), FM(0xf7), FM(0x0b), FM(0x8b), FM(0x4b), FM(0xcb), FM(0x2b), FM(0xab), FM(0x6b), FM(0xeb), FM(0x1b), FM(0x9b), FM(0x5b), FM(0xdb), FM(0x3b), FM(0xbb), FM(0x7b), FM(0xfb), FM(0x03), FM(0x83), FM(0x43), FM(0xc3), FM(0x23), FM(0xa3), FM(0x63), FM(0xe3), FM(0x13), FM(0x93), FM(0x53), FM(0xd3), FM(0x33), FM(0xb3), FM(0x73), FM(0xf3), FM(0x0d), FM(0x8d), FM(0x4d), FM(0xcd), FM(0x2d), FM(0xad), FM(0x6d), FM(0xed), FM(0x1d), FM(0x9d), FM(0x5d), FM(0xdd), FM(0x3d), FM(0xbd), FM(0x7d), FM(0xfd), FM(0x05), FM(0x85), FM(0x45), FM(0xc5), FM(0x25), FM(0xa5), FM(0x65), FM(0xe5), FM(0x15), FM(0x95), FM(0x55), FM(0xd5), FM(0x35), FM(0xb5), FM(0x75), FM(0xf5), FM(0x09), FM(0x89), FM(0x49), FM(0xc9), FM(0x29), FM(0xa9), FM(0x69), FM(0xe9), FM(0x19), FM(0x99), FM(0x59), FM(0xd9), FM(0x39), FM(0xb9), FM(0x79), FM(0xf9), FM(0x01), FM(0x81), FM(0x41), FM(0xc1), FM(0x21), FM(0xa1), FM(0x61), FM(0xe1), FM(0x11), FM(0x91), FM(0x51), FM(0xd1), FM(0x31), FM(0xb1), FM(0x71), FM(0xf1),
int main(int argc, const char **argv) { bool PreprocessorOnly = false; std::vector<std::string> Argv; Argv.push_back(argv[0]); Argv.push_back("-x"); // Type need to go first Argv.push_back("c++"); Argv.push_back("-fPIE"); Argv.push_back("-Wno-microsoft"); // get rid of a warning in qtextdocument.h Options.Output = "-"; bool NextArgNotInput = false; bool HasInput = false; for (int I = 1 ; I < argc; ++I) { if (argv[I][0] == '-') { NextArgNotInput = false; switch (argv[I][1]) { case 'h': case '?': showHelp(); return EXIT_SUCCESS; case 'v': showVersion(true); return EXIT_SUCCESS; case 'o': if (argv[I][2]) Options.Output = &argv[I][2]; else if ((++I) < argc) Options.Output = argv[I]; continue; case 'i': if (argv[I] == llvm::StringRef("-i")) { Options.NoInclude = true; continue; } else if (argv[I] == llvm::StringRef("-include")) { NextArgNotInput = true; break; } goto invalidArg; case 'M': { llvm::StringRef Arg; if (argv[I][2]) Arg = &argv[I][2]; else if ((++I) < argc) Arg = argv[I]; size_t Eq = Arg.find('='); if (Eq == llvm::StringRef::npos) { std::cerr << "moc-ng: missing key or value for option '-M'" << std::endl; return EXIT_FAILURE; } Options.MetaData.push_back({Arg.substr(0, Eq), Arg.substr(Eq+1)}); continue; } case 'E': PreprocessorOnly = true; break; case 'I': case 'U': case 'D': NextArgNotInput = (argv[I][2] == '\0'); break; case 'X': NextArgNotInput = true; break; case 'f': //this is understood as compiler option rather than moc -f case 'W': // same break; case 'n': //not implemented, silently ignored continue; default: invalidArg: std::cerr << "moc-ng: Invalid argument '" << argv[I] << "'" << std::endl; showHelp(); return EXIT_FAILURE; } } else if (!NextArgNotInput) { if (HasInput) { std::cerr << "error: Too many input files specified" << std::endl; return EXIT_FAILURE; } HasInput = true; } Argv.push_back(argv[I]); } //FIXME Argv.push_back("-I/usr/include/qt5"); Argv.push_back("-I/usr/include/qt5/QtCore"); Argv.push_back("-I/builtins"); clang::FileManager FM({"."}); if (PreprocessorOnly) { Argv.push_back("-P"); clang::tooling::ToolInvocation Inv(Argv, new clang::PrintPreprocessedAction, &FM); return !Inv.run(); } Argv.push_back("-fsyntax-only"); clang::tooling::ToolInvocation Inv(Argv, new MocAction, &FM); const EmbeddedFile *f = EmbeddedFiles; while (f->filename) { Inv.mapVirtualFile(f->filename, {f->content , f->size } ); f++; } return !Inv.run(); }
void test3(struct Point *p) { FM(p->x, a); }