void TroveBasisSet::Initialize(){ ReadBasisSet(); Correlate(); ComputeijTerms(); }
//----------------------------------------------------------------------------- // Purpose: // Input : argc - // argv[] - // Output : int //----------------------------------------------------------------------------- int main( int argc, char* argv[] ) { SpewOutputFunc( SpewFunc ); SpewActivate( "unusedcontent", 2 ); CommandLine()->CreateCmdLine( argc, argv ); int i=1; for ( i ; i<argc ; i++) { if ( argv[ i ][ 0 ] == '-' ) { switch( argv[ i ][ 1 ] ) { case 'l': uselogfile = true; break; case 'v': verbose = true; break; case 'r': showreferencedfiles = true; break; case 'd': spewdeletions = true; break; case 'i': immediatedelete = true; break; case 'w': printwhitelist = true; break; case 'm': showmapfileusage = true; break; case 'g': // Just skip -game Assert( !Q_stricmp( argv[ i ], "-game" ) ); ++i; break; case 'f': // grab reslists folder { ++i; Q_strncpy( g_szReslistDir, argv[ i ], sizeof( g_szReslistDir ) ); Q_strlower( g_szReslistDir ); Q_FixSlashes( g_szReslistDir ); Q_AppendSlash( g_szReslistDir, sizeof( g_szReslistDir ) ); } break; default: printusage(); break; } } } if ( argc < 3 || ( i != argc ) ) { PrintHeader(); printusage(); return 0; } CheckLogFile(); PrintHeader(); vprint( 0, " Using reslist dir '%s'\n", g_szReslistDir ); vprint( 0, " Looking for extraneous content...\n" ); char resfile[ 256 ]; strcpy( resfile, argv[ i - 1 ] ); vprint( 0, " Comparing results of resfile (%s) with files under current directory...\n", resfile ); char workingdir[ 256 ]; workingdir[0] = 0; Q_getwd( workingdir, sizeof( workingdir ) ); // If they didn't specify -game on the command line, use VPROJECT. CmdLib_InitFileSystem( workingdir ); filesystem = (IFileSystem *)(CmdLib_GetFileSystemFactory()( FILESYSTEM_INTERFACE_VERSION, NULL )); if ( !filesystem ) { AssertMsg( 0, "Failed to create/get IFileSystem" ); return 1; } g_pFullFileSystem->RemoveAllSearchPaths(); g_pFullFileSystem->AddSearchPath(gamedir, "GAME"); Q_strlower( gamedir ); Q_FixSlashes( gamedir ); // //ProcessMaterialsDirectory( vmtdir ); // find out the mod dir name Q_strncpy( modname, gamedir, sizeof(modname) ); modname[ strlen(modname) - 1] = 0; if ( strrchr( modname, '\\' ) ) { Q_strncpy( modname, strrchr( modname, '\\' ) + 1, sizeof(modname) ); } else { Q_strncpy( modname, "", sizeof(modname) ); } vprint( 1, "Mod Name:%s\n", modname); BuildCheckdirList(); BuildWhiteList(); vprint( 0, "Building aggregate file list from resfile output\n" ); CUtlRBTree< ReferencedFile, int > referencedfiles( 0, 0, RefFileLessFunc ); CUtlVector< UnusedContent::CUtlSymbol > resfiles; BuildReferencedFileList( resfiles, referencedfiles, resfile ); vprint( 0, "found %i files\n\n", referencedfiles.Count() ); vprint( 0, "Building list of all game content files\n" ); CUtlVector< FileEntry > contentfiles; CUtlVector< FileEntry > otherfiles; BuildFileList( 0, contentfiles, &otherfiles, "", 0 ); vprint( 0, "found %i files in content tree\n\n", contentfiles.Count() ); Correlate( referencedfiles, contentfiles, modname ); // now output the files not referenced in the whitelist or general reslists filesystem->RemoveFile( CFmtStr( "%sunreferenced_files.lst", g_szReslistDir ), "GAME" ); int c = otherfiles.Count(); for ( i = 0; i < c; ++i ) { FileEntry & entry = otherfiles[ i ]; char const *name = g_Analysis.symbols.String( entry.sym ); logprint( CFmtStr( "%sunreferenced_files.lst", g_szReslistDir ), "\"%s\\%s\"\n", modname, name ); } // also include the files from deletions.bat, as we don't actually run that now c = contentfiles.Count(); for ( i = 0; i < c; ++i ) { FileEntry & entry = contentfiles[ i ]; if ( entry.referenced != REFERENCED_NO ) continue; char const *fn = g_Analysis.symbols.String( entry.sym ); logprint( CFmtStr( "%sunreferenced_files.lst", g_szReslistDir ), "\"%s\\%s\"\n", modname, fn ); } FileSystem_Term(); return 0; }
int main(){ int tournamentCheck=0; int tournamentWrong=0; int tournamentHits=0; int ja=0; int w=0; int Wrong1C=0; int Right=0; int SelectedP=1; //gia timi 1 epilegmenos o prediction Taken gia timi 0 epilegmenos o not Taken int predictionT=1; int predictionNT=1; int real=1; int i; int innerCheck=0; int counter=0; int counterL=0; char c; char Arr1[8]; char Arr2[8]; char Arr3[8]; int check=0; int z=0; int j=0; int d=0; int x=0; int k=0; int action=0; int action3=0; int action2=0; int pointer=0; int outer=0; int inner=0; int prediction=1; int wrong1=0; int correctP=0; int prediction2=1; int Correct2B=0; int wrong2=0; int Counter2B=0; input_file=fopen("input.txt","r"); OneBit=fopen("1Bitresults.txt","w"); TwoBit=fopen("2Bitresults.txt","w"); Correlated=fopen("Correlated.txt","w"); yeeh_Paat=fopen("Yeh_pat.txt","w"); tournament=fopen("TournamentResults.txt","w"); ALLRESULTS=fopen("AllpredictorsResults.txt","w"); printf("Correlate prediction 1: Taken \nCorrelate prediction 2: Taken\n\n"); printf("Press 1 to print the results of the Correlated 1.1 predictor in the terminal or 0 to not print the result in the terminal\n"); scanf("%d",&w); if(w==1) { printf("Correlate prediction 1: Taken \nCorrelate prediction 2: Taken\n\n"); } while ((c=fgetc(input_file))!=EOF) { if(c!='a'&&c!='b'&&c!='c'&&c!='d'&&c!='e'&&c!='f'&&c!='A'&&c!='B'&&c!='C'&&c!='D'&&c!='E'&&c!='F'&&c!='0'&&c!='1'&&c!='2'&&c!='3'&&c!='4'&&c!='5'&&c!='6'&&c!='7'&&c!='8'&&c!='9'&&c!='\n') { printf("Error Character, Check input file\n"); system("PAUSE"); return 0; } pointer=-1; if ((check==0)&&(c!='\n')) { Arr1[counter]=c; } if ((check==1)&&(c!='\n')) { Arr2[counter]=c; } if ((check==2)&&(c!='\n')) { Arr3[counter]=c; } if ((check==2)&&(c=='\n')) { action2=ArrayCheck(Arr1,Arr3); action3=ArrayCheck(Arr2,Arr3); pointer=2; } if ((check==1)&&(c=='\n')) { action=ArrayCheck(Arr1,Arr2); pointer=1; } if ((check==0)&&(c=='\n')){ pointer=0; } if(pointer==0){ check=1; } if(pointer==1){ if(action==0) { if (prediction==1){ wrong1++; prediction=0; if(tournamentCheck==0) {tournamentWrong++;} } else if(prediction==0) {correctP++; if(tournamentCheck==0) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } if (prediction2==1){ wrong2++; Counter2B++; } else if (prediction2==0){ Correct2B++; } if ((Counter2B==2)&&(prediction2==1)){ prediction2=0; Counter2B=0; } else if ((Counter2B==2)&&(prediction2==0)){ prediction2=1; Counter2B=0; } Correlate(predictionT,predictionNT,Arr1,action,w);///////////// if (SelectedP==1) { if(predictionT==1) { Wrong1C++; predictionT=0; SelectedP=0; if(tournamentCheck==1) {tournamentWrong++;} } else if(predictionT==0) { predictionT=0; Right++; if(tournamentCheck==1) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } }else if (SelectedP==0) { if(predictionNT==1) {predictionNT=0; Wrong1C++; SelectedP=1; if(tournamentCheck==1) {tournamentWrong++;} } else if(predictionNT==0) { Right++; if(tournamentCheck==1) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } } //printf("Not Taken\n"); check=2; Yeeh_Pat(action); for(ja=0;ja<5;ja++) { diktis[ja]=diktis[ja+1]; } diktis[4]=action; } else if (action==1) { check=1; if (prediction==1) { correctP++; if(tournamentCheck==0) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } else if(prediction==0) { wrong1++; prediction=0; if(tournamentCheck==0) {tournamentWrong++;} } if (prediction2==1){ Correct2B++; } else if (prediction2==0){ wrong2++; Counter2B++; } if ((Counter2B==2)&&(prediction2==1)){ prediction2=0; Counter2B=0; } else if ((Counter2B==2)&&(prediction2==0)){ prediction2=1; Counter2B=0; } Correlate(predictionT,predictionNT,Arr1,action,w); if (SelectedP==1) { if(predictionT==1) { Right++; if(tournamentCheck==1) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } else if(predictionT==0) { predictionT=1; SelectedP=0; Wrong1C++; if(tournamentCheck==1) {tournamentWrong++;} } }else if (SelectedP==0) { if(predictionNT==1) {predictionNT=1; Right++; if(tournamentCheck==1) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } else if(predictionNT==0) { predictionNT=1; SelectedP=1; Wrong1C++; if(tournamentCheck==1) {tournamentWrong++;} } } //printf("Taken\n"); outer++; Yeeh_Pat(action); for(ja=0;ja<5;ja++) { diktis[ja]=diktis[ja+1]; } diktis[4]=action; } } if(pointer==2) { if (action2==1) { while(z<8) { Arr1[z]=Arr2[z]; z++; } z=0; while(z<8) { Arr2[z]=Arr3[z]; z++; } if (prediction==1) { correctP++; if(tournamentCheck==0) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } else if(prediction==0) { wrong1++; prediction=0; if(tournamentCheck==0) {tournamentWrong++;} } if (prediction2==1){ Correct2B++; } else if (prediction2==0){ wrong2++; Counter2B++; } if ((Counter2B==2)&&(prediction2==1)){ prediction2=0; Counter2B=0; } else if ((Counter2B==2)&&(prediction2==0)){ prediction2=1; Counter2B=0; } Correlate(predictionT,predictionNT,Arr1,action2,w); if (SelectedP==1) { if(predictionT==1) { Right++; if(tournamentCheck==1) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } else if(predictionT==0) { predictionT=1; SelectedP=0; Wrong1C++; if(tournamentCheck==1) {tournamentWrong++;} } }else if (SelectedP==0) { if(predictionNT==1) { predictionNT=1; Right++; if(tournamentCheck==1) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } else if(predictionNT==0) { predictionNT=1; SelectedP=1; Wrong1C++; if(tournamentCheck==1) {tournamentWrong++;} } } //printf("Taken\n"); outer++; check=2; Yeeh_Pat(action2); for(ja=0;ja<5;ja++) { diktis[ja]=diktis[ja+1]; } diktis[4]=action2; } else if (action3==1) { if (prediction==1) { correctP++; if(tournamentCheck==0) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } else if(prediction==0) { wrong1++; prediction=0; if(tournamentCheck==0) {tournamentWrong++;} } if (prediction2==1){ Correct2B++; } else if (prediction2==0){ wrong2++; Counter2B++; } if ((Counter2B==2)&&(prediction2==1)){ prediction2=0; Counter2B=0; } else if ((Counter2B==2)&&(prediction2==0)){ prediction2=1; Counter2B=0; } Correlate(predictionT,predictionNT,Arr2,action3,w); if (SelectedP==1) { if(predictionT==1) { Right++; if(tournamentCheck==1) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } }else if(predictionT==0) { predictionT=1; SelectedP=0; Wrong1C++; if(tournamentCheck==1) {tournamentWrong++;} } }else if (SelectedP==0) { if(predictionNT==1) { predictionNT=1; Right++; if(tournamentCheck==1) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } else if(predictionNT==0) { predictionNT=1; SelectedP=1; Wrong1C++; if(tournamentCheck==1) {tournamentWrong++;} } } //printf("Taken\n"); check=2; inner++; Yeeh_Pat(action3); for(ja=0;ja<5;ja++) { diktis[ja]=diktis[ja+1]; } diktis[4]=action3; } else { while(z<8) { Arr1[z]=Arr2[z]; z++; } z=0; while(z<8) { Arr2[z]=Arr3[z]; z++; } if (prediction==1){ wrong1++; prediction=0; if(tournamentCheck==0) {tournamentWrong++;} } else if(prediction==0) { correctP++; if(tournamentCheck==0) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } if (prediction2==1){ wrong2++; Counter2B++; } else if (prediction2==0){ Correct2B++; } if ((Counter2B==2)&&(prediction2==1)){ prediction2=0; Counter2B=0; } else if ((Counter2B==2)&&(prediction2==0)){ prediction2=1; Counter2B=0; } Correlate(predictionT,predictionNT,Arr1,action3,w);///////////// if (SelectedP==1) { if(predictionT==1) { Wrong1C++; predictionT=0; SelectedP=0; if(tournamentCheck==1) {tournamentWrong++;} } else if(predictionT==0) { predictionT=0; Right++; if(tournamentCheck==1) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } }else if (SelectedP==0) { if(predictionNT==1) {predictionNT=0; Wrong1C++; SelectedP=1; if(tournamentCheck==1) {tournamentWrong++;} } else if(predictionNT==0) { Right++; if(tournamentCheck==1) { tournamentHits++; if(tournamentWrong==0) {tournamentWrong=0;} else if(tournamentWrong==1) {tournamentWrong=0;} } } } //printf("Not Taken\n"); check=2; Yeeh_Pat(0); for(ja=0;ja<5;ja++) { diktis[ja]=diktis[ja+1]; } diktis[4]=0; } } counter++; if(c=='\n') { counter=0; if(tournamentCheck==0) { fprintf(tournament,"1-bit Predictor is selected\n"); }else if(tournamentCheck==1) { fprintf(tournament,"Correlated predictor is selected\n"); } if(tournamentWrong==2) { if(tournamentCheck==0) {tournamentCheck=1;} else if(tournamentCheck==1) {tournamentCheck=0;} tournamentWrong==0; } } } printf("Total Loops: %d\n",outer+inner); printf("outer %d\n",outer); printf("inner %d\n",inner); printf("\nCorrect prediction of 1-bit: %d/%d\n",correctP,correctP+wrong1); printf("Wrong prediction of 1-bit: %d\n",wrong1); printf("\nCorrect prediction of 2-bit : %d/%d\n",Correct2B,Correct2B+wrong2); printf("Wrong prediction of 2-bit : %d\n\n",wrong2); printf("Correct predictions of 1.1 Correlate predictor out of total: %d/%d\n\n",Right,Right+Wrong1C); fprintf(OneBit,"Correct predictions of 1-bit out of total: %d/%d\n",correctP,correctP+wrong1); fprintf(TwoBit,"Correct predictions of 2-bit out of total: %d/%d\n",Correct2B,Correct2B+wrong2); fprintf(Correlated,"Correct predictions of 1.1 Correlate predictor out of total: %d/%d",Right,Right+Wrong1C); fprintf(tournament,"Hits from tournament %d ",tournamentHits); fprintf(ALLRESULTS,"Correct predictions of 1-bit out of total: %d/%d\n\n",correctP,correctP+wrong1); fprintf(ALLRESULTS,"Correct predictions of 2-bit out of total: %d/%d\n\n",Correct2B,Correct2B+wrong2); fprintf(ALLRESULTS,"Correct predictions of 1.1 Correlate predictor out of total: %d/%d\n\n",Right,Right+Wrong1C); fprintf(ALLRESULTS,"Hits from tournament %d ",tournamentHits); Yehprint(); fclose(input_file); fclose(OneBit); fclose(TwoBit); fclose(Correlated); system("pause"); return 0; }
// Wrapper for Correlate to avoid ambiguity inline void Correlate(const arma::subview_cube<T>& vec1, const arma::subview_cube<T>& vec2, const int mod) { Correlate(arma::Row<T>(vec1), arma::Row<T>(vec2), mod); }