diff --git a/test/unitvectortest.cc b/test/unitvectortest.cc index 0b1880fed85102f9b152ac65d9637031e33703fb..ded44a5f81a66cdaa0db9c1d4970c94b5b6d6ba9 100644 --- a/test/unitvectortest.cc +++ b/test/unitvectortest.cc @@ -82,6 +82,17 @@ FieldMatrix<double,worldDim,worldDim> getSecondDerivativeOfSecondArgumentFD(cons return ret2; } +template <class TargetSpace, int worldDim> +void testOrthonormalFrame(const TargetSpace& a) +{ + const size_t spaceDim = TargetSpace::dim; + FieldMatrix<double,spaceDim,worldDim> B = a.orthonormalFrame(); + + for (int i=0; i<spaceDim; i++) + for (int j=0; j<spaceDim; j++) + assert( std::fabs(B[i]*B[j] - (i==j)) < 1e-10 ); +} + template <class TargetSpace, int dim> void testDerivativeOfSquaredDistance(const TargetSpace& a, const TargetSpace& b) { @@ -291,10 +302,13 @@ void testUnitVector2d() // Set up elements of S^1 for (int i=0; i<nTestPoints; i++) { + Dune::array<double,2> w0 = {testPoints[i][0], testPoints[i][1]}; + UnitVector<2> v0(w0); + + testOrthonormalFrame<UnitVector<2>, 2>(v0); + for (int j=0; j<nTestPoints; j++) { - Dune::array<double,2> w0 = {testPoints[i][0], testPoints[i][1]}; - UnitVector<2> v0(w0); Dune::array<double,2> w1 = {testPoints[j][0], testPoints[j][1]}; UnitVector<2> v1(w1); @@ -319,10 +333,13 @@ void testUnitVector3d() // Set up elements of S^1 for (int i=0; i<nTestPoints; i++) { + Dune::array<double,3> w0 = {testPoints[i][0], testPoints[i][1], testPoints[i][2]}; + UnitVector<3> uv0(w0); + + testOrthonormalFrame<UnitVector<3>, 3>(uv0); + for (int j=0; j<nTestPoints; j++) { - Dune::array<double,3> w0 = {testPoints[i][0], testPoints[i][1], testPoints[i][2]}; - UnitVector<3> uv0(w0); Dune::array<double,3> w1 = {testPoints[j][0], testPoints[j][1], testPoints[j][2]}; UnitVector<3> uv1(w1);