/** Wrap the input angle to keep it within 2pi radians of the * angle to compare. * * @param [in] compareAngle * @param [in] angle Angle to be wrapped if needed * @return double Wrapped angle * */ double PixelOffset::WrapAngle(double compareAngle, double angle) { double diff1 = compareAngle - angle; if ( diff1 < -1*pi_c() ){ angle -= twopi_c(); } else if (diff1 > pi_c() ) { angle += twopi_c(); } return angle; }
int main (int argc, char **argv) { double lat, lon, time; furnsh_c("/home/user/BCGIT/ASTRO/standard.tm"); for (int i=0; i< 100000; i++) { lat = pi_c()*rand()/RAND_MAX-halfpi_c(); lon = twopi_c()*rand()/RAND_MAX-pi_c(); time = 1167721200.*rand()/RAND_MAX + 946684800.; // failing badly, so testing w/ knownish values // lat = 0.611738; // lon = -1.85878; // time = 1554616800.+i; // double elev = bc_elev(lat, lon, unix2et(time), "10"); double elev = bc_elev(lat, lon, unix2et(time), "10"); printf("%f,%f,%f,%f\n", lat, lon, time, elev); } }
void gfq5 (SpiceDouble et, SpiceDouble *value) { SpiceDouble u[3], v[3], lt; spkezp_c(10,et,REF,"NONE",601,u,<); spkezp_c( 5,et,REF,"NONE",601,v,<); // set global variable "s" to extra data, caller not required to use it // This is really ugly; if global variable 'extra' is set, print out // extra information; this should only be used when printing results // NOT during the search phase (TODO: this is ugly, better way?) if (vnorm_c(u)<vnorm_c(v)) { strcpy(s, "SUN IS CLOSER"); } else { strcpy(s, "POSSIBLE TRANSIT"); } *value = vsep_c(u,v)*180./pi_c(); }
void RenderableCrawlingLine::render(const RenderData& data) { if (_drawLine) { _program->activate(); _frameCounter++; // fetch data psc currentPosition = data.position; psc campos = data.camera.position(); glm::mat4 camrot = data.camera.viewRotationMatrix(); glm::mat4 transform = glm::mat4(1); // setup the data to the shader _program->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); _program->setUniform("ModelTransform", transform); int frame = _frameCounter % 60; float fadingFactor = static_cast<float>(sin((frame * pi_c()) / 60)); float alpha = 0.6f + fadingFactor*0.4f; glLineWidth(2.f); _program->setUniform("_alpha", alpha); _program->setUniform("color", _lineColor); setPscUniforms(_program, &data.camera, data.position); glBindVertexArray(_vao); glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(psc) * 2, _positions); glEnableVertexAttribArray(0); glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); glDrawArrays(GL_LINES, 0, 2); glBindVertexArray(0); _program->deactivate(); } }
SpiceDouble vsepg_c ( ConstSpiceDouble * v1, ConstSpiceDouble * v2, SpiceInt ndim ) /* -Brief_I/O VARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- v1 I First vector. v2 I Second vector. ndim I The number of elements in v1 and v2. -Detailed_Input v1 is any double precision vector of arbitrary dimension. v2 is also a double precision vector of arbitrary dimension. v1 or v2 or both may be the zero vector. ndim is the dimension of the both of the input vectors v1 and v2. -Detailed_Output vsepg_c the angle between v1 and v2 expressed in radians. vsepg_c is strictly non-negative. For input vectors of four or more dimensions, the angle is defined as the generalization of the definition for three dimensions. If either v1 or v2 is the zero vector, then vsepg_c is defined to be 0 radians. -Parameters None. -Particulars In four or more dimensions this angle does not have a physically realizable interpretation. However, the angle is defined as the generalization of the following definition which is valid in three or two dimensions: In the plane, it is a simple matter to calculate the angle between two vectors once the two vectors have been made to be unit length. Then, since the two vectors form the two equal sides of an isosceles triangle, the length of the third side is given by the expression length = 2.0 * sine ( vsepg/2.0 ) The length is given by the magnitude of the difference of the two unit vectors length = norm ( u1 - u2 ) Once the length is found, the value of vsepg_c may be calculated by inverting the first expression given above as vsepg_c = 2.0 * arcsine ( length/2.0 ) This expression becomes increasingly unstable when vsepg_c gets larger than pi/2 or 90 degrees. In this situation (which is easily detected by determining the sign of the dot product of v1 and v2) the supplementary angle is calculated first and then vsepg_c is given by vsepg_c = pi - SUPPLEMENTARY_ANGLE -Examples The following table gives sample values for v1, v2 and vsepg_c implied by the inputs. v1 v2 ndim vsepg_c ----------------------------------------------------------------- (1, 0, 0, 0) (1, 0, 0, 0) 4 0.0 (1, 0, 0) (0, 1, 0) 3 pi/2 (=1.71...) (3, 0) (-5, 0) 2 pi (=3.14...) -Restrictions The user is required to insure that the input vectors will not cause floating point overflow upon calculation of the vector dot product since no error detection or correction code is implemented. In practice, this is not a significant restriction. -Exceptions Error free. -Files None -Author_and_Institution C.A. Curzon (JPL) K.R. Gehringer (JPL) H.A. Neilan (JPL) W.L. Taber (JPL) E.D. Wright (JPL) -Literature_References None -Version -CSPICE Version 1.0.0, 29-JUN-1999 -Index_Entries angular separation of n-dimensional vectors -& */ { /* Begin vsepg_c */ /* Local variables */ SpiceDouble mag1; SpiceDouble mag2; SpiceDouble mag_dif; SpiceDouble r1; SpiceDouble r2; SpiceInt i; mag1 = vnormg_c( v1, ndim); mag2 = vnormg_c( v2, ndim); /* If either v1 or v2 have magnitude zero, the separation is 0. */ if ( ( mag1 == 0.) || ( mag2 == 0.) ) { return 0; } if ( vdotg_c( v1, v2, ndim ) < 0. ) { r1 = 1./mag1; r2 = 1./mag2; mag_dif = 0.; for ( i = 0; i < ndim; i++ ) { mag_dif += pow( ( v1[i]*r1 - v2[i]*r2 ), 2); } mag_dif = sqrt(mag_dif); return ( 2. * asin (0.5 * mag_dif) ); } else if ( vdotg_c (v1, v2, ndim) > 0. ) { r1 = 1./mag1; r2 = 1./mag2; mag_dif = 0.; for ( i = 0; i < ndim; i++ ) { mag_dif += pow( ( v1[i]*r1 + v2[i]*r2 ), 2); } mag_dif = sqrt(mag_dif); return ( pi_c() - 2. * asin (0.5 * mag_dif) ); } return ( halfpi_c()); } /* End vsepg_c */
void gfq ( SpiceDouble et, SpiceDouble *value ) { *value = distance_to_cusp(pi_c()/6, gplanet, et, FRAME, 399); }
SpiceDouble distance_to_cusp (SpiceDouble n, SpiceInt targ, SpiceDouble et, ConstSpiceChar *ref, SpiceInt obs) { SpiceDouble *results = geom_info(targ, et, ref, obs); return sin(pi_c()/n*results[11]); }
/** Cache J2000 rotation over existing cached time range using polynomials * * This method will reload an internal cache with matrices * formed from rotation angles fit to polynomials over a time * range. * * @param function1 The first polynomial function used to * find the rotation angles * @param function2 The second polynomial function used to * find the rotation angles * @param function3 The third polynomial function used to * find the rotation angles */ void LineScanCameraRotation::ReloadCache() { NaifStatus::CheckErrors(); // Make sure caches are already loaded if(!p_cachesLoaded) { QString msg = "A LineScanCameraRotation cache has not been loaded yet"; throw IException(IException::Programmer, msg, _FILEINFO_); } // Clear existing matrices from cache p_cache.clear(); // Create polynomials fit to angles & use to reload cache Isis::PolynomialUnivariate function1(p_degree); Isis::PolynomialUnivariate function2(p_degree); Isis::PolynomialUnivariate function3(p_degree); // Get the coefficients of the polynomials already fit to the angles of rotation defining [CI] std::vector<double> coeffAng1; std::vector<double> coeffAng2; std::vector<double> coeffAng3; GetPolynomial(coeffAng1, coeffAng2, coeffAng3); // Reset linear term to center around zero -- what works best is either roll-avg & pitchavg+ or pitchavg+ & yawavg- // coeffAng1[1] -= 0.0000158661225; // coeffAng2[1] = 0.0000308433; // coeffAng3[0] = -0.001517547; if(p_pitchRate) coeffAng2[1] = p_pitchRate; if(p_yaw) coeffAng3[0] = p_yaw; // Load the functions with the coefficients function1.SetCoefficients(coeffAng1); function2.SetCoefficients(coeffAng2); function3.SetCoefficients(coeffAng3); double CI[3][3]; double IJ[3][3]; std::vector<double> rtime; SpiceRotation *prot = p_spi->bodyRotation(); std::vector<double> CJ; CJ.resize(9); for(std::vector<double>::size_type pos = 0; pos < p_cacheTime.size(); pos++) { double et = p_cacheTime.at(pos); rtime.push_back((et - GetBaseTime()) / GetTimeScale()); double angle1 = function1.Evaluate(rtime); double angle2 = function2.Evaluate(rtime); double angle3 = function3.Evaluate(rtime); rtime.clear(); // Get the first angle back into the range Naif expects [180.,180.] if(angle1 < -1 * pi_c()) { angle1 += twopi_c(); } else if(angle1 > pi_c()) { angle1 -= twopi_c(); } eul2m_c((SpiceDouble) angle3, (SpiceDouble) angle2, (SpiceDouble) angle1, p_axis3, p_axis2, p_axis1, CI); mxm_c((SpiceDouble( *)[3]) & (p_jitter->SetEphemerisTimeHPF(et))[0], CI, CI); prot->SetEphemerisTime(et); mxm_c((SpiceDouble( *)[3]) & (p_cacheIB.at(pos))[0], (SpiceDouble( *)[3]) & (prot->Matrix())[0], IJ); mxm_c(CI, IJ, (SpiceDouble( *)[3]) &CJ[0]); p_cache.push_back(CJ); // J2000 to constant frame } // Set source to cache to get updated values SetSource(SpiceRotation::Memcache); // Make sure SetEphemerisTime updates the matrix by resetting it twice (in case the first one // matches the current et. p_et is private and not available from the child class NaifStatus::CheckErrors(); SetEphemerisTime(p_cacheTime[0]); SetEphemerisTime(p_cacheTime[1]); NaifStatus::CheckErrors(); }
double r2d(double d) {return d*180./pi_c();}
// main function int main(int argc, const char * argv[]) { gettimeofday(&start_timeval_rd1, NULL); SparseMatrix<double> Gx_a(NX,NA); Gx_a.resize(NX,NA); SparseMatrix<double> Gx_b(NX,NB); Gx_b.resize(NX,NB); SparseMatrix<double> Gx_c(NX,NC); Gx_c.resize(NX,NC); Gx_a.makeCompressed(); Gx_b.makeCompressed(); Gx_c.makeCompressed(); // reading the partitions Gx_a = read_G_sparse((char *) FILE_GA , "GX_A" ,NX, NA); Gx_b = read_G_sparse((char *) FILE_GB , "GX_B" ,NX, NB); Gx_c = read_G_sparse((char *) FILE_GC , "GX_C" ,NX, NC); gettimeofday(&stop_timeval_rd1, NULL); measure_stop_rd1 = stop_timeval_rd1.tv_usec + (timestamp_t)stop_timeval_rd1.tv_sec * 1000000; measure_start_rd1 = start_timeval_rd1.tv_usec + (timestamp_t)start_timeval_rd1.tv_sec * 1000000; time_rd1 = (measure_stop_rd1 - measure_start_rd1) / 1000000.0L; printf("Exec Time reading matrices before preproc = %5.25e (Seconds)\n",time_rd1); // initialize W, Z_B,Z_C, mu_a, mu_b, mu_c; SparseMatrix<double> W(NA,KHID); W.resize(NA,KHID); W.makeCompressed(); SparseMatrix<double> Z_B(NA,NB); Z_B.resize(NA,NB); Z_B.makeCompressed(); SparseMatrix<double> Z_C(NA,NC); Z_C.resize(NA,NC); Z_C.makeCompressed(); VectorXd mu_a(NA); VectorXd mu_b(NB); VectorXd mu_c(NC); cout << "----------------------------Before whitening--------------------------" << endl; gettimeofday(&start_timeval_pre, NULL); // measuring start time for pre processing second_whiten(Gx_a,Gx_b,Gx_c,W,Z_B,Z_C,mu_a,mu_b,mu_c); // whitened datapoints SparseMatrix<double> Data_a_G = W.transpose() * Gx_a.transpose(); VectorXd Data_a_mu = W.transpose() * mu_a; SparseMatrix<double> Data_b_G = W.transpose() * Z_B * Gx_b.transpose(); VectorXd Data_b_mu = W.transpose() * Z_B * mu_b; SparseMatrix<double> Data_c_G = W.transpose() * Z_C * Gx_c.transpose(); VectorXd Data_c_mu = W.transpose() * Z_C * mu_c; gettimeofday(&stop_timeval_pre, NULL); // measuring stop time for pre processing measure_stop_pre = stop_timeval_pre.tv_usec + (timestamp_t)stop_timeval_pre.tv_sec * 1000000; measure_start_pre = start_timeval_pre.tv_usec + (timestamp_t)start_timeval_pre.tv_sec * 1000000; time_pre = (measure_stop_pre - measure_start_pre) / 1000000.0L; printf("time taken by preprocessing = %5.25e (Seconds)\n",time_pre); cout << "----------------------------After whitening---------------------------" << endl; // stochastic updates VectorXd lambda(KHID); MatrixXd phi_new(KHID,KHID); cout << "------------------------------Before tensor decomposition----------------" << endl; gettimeofday(&start_timeval_stpm, NULL); // measuring start time for stochastic updates tensorDecom_alpha0(Data_a_G,Data_a_mu,Data_b_G,Data_b_mu,Data_c_G,Data_c_mu,lambda,phi_new); gettimeofday(&stop_timeval_stpm, NULL); // measuring stop time for stochastic updates cout << "after tensor decomposition" << endl; measure_stop_stpm = stop_timeval_stpm.tv_usec + (timestamp_t)stop_timeval_stpm.tv_sec * 1000000; measure_start_stpm = start_timeval_stpm.tv_usec + (timestamp_t)start_timeval_stpm.tv_sec * 1000000; time_stpm = (measure_stop_stpm - measure_start_stpm) / 1000000.0L; cout << "------------------------------After tensor decomposition----------------" << endl; printf("time taken by stochastic tensor decomposition = %5.25e (Seconds)\n",time_stpm); //cout << phi_new << endl; // optionally print eigenvectors cout << "the eigenvalues are:" << endl; cout << lambda << endl; // post processing cout << "------------Reading Gb_a, Gc_a---------"<<endl; gettimeofday(&start_timeval_rd2, NULL); #ifdef CalErrALL // read the matrix Gab and Gac SparseMatrix<double> Gb_a(NB,NA);Gb_a.resize(NB,NA); SparseMatrix<double> Gc_a(NC,NA);Gc_a.resize(NC,NA); Gb_a = read_G_sparse((char *) FILE_Gb_a, "GB_A" ,NB, NA); Gb_a.makeCompressed(); Gc_a = read_G_sparse((char *) FILE_Gc_a ,"GC_A" ,NC, NA); Gc_a.makeCompressed(); // releasing memory of Gx_a, Gx_b, Gx_c; Gx_b.resize(0,0);Gx_c.resize(0,0); #endif MatrixXd Inv_Lambda = (pinv_vector(lambda)).asDiagonal(); SparseMatrix<double> inv_lam_phi = (Inv_Lambda.transpose() * phi_new.transpose()).sparseView(); gettimeofday(&stop_timeval_rd2, NULL); measure_stop_rd2 = stop_timeval_rd2.tv_usec + (timestamp_t)stop_timeval_rd2.tv_sec * 1000000; measure_start_rd2 = start_timeval_rd2.tv_usec + (timestamp_t)start_timeval_rd2.tv_sec * 1000000; time_rd2 = (measure_stop_rd2 - measure_start_rd2) / 1000000.0L; cout << "------------After reading Gb_a, Gc_a---------"<<endl; printf("time taken for reading matrices after post processing = %5.25e (Seconds)\n",time_rd2); cout << "---------------------------Computing pi matrices-----------------------------" << endl; gettimeofday(&start_timeval_post, NULL); // measuring start time for post processing SparseMatrix<double> pi_x(KHID,NX);pi_x.reserve(KHID*NX);pi_x.makeCompressed(); SparseMatrix<double> pi_x_tmp1 = inv_lam_phi * W.transpose(); #ifdef CalErrALL SparseMatrix<double> pi_a(KHID,NA);pi_a.reserve(KHID*NA);pi_a.makeCompressed(); SparseMatrix<double> pi_b(KHID,NB);pi_b.reserve(KHID*NB);pi_b.makeCompressed(); SparseMatrix<double> pi_c(KHID,NC);pi_c.reserve(KHID*NC);pi_c.makeCompressed(); pi_a = pi_x_tmp1 * Z_B * Gb_a; MatrixXd pi_a_full = (MatrixXd) pi_a;pi_a.resize(0,0); pi_b = pi_x_tmp1 * Gb_a.transpose(); MatrixXd pi_b_full = (MatrixXd) pi_b;pi_b.resize(0,0); pi_c = pi_x_tmp1 * Gc_a.transpose(); MatrixXd pi_c_full = (MatrixXd) pi_c;pi_c.resize(0,0); #endif pi_x =pi_x_tmp1 * Gx_a.transpose();Gx_a.resize(0,0); MatrixXd pi_x_full = (MatrixXd) pi_x;pi_x.resize(0,0); gettimeofday(&stop_timeval_post, NULL); // measuring stop time for post processing measure_stop_post = stop_timeval_post.tv_usec + (timestamp_t)stop_timeval_post.tv_sec * 1000000; measure_start_post = start_timeval_post.tv_usec + (timestamp_t)start_timeval_post.tv_sec * 1000000; time_post = (measure_stop_post - measure_start_post) / 1000000.0L; cout << "---------After post processing------------" << endl; printf("time taken for post processing = %5.25e (Seconds)\n",time_post); cout<<"-------------------------Concatenation for pi_est-------------------- "<< endl; // store true_pi #ifdef CalErrALL long PI_LEN =(long) NX+NA+NB+NC; #else long PI_LEN =(long) NX; #endif MatrixXd My_pi_true_mat(KTRUE,PI_LEN); MatrixXd My_pi_est_mat(KHID,PI_LEN); #ifdef CalErrALL for (int kk = 0; kk < KHID; kk++) { // for My_pi_est; VectorXd My_pi_est1(NX+NA); My_pi_est1 = concatenation_vector (pi_x_full.row(kk), pi_a_full.row(kk)); VectorXd My_pi_est2(NX+NA+NB); My_pi_est2 =concatenation_vector (My_pi_est1, pi_b_full.row(kk)); VectorXd My_pi_est3(NX+NA+NB+NC); My_pi_est3 =concatenation_vector (My_pi_est2, pi_c_full.row(kk)); My_pi_est_mat.row(kk) = My_pi_est3; } pi_a_full.resize(0,0); pi_b_full.resize(0,0); pi_c_full.resize(0,0); #else My_pi_est_mat =pi_x_full; #endif pi_x_full.resize(0,0); // converting them to stochastic matrix My_pi_est_mat = normProbMatrix(My_pi_est_mat); SparseMatrix<double> sparse_my_pi_est_mat = My_pi_est_mat.sparseView(); cout << "-----------Before writing results: W, Z_B,Z_C and pi-----------"<<endl; write_pi(FILE_PI_WRITE, sparse_my_pi_est_mat); write_pi(FILE_WHITE_WRITE, W); write_pi(FILE_INVLAMPHI_WRITE, inv_lam_phi); cout << "-----------After writing results---------"<< endl; #ifdef ErrCal // set error calculation flag if it needs to be computed cout << "--------------------------------Calculating error------------------------------" << endl; gettimeofday(&start_timeval_error, NULL); // measuring start time for error calculation #ifdef CalErrALL // calculate error Gb_a.resize(0,0); Gc_a.resize(0,0); // read pi_true, i.e., ground truth matrices SparseMatrix<double> Pi_true_a(KTRUE,NA);Pi_true_a.makeCompressed();Pi_true_a = read_G_sparse((char *) FILE_Pi_a , "Pi_true_A" ,KTRUE, NA); MatrixXd Pi_true_a_full = (MatrixXd) Pi_true_a; Pi_true_a.resize(0,0); SparseMatrix<double> Pi_true_b(KTRUE,NB);Pi_true_b.makeCompressed();Pi_true_b = read_G_sparse((char *) FILE_Pi_b , "Pi_true_B" ,KTRUE, NB); MatrixXd Pi_true_b_full = (MatrixXd) Pi_true_b; Pi_true_b.resize(0,0); SparseMatrix<double> Pi_true_c(KTRUE,NC);Pi_true_c.makeCompressed();Pi_true_c = read_G_sparse((char *) FILE_Pi_c , "Pi_true_C" ,KTRUE, NC); MatrixXd Pi_true_c_full = (MatrixXd) Pi_true_c; Pi_true_c.resize(0,0); #endif SparseMatrix<double> Pi_true_x(KTRUE,NX);Pi_true_x.makeCompressed();Pi_true_x = read_G_sparse((char *) FILE_Pi_x , "Pi_true_X" ,KTRUE, NX); MatrixXd Pi_true_x_full = (MatrixXd) Pi_true_x; Pi_true_x.resize(0,0); /* // this is only for yelp, comment this for DBLP long PI_LEN = (long)NX; MatrixXd My_pi_true_mat(KTRUE,PI_LEN); My_pi_true_mat = Pi_true_x_full; MatrixXd My_pi_est_mat(KHID,PI_LEN); My_pi_est_mat = pi_x_full; */ cout<<"-------------------------Concatenation for pi_true-------------------- "<< endl; #ifdef CalErrALL for ( int k = 0; k < KTRUE; k++) { // for My_pi_true; VectorXd My_pi_true1(NX+NA); My_pi_true1 = concatenation_vector ((Pi_true_x_full.row(k)),(Pi_true_a_full.row(k))); VectorXd My_pi_true2(NX+NA+NB); My_pi_true2 =concatenation_vector (My_pi_true1, (Pi_true_b_full.row(k))); VectorXd My_pi_true3(NX+NA+NB+NC); My_pi_true3 =concatenation_vector (My_pi_true2, (Pi_true_c_full.row(k))); My_pi_true_mat.row(k) = My_pi_true3; } Pi_true_a_full.resize(0,0); Pi_true_b_full.resize(0,0); Pi_true_c_full.resize(0,0); #else My_pi_true_mat = Pi_true_x_full; #endif Pi_true_x_full.resize(0,0); double thresh_vec[NUM_THRESH] = thresh_vec_def; //{0.3, 0.25, 0.2, 0.18, 0.15, 0.12, 0.1,0.08}; double error_vec[NUM_THRESH] = {0.0}; double match_vec[NUM_THRESH] = {0.0}; for (int tttt = 0; tttt < NUM_THRESH; tttt++) { MatrixXd p_values=MatrixXd::Zero(KTRUE,KHID); MatrixXd errors=MatrixXd::Zero(KTRUE,KHID); for ( int k = 0; k < KTRUE; k++) { VectorXd my_pi_true_eigen = My_pi_true_mat.row(k); double *my_pi_true = my_pi_true_eigen.data(); for (int kk = 0; kk < KHID; kk++) { VectorXd my_pi_est_eigen = My_pi_est_mat.row(kk); double *my_pi_est = my_pi_est_eigen.data(); for(long lltt = 0; lltt < PI_LEN; lltt++) { if(my_pi_est[lltt] < thresh_vec[tttt]) my_pi_est[lltt] = 0; else my_pi_est[lltt] = 1; } // calculate p-values and error double correlation = Calculate_Correlation(my_pi_est, my_pi_true, (long)PI_LEN); //{long} if (correlation > 0) { p_values(k,kk)=Calculate_Pvalue(my_pi_true, my_pi_est, (long)PI_LEN); //{long} if (p_values(k,kk) < PVALUE_TOLE) { errors(k,kk)=(my_pi_true_eigen - my_pi_est_eigen).cwiseAbs().sum(); } else { errors(k,kk)=0; } } else { p_values(k,kk)=-1; errors(k,kk)=0; } } } VectorXd matched = errors.rowwise().sum(); double nnz =0; for(long calc=0; calc <KTRUE; calc++) { if(matched(calc)>0) nnz++; } error_vec[tttt]=(double)errors.sum()/((double)PI_LEN*KTRUE); match_vec[tttt]=((double)nnz)/((double)KTRUE); } gettimeofday(&stop_timeval_error, NULL); // measuring stop time for error calculation measure_stop_error = stop_timeval_error.tv_usec + (timestamp_t)stop_timeval_error.tv_sec * 1000000; measure_start_error = start_timeval_error.tv_usec + (timestamp_t)start_timeval_error.tv_sec * 1000000; time_error = (measure_stop_error - measure_start_error) / 1000000.0L; cout << "---------After error calculation------------"<<endl; printf("time taken for error calculation = %5.25e (Seconds)\n",time_error); furongprintVector(thresh_vec, NUM_THRESH, "thresh vector "); // outputs are printed furongprintVector(error_vec, NUM_THRESH, "error vector "); furongprintVector(match_vec, NUM_THRESH, "match vector "); #endif cout << "Program over" << endl; printf("\ntime taken for execution of the whole program = %5.25e (Seconds)\n", time_rd1 + time_pre + time_stpm + time_rd2 + time_post); return 0; }