void orbit_option(int option, int **perms, int **a, int **b, char **c, int **orbit_length, struct pga_vars *pga) { int t; Logical soluble_group; /* FILE * file; */ if (option != COMBINATION && option != STANDARDISE) { query_solubility(pga); if (pga->soluble) query_space_efficiency(pga); else pga->space_efficient = FALSE; query_orbit_information(pga); } else if (option == COMBINATION) { pga->print_orbit_summary = FALSE; pga->print_orbits = FALSE; } else if (option == STANDARDISE) { pga->print_orbit_summary = FALSE; pga->print_orbits = FALSE; } soluble_group = (pga->soluble || pga->Degree == 1 || pga->nmr_of_perms == 0); if (!pga->space_efficient) { t = runTime(); if (soluble_group) compute_orbits(a, b, c, perms, pga); else insoluble_compute_orbits(a, b, c, perms, pga); if (option != COMBINATION && option != STANDARDISE) { t = runTime() - t; printf("Time to compute orbits is %.2f seconds\n", t * CLK_SCALE); } } /* if in soluble portion of combination, we do not need to set up representives */ if (option == COMBINATION && pga->soluble) return; *orbit_length = find_orbit_reps(*a, *b, pga); if (pga->print_orbit_summary) orbit_summary(*orbit_length, pga); /* file = OpenFile ("COUNT", "a+"); fprintf (file, "%d,\n", pga->nmr_orbits); */ }
void CEnumInfo<T>::outEnumInfo(FILE **pOutFile, bool removeReportFile, const CGroupsInfo *pGroupInfo) { setRunTime(); FILE *outFile = pOutFile ? *pOutFile : NULL; if (!outFile) return; if (!pGroupInfo) pGroupInfo = this; pGroupInfo->printGroupInfo(outFile); const ulonglong nConstrMatr = constrCanonical(); char buff[256]; SPRINTF(buff, "\n%10llu matri%s" CONSTRUCTED_IN " ", nConstrMatr, nConstrMatr == 1 ? "x" : "ces"); const size_t len = strlen(buff); convertTime(runTime(), buff + len, countof(buff) - len, false); outString(buff, outFile); const ulonglong nMatr = numbSimpleDesign(); if (nConstrMatr > 0) { SPRINTF(buff, "%10llu matri%s ha%s no replicated blocks\n", nMatr, nMatr == 1 ? "x" : "ces", nMatr == 1 ? "s" : "ve"); outString(buff, outFile); } SPRINTF(buff, "%10llu matri%s fully constructed\n", constrTotal(), constrTotal() == 1 ? "x was" : "ces were"); outString(buff, outFile); outEnumInformation(pOutFile); if (removeReportFile) // Remove temporary file with the intermediate results remove(reportFileName()); }
int32 psIdeaTest(void) { psCipherContext_t eCtx; psIdeaInit(&eCtx.idea, iv, key); runTime(&eCtx, NULL, TINY_CHUNKS, IDEA_ALG); runTime(&eCtx, NULL, SMALL_CHUNKS, IDEA_ALG); runTime(&eCtx, NULL, MEDIUM_CHUNKS, IDEA_ALG); runTime(&eCtx, NULL, LARGE_CHUNKS, IDEA_ALG); runTime(&eCtx, NULL, HUGE_CHUNKS, IDEA_ALG); psIdeaClear(&eCtx.idea); return PS_SUCCESS; }
int32 psSeedTest(void) { psCipherContext_t eCtx; psSeedInit(&eCtx.seed, iv, key); runTime(&eCtx, NULL, TINY_CHUNKS, SEED_ALG); runTime(&eCtx, NULL, SMALL_CHUNKS, SEED_ALG); runTime(&eCtx, NULL, MEDIUM_CHUNKS, SEED_ALG); runTime(&eCtx, NULL, LARGE_CHUNKS, SEED_ALG); runTime(&eCtx, NULL, HUGE_CHUNKS, SEED_ALG); psSeedClear(&eCtx.seed); return PS_SUCCESS; }
int32 psArc4Test(void) { psCipherContext_t eCtx; psArc4Init(&eCtx.arc4, key, 16); runTime(&eCtx, NULL, TINY_CHUNKS, ARC4_ALG); runTime(&eCtx, NULL, SMALL_CHUNKS, ARC4_ALG); runTime(&eCtx, NULL, MEDIUM_CHUNKS, ARC4_ALG); runTime(&eCtx, NULL, LARGE_CHUNKS, ARC4_ALG); runTime(&eCtx, NULL, HUGE_CHUNKS, ARC4_ALG); psArc4Clear(&eCtx.arc4); return 0; }
int main( int argc, char * argv[] ) { std::shared_ptr<argList> args( new argList( argc, argv ) ); if ( !args->checkRootCase() ) { FatalError.exit(); } std::shared_ptr<Time> runTime( new Time ( Time::controlDictName, args->rootPath(), args->caseName() ) ); string filename = static_cast<std::string>( args->rootPath() ) + "/" + static_cast<std::string>( args->globalCaseName() ) + "/constant/fsi.yaml"; YAML::Node config = YAML::LoadFile( filename ); assert( config["fluid-solver"] ); std::string fluidSolver = config["fluid-solver"].as<std::string>(); assert( fluidSolver == "coupled-pressure-velocity-solver" || fluidSolver == "pimple-solver" || fluidSolver == "compressible-solver" ); std::shared_ptr<foamFluidSolver> fluid; if ( fluidSolver == "coupled-pressure-velocity-solver" ) fluid = std::shared_ptr<foamFluidSolver> ( new CoupledFluidSolver( Foam::fvMesh::defaultRegion, args, runTime ) ); if ( fluidSolver == "pimple-solver" ) fluid = std::shared_ptr<foamFluidSolver> ( new FluidSolver( Foam::fvMesh::defaultRegion, args, runTime ) ); if ( fluidSolver == "compressible-solver" ) fluid = std::shared_ptr<foamFluidSolver> ( new CompressibleFluidSolver( Foam::fvMesh::defaultRegion, args, runTime ) ); assert( fluid ); PreciceFluidSolver solver( fluid ); solver.run(); Info << "End\n" << endl; label tmp = Pstream::myProcNo(); reduce( tmp, sumOp<label>() ); return (0); }
int main( int argc, char *argv[ ] ){ allocator_init(); int testNumber = 0; if( argc != 2 ){ printf("Usage: %s | 1 | 2 | 3 | 4 | 5 | 6 |\n", argv[ 0 ] ); return 0; } testNumber = atoi(argv[1]); if ( ( testNumber < 1 ) || ( testNumber > 6 ) ) { printf("\nError.\nOption %d is an invalid token!.\n", testNumber ); printf( "Please choose a test number between 1 and 6 \n\n" ); return 0; } if ( testNumber == 1 ) { runTime( test1 ); } else if ( testNumber == 2 ){ runTime( test2 ); } else if ( testNumber == 3 ){ runTime( test3 ); } else if ( testNumber == 4 ){ runTime( test4 ); } else if ( testNumber == 5 ){ runTime( test5 ); } else if ( testNumber == 6 ){ runTime( test6 ); } allocator_finalize(); return 0; }
int32 psAesTestGCM(void) { int32 err; psCipherContext_t eCtx; psCipherGivContext_t eCtxGiv; memset(&eCtxGiv, 0, sizeof(eCtxGiv)); #ifndef USE_LIBSODIUM_AES_GCM _psTrace("***** AES-GCM-128 *****\n"); if ((err = psAesInitGCM(&eCtx.aesgcm, key, 16)) != PS_SUCCESS) { _psTraceInt("FAILED: psAesInitGCM returned %d\n", err); return err; } psAesReadyGCM(&eCtx.aesgcm, iv, iv, 16); runTime(&eCtx, &eCtxGiv, TINY_CHUNKS, AES_GCM_ALG); runTime(&eCtx, &eCtxGiv, SMALL_CHUNKS, AES_GCM_ALG); runTime(&eCtx, &eCtxGiv, MEDIUM_CHUNKS, AES_GCM_ALG); runTime(&eCtx, &eCtxGiv, LARGE_CHUNKS, AES_GCM_ALG); runTime(&eCtx, &eCtxGiv, HUGE_CHUNKS, AES_GCM_ALG); #else _psTrace("***** Skipping AES-GCM-128 *****\n"); #endif /* !USE_LIBSODIUM */ _psTrace("***** AES-GCM-256 *****\n"); if ((err = psAesInitGCM(&eCtx.aesgcm, key, 32)) != PS_SUCCESS) { _psTraceInt("FAILED: psAesInitGCM returned %d\n", err); return err; } psAesReadyGCM(&eCtx.aesgcm, iv, iv, 16); runTime(&eCtx, &eCtxGiv, TINY_CHUNKS, AES_GCM_ALG); runTime(&eCtx, &eCtxGiv, SMALL_CHUNKS, AES_GCM_ALG); runTime(&eCtx, &eCtxGiv, MEDIUM_CHUNKS, AES_GCM_ALG); runTime(&eCtx, &eCtxGiv, LARGE_CHUNKS, AES_GCM_ALG); runTime(&eCtx, &eCtxGiv, HUGE_CHUNKS, AES_GCM_ALG); psAesClearGCM(&eCtx.aesgcm); return PS_SUCCESS; }
int32 psDes3Test(void) { psCipherContext_t eCtx; #if defined(USE_MATRIX_3DES) && !defined(PS_3DES_IMPROVE_PERF_INCREASE_CODESIZE) _psTrace("##########\n#\n# "); _psTrace("3DES speeds can be improved by enabling\n# "); _psTrace("PS_3DES_IMPROVE_PERF_INCREASE_CODESIZE in cryptoConfig.h\n"); _psTrace("#\n#\n#########\n"); #endif psDes3Init(&eCtx.des3, iv, key); runTime(&eCtx, NULL, TINY_CHUNKS, DES3_ALG); runTime(&eCtx, NULL, SMALL_CHUNKS, DES3_ALG); runTime(&eCtx, NULL, MEDIUM_CHUNKS, DES3_ALG); runTime(&eCtx, NULL, LARGE_CHUNKS, DES3_ALG); runTime(&eCtx, NULL, HUGE_CHUNKS, DES3_ALG); psDes3Clear(&eCtx.des3); return 0; }
Foam::polyMesh::readUpdateState Foam::readerDatabase::setTime ( const instant& timeInstance, const label timeIndex ) { runTime().setTime(timeInstance, timeIndex); polyMesh::readUpdateState meshChange; if (meshPtr_) { // Update loaded mesh meshChange = meshPtr_->readUpdate(); if (setName_.size() && meshChange != polyMesh::UNCHANGED) { Info<< "Subsetting mesh based on " << setName_ << endl; fvMeshSubset& mesh = *meshPtr_; cellSet currentSet(mesh, setName_); mesh.setCellSubset(currentSet); } if ( (meshChange == polyMesh::TOPO_CHANGE) || (meshChange == polyMesh::TOPO_PATCH_CHANGE) ) { getPolyHedra(); } } else { // Force new mesh to be loaded for current time loadMesh(); meshChange = polyMesh::TOPO_CHANGE; } return meshChange; }
/** * Number of milliseconds since this game was started. Note, this * is really only useful looking at the time between two calls of this. */ long Sys::runTime() { static bool firstTime = true; // In some cases it's easier to get the number of milliseconds since some external // event (e.g. the epoch) than the start of this program. So we record that time at // the start of the program and return the difference with every subsequent time. if (firstTime) { firstTime = false; startOfProgramTime = 0; startOfProgramTime = runTime(); } long currentTime; #ifdef WIN32 return GetTickCount64(); #else static timeval timeval; gettimeofday(&timeval, NULL); currentTime = timeval.tv_sec*1000 + timeval.tv_usec/1000; #endif return currentTime - startOfProgramTime; }
void interactive_pga(Logical group_present, FILE *StartFile, int group_nmr, int ***auts, struct pga_vars *pga, struct pcp_vars *pcp) { struct pga_vars flag; int option; Logical soluble_group = TRUE; FILE *OutputFile = 0; FILE *LINK_input = 0; char *StartName = 0; int t; int **perms = 0; int index; int **S = 0; int k; int K; int label; int *a = 0, *b = 0; char *c = 0; int *orbit_length = 0; int nmr_of_exponents; int *subset = 0; int alpha; int upper_step; int rep; int i; list_interactive_pga_menu(); do { option = read_option(MAX_INTERACTIVE_OPTION); switch (option) { case -1: list_interactive_pga_menu(); break; case SUPPLY_AUTS: auts = read_auts(PGA, &pga->m, &nmr_of_exponents, pcp); #ifdef HAVE_GMP autgp_order(pga, pcp); #endif pga->soluble = TRUE; start_group(&StartFile, auts, pga, pcp); break; case EXTEND_AUTS: extend_automorphisms(auts, pga->m, pcp); print_auts(pga->m, pcp->lastg, auts, pcp); break; case RESTORE_GP: StartName = GetString("Enter input file name: "); StartFile = OpenFileInput(StartName); if (StartFile != NULL) { read_value(TRUE, "Which group? ", &group_nmr, 0); auts = restore_group(TRUE, StartFile, group_nmr, pga, pcp); RESET(StartFile); } break; case DISPLAY_GP: print_presentation(FALSE, pcp); print_structure(1, pcp->lastg, pcp); print_pcp_relations(pcp); break; case SINGLE_STAGE: t = runTime(); if (group_present && pga->m == 0) start_group(&StartFile, auts, pga, pcp); assert(OutputFile); construct(1, &flag, SINGLE_STAGE, OutputFile, StartFile, 0, ALL, group_nmr, pga, pcp); t = runTime() - t; printf("Time for intermediate stage is %.2f seconds\n", t * CLK_SCALE); break; case DEGREE: read_step_size(pga, pcp); read_subgroup_rank(&k); query_exponent_law(pga); enforce_laws(pga, pga, pcp); extend_automorphisms(auts, pga->m, pcp); step_range(k, &pga->s, &upper_step, auts, pga, pcp); if (pga->s > upper_step) printf("Desired step size is invalid for current group\n"); else { if (pga->s < upper_step) { printf("The permitted relative step sizes range from %d to %d\n", pga->s, upper_step); read_value( TRUE, "Input the chosen relative step size: ", &pga->s, 0); } store_definition_sets(pga->r, pga->s, pga->s, pga); get_definition_sets(pga); pga->print_degree = TRUE; compute_degree(pga); pga->print_degree = FALSE; } break; case PERMUTATIONS: if (pga->Degree != 0) { t = runTime(); query_solubility(pga); pga->trace = FALSE; if (pga->soluble) query_space_efficiency(pga); else pga->space_efficient = FALSE; query_perm_information(pga); strip_identities(auts, pga, pcp); soluble_group = (pga->soluble || pga->Degree == 1 || pga->nmr_of_perms == 0); if (!soluble_group) { #if defined(GAP_LINK) StartGapFile(pga); #else #if defined(GAP_LINK_VIA_FILE) start_GAP_file(&LINK_input, auts, pga, pcp); #endif #endif } perms = permute_subgroups(LINK_input, &a, &b, &c, auts, pga, pcp); #if defined(GAP_LINK_VIA_FILE) if (!soluble_group) CloseFile(LINK_input); #endif t = runTime() - t; printf("Time to compute permutations is %.2f seconds\n", t * CLK_SCALE); } else printf("You must first select option %d\n", DEGREE); break; case ORBITS: orbit_option(option, perms, &a, &b, &c, &orbit_length, pga); break; case STABILISERS: case STABILISER: assert(perms); stabiliser_option( option, auts, perms, a, b, c, orbit_length, pga, pcp); /* free_space (pga->soluble, perms, orbit_length, a, b, c, pga); */ break; case MATRIX_TO_LABEL: S = allocate_matrix(pga->s, pga->q, 0, FALSE); subset = allocate_vector(pga->s, 0, FALSE); printf("Input the %d x %d subgroup matrix:\n", pga->s, pga->q); read_matrix(S, pga->s, pga->q); K = echelonise_matrix(S, pga->s, pga->q, pga->p, subset, pga); printf("The standard matrix is:\n"); print_matrix(S, pga->s, pga->q); printf("The label is %d\n", subgroup_to_label(S, K, subset, pga)); free_vector(subset, 0); break; case LABEL_TO_MATRIX: read_value(TRUE, "Input allowable subgroup label: ", &label, 1); S = label_to_subgroup(&index, &subset, label, pga); printf("The corresponding standard matrix is\n"); print_matrix(S, pga->s, pga->q); break; case IMAGE: t = runTime(); /* invert_automorphisms (auts, pga, pcp); print_auts (pga->m, pcp->lastg, auts, pcp); */ printf("Input the subgroup label and automorphism number: "); read_value(TRUE, "", &label, 1); read_value(FALSE, "", &alpha, 1); printf("Image is %d\n", find_image(label, auts[alpha], pga, pcp)); t = runTime() - t; printf("Computation time in seconds is %.2f\n", t * CLK_SCALE); break; case SUBGROUP_RANK: read_subgroup_rank(&k); printf("Closure of initial segment subgroup has rank %d\n", close_subgroup(k, auts, pga, pcp)); break; case ORBIT_REP: printf("Input label for subgroup: "); read_value(TRUE, "", &label, 1); rep = abs(a[label]); for (i = 1; i <= pga->nmr_orbits && pga->rep[i] != rep; ++i) ; printf("Subgroup with label %d has representative %d and is in orbit " "%d\n", label, rep, i); break; case COMPACT_DESCRIPTION: Compact_Description = TRUE; read_value(TRUE, "Lower bound for order (0 for all groups generated)? ", &Compact_Order, 0); break; case AUT_CLASSES: t = runTime(); permute_elements(); t = runTime() - t; printf("Time to compute orbits is %.2f seconds\n", t * CLK_SCALE); break; /* printf ("Input label: "); scanf ("%d", &l); process_complete_orbit (a, l, pga, pcp); break; case TEMP: printf ("Input label: "); scanf ("%d", &l); printf ("Input label: "); scanf ("%d", &u); for (i = l; i <= u; ++i) { x = IsValidAllowableSubgroup (i, pga); printf ("%d is %d\n", i, x); } StartName = GetString ("Enter output file name: "); OutputFile = OpenFileOutput (StartName); part_setup_reps (pga->rep, pga->nmr_orbits, orbit_length, perms, a, b, c, auts, OutputFile, OutputFile, pga, pcp); list_word (pga, pcp); read_value (TRUE, "Input the rank of the subgroup: ", &pga->q, 1); strip_identities (auts, pga, pcp); break; */ case EXIT: case MAX_INTERACTIVE_OPTION: printf("Exiting from interactive p-group generation menu\n"); break; } /* switch */ } while (option != 0 && option != MAX_INTERACTIVE_OPTION); #if defined(GAP_LINK) if (!soluble_group) QuitGap(); #endif }
int main( int argc, char * argv[] ) { std::shared_ptr<argList> args( new argList( argc, argv ) ); if ( !args->checkRootCase() ) { FatalError.exit(); } std::shared_ptr<Time> runTime( new Time ( Time::controlDictName, args->rootPath(), args->caseName() ) ); string filename = static_cast<std::string>( args->rootPath() ) + "/" + static_cast<std::string>( args->globalCaseName() ) + "/constant/fsi.yaml"; YAML::Node config = YAML::LoadFile( filename ); assert( config["fluid-solver"] ); std::string fluidSolver = config["fluid-solver"].as<std::string>(); assert( fluidSolver == "coupled-pressure-velocity-solver" || fluidSolver == "pimple-solver" || fluidSolver == "compressible-solver" || fluidSolver == "sdc-pimple-solver" || fluidSolver == "sdc-laplacian-solver" || fluidSolver == "esdirk-pimple-solver" ); std::shared_ptr<foamFluidSolver> fluid; std::shared_ptr<sdc::SDC> sdc; std::shared_ptr<sdc::ESDIRK> esdirk; if ( fluidSolver == "coupled-pressure-velocity-solver" ) fluid = std::shared_ptr<foamFluidSolver> ( new CoupledFluidSolver( Foam::fvMesh::defaultRegion, args, runTime ) ); if ( fluidSolver == "pimple-solver" ) fluid = std::shared_ptr<foamFluidSolver> ( new FluidSolver( Foam::fvMesh::defaultRegion, args, runTime ) ); if ( fluidSolver == "compressible-solver" ) fluid = std::shared_ptr<foamFluidSolver> ( new CompressibleFluidSolver( Foam::fvMesh::defaultRegion, args, runTime ) ); std::shared_ptr<sdc::AdaptiveTimeStepper> adaptiveTimeStepper; if ( fluidSolver == "sdc-pimple-solver" || fluidSolver == "esdirk-pimple-solver" || fluidSolver == "sdc-laplacian-solver" ) { YAML::Node adaptiveTimeConfig( config["adaptive-time-stepping"] ); assert( adaptiveTimeConfig["enabled"] ); bool adaptiveTimeStepping = adaptiveTimeConfig["enabled"].as<bool>(); std::string filter = "elementary"; double adaptiveTolerance = 1.0e-3; double safetyFactor = 0.5; if ( adaptiveTimeStepping ) { assert( adaptiveTimeConfig["filter"] ); assert( adaptiveTimeConfig["tolerance"] ); assert( adaptiveTimeConfig["safety-factor"] ); filter = adaptiveTimeConfig["filter"].as<std::string>(); adaptiveTolerance = adaptiveTimeConfig["tolerance"].as<double>(); safetyFactor = adaptiveTimeConfig["safety-factor"].as<double>(); } adaptiveTimeStepper = std::shared_ptr<sdc::AdaptiveTimeStepper> ( new sdc::AdaptiveTimeStepper( adaptiveTimeStepping, filter, adaptiveTolerance, safetyFactor ) ); } if ( fluidSolver == "sdc-pimple-solver" || fluidSolver == "sdc-laplacian-solver" ) { YAML::Node sdcConfig( config["sdc"] ); assert( sdcConfig["convergence-tolerance"] ); assert( sdcConfig["number-of-points"] ); assert( sdcConfig["quadrature-rule"] ); assert( adaptiveTimeStepper ); int n = sdcConfig["number-of-points"].as<int>(); double tol = sdcConfig["convergence-tolerance"].as<double>(); std::string quadratureRule = sdcConfig["quadrature-rule"].as<std::string>(); std::shared_ptr<sdc::SDCSolver> solver; if ( fluidSolver == "sdc-pimple-solver" ) solver = std::shared_ptr<sdc::SDCSolver>( new SDCFluidSolver( Foam::fvMesh::defaultRegion, args, runTime ) ); if ( fluidSolver == "sdc-laplacian-solver" ) solver = std::shared_ptr<sdc::SDCSolver>( new SDCLaplacianSolver( Foam::fvMesh::defaultRegion, args, runTime ) ); sdc = std::shared_ptr<sdc::SDC> ( new sdc::SDC( solver, adaptiveTimeStepper, quadratureRule, n, tol ) ); } if ( fluidSolver == "esdirk-pimple-solver" ) { YAML::Node esdirkConfig( config["esdirk"] ); assert( esdirkConfig["method"] ); assert( adaptiveTimeStepper ); std::string method = esdirkConfig["method"].as<std::string>(); std::shared_ptr<sdc::SDCSolver> solver; solver = std::shared_ptr<sdc::SDCSolver>( new SDCFluidSolver( Foam::fvMesh::defaultRegion, args, runTime ) ); esdirk = std::shared_ptr<sdc::ESDIRK>( new sdc::ESDIRK( solver, method, adaptiveTimeStepper ) ); } assert( fluid || sdc || esdirk ); if ( fluid ) fluid->run(); if ( sdc ) sdc->run(); if ( esdirk ) esdirk->run(); Info << "End\n" << endl; return 0; }
static int32 psAesTestCBC(void) { int32 err; psCipherContext_t eCtx; #if defined(USE_MATRIX_AES_CBC) && !defined(PS_AES_IMPROVE_PERF_INCREASE_CODESIZE) _psTrace("##########\n#\n# "); _psTrace("AES speeds can be improved by enabling\n# "); _psTrace("PS_AES_IMPROVE_PERF_INCREASE_CODESIZE in cryptoConfig.h\n"); _psTrace("#\n#\n#########\n"); #endif _psTrace("***** AES-128 CBC *****\n"); if ((err = psAesInitCBC(&eCtx.aes, iv, key, 16, PS_AES_ENCRYPT)) != PS_SUCCESS) { _psTraceInt("FAILED: returned %d\n", err); return err; } runTime(&eCtx, NULL, TINY_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, SMALL_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, MEDIUM_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, LARGE_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, LARGE_CHUNKS, AES_DEC_ALG); runTime(&eCtx, NULL, HUGE_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, HUGE_CHUNKS, AES_DEC_ALG); psAesClearCBC(&eCtx.aes); _psTrace("***** AES-192 CBC *****\n"); if ((err = psAesInitCBC(&eCtx.aes, iv, key, 24, PS_AES_ENCRYPT)) != PS_SUCCESS) { _psTraceInt("FAILED: returned %d\n", err); return err; } runTime(&eCtx, NULL, TINY_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, SMALL_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, MEDIUM_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, LARGE_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, LARGE_CHUNKS, AES_DEC_ALG); runTime(&eCtx, NULL, HUGE_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, HUGE_CHUNKS, AES_DEC_ALG); psAesClearCBC(&eCtx.aes); _psTrace("***** AES-256 CBC *****\n"); if ((err = psAesInitCBC(&eCtx.aes, iv, key, 32, PS_AES_ENCRYPT)) != PS_SUCCESS) { _psTraceInt("FAILED: returned %d\n", err); return err; } runTime(&eCtx, NULL, TINY_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, SMALL_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, MEDIUM_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, LARGE_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, LARGE_CHUNKS, AES_DEC_ALG); runTime(&eCtx, NULL, HUGE_CHUNKS, AES_ENC_ALG); runTime(&eCtx, NULL, HUGE_CHUNKS, AES_DEC_ALG); psAesClearCBC(&eCtx.aes); return 0; }
static Logical setup_start_info (Logical identity_map, Logical status, FILE *file, int format, struct pga_vars *pga, struct pcp_vars *pcp) { register int *y = y_address; FILE * FileName; FILE * presentation_file; Logical group_present = FALSE; int exit_value; int *list, *head; int i; #if defined (TIME) int t; t = runTime (); #endif if (!identity_map) { /* we must recompute the presentation since generators and relations have been altered by applying the standard map */ /* memory leak September 1996 */ if (user_gen_name != NULL) { num_gens = user_gen_name[0].first; for (i = 1; i <= num_gens; ++i) { free_vector (user_gen_name[i].g, 0); } free (user_gen_name); user_gen_name = NULL; free_vector (inv_of, 0); free_vector (pairnumber, 0); } exit_value = pquotient (0, 0, file, format, pcp); if (exit_value == SUCCESS) group_present = TRUE; #if defined (TIME) printf ("Time to recompute pcp is %.2f\n", (runTime () - t) * CLK_SCALE); #endif } else { /* generators and relations of presentation have not changed -- we can restore presentation for either full p-covering group or class c + 1 quotient */ if (status == END_OF_CLASS) presentation_file = OpenFile ("ISOM_group_file", "r"); else presentation_file = OpenFile ("ISOM_cover_file", "r"); restore_pcp (presentation_file, pcp); CloseFile (presentation_file); group_present = TRUE; } #if defined (DEBUG) pcp->diagn = TRUE; printf ("The modified presentation is \n"); print_presentation (TRUE, pcp); pcp->diagn = FALSE; #endif if (!group_present || pcp->cc == 0) return group_present; /* do we need to compute the full p-covering group? */ if (!identity_map || status == END_OF_CLASS) { pcp->multiplicator = TRUE; next_class (FALSE, &head, &list, pcp); pga->exponent_law = pcp->extra_relations; pga->metabelian = pcp->metabelian; enforce_laws (pga, pga, pcp); pcp->multiplicator = FALSE; FileName = OpenFile ("ISOM_cover_file", "w"); save_pcp (FileName, pcp); CloseFile (FileName); } initialise_pga (pga, pcp); pga->m = 0; pga->ndgen = y[pcp->clend + 1]; set_values (pga, pcp); return group_present; }
void isom_options (int format, struct pcp_vars *pcp) { register int *y = y_address; FILE *Status; FILE *FileName; FILE *Subgroup; struct pga_vars pga; Logical user_supplied = FALSE; Logical group_present = FALSE; Logical identity_map; Logical finished; Logical valid; Logical equal; int output = DEFAULT_STANDARD_PRINT; int start_class, final_class; int option; int t; int status; int complete; int iteration; int *seq1; int *seq2; int len1, len2; int nmr_items; int ***auts; int x_dim, y_dim; FILE * GAP_library; char *name; int nmr_of_exponents; StandardPresentation = TRUE; pga.nmr_soluble = 0; list_isom_menu (); do { option = read_option (MAXOPTION); switch (option) { case -1: list_isom_menu (); break; case START_INFO: t = runTime (); group_present = setup_start_info (FALSE, 0, stdin, format, &pga, pcp); handle_error (group_present); user_supplied = TRUE; t = runTime () - t; /* it is possible that the p-quotient is trivial */ if (pcp->cc == 0) { group_present = FALSE; break; } printf ("Class %d %d-quotient and its %d-covering group computed in %.2f seconds\n", pcp->cc - 1, pcp->p, pcp->p, t * CLK_SCALE); break; case CONSTRUCT: if (!user_supplied) { name = GetString ("Enter input file name for group information: "); FileName = OpenFile (name, "r"); if (FileName == NULL) break; } name = GetString ("Enter output file name for group information: "); read_value (TRUE, "Standardise presentation to what class? ", &final_class, 0); if (user_supplied && final_class < pcp->cc) { printf ("Value supplied for end class must be at least %d\n", pcp->cc); } /* read in data from file and set up group to end of start_class and compute its p-covering group */ if (!user_supplied) { group_present = setup_start_info (FALSE, 0, FileName, FILE_INPUT, &pga, pcp); handle_error (group_present); if (final_class < pcp->cc) { CloseFile (FileName); printf ("Value supplied for end class must be at least %d\n", pcp->cc); } } if (pcp->cc == 0) { printf ("%d-quotient is trivial\n", pcp->p); break; } complete = (pcp->newgen == 0) ? TERMINAL : CAPABLE; iteration = 0; for (start_class = pcp->cc; start_class <= final_class && complete != TERMINAL; ++start_class) { t = runTime (); identity_map = FALSE; Subgroup = OpenFile ("ISOM_Subgroup", "w"); do { ++iteration; set_defaults (&pga); /* pga.space_efficient = TRUE; */ /* either prompt for information or read it from file */ if (user_supplied) { auts = read_auts (STANDARDISE, &pga.m, &nmr_of_exponents, pcp) ; pga.fixed = 0; query_solubility (&pga); user_supplied = FALSE; #ifdef HAVE_GMP autgp_order (&pga, pcp); #endif } else { auts = read_auts_from_file (FileName, &pga.m, pcp); nmr_items = fscanf (FileName, "%d", &pga.fixed); verify_read (nmr_items, 1); nmr_items = fscanf (FileName, "%d", &pga.soluble); verify_read (nmr_items, 1); #ifdef HAVE_GMP fscanf (FileName, "\n"); mpz_init (&pga.aut_order); mpz_inp_str (&pga.aut_order, FileName, 10); #endif CloseFile (FileName); } x_dim = pga.m; y_dim = pcp->lastg; /* construct standard presentation relative to smallest permissible characteristic subgroup in p-multiplicator */ standard_presentation (&identity_map, output, auts, &pga, pcp); free_array (auts, x_dim, y_dim, 1); /* was the characteristic subgroup chosen in this iteration the whole of the p-multiplicator? */ Status = OpenFile ("ISOM_Status", "r"); fscanf (Status, "%d", &status); fscanf (Status, "%d", &complete); CloseFile (Status); /* have we finished the construction? */ finished = (status == END_OF_CLASS && (start_class == final_class || complete == TERMINAL)); /* organise to write modified presentation + automorphisms to file ISOM_PP */ if (!identity_map || finished) { copy_file( "ISOM_present", "ISOM_PP" ); append_file( "ISOM_NextClass", "ISOM_PP" ); } else copy_file( "ISOM_NextClass", "ISOM_PP" ); if (finished) break; /* if necessary, set up new presentation + other information */ FileName = OpenFile ("ISOM_PP", "r"); group_present = setup_start_info (identity_map, status, FileName, FILE_INPUT, &pga, pcp); handle_error (group_present); /* if appropriate, factor subgroup from p-multiplicator */ if (status != END_OF_CLASS) factor_subgroup (pcp); /* reinitialise pga structure */ initialise_pga (&pga, pcp); pga.m = 0; pga.ndgen = y[pcp->clend + 1]; set_values (&pga, pcp); } while (status != END_OF_CLASS && complete != TERMINAL); CloseFile (Subgroup); /* the group may have completed only when relations are enforced; this is an attempt to determine this case */ if (pga.nuclear_rank != 0 && pcp->complete) break; t = runTime () - t; printf ("Computing standard presentation for class %d took %.2f seconds\n", start_class, t * CLK_SCALE); } /* we currently may have presentation for p-covering group; or is the starting group terminal? if so, we may want to use last_class to revert to group presentation */ if (!user_supplied && iteration == 0 && !pcp->complete) last_class (pcp); /* is the group terminal? */ if (complete == TERMINAL) printf ("The largest %d-quotient of the group has class %d\n", pcp->p, pcp->cc); if (iteration == 0) break; /* rename file ISOM_PP containing iteration info to nominated file */ rename( "ISOM_PP", name ); break; case PRINT_PCP: if (group_present) print_presentation (TRUE, pcp); break; case SAVE_PRES: name = GetString ("Enter output file name: "); FileName = OpenFileOutput (name); if (group_present && FileName != NULL) { save_pcp (FileName, pcp); CloseFile (FileName); printf ("Presentation written to file\n"); } break; case COMPARE: valid = get_description ("Enter file name storing first presentation: ", &len1, &seq1, pcp); if (!valid) break; valid = get_description ("Enter file name storing second presentation: ", &len2, &seq2, pcp); if (!valid) break; equal = (len1 == len2) ? compare_sequences (seq1, seq2, len1): FALSE; printf ("Identical presentations? %s\n", equal == TRUE ? "True" : "False"); free_vector (seq1, 1); free_vector (seq2, 1); break; case STANDARD_PRINT_LEVEL: read_value (TRUE, "Input print level for construction (0-2): ", &output, 0); /* allow user to supply same max print level as for p-quotient calculations */ if (output == MAX_STANDARD_PRINT + 1) --output; if (output > MAX_STANDARD_PRINT) { printf ("Print level must lie between %d and %d\n", MIN_STANDARD_PRINT, MAX_STANDARD_PRINT); output = DEFAULT_STANDARD_PRINT; } break; case PQ_MENU: options (ISOM_MENU, format, pcp); break; case ISOM_OPTION: FileName = OpenFile (name, "r"); group_present = setup_start_info (FALSE, 0, FileName, FILE_INPUT, &pga, pcp); pcp->multiplicator_rank = pcp->lastg - y[pcp->clend + pcp->cc-1]; last_class (pcp); auts = read_auts_from_file (FileName, &pga.m, pcp); nmr_items = fscanf (FileName, "%d", &pga.fixed); verify_read (nmr_items, 1); nmr_items = fscanf (FileName, "%d", &pga.soluble); verify_read (nmr_items, 1); printf ("Images of user-supplied generators are listed last below\n"); print_map (pcp); #ifdef HAVE_GMP fscanf (FileName, "\n"); mpz_init (&pga.aut_order); mpz_inp_str (&pga.aut_order, FileName, 10); #endif CloseFile (FileName); GAP_library = OpenFile ("GAP_library", "a+"); write_GAP_library (GAP_library, pcp); pga.nmr_centrals = pga.m; pga.nmr_stabilisers = 0; GAP_auts (GAP_library, auts, auts, &pga, pcp); CloseFile (GAP_library); printf ("Presentation listing images of user-supplied generators written to GAP_library\n"); break; case EXIT: case MAXOPTION: unlink( "ISOM_present" ); unlink( "ISOM_Subgroup" ); unlink( "ISOM_cover_file" ); unlink( "ISOM_group_file" ); unlink( "ISOM_XX" ); unlink( "ISOM_NextClass" ); unlink( "ISOM_Status" ); printf ("Exiting from ANU p-Quotient Program\n"); break; } /* switch */ } while (option != 0 && option != MAXOPTION); }
void stabiliser_option(int option, int ***auts, int **perms, int *a, int *b, char *c, int *orbit_length, struct pga_vars *pga, struct pcp_vars *pcp) { int t; int i; /*Logical soluble_group;*/ FILE *OutputFile; char *StartName; int *rep; int *length; rep = allocate_vector(1, 1, 0); length = allocate_vector(1, 1, 0); t = runTime(); query_solubility(pga); if (pga->soluble) query_space_efficiency(pga); else pga->space_efficient = FALSE; /*soluble_group = (pga->soluble || pga->Degree == 1 || pga->nmr_of_perms == 0);*/ query_terminal(pga); query_exponent_law(pga); query_metabelian_law(pga); query_group_information(pga->p, pga); query_aut_group_information(pga); StartName = GetString("Enter output file name: "); OutputFile = OpenFileOutput(StartName); pga->final_stage = (pga->q == pga->multiplicator_rank); pga->nmr_of_descendants = 0; pga->nmr_of_capables = 0; if (option == STABILISER) { read_value(TRUE, "Input the orbit representative: ", &rep[1], 1); /* find the length of the orbit having this representative */ for (i = 1; i <= pga->nmr_orbits && pga->rep[i] != rep[1]; ++i) ; if (pga->rep[i] == rep[1]) length[1] = orbit_length[i]; else { printf("%d is not an orbit representative\n", rep[1]); return; } } if (option == STABILISER) setup_reps(rep, 1, length, perms, a, b, c, auts, OutputFile, OutputFile, pga, pcp); else setup_reps(pga->rep, pga->nmr_orbits, orbit_length, perms, a, b, c, auts, OutputFile, OutputFile, pga, pcp); /* #if defined (GAP_LINK) if (!soluble_group) QuitGap (); #endif */ RESET(OutputFile); printf("Time to process representative is %.2f seconds\n", (runTime() - t) * CLK_SCALE); }
int main(int argc, char *argv[]) { // create argList object "args" (previously explained) #include "setRootCase.H" // Time object is conventionally called "runTime" Time runTime(Foam::Time::controlDictName, args); /*************************************************************************\ // alternatively, inclusion of "createTime.H" // creates Time object "runTime" (see the actual definition inside) // this is what is used in most of the codes provided by OpenFOAM #include "createTime.H" \*************************************************************************/ Info << "root path = " << runTime.rootPath() << endl; Info << "caseName = " << runTime.caseName() << endl; Info << "path = " << runTime.path() << endl; // time path is a name of current time path (default is 0) Info << "time path = " << runTime.timePath() << endl; Info << "start time = " << runTime.startTime() << endl; Info << "end time = " << runTime.endTime() << endl; Info << "deltaT = " << runTime.deltaT() << endl; Info << "valid time directories = " << runTime.times() << endl; // write data runTime.writeNow(); // function loop() return true if run should continue and if so // increment time while(runTime.loop()) { // function timeName() returns the current time in "word" format // note that this is not a "number" and cannot be used for // mathematical operation Info << "current time in word = " << runTime.timeName() << endl; // function value() returns the current time in scalar // this can be used for mathematical operation Info << "current time + 1 = " << runTime.value()+1 << endl; runTime.write(); } /*************************************************************************\ // alternatively, function run() can also be used // the following is the same as loop() structure while(runTime.run()) { // using run(), it has to be manually increment the time runTime++; Info << "current time in word = " << runTime.timeName() << endl; Info << "current time + 1 = " << runTime.value()+1 << endl; runTime.write(); } \*************************************************************************/ return 0; }