static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedValue initializing(cx); bool isNewValid = true; JS::RootedObject global(cx, ScriptingCore::getInstance()->getGlobalObject()); isNewValid = JS_GetProperty(cx, global, "initializing", &initializing) && initializing.toBoolean(); if (isNewValid) { TypeTest<T> t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject parent(cx, typeClass->parentProto.get()); JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); args.rval().set(OBJECT_TO_JSVAL(_tmp)); return true; } JS_ReportError(cx, "Constructor for the requested class is not available, please refer to the API reference."); return false; }
static bool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedValue initializing(cx); bool isNewValid = true; if (isNewValid) { TypeTest<T> t; js_type_class_t *typeClass = nullptr; std::string typeName = t.s_name(); auto typeMapIter = _js_global_type_map.find(typeName); CCASSERT(typeMapIter != _js_global_type_map.end(), "Can't find the class type!"); typeClass = typeMapIter->second; CCASSERT(typeClass, "The value is null."); #if (COCOS2D_VERSION >= 0x00031000) JS::RootedObject proto(cx, typeClass->proto.ref()); JS::RootedObject parent(cx, typeClass->parentProto.ref()); #else JS::RootedObject proto(cx, typeClass->proto.get()); JS::RootedObject parent(cx, typeClass->parentProto.get()); #endif JS::RootedObject _tmp(cx, JS_NewObject(cx, typeClass->jsclass, proto, parent)); T* cobj = new T(); js_proxy_t *pp = jsb_new_proxy(cobj, _tmp); AddObjectRoot(cx, &pp->obj); args.rval().set(OBJECT_TO_JSVAL(_tmp)); return true; } return false; }
void Generator::read(const QString &fpath) { QFile f(fpath); if (!f.exists()) qWarning() << QString("Error: CSS file doesn't exist %1").arg(fpath); if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) qWarning() << QString("Error: can not open file %1").arg(fpath); QTextStream _tmp(&f); _result = _tmp.readAll(); f.close(); }
void ShadowDemo::OnMouseMove(WPARAM btnState, int x, int y) { if (bMouseDown) { MousePos _tmp(x, y); x -= mouseLast.X; y -= mouseLast.Y; mouseLast.X = _tmp.X; mouseLast.Y = _tmp.Y; g_objTrackballCameraController.Rotate((float)x, (float)y); printf("%d %d\n", x, y); } }
void InputManager::MouseEven(MouseType nType, MousePos pos) { switch (nType) { case MouseDown: { mouseLast.X = pos.X; mouseLast.Y = pos.Y; bMouseMove = true; } break; case MouseUp: { mouseLast.X = pos.X; mouseLast.Y = pos.Y; bMouseMove = false; } break; case MouseDClick: { mouseLast.X = pos.X; mouseLast.Y = pos.Y; } break; case MouseMove: { if (bMouseMove) { MousePos _tmp(pos.X, pos.Y); pos.X -= mouseLast.X; pos.Y -= mouseLast.Y; mouseLast.X = _tmp.X; mouseLast.Y = _tmp.Y; } else { return; } } break; case MouseWheel: { } break; } g_objGameManager.MouseEven(nType,pos); //_handle(nType, pos); }
Ogre::Vector4 InputManager::InputListener::getVectorId(int joystick) { Ogre::Vector4 _tmp(0.0, 0.0, 0.0, 0.0); if (_joyPos.id == joystick) { _tmp[0] = _joyPos.right_x; _tmp[1] = _joyPos.right_y; _tmp[2] = _joyPos.left_x; _tmp[3] = _joyPos.left_y; _tmp = normalizeVector(_tmp); } return _tmp; }
SSH float* ssh_mtx_mtx(const float* m1, const float* m2) { static float flt[16]; __m128 _m[4]; _m[0] = _mm_set_ps(m2[0], m2[4], m2[8], m2[12]); _m[1] = _mm_set_ps(m2[1], m2[5], m2[9], m2[13]); _m[2] = _mm_set_ps(m2[2], m2[6], m2[10], m2[14]); _m[3] = _mm_set_ps(m2[3], m2[7], m2[11], m2[15]); for(ssh_u i = 0; i < 4; i++) { for(ssh_u j = 0; j < 4; j++) { __m128 _tmp(_mm_mul_ps(*(__m128*)&m1[i * 4], _m[j])); _tmp = _mm_hadd_ps(_tmp, _tmp); flt[i * 4 + j] = _mm_hadd_ps(_tmp, _tmp).m128_f32[0]; } } return flt; }
// Process a single read by quality trimming, filtering // returns true if the read should be kept bool processRead(SeqRecord& record) { // let's remove the adapter if the user has requested so // before doing any filtering if(!opt::adapterF.empty()) { std::string _tmp(record.seq.toString()); size_t found = _tmp.find(opt::adapterF); int _length; if(found != std::string::npos) { _length = opt::adapterF.length(); } else { // Couldn't find the fwd adapter; Try the reverse version found = _tmp.find(opt::adapterR); _length = opt::adapterR.length(); } if(found != std::string::npos) // found the adapter { _tmp.erase(found, _length); record.seq = _tmp; // We have to remove the qualities of the adapter if(!record.qual.empty()) { _tmp = record.qual; _tmp.erase(found, _length); record.qual = _tmp; } } } // Check if the sequence has uncalled bases std::string seqStr = record.seq.toString(); std::string qualStr = record.qual; ++s_numReadsRead; s_numBasesRead += seqStr.size(); // If ambiguity codes are present in the sequence // and the user wants to keep them, we randomly // select one of the DNA symbols from the set of // possible bases if(!opt::bDiscardAmbiguous) { for(size_t i = 0; i < seqStr.size(); ++i) { // Convert '.' to 'N' if(seqStr[i] == '.') seqStr[i] = 'N'; if(!IUPAC::isAmbiguous(seqStr[i])) continue; // Get the string of possible bases for this ambiguity code std::string possibles = IUPAC::getPossibleSymbols(seqStr[i]); // select one of the bases at random int j = rand() % possibles.size(); seqStr[i] = possibles[j]; } } // Ensure sequence is entirely ACGT size_t pos = seqStr.find_first_not_of("ACGT"); if(pos != std::string::npos) return false; // Validate the quality string (if present) and // perform any necessary transformations if(!qualStr.empty()) { // Calculate the range of phred scores for validation bool allValid = true; for(size_t i = 0; i < qualStr.size(); ++i) { if(opt::qualityScale == QS_PHRED64) qualStr[i] = Quality::phred64toPhred33(qualStr[i]); allValid = Quality::isValidPhred33(qualStr[i]) && allValid; } if(!allValid) { std::cerr << "Error: read " << record.id << " has out of range quality values.\n"; std::cerr << "Expected phred" << (opt::qualityScale == QS_SANGER ? "33" : "64") << ".\n"; std::cerr << "Quality string: " << qualStr << "\n"; std::cerr << "Check your data and re-run preprocess with the correct quality scaling flag.\n"; exit(EXIT_FAILURE); } } // Hard clip if(opt::hardClip > 0) { seqStr = seqStr.substr(0, opt::hardClip); if(!qualStr.empty()) qualStr = qualStr.substr(0, opt::hardClip); } // Quality trim if(opt::qualityTrim > 0 && !qualStr.empty()) softClip(opt::qualityTrim, seqStr, qualStr); // Quality filter if(opt::qualityFilter >= 0 && !qualStr.empty()) { int numLowQuality = countLowQuality(seqStr, qualStr); if(numLowQuality > opt::qualityFilter) return false; } // Dust filter if(opt::bDustFilter) { double dustScore = calculateDustScore(seqStr); bool bAcceptDust = dustScore < opt::dustThreshold; if(!bAcceptDust) { s_numFailedDust += 1; if(opt::verbose >= 1) { printf("Failed dust: %s %s %lf\n", record.id.c_str(), seqStr.c_str(), dustScore); } return false; } } // Filter by GC content if(opt::bFilterGC) { double gc = calcGC(seqStr); if(gc < opt::minGC || gc > opt::maxGC) return false; } // Primer screen if(!opt::bDisablePrimerCheck) { bool containsPrimer = PrimerScreen::containsPrimer(seqStr); if(containsPrimer) { ++s_numReadsPrimer; return false; } } record.seq = seqStr; record.qual = qualStr; if(record.seq.length() == 0 || record.seq.length() < opt::minLength) return false; return true; }
template<typename MatrixType> void householder(const MatrixType& m) { typedef typename MatrixType::Index Index; static bool even = true; even = !even; /* this test covers the following files: Householder.h */ Index rows = m.rows(); Index cols = m.cols(); typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType; typedef Matrix<Scalar, internal::decrement_size<MatrixType::RowsAtCompileTime>::ret, 1> EssentialVectorType; typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> SquareMatrixType; typedef Matrix<Scalar, Dynamic, MatrixType::ColsAtCompileTime> HBlockMatrixType; typedef Matrix<Scalar, Dynamic, 1> HCoeffsVectorType; typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, MatrixType::RowsAtCompileTime> TMatrixType; Matrix<Scalar, EIGEN_SIZE_MAX(MatrixType::RowsAtCompileTime,MatrixType::ColsAtCompileTime), 1> _tmp((std::max)(rows,cols)); Scalar* tmp = &_tmp.coeffRef(0,0); Scalar beta; RealScalar alpha; EssentialVectorType essential; VectorType v1 = VectorType::Random(rows), v2; v2 = v1; v1.makeHouseholder(essential, beta, alpha); v1.applyHouseholderOnTheLeft(essential,beta,tmp); VERIFY_IS_APPROX(v1.norm(), v2.norm()); if(rows>=2) VERIFY_IS_MUCH_SMALLER_THAN(v1.tail(rows-1).norm(), v1.norm()); v1 = VectorType::Random(rows); v2 = v1; v1.applyHouseholderOnTheLeft(essential,beta,tmp); VERIFY_IS_APPROX(v1.norm(), v2.norm()); MatrixType m1(rows, cols), m2(rows, cols); v1 = VectorType::Random(rows); if(even) v1.tail(rows-1).setZero(); m1.colwise() = v1; m2 = m1; m1.col(0).makeHouseholder(essential, beta, alpha); m1.applyHouseholderOnTheLeft(essential,beta,tmp); VERIFY_IS_APPROX(m1.norm(), m2.norm()); if(rows>=2) VERIFY_IS_MUCH_SMALLER_THAN(m1.block(1,0,rows-1,cols).norm(), m1.norm()); VERIFY_IS_MUCH_SMALLER_THAN(internal::imag(m1(0,0)), internal::real(m1(0,0))); VERIFY_IS_APPROX(internal::real(m1(0,0)), alpha); v1 = VectorType::Random(rows); if(even) v1.tail(rows-1).setZero(); SquareMatrixType m3(rows,rows), m4(rows,rows); m3.rowwise() = v1.transpose(); m4 = m3; m3.row(0).makeHouseholder(essential, beta, alpha); m3.applyHouseholderOnTheRight(essential,beta,tmp); VERIFY_IS_APPROX(m3.norm(), m4.norm()); if(rows>=2) VERIFY_IS_MUCH_SMALLER_THAN(m3.block(0,1,rows,rows-1).norm(), m3.norm()); VERIFY_IS_MUCH_SMALLER_THAN(internal::imag(m3(0,0)), internal::real(m3(0,0))); VERIFY_IS_APPROX(internal::real(m3(0,0)), alpha); // test householder sequence on the left with a shift Index shift = internal::random<Index>(0, std::max<Index>(rows-2,0)); Index brows = rows - shift; m1.setRandom(rows, cols); HBlockMatrixType hbm = m1.block(shift,0,brows,cols); HouseholderQR<HBlockMatrixType> qr(hbm); m2 = m1; m2.block(shift,0,brows,cols) = qr.matrixQR(); HCoeffsVectorType hc = qr.hCoeffs().conjugate(); HouseholderSequence<MatrixType, HCoeffsVectorType> hseq(m2, hc); hseq.setLength(hc.size()).setShift(shift); VERIFY(hseq.length() == hc.size()); VERIFY(hseq.shift() == shift); MatrixType m5 = m2; m5.block(shift,0,brows,cols).template triangularView<StrictlyLower>().setZero(); VERIFY_IS_APPROX(hseq * m5, m1); // test applying hseq directly m3 = hseq; VERIFY_IS_APPROX(m3 * m5, m1); // test evaluating hseq to a dense matrix, then applying // test householder sequence on the right with a shift TMatrixType tm2 = m2.transpose(); HouseholderSequence<TMatrixType, HCoeffsVectorType, OnTheRight> rhseq(tm2, hc); rhseq.setLength(hc.size()).setShift(shift); VERIFY_IS_APPROX(rhseq * m5, m1); // test applying rhseq directly m3 = rhseq; VERIFY_IS_APPROX(m3 * m5, m1); // test evaluating rhseq to a dense matrix, then applying }