Example #1
0
void PPCA::normalize(complex_2d_array a){

	for(int i=0; i<a.cols(); i++){
	double nl2 = norm_L2(a, i);
	for(int j=0; j<a.rows(); j++){
	a(j,i).x /= nl2;
	}
	}
	
}
Example #2
0
double PPCA::err(){
//	||(I-QQ*)A||

	alglib::complex_2d_array tmp;
	alglib::complex_2d_array tmp2;
	alglib::complex_2d_array Q_t;
	
	Q_t.setlength(Q.cols(), Q.rows());
	alglib::cmatrixtranspose(Q.rows(), Q.cols(), Q, 0, 0, Q_t, 0, 0);

	tmp.setlength(Q_t.rows(), data.cols());
	tmp2.setlength(Q.rows(), tmp.cols());
	alglib::cmatrixgemm(Q_t.rows(), data.cols(), Q_t.cols(), 1.0, Q_t, 0, 0, 0, data, 0, 0, 0, 0, tmp, 0, 0);
        alglib::cmatrixgemm(Q.rows(), tmp.cols(), Q.cols(), 1.0, Q, 0, 0, 0, tmp, 0, 0, 0, 0, tmp2, 0, 0);

        return norm_L2(csub(data,tmp2));

}
// Calculate Cij Norm
void calculateCijNorm(pMesh theMesh, GeomData *pGCData, std::set<int> setOfDomains){
	int dim = theMesh->getDim();
	double Cij[3];
	std::set<int>::iterator iter = setOfDomains.begin();
	for(;iter!=setOfDomains.end();iter++){
		EIter eit = M_edgeIter(theMesh);
		pEdge edge;
		while ( (edge = EIter_next(eit)) ){
			if (!theMesh->getRefinementDepth(edge)){
				pGCData->getCij(edge,*iter,Cij);
				double Cij_norm = norm_L2(Cij,dim);
				if (Cij_norm > 0.0){
					pGCData->setCij_norm(edge,*iter,Cij_norm);
					int flag = EN_getFlag(edge);
					pGCData->set_belongsToBoundary(edge, flag != *iter );
				}
			}
		}
		EIter_delete(eit);
	}
}
   inline void
   showErrorStatistics(vector<double> const& origFocalLengths,
                       vector<StdDistortionFunction> const& distortions,
                       vector<CameraMatrix> const& cams,
                       vector<Vector3d> const& Xs,
                       vector<Vector2d> const& measurements,
                       vector<int> const& correspondingView,
                       vector<int> const& correspondingPoint)
   {
      int const K = measurements.size();

      double meanReprojectionError = 0.0;
      for (int k = 0; k < K; ++k)
      {
         int const i = correspondingView[k];
         int const j = correspondingPoint[k];
         Vector2d p = cams[i].projectPoint(distortions[i], Xs[j]);

         double const f0 = origFocalLengths[i];
         double reprojectionError = norm_L2(f0 * (p - measurements[k]));
         meanReprojectionError += reprojectionError;
      }
      cout << "mean reprojection error (in pixels): " << meanReprojectionError/K << endl;
   }