22 int main(
int argc,
char**argv)
32 JParser<> zap(
"Example program to test inversion and eigenvalue decomposition of 3D symmetric matrix.");
39 catch(
const exception &error) {
40 FATAL(error.what() << endl);
47 JMatrix3S
A = getRandom<JMatrix3S>();
49 DEBUG(
"Matrix A" << endl);
52 NOTICE(
"Determinant A " <<
A.getDeterminant() << endl);
60 DEBUG(
"Matrix A^-1" << endl);
63 NOTICE(
"Determinant A^-1 = " << B.getDeterminant() << endl);
67 DEBUG(
"Matrix A x A^-1" << endl);
70 NOTICE(
"Determinant (A x A^-1) = " << C.getDeterminant() << endl);
71 NOTICE(
"Determinant A x Determinant A^-1 = " <<
A.getDeterminant() * B.getDeterminant() << endl);
72 NOTICE(
"A x A^-1 = I ? " << C.isIdentity(precision) << endl);
74 if (!C.isIdentity(precision)) {
75 ERROR(
"Matrix A x A^-1 /= I" << endl);
78 JMatrix3D
D = C - JMatrix3D::getIdentity();
80 DEBUG(
"Matrix D = C - I" << endl);
83 DEBUG(
"Eigenvalues v of matrix A" << endl);
85 JMatrix3S::eigen_values
v =
A.getEigenValues();
87 for (JMatrix3S::eigen_values::const_iterator i = v.cbegin(); i != v.cend(); ++i) {
93 ASSERT(fabs(v[0]) > fabs(v[1]));
94 ASSERT(fabs(v[1]) > fabs(v[2]));
96 ASSERT(JMatrix3S(
A).sub(v[0] * JMatrix3D::getIdentity()).getDeterminant() < precision);
97 ASSERT(JMatrix3S(
A).sub(v[1] * JMatrix3D::getIdentity()).getDeterminant() < precision);
98 ASSERT(JMatrix3S(
A).sub(v[2] * JMatrix3D::getIdentity()).getDeterminant() < precision);
100 ASSERT(C.isIdentity(precision));
102 catch (
const JException& error) {
103 FATAL(error << endl);
Utility class to parse command line options.
int main(int argc, char *argv[])
static const double C
Physics constants.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
General purpose messaging.
Utility class to parse command line options.
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
Auxiliary data structure for floating point format specification.
do echo Generating $dir eval D
#define DEBUG(A)
Message macros.