int Matrix_T::inverseTest(void)
{
	TestUtil testFramework("Matrix", "Inverse", __FILE__, __LINE__);

	gpstk::Matrix<double> A1inv(2,2),A2inv(3,3),A3inv(4,4),A4inv(3,4);
	gpstk::Matrix<double> CompareA1inv(2,2),CompareA2inv(3,3),CompareA3inv(4,4),CompareA4inv(3,4);
	A1inv = gpstk::inverse(A1);
	A2inv = gpstk::inverse(A2);
	A3inv = gpstk::inverse(A3);
	try{A4inv = gpstk::inverse(A4); testFramework.assert(false, failMesg, __LINE__);}
	catch(gpstk::Exception e) {testFramework.assert(true, failMesg, __LINE__);}

	double temp1[4] = {-7,-5,3,2};
	double temp2[9] = {7./3,2./3,2./3,-17./3,-1./3,-4./3,2./3,1./3,1./3};
	double temp3[16] = {18, -35, -28, 1, 9, -18, -14, 1, -2, 4, 3, 0, -12, 24, 19, -1};

	CompareA1inv = temp1;
	CompareA2inv = temp2;
	CompareA3inv = temp3;

	int badCount = 0;

	//testFramework.assert(Ainv == CompareAinv, testMesg, __LINE__);
	for(int i = 0; i < A1inv.rows(); i++)
		for(int j = 0; j < A1inv.cols(); j++)
     			if (std::abs(A1inv(i,j) - CompareA1inv(i,j)) > eps) {badCount++;}
	failDescriptionStream << "Check if gpstk::inverse(A1) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter

	for(int i = 0; i < A2inv.rows(); i++)
		for(int j = 0; j < A2inv.cols(); j++)
     			if (std::abs(A2inv(i,j) - CompareA2inv(i,j)) > eps) {badCount++;}
	failDescriptionStream << "Check if gpstk::inverse(A2) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter

	for(int i = 0; i < A3inv.rows(); i++)
		for(int j = 0; j < A3inv.cols(); j++)
     			if (std::abs(A3inv(i,j) - CompareA3inv(i,j)) > eps) {badCount++;}
	failDescriptionStream << "Check if gpstk::inverse(A3) returns the right matrix. " << badCount << " of the elements are incorrect.";
	failDescriptionString = failDescriptionStream.str(); failDescriptionStream.str("");
    testFramework.assert(badCount==0, failDescriptionString, __LINE__);
  	badCount = 0; // Reset error counter      	      	

  	return testFramework.countFails();
}
Beispiel #2
0
Float VonMisesFisherDistr::convolve(Float kappa1, Float kappa2) {
	return A3inv(A3(kappa1) * A3(kappa2), std::min(kappa1, kappa2));
}