Nektar++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
Nektar::NekLinAlgTests Namespace Reference

Functions

 BOOST_AUTO_TEST_CASE (TestGramSchmidtOrthogonalizationBookExample)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

Nektar::NekLinAlgTests::BOOST_AUTO_TEST_CASE ( TestGramSchmidtOrthogonalizationBookExample  )

Definition at line 47 of file testNekLinAlgAlgorithms.cpp.

48{
49 double buf_0[] = {1.0, 0.0, 2.0};
50 double buf_1[] = {2.0, 3.0, 0.0};
51
52 std::vector<NekVector<double>> x;
53 x.push_back(NekVector<double>(3, buf_0));
54 x.push_back(NekVector<double>(3, buf_1));
55
56 std::vector<NekVector<double>> q = GramSchmidtOrthogonalization(x);
57
58 BOOST_CHECK_EQUAL(q.size(), 2);
59
60 double epsilon = 1e-1;
61 BOOST_CHECK_CLOSE(q[0][0], .4472, epsilon);
62 BOOST_CHECK_CLOSE(q[0][1], .0, epsilon);
63 BOOST_CHECK_CLOSE(q[0][2], .8942, epsilon);
64
65 BOOST_CHECK_CLOSE(q[1][0], .45811, epsilon);
66 BOOST_CHECK_CLOSE(q[1][1], .85890, epsilon);
67 BOOST_CHECK_CLOSE(q[1][2], -.22890, epsilon);
68}
std::vector< double > q(NPUPPER *NPUPPER)
std::vector< NekVector< DataType > > GramSchmidtOrthogonalization(const std::vector< NekVector< DataType > > &x)
Calculates the orthogonal, normalized vectors from linearly independent input.

References Nektar::GramSchmidtOrthogonalization(), and Nektar::UnitTests::q().