int PaperInkConverter::EOF_Found() { if (FileClose) { freeAllMemory(); return(MANAGED_TRUE); } else { return(MANAGED_FALSE); } }
PaperInkConverter::PaperInkConverter(wchar_t* Filename, int StrokeThreshold_In, int AllThreshold_In, int SlidingThreshold_In){ f = _wfopen(Filename,L"rb"); if (f == NULL) { SensitivityStrokeIndexList = NULL; PenPosition_X = NULL; PenPosition_Y = NULL; PenPressure = NULL; PenTilt_X = NULL; PenTilt_Y = NULL; Number_of_Points_in_Substroke = -1; FileClose = true; } else { FileClose = false; maxLayerPressure = 0; maxSlidingPressure = 0; AllThreshold = AllThreshold_In * 164; // Threshold in % * 16384 / 100 (2**14); StrokeThreshold = StrokeThreshold_In * 164; // Threshold in % * 16384 / 100 (2**14) char DummyMem[0x7f8]; // Dummy Buffer to receive unused Dummy information size_t FileSize = fread((void*)&DummyMem[0],1,sizeof(DummyMem),f); if (FileSize != sizeof(DummyMem)) { fclose(f); Number_of_Points_in_Substroke = -1; FileClose = true; } else { SensitivityStrokeIndexList = (short*)malloc(MaxStoreBuffer*sizeof(short)); PenPosition_X = (short*)malloc(MaxStoreBuffer*sizeof(short)); PenPosition_Y = (short*)malloc(MaxStoreBuffer*sizeof(short)); PenPressure = (short*)malloc(MaxStoreBuffer*sizeof(short)); PenTilt_X = (unsigned char*)malloc(MaxStoreBuffer); PenTilt_Y = (unsigned char*)malloc(MaxStoreBuffer); *SensitivityStrokeIndexList = 0; // Preset this 2 Values Only Relevant, if there ist *(SensitivityStrokeIndexList+1) = 0; // no Stroke in the file int Status = ReadNextCompleteStroke(); if (Status == 2) { // End of File found freeAllMemory(); // Already done in ReadNextCompleteStroke // fclose(f); // Number_of_Points_in_Substroke = -1; // FileClose = true; } } } }
int main( int argc, char *argv[] ) { time_t startTime, stopTime; clock_t startCPU, stopCPU; double elapsedCPUsecs; int capacity = INITIAL_CAPACITY; int count =0; char **dictionary = malloc( capacity * sizeof(char *) ); if (dictionary == NULL ) { printf("Initial malloc of dictionary failed. Program exiting\n"); return EXIT_FAILURE; /* EXIT_FAILURE defined as non zero in stdlib.h */ } if (argc < 3 ) { printf("usage: ./%s <infileName> <outFilename>\n",argv[0]); /* you gotta put in & out file names on cmd line! */ return EXIT_FAILURE; } startTime = time( NULL ); printf("\nStarting load of %s at %s", argv[1], ctime( &startTime) ); printf("each '*' represents 10,000 words loaded into dictionary\n"); startCPU = clock(); loadDictionary( argv[1], &dictionary, &count, & capacity ); stopCPU = clock(); stopTime = time( NULL ); printf("\nFinished load of %s at %s", argv[1], ctime( &stopTime) ); printf("%d words loaded in %lu seconds\n", count, stopTime-startTime ); elapsedCPUsecs = ((double)(stopCPU-startCPU)) / CLOCKS_PER_SEC; printf("Elapsed CPU seconds: %f\n", elapsedCPUsecs ); doMenu( argv[2], &dictionary, &count, &capacity ); freeAllMemory( dictionary, count ); return EXIT_SUCCESS; /* EXIT_SUCCESS defined as 0 in stdlib.h */ }
double* sqrtMethodSolver_direct::getSolve(double** m, int size) { systemSize=size; if(systemSize<2) { std::cerr << "Bad Matrix Size!" << std::endl; return NULL; } matrix=new std::complex<double>*[systemSize]; for(int j=0; j<systemSize; j++) matrix[j]=new std::complex<double>[systemSize+1]; for(int i=0; i<systemSize; i++) for(int j=0; j<systemSize+1; j++) matrix[i][j]=std::complex<double>(m[i][j], 0.0); for(int j=0; j<systemSize+1; j++) if(!systemChecking(j)) { std::cerr << "Non equatable matrix!" << std::endl; return NULL; } for(int i=0; i<systemSize; i++) for(int j=0; j<systemSize; j++) if(matrix[i][j]!=matrix[j][i]) { std::cerr << "Non symmetrical matrix!" << std::endl; freeMatrix(); return NULL; } for(int i=0; i<systemSize; i++) { std::complex<double> sum(0.0, 0.0); for(int k=0; k<i; k++) { sum+=pow(matrix[k][i], 2.0); } matrix[i][i]=pow(m[i][i]-sum, 0.5); for(int j=i+1; j<systemSize+1; j++) { std::complex<double> sum(0.0,0.0); for(int k=0; k<i; k++) { sum+=(matrix[k][i]*matrix[k][j]); }; matrix[i][j]=(m[i][j]-sum)/matrix[i][i]; } } solve=new std::complex<double>[systemSize]; for(int i=systemSize-1; i>=0; i--) { std::complex<double> sum(0.0,0.0); for(int k=i+1; k<systemSize; k++) sum+=matrix[i][k]*solve[k]; solve[i]=(matrix[i][systemSize]-sum)/matrix[i][i]; } double* realSolve=new double[systemSize+1]; for(int j=0; j<systemSize+1; j++) realSolve[j]=solve[j].real(); freeAllMemory(); return realSolve; }
PaperInkConverter::~PaperInkConverter() { freeAllMemory(); }