53 "Householder Transformation is square.",
57 for (
int i = 0; i < HH.
A.
rows(); i++)
59 for (
int j = 0; j < HH.
A.
cols(); j++)
61 if (j == i && HH.
A(i,j) == 0)
63 if (j < i && HH.
A(i,j) != 0)
69 "Householder Transformation is upper triangular",
72 int zeroCount=0, badCount = 0;
73 int iRowNegCount=0, oRowNegCount=0;
75 for(
int i = 0; i < A.rows(); i++)
77 for(
int j = 0; j < A.cols(); j++)
80 if ((std::abs(HH.
A(i,j) - HH_ref(i,j)) > eps))
82 if (std::abs(-1 * HH.
A(i,j) - HH_ref(i,j)) < eps)
91 if (iRowNegCount == A.cols() - zeroCount)
94 else if (iRowNegCount != 0)
95 badCount += iRowNegCount;
101 "Householder Transformation matches expected values",
107 int errorCounter = 0;
108 gnsstk::TestUtil testFramework(
"Matrix Householder",
"--", __FILE__, __LINE__);
119 pow(2,.5), pow(2,-.5), pow(2,-.5),
120 0, pow(1.5,.5), pow(6,-.5),
123 hhtest(3, 3, a5, ref5, testFramework);
134 hhtest(3, 3, a6, ref6, testFramework);
141 -1*pow(2,.5),-1*pow(2,.5),-1*pow(18,.5),
142 0,-1*pow(6,.5),pow(6,.5),
145 hhtest(3, 3, a7, ref7, testFramework);
151 pow(61, .5), -5./pow(61, .5),
154 hhtest(2, 2, a8, ref8, testFramework);
162 pow(5, .5), 4./pow(5, .5), 1./pow(5, .5), 0,
163 0, pow(14./5, .5), 3*pow(2./35, .5)+pow(10./7, .5), pow(5./14, .5),
164 0, 0, pow(15./7, .5), 2*pow(3./35, .5)+2*pow(7./15, .5),
165 0, 0, 0, pow(5./6, .5)};
167 hhtest(4, 4, a9, ref9, testFramework);
169 std::cout <<
"Total Failures for " << __FILE__ <<
": " << testFramework.
countFails() << std::endl;