QSharedPointer<SumFileManagerIfc> SumShaType::getSumFileManager() { return QSharedPointer<SumFileManagerIfc>(new SumFileShaManager(getTypeHash(), getAlgorithm(), SumTypeManager::getInstance()->getSettings(), SumTypeManager::getInstance()->getFileLock(), SumTypeManager::getInstance()->getDataCache(), SumTypeManager::getInstance()->getErrorCollector())); }
void EnemysGenerator::addEnemy( sf::Texture& image, bool enableRotation, MOVE_TYPE type, const float scaleFactor) { for(size_t i = 0; i < 3; ++i) { Enemy* enemy = new Enemy(mGamemanager); enemy->setTexture(&image); enemy->setAlgorithm(getAlgorithm(type)); if(enableRotation) { enemy->enableRotation(); } enemy->getSprite()->SetScale(scaleFactor, scaleFactor); mEnemyPool.push_back(enemy); } }
/* Assumes there is a net */ flag standardNetTrain(void) { int i, lastReport, batchesAtCriterion; flag willReport, groupCritReached, value = TCL_OK, done; unsigned long startTime; Algorithm A; if (Net->numUpdates < 0) return warning("numUpdates (%d) must be positive.", Net->numUpdates); if (Net->numUpdates == 0) return result(""); if (!Net->trainingSet) return warning("There is no training set."); if (Net->learningRate < 0.0) return warning("learningRate (%f) cannot be negative.", Net->learningRate); if (Net->momentum < 0.0 && Net->momentum >= 1.0) return warning("momentum (%f) is out of range [0,1).", Net->momentum); if (Net->weightDecay < 0.0 || Net->weightDecay > 1.0) return warning("weightDecay (%f) must be in the range [0,1].", Net->weightDecay); if (Net->reportInterval < 0) return warning("reportInterval (%d) cannot be negative.", Net->reportInterval); A = getAlgorithm(Net->algorithm); print(1, "Performing %d updates using %s...\n", Net->numUpdates, A->longName); if (Net->reportInterval) printReportHeader(); startTime = getTime(); lastReport = batchesAtCriterion = 0; groupCritReached = FALSE; done = FALSE; /* It always does at least one update. */ for (i = 1; !done; i++) { RUN_PROC(preEpochProc); if ((value = Net->netTrainBatch(&groupCritReached))) break; if (Net->error < Net->criterion || groupCritReached) batchesAtCriterion++; else batchesAtCriterion = 0; if ((Net->minCritBatches > 0 && batchesAtCriterion >= Net->minCritBatches) || i >= Net->numUpdates) done = TRUE; willReport = (Net->reportInterval && ((i % Net->reportInterval == 0) || done)) ? TRUE : FALSE; RUN_PROC(postEpochProc); /* Here's the weight update (one epoch). */ A->updateWeights(willReport); RUN_PROC(postUpdateProc); updateDisplays(ON_UPDATE); Net->totalUpdates++; if (willReport) { printReport(lastReport, i, startTime); lastReport = i; } /* Stop if requested. */ if (smartUpdate(FALSE)) break; /* Change the algorithm if requested. */ if (A->code != Net->algorithm) { A = getAlgorithm(Net->algorithm); print(1, "Changing algorithm to %s...\n", A->longName); } } startTime = (getTime() - startTime); updateDisplays(ON_TRAINING); if (value == TCL_ERROR) return TCL_ERROR; result("Performed %d updates\n", i - 1); if (!done) { append("Training halted prematurely\n", i); value = TCL_ERROR; } if (Net->error <= Net->criterion && batchesAtCriterion >= Net->minCritBatches) append("Network reached overall error criterion of %f\n", Net->criterion); if (groupCritReached && batchesAtCriterion >= Net->minCritBatches) append("Network reached group output criterion\n"); append("Total time elapsed: %.3f seconds", ((real) startTime * 1e-3)); return value; }
QSharedPointer<SumTypeCalculatorIfc> SumShaType::createCalculator(const QString &input_path, FileInfo *file) { return QSharedPointer<SumTypeCalculatorIfc>(new SumShaCalculator(input_path, file, getSumFileManager(), getAlgorithm())); }
JNIEXPORT jint JNICALL Java_com_samsung_ip_JniIPActivity_nativeGetOutputPixel (JNIEnv *env, jclass thiz, jbyteArray inputarr, jbyteArray outpuarr, jobject algorithmObject, jint width, jint height) { unsigned char **OutputImage; int c_height = height<<1; int c_width = width<<1; int size = c_height * c_width; unsigned char *srcdata = new unsigned char[(width*height)<<2]; env->GetByteArrayRegion (inputarr, 0, (width*height)<<2, reinterpret_cast<jbyte*>(srcdata)); //inputData unsigned char **InputImage = memoryCopy1Dto2D(srcdata, c_width, c_height); jclass algorithmClass = env->GetObjectClass(algorithmObject); jmethodID method = env->GetMethodID(algorithmClass, "getAlgorithmListSize", "()I"); int algoLength = env->CallIntMethod(algorithmObject, method); for (int i = 0; i < algoLength; i++) { const char *name = getAlgorithm(env, algorithmObject, algorithmClass, i, "algorithmName"); if (!strcmp("SLCE", name)) { __android_log_print(ANDROID_LOG_ERROR, "JNI", "---SLCE Algorithm"); struct SLCEFuncParameter paramSet = getSLCEFuncParameter(env,algorithmObject, algorithmClass, i); OutputImage = SLCEFunc(InputImage, c_width, c_height,paramSet); InputImage = memoryCopy2DTo2D(OutputImage, c_width, c_height); } else if (!strcmp("NR", name)) { __android_log_print(ANDROID_LOG_ERROR, "JNI", "---NR Algorithm"); struct NRFuncParameter paramSet = getNRFuncParameter(env,algorithmObject, algorithmClass, i); OutputImage = NRFunc(InputImage, c_width, c_height,paramSet); InputImage = memoryCopy2DTo2D(OutputImage, c_width, c_height); }else if (!strcmp("DE_FA", name)) { __android_log_print(ANDROID_LOG_ERROR, "JNI", "---DE_FA Algorithm"); struct DE_FAFuncParameter paramSet = getDE_FAFuncParameter(env,algorithmObject, algorithmClass, i); OutputImage = DE_FAFunc(InputImage, c_width, c_height,paramSet); InputImage = memoryCopy2DTo2D(OutputImage, c_width, c_height); }else if (!strcmp("CS", name)) { __android_log_print(ANDROID_LOG_ERROR, "JNI", "---CS Algorithm"); struct CSFuncParameter paramSet = getCSFuncParameter(env,algorithmObject, algorithmClass, i); OutputImage = CSFunc(InputImage, c_width, c_height,paramSet); InputImage = memoryCopy2DTo2D(OutputImage, c_width, c_height); }else if (!strcmp("CC", name)) { __android_log_print(ANDROID_LOG_ERROR, "JNI", "---CC Algorithm"); struct CCFuncParameter paramSet = getCCFuncParameter(env,algorithmObject, algorithmClass, i); OutputImage = CCFunc(InputImage, c_width, c_height,paramSet); InputImage = memoryCopy2DTo2D(OutputImage, c_width, c_height); }else if (!strcmp("ASCR", name)) { __android_log_print(ANDROID_LOG_ERROR, "JNI", "---ASCR Algorithm"); struct ASCRFuncParameter paramSet = getASCRFuncParameter(env,algorithmObject, algorithmClass, i); OutputImage = ASCRFunc(InputImage, c_width, c_height,paramSet); InputImage = memoryCopy2DTo2D(OutputImage, c_width, c_height); } } unsigned char *destdata = memoryCopy2Dto1D(InputImage, c_width, c_height); env->SetByteArrayRegion(outpuarr, 0, (width*height)<<2, reinterpret_cast<jbyte*>(destdata)); env->ReleaseByteArrayElements(inputarr, (jbyte *)srcdata, 0); delete destdata; delete InputImage; delete OutputImage; return (width*height)<<2; }
void QblEvpDigest::init() { EVP_MD_CTX_init(&mdctx); EVP_DigestInit_ex(&mdctx, getAlgorithm(), NULL); }