//c = a * b void conv (double *aa, double *bb, double *c, const int &n){ if (n <= 500){ for (int i = 0; i < 2*n; ++ i) c[i] = 0; for (int i = 0; i < n; ++ i) for (int j = 0; j < n; ++ j) c[i+j] += aa[i] * bb[j]; return ; } int N = 1; for (; N < n; N <<= 1); N <<= 1; for (int i = 0; i < N; ++ i){ if (i < n) a[i] = aa[i], b[i] = bb[i]; else a[i] = b[i] = 0.0; } DFT (a, N, 1); DFT (b, N, 1); for (int i = 0; i < N; ++ i){ a[i] *= b[i]; } DFT (a, N, -1); for (int i = 0; i < N; ++ i){ c[i] = a[i].real() / N; } }
void Process2(fType ftype) { switch (ftype) { case ftReal: DFT(signal1, signal1FR, signal1FI, SIGNAL_FFT_LENGTH); break; case ftAbs: DFT(signal1, signal1FR, signal1FI, SIGNAL_FFT_LENGTH); ABS(signal1FR, signal1FI, signal1FA, SIGNAL_FFT_LENGTH); break; case ftPeriodogram: DFT(signal1, signal1FR, signal1FI, SIGNAL_FFT_LENGTH); ABS(signal1FR, signal1FI, signal1FA, SIGNAL_FFT_LENGTH); PeridogramCalc(signal1FA, signal1FPRDGRM, SIGNAL_FFT_LENGTH); break; case ftARMA: EstimateARMASpectrum(signal1, autoCorr, aCoeff, spectrumEstimate, SIGNAL_LENGTH, 16, errorHistory); //EstimateARMASpectrum(sAc, autoCorr, aCoeff, spectrumEstimate, 28, 3, errorHistory); break; default: break; } PrepareGraph2ForPlot(ftype); }
void DFT(struct AdjListNode* node, bool* visited){ if(visited[node->dest] == true) return; else{ printf("%d ",node->dest); visited[node->dest] = true; struct AdjListNode* neighbour = node->next; while(neighbour){ DFT(neighbour, visited); neighbour = neighbour->next; } } //错误的思路,利用visited 属性 /* if(node->visited == true) * return; * else{ * printf("%d ",node->dest); * node->visited = true; * struct AdjListNode* neighbour = node->next; * while(neighbour){ * if(neighbour->visited == false) * DFT(neighbour); * neighbour = neighbour->next; * } */ }
int tarversal(struct Graph* graph){ int component = 0;// 连通分支数 int ver = graph->V; //全局的visited 而不是在 struct AdjListNode 中添加 visited 属性 bool *visited = malloc(sizeof(bool) * ver); for(int v = 0;v < graph->V; ++v) visited[v] = false; // bool visited[ver] = {false}; 这个错误重要 for(int v = 0; v < ver; ++v) if(visited[v] == false){ DFT(graph->array[v].head, visited); ++component; printf("\n"); } return component; /* 错误的思路 利用visited 属性 * if(graph->array[v].head->visited == false){ * printf("start is %d\n",v); * DFT(graph->array[v].head); * printf("\n"); * } */ }
//Perform DFT on the rows of a matrix void RowDFT(Complex** matrix, int rows, int columns){ for (int i=0; i<rows; i++){ Complex* fftSig = malloc(sizeof(Complex)*columns); DFT(matrix[i],fftSig,columns); matrix[i] = fftSig; } }
//--------------------------------------------------------- bool COpenCV_FFT::On_Execute(void) { CSG_Grid *pInput, *pReal, *pImag; pInput = Parameters("INPUT") ->asGrid(); pReal = Parameters("REAL") ->asGrid(); pImag = Parameters("IMAG") ->asGrid(); //----------------------------------------------------- IplImage *cv_pInput = Get_CVImage(pInput, SG_DATATYPE_Float); IplImage *cv_pReal = NULL;// Get_CVImage(Get_NX(), Get_NY(), SG_DATATYPE_Float); IplImage *cv_pImag = NULL;// Get_CVImage(Get_NX(), Get_NY(), SG_DATATYPE_Float); //----------------------------------------------------- DFT(cv_pInput, &cv_pReal, &cv_pImag); //----------------------------------------------------- Copy_CVImage_To_Grid(pReal, cv_pReal, false); Copy_CVImage_To_Grid(pImag, cv_pImag, false); cvReleaseImage(&cv_pInput); cvReleaseImage(&cv_pReal); cvReleaseImage(&cv_pImag); pReal->Set_Name(CSG_String::Format(SG_T("%s [DFT, %s]"), pInput->Get_Name(), _TL("Real"))); pImag->Set_Name(CSG_String::Format(SG_T("%s [DFT, %s]"), pInput->Get_Name(), _TL("Imaginary"))); return( true ); }
//Perform DFT on the columns of a matrix void ColumnDFT(Complex** matrix, int rows, int columns){ for(int i=0; i<columns; i++){ Complex* inSig = malloc(sizeof(Complex)*rows); Complex* outFft = malloc(sizeof(Complex)*rows); for(int j=0; j<rows; j++){ inSig[j].real = matrix[j][i].real; inSig[j].img = matrix[j][i].img; } DFT(inSig, outFft, rows); for(int j=0; j<rows; j++){ matrix[j][i] = outFft[j]; } } }
int main(int argc, char** argv){ Complex inSignal[30] = { {0 ,0}, {1 ,0}, {2 ,0}, {3 ,0}, {4 ,0}, {5 ,0}, {6 ,0}, {7 ,0}, {8 ,0}, {9 ,0}, {10,0}, {11,0}, {12,0}, {13,0}, {14,0}, {15,0}, {16,0}, {17,0}, {18,0}, {19,0}, {20,0}, {21,0}, {22,0}, {23,0}, {24,0}, {25,0}, {26,0}, {27,0}, {28,0}, {29,0} }; Complex outSignal[30]; Complex **outSplitSignal = (Complex **) malloc(sizeof(Complex*)*5); for(int i = 0; i<5;i++){ Complex * tmp = (Complex*) malloc (sizeof(Complex)*6); for(int j=0; j<6; j++){ tmp[j].real = i*6+j; tmp[j].img = 0; } outSplitSignal[i] = tmp; } // Initialise the vector, to overwrite with the DFT Complex outSignalVector[30]; // General DFT printf("IN Signal\n"); DEBUG_VECTOR_PRINT(inSignal, 30); printf("\n"); DFT(inSignal, outSignal, 30); printf("OUT Signal DFT\n"); DEBUG_VECTOR_PRINT(outSignal, 30); // Print the single-phase DFT printf("\n"); //Cooley Tukey printf("In Signal CT Matrix\n"); DEBUG_MATRIX_PRINT(&outSplitSignal[0], 5, 6); printf("\n"); ColumnDFT((Complex**)outSplitSignal, 5, 6); // Perform DFT only on the Columns MultiplyTwiddle((Complex**)outSplitSignal, (Complex**)TwiddleMatrix(5,6),5, 6); // Element-wise multiplication with the Twiddle RowDFT((Complex**)outSplitSignal, 5, 6); // Perform row DFT on all matrix rows UnloadCTMatrix((Complex*)outSignalVector, (Complex**)outSplitSignal, 5, 6); // Unload the matrix into a vector by columns printf("Twiddle Matrix\n"); DEBUG_MATRIX_PRINT((Complex**)TwiddleMatrix(5,6),5, 6); // Double checking the twiddle matrix printf("\n"); printf("OUT Signal Matrix Cooley-Tukey DFT\n"); DEBUG_VECTOR_PRINT(outSignalVector, 30); // Final answer to using Cooley-Tukey Algorithm printf("\n"); }
// Compute Minimum Phase Reconstruction Of Signal void MinimumPhase(int n, float *realCepstrum, float *minimumPhase) { int i, nd2; float *realTime, *imagTime, *realFreq, *imagFreq; nd2 = n / 2; realTime = new float[n]; imagTime = new float[n]; realFreq = new float[n]; imagFreq = new float[n]; if((n % 2) == 1) { realTime[0] = realCepstrum[0]; for(i = 1; i < nd2; i++) realTime[i] = 2.0f * realCepstrum[i]; for(i = nd2; i < n; i++) realTime[i] = 0.0f; } else { realTime[0] = realCepstrum[0]; for(i = 1; i < nd2; i++) realTime[i] = 2.0f * realCepstrum[i]; realTime[nd2] = realCepstrum[nd2]; for(i = nd2 + 1; i < n; i++) realTime[i] = 0.0f; } for(i = 0; i < n; i++) imagTime[i] = 0.0f; DFT(n, realTime, imagTime, realFreq, imagFreq); for(i = 0; i < n; i++) cexp(realFreq[i], imagFreq[i], &realFreq[i], &imagFreq[i]); InverseDFT(n, realTime, imagTime, realFreq, imagFreq); for(i = 0; i < n; i++) minimumPhase[i] = realTime[i]; delete realTime; delete imagTime; delete realFreq; delete imagFreq; }
int main( int argc, char *argv[] ) { int i, nskip, framelen; double spec; short *sdata; double *xr, *xi, *Xr, *Xi; FILE *fpDAT;y if( 4 != argc ) { fprintf( stderr, "Usage : %s DATfile skip[sample] frame_length[sample]\n", argv[0] ); exit( 1 ); } if( NULL == ( fpDAT = fopen( argv[1], "r" ) ) ) exit( 1 ); if( 0 > ( nskip = atoi( argv[2] ) ) ) exit( 1 ); if( 0 > ( framelen = atoi( argv[3] ) ) ) exit( 1 ); fprintf( stderr, "# DATfile = %s\n", argv[1] ); fprintf( stderr, "# %d samples are skipped.\n", nskip ); fprintf( stderr, "# 1 frame contains %d sampels.\n", framelen ); b /* memory allocation */ sdata = (short*)calloc( sizeof(short), framelen ); xr = (double*)calloc( sizeof(double), framelen ); xi = (double*)calloc( sizeof(double), framelen ); Xr = (double*)calloc( sizeof(double), framelen ); Xi = (double*)calloc( sizeof(double), framelen ); if( NULL == sdata || NULL == xi || NULL == xi || NULL == Xr || NULL == Xi ) exit( 1 ); fseek( fpDAT, nskip*sizeof(short), SEEK_SET ); fread( sdata, sizeof(short), framelen, fpDAT ); fclose( fpDAT ); for( i = 0 ; i < framelen ; i++ ) { xr[i] = sdata[i]; xi[i] = Xr[i] = Xi[i] = 0.0; } DFT( xr, xi, Xr, Xi, framelen ); for( i = 0 ; i < framelen/2 ; i++ ) { spec = log10( (1.0/framelen)*( Xr[i]*Xr[i]+Xi[i]*Xi[i] ) ); printf( "%d %lf\n", i, spec ); } return( 0 ); }
// Compute Real Cepstrum Of Signal void RealCepstrum(int n, float *signal, float *realCepstrum) { float *realTime, *imagTime, *realFreq, *imagFreq; int i; realTime = new float[n]; imagTime = new float[n]; realFreq = new float[n]; imagFreq = new float[n]; // Compose Complex FFT Input for(i = 0; i < n; i++) { realTime[i] = signal[i]; imagTime[i] = 0.0f; } // Perform DFT DFT(n, realTime, imagTime, realFreq, imagFreq); // Calculate Log Of Absolute Value for(i = 0; i < n; i++) { realFreq[i] = logf(cabs(realFreq[i], imagFreq[i])); imagFreq[i] = 0.0f; } // Perform Inverse FFT InverseDFT(n, realTime, imagTime, realFreq, imagFreq); // Output Real Part Of FFT for(i = 0; i < n; i++) realCepstrum[i] = realTime[i]; delete realTime; delete imagTime; delete realFreq; delete imagFreq; }
Gene Gene::cross(Gene* father, Gene* mother, bool mutate) { double perfectChild[100]; double* fatherDist = father->getDist(); double* motherDist = mother->getDist(); for(int i = 0; i < 100; i++) perfectChild[i] = (fatherDist[i] + motherDist[i]) / 2; delete[] fatherDist; delete[] motherDist; double imaginary[100]; for(int i = 0; i < 100; imaginary[i++] = 0); bool succeed = DFT(1, 100, perfectChild, imaginary); if(!succeed) exit(0); int* sines = selectTop(imaginary); int* cosines = selectTop(perfectChild); Harmonic waves[WAVECOUNT]; for(int i = 0; i < WAVECOUNT; i++) { double alpha = mutate && randFloat() <= MUTATION_RATE ? MAX_OF_SCALED_SIN_PLUS_COS - 2 * randFloat() * MAX_OF_SCALED_SIN_PLUS_COS : imaginary[sines[i]]; double beta = mutate && randFloat() <= MUTATION_RATE ? MAX_OF_SCALED_SIN_PLUS_COS - 2 * randFloat() * MAX_OF_SCALED_SIN_PLUS_COS : perfectChild[cosines[i]]; int mu = mutate && randFloat() <= MUTATION_RATE ? (rand() % 48) + 1 : sines[i]; int omega = mutate && randFloat() <= MUTATION_RATE ? (rand() % 48) + 1 : cosines[i]; waves[i] = Harmonic(alpha, mu, beta, omega); } double magnitude = mutate && randFloat() <= MUTATION_RATE ? randFloat() * (father->magnitude + mother->magnitude) : ((father->magnitude + mother->magnitude) / 2); return Gene(magnitude, waves); }
int run_main(int argc, char *argv[], int numprocs0, int myid0) { int MD_iter,i,j,po,ip; char fileE[YOUSO10] = ".ene"; char fileDRC[YOUSO10] = ".md"; char fileMemory[YOUSO10]; char fileRestart[YOUSO10]; char operate[200]; double TStime,TEtime; /* for idle CPUs */ int tag; int complete; MPI_Request request; MPI_Status status; /* for measuring elapsed time */ dtime(&TStime); /* allocation of CompTime */ CompTime = (double**)malloc(sizeof(double*)*numprocs0); for (i=0; i<numprocs0; i++){ CompTime[i] = (double*)malloc(sizeof(double)*30); for (j=0; j<30; j++) CompTime[i][j] = 0.0; } if (myid0==Host_ID){ printf("\n*******************************************************\n"); printf("*******************************************************\n"); printf(" Welcome to OpenMX Ver. %s \n",Version_OpenMX); printf(" Copyright (C), 2002-2009, T.Ozaki \n"); printf(" OpenMX comes with ABSOLUTELY NO WARRANTY. \n"); printf(" This is free software, and you are welcome to \n"); printf(" redistribute it under the constitution of the GNU-GPL.\n"); printf("*******************************************************\n"); printf("*******************************************************\n\n"); } Init_List_YOUSO(); remake_headfile = 0; ScaleSize = 1.2; /**************************************************** Read the input file ****************************************************/ init_alloc_first(); CompTime[myid0][1] = readfile(argv); MPI_Barrier(MPI_COMM_WORLD1); /* initialize PrintMemory routine */ sprintf(fileMemory,"%s%s.memory%i",filepath,filename,myid0); PrintMemory(fileMemory,0,"init"); PrintMemory_Fix(); /* initialize */ init(); fnjoint(filepath,filename,fileE); fnjoint(filepath,filename,fileDRC); /**************************************************** SCF-DFT calculations and MD and geometrical optimization. ****************************************************/ MD_iter = 1; do { CompTime[myid0][2] += truncation(MD_iter,1); if (ML_flag==1 && myid0==Host_ID) Get_VSZ(MD_iter); if (Solver==4) { TRAN_Calc_GridBound( mpi_comm_level1, atomnum, WhatSpecies, Spe_Atom_Cut1, Ngrid1, Grid_Origin, Gxyz, tv, gtv, rgtv, Left_tv, Right_tv ); /* output: TRAN_region[], TRAN_grid_bound */ } CompTime[myid0][3] += DFT(MD_iter,(MD_iter-1)%orbitalOpt_per_MDIter+1); if (myid0==Host_ID) iterout(MD_iter,MD_TimeStep*MD_iter,fileE,fileDRC); if (ML_flag==0) CompTime[myid0][4] += MD_pac(MD_iter,argv[1]); MD_iter++; } while(MD_Opt_OK==0 && MD_iter<=MD_IterNumber); if ( TRAN_output_hks ) { /* left is dummy */ TRAN_RestartFile(mpi_comm_level1, "write","left",filepath,TRAN_hksoutfilename); } /**************************************************** calculate Voronoi charge ****************************************************/ if (Voronoi_Charge_flag==1) Voronoi_Charge(); /**************************************************** making of a file *.frac for the fractional coordinates ****************************************************/ Make_FracCoord(argv[1]); /**************************************************** generate Wannier functions added by Hongming Weng ****************************************************/ /* hmweng */ if(Wannier_Func_Calc){ if (myid0==Host_ID) printf("Calling Generate_Wannier...\n");fflush(0); Generate_Wannier(argv[1]); } /**************************************************** Making of output files ****************************************************/ CompTime[myid0][20] = OutData(argv[1]); /**************************************************** write connectivity, Hamiltonian, overlap, density matrices, and etc. to a file, filename.scfout ****************************************************/ if (HS_fileout==1) SCF2File("write",argv[1]); /* elapsed time */ dtime(&TEtime); CompTime[myid0][0] = TEtime - TStime; Output_CompTime(); for (i=0; i<numprocs0; i++){ free(CompTime[i]); } free(CompTime); /* merge log files */ Merge_LogFile(argv[1]); /* free arrays */ Free_Arrays(0); /* print memory */ PrintMemory("total",0,"sum"); /**************************************************** reconstruct the original MPI group ****************************************************/ { int *new_ranks; MPI_Group new_group,old_group; new_ranks = (int*)malloc(sizeof(int)*numprocs0); for (i=0; i<numprocs0; i++) { new_ranks[i]=i; /* a new group is made of original rank=0:Pnum[k]-1 */ } MPI_Comm_group(MPI_COMM_WORLD1, &old_group); /* define a new group */ MPI_Group_incl(old_group,numprocs0,new_ranks,&new_group); MPI_Comm_create(MPI_COMM_WORLD1,new_group,&mpi_comm_level1); MPI_Group_free(&new_group); free(new_ranks); /* never forget cleaning! */ } MPI_Barrier(MPI_COMM_WORLD1); if (myid0==Host_ID){ printf("\nThe calculation was normally finished.\n"); } return 0; }
int main( int argc, char *argv[] ) { int i, nskip, framelen; double spec; short *sdata; double *xr, *xi, *Xr, *Xi; FILE *fpDAT; long fsize; /*filesize*/ if( 4 != argc ) { fprintf( stderr, "Usage : %s DATfile skip[sample] frame_length[sample]\n", argv[0] ); exit( 1 ); } if( NULL == ( fpDAT = fopen( argv[1], "r" ) ) ) exit( 1 ); if( 0 > ( nskip = atoi( argv[2] ) ) ) exit( 1 ); if( 0 > ( framelen = atoi( argv[3] ) ) ) exit( 1 ); fprintf( stderr, "# DATfile = %s\n", argv[1] ); fprintf( stderr, "# %d samples are skipped.\n", nskip ); fprintf( stderr, "# 1 frame contains %d sampels.\n", framelen ); /* memory allocation */ sdata = (short*)calloc( sizeof(short), framelen ); xr = (double*)calloc( sizeof(double), framelen ); xi = (double*)calloc( sizeof(double), framelen ); Xr = (double*)calloc( sizeof(double), framelen ); Xi = (double*)calloc( sizeof(double), framelen ); if( NULL == sdata || NULL == xi || NULL == xi || NULL == Xr || NULL == Xi ) exit( 1 ); fseek(fpDAT, 0, SEEK_END); fsize = ftell(fpDAT); //printf("fsize = %ld\n", fsize); i = 0; /*for(nskip = 0; nskip < fsize; nskip += framelen/2){ i++; } */ const int shift = i; int count = 0; /*ここから繰り返し*/ /* for(nskip = 0; nskip < fsize; nskip += framelen/2){*/ fseek( fpDAT, nskip*sizeof(short), SEEK_SET ); fread( sdata, sizeof(short), framelen, fpDAT ); fclose( fpDAT ); /* for(i = 0; i < framelen; i++){ printf("%lf %d\n", i/16000.0, sdata[i]); } */ for( i = 0 ; i < framelen ; i++ ) { xr[i] = (0.54-0.46*cos(2*M_PI*i/(framelen-1)))*sdata[i]; xi[i] = 0.0; } /* for(i = 0; i < framelen; i++){ printf("%lf %lf\n", i/16.0, xr[i]); } */ int t; double *rr = (double*)calloc( sizeof(double), framelen ); double *vr = (double*)calloc( sizeof(double), framelen ); double max = -1; int tau; for(i = 0; i < framelen; i++){ /*r[i] = stst+1*/ for(t = 0; t < framelen; t++){ rr[i] += xr[t]*xr[(t+i)%framelen]; } vr[i] = rr[i]/framelen; /*if(i != 0 && max < fabs(v[i]) && fabs(v[i-1]) < fabs(v[i])){ max = fabs(v[i]); tau = i; } */ } /* double pitch = log10(1.0/tau); printf("%d %lf\n", count, pitch); count++; */ /* for(i = 0; i < framelen; i++){ printf("%lf %lf\n", i/16.0, v[i]); } */ /* }*/ //fclose( fpDAT ); double * vi = (double*)calloc(sizeof(double), framelen); for(i = 0; i < framelen; i++){ vi[i] = 1; } /* for ( i = 0 ; i < 1000 ; i++ ) { */ DFT( vr, vi, Xr, Xi, framelen ); /* } */ /* IDFT( Xr, Xi, xr, xi, framelen ); */ /* for( i = 0 ; i < framelen ; i++ ) { spec = log10( (1.0/framelen)*( Xr[i]*Xr[i]+Xi[i]*Xi[i] ) ); printf( "%d %lf\n", i, spec ); } */ for(i = 0; i < framelen; i++){ spec = log10(Xr[i]); printf("%d %lf\n", i, spec); } /* for( i = 0 ; i < framelen ; i++ ) { printf( "%d %lf\n", i, xr[i] ); } */ return( 0 ); }
void Check_Force(char *argv[]) { int ixyz; int time1,time2,MD_iter; double step; double original_x,original_y,original_z; double Analytic_Force[4]; double Numerical_Force[4]; double Utot1,Utot2,Utot3; FILE *fp1; char fname1[YOUSO10]; static int numprocs,myid; /* MPI */ MPI_Comm_size(MPI_COMM_WORLD1,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD1,&myid); /* initialize */ for (ixyz=0; ixyz<=3; ixyz++){ Analytic_Force[ixyz] = 0.0; Numerical_Force[ixyz] = 0.0; } /* step for calculation of the numerical derivatives */ step = 0.0003; /* flags */ F_Kin_flag = mbit[force_flag][0]; F_NL_flag = mbit[force_flag][1]; F_VNA_flag = mbit[force_flag][2]; F_dVHart_flag = mbit[force_flag][3]; F_Vxc_flag = mbit[force_flag][4]; F_VEF_flag = mbit[force_flag][5]; F_U_flag = mbit[force_flag][6]; /* store original coordinates */ original_x = Gxyz[1][1]; original_y = Gxyz[1][2]; original_z = Gxyz[1][3]; /* loop for ixyz */ for (ixyz=1; ixyz<=3; ixyz++){ Gxyz[1][1] = original_x; Gxyz[1][2] = original_y; Gxyz[1][3] = original_z; MD_iter = 1; time1 = truncation(MD_iter,1); time2 = DFT(MD_iter,(MD_iter-1)%orbitalOpt_per_MDIter+1); Utot1 = Utot; /* analytic force */ if (myid==G2ID[1]){ Analytic_Force[ixyz] = -Gxyz[1][16+ixyz]; } MPI_Bcast(&Analytic_Force[ixyz], 1, MPI_DOUBLE, G2ID[1], MPI_COMM_WORLD1); /* do not use the restart files for later calculations */ Scf_RestartFromFile = 0; MD_iter = 2; Gxyz[1][ixyz] -= step; time1 = truncation(MD_iter,1); time2 = DFT(MD_iter,(MD_iter-1)%orbitalOpt_per_MDIter+1); Utot2 = Utot; /* do not use the restart files for later calculations */ Scf_RestartFromFile = 0; MD_iter = 3; Gxyz[1][ixyz] += 2.0*step; time1 = truncation(MD_iter,1); time2 = DFT(MD_iter,(MD_iter-1)%orbitalOpt_per_MDIter+1); Utot3 = Utot; /* numerical force */ if (myid==G2ID[1]){ Numerical_Force[ixyz] = -0.5*(Utot3 - Utot2)/step; } MPI_Bcast(&Numerical_Force[ixyz], 1, MPI_DOUBLE, G2ID[1], MPI_COMM_WORLD1); } /* save forces to a file */ if (myid==Host_ID){ sprintf(fname1,"forcetest.result"); if ( (fp1 = fopen(fname1,"a")) != NULL ){ fprintf(fp1,"\n"); fprintf(fp1,"%s\n",argv[1]); fprintf(fp1," flag=%2d\n",force_flag); fprintf(fp1," Numerical force= -(Utot(s+ds)-Utot(s-ds))/(2*ds)\n"); fprintf(fp1," ds=%15.10f\n",step); fprintf(fp1," Forces (Hartree/Bohr) on atom 1\n"); fprintf(fp1," x y z\n"); fprintf(fp1," Analytic force %15.12f %15.12f %15.12f\n", Analytic_Force[1],Analytic_Force[2],Analytic_Force[3]); fprintf(fp1," Numerical force %15.12f %15.12f %15.12f\n", Numerical_Force[1],Numerical_Force[2],Numerical_Force[3]); fprintf(fp1," diff %15.12f %15.12f %15.12f\n", Analytic_Force[1]-Numerical_Force[1], Analytic_Force[2]-Numerical_Force[2], Analytic_Force[3]-Numerical_Force[3]); fclose(fp1); } else{ printf("Could not find %s in checking force consistency\n",fname1); } } }
// converts a string of '0' and '1' into a Vector<uint8_t> static Vector<uint8_t> DFTStringToVector(const std::string &DFTString) { Vector<uint8_t> DFT(DFTString.size()); DFTStringAppendToVector(&DFT, DFTString); return DFT; }
void TestCase1(){ DFT(s3, s3FR, s3FI, 4); filterSignal(s1, s2, f1, 8, 3); TestREstimate(); }