Go to the documentation of this file.
29 if (((e(0)*e(0)+e(1)*e(1))<1)&&((e(2)*e(2)+e(3)*e(3))<1))
31 double norma = sqrt((1-e(0)*e(0)-e(1)*e(1))/(e(2)*e(2)+e(3)*e(3)));
43 real e00,e01,e02,e03,e11,e12,e13,e22,e23,e33;
59 R(0,0) = e00 + e11 - e22 - e33;
60 R(0,1) = 2 * (e12 - e03);
61 R(0,2) = 2 * (e13 + e02);
63 R(1,0) = 2 * (e12 + e03);
64 R(1,1) = e00 - e11 + e22 - e33;
65 R(1,2) = 2 * (e23 - e01);
67 R(2,0) = 2 * (e13 - e02);
68 R(2,1) = 2 * (e23 + e01);
69 R(2,2) = e00 - e11 - e22 + e33;
73 real n=(e00 + e11 + e22+ e33);
81 static std::normal_distribution<real> normal(0,0.5);
82 static std::uniform_real_distribution<real> uniform(-1,1);
86 for( unsigned int i=0;i<3;i++)
88 for( unsigned int j=0;j<3;j++)
89 M(i,j)=normal(e)*noiseLevel;
94 for( unsigned int i=0;i<3;i++)
96 for( unsigned int j=0;j<3;j++)
97 M(i,j)=uniform(e)*noiseLevel;
106 Matrix3d Xd,E1,E2,I=Matrix3d::Identity();
107 Array<double,Dynamic,Dynamic> error(nRep,2);
110 auto start = chrono::high_resolution_clock::now();
115 auto finish = chrono::high_resolution_clock::now();
116 chrono::duration<double> time = finish - start;
117 res[ AverageT]=time.count()/(double)nRep;
128 E1=Xd-N[i].cast< double>();
129 error(i,0)=E1.norm();
132 E2=(Xd.transpose()*Xd)-I;
133 error(i,1)=E2.norm();
137 res[ MaxDstE]=error.col(0).maxCoeff();
138 res[ MinDstE]=error.col(0).minCoeff();
141 res[ MaxOrtoE]=error.col(1).maxCoeff();
142 res[ MinOrtoE]=error.col(1).minCoeff();
146 unsigned int nResults, string *resultLabel,
147 unsigned int noiseTicks, noise &noiseLevel, double ***results)
151 cout.setf(ios::fixed, ios::floatfield);
155 for(l=0;l<nResults;l++)
157 cout << resultLabel[l] << endl << endl;
160 for(k=0;k<nMethods;k++)
162 cout << methodLabel[k];
169 cout << "-----------------------------------------------------------------------------------------------------------------------" << endl;
171 for(i=0;i<noiseTicks;i++)
173 for(k=0;k<nMethods;k++)
175 cout << results[k][i][l];
182 cout << endl << endl << endl;
187 unsigned int nResults, string *resultLabel,
188 bool gaussian, unsigned int noiseTicks, noise &noiseLevel, double ***results)
196 string precision= "_double";
198 string precision= "_float";
202 suffix= "_gaussian"+precision;
204 suffix= "_uniform"+precision;
207 for(k=0;k<nMethods;k++)
209 string fname= "results/"+methodLabel[k]+suffix+ ".csv";
210 cout << "Generating file : " << fname << endl;
218 file << "N, " << "Noise, ";
219 for(l=0;l<nResults;l++)
221 file << resultLabel[l] ;
228 for(i=0;i<noiseTicks;i++)
230 file << i << ", " << noiseLevel(i) << ", ";
231 for(l=0;l<nResults;l++)
233 file << results[k][i][l];
244 string fname= "results/results_cpp"+suffix+ ".m";
246 cout << "Generating file : " << fname << endl;
249 file << "function [errorbound_cpp"<< suffix << ",error_cpp"<< suffix << ",time_cpp"<< suffix << "]=results_cpp"<< suffix << "()"<< endl;
250 file << " %% Error levels" << endl;
251 file << " errorbound_cpp"<< suffix << "=[";
252 for(i=0;i<noiseTicks;i++)
253 file << noiseLevel(i) << " ";
254 file << "];" << endl<< endl;
255 file << " error_cpp"<< suffix << "=zeros("<< nResults-1 << "," << nMethods << "," << noiseTicks << ");" << endl;
256 for(l=0;l<nResults;l++)
260 file << " %% " << resultLabel[l] << " (rows: method columns: noise level)" << endl;
261 file << " error_cpp" << suffix << "("<< (l< AverageT?l+1:l) << ",:,:)=[";
262 for(k=0;k<nMethods;k++)
264 for(i=0;i<noiseTicks;i++)
265 file << results[k][i][l] << " ";
271 file << " %% Execution time (rows: method columns: noise level)" << endl;
272 file << " time_cpp" << suffix << "=[";
273 for(k=0;k<nMethods;k++)
275 for(i=0;i<noiseTicks;i++)
276 file << results[k][i][ AverageT] << " ";
|
Follow us!