Example program to test inversion of symmetric matrix.
More...
#include <string>
#include <iostream>
#include <iomanip>
#include "TRandom3.h"
#include "JLang/JException.hh"
#include "JMath/JMatrixNS.hh"
#include "Jeep/JTimer.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
Go to the source code of this file.
|
int | main (int argc, char **argv) |
|
Example program to test inversion of symmetric matrix.
- Author
- mdejong
Definition in file JMatrixNS.cc.
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 21 of file JMatrixNS.cc.
32 JParser<> zap(
"Example program to test inversion of symmetric matrix.");
41 catch(
const exception &error) {
42 FATAL(error.what() << endl);
47 gRandom->SetSeed(seed);
49 const Double_t xmin = -1.0;
50 const Double_t xmax = +1.0;
54 for (
int i = 0; i != N; ++i) {
56 A(i,i) = gRandom->Uniform(xmin,xmax);
58 for (
int j = i; j != i; ++j) {
59 A(j,i) = A(i,j) = gRandom->Uniform(xmin,xmax);
66 DEBUG(
"Matrix A" << endl);
69 NOTICE(
"Determinant A = " << A.getDeterminant() << endl);
81 NOTICE(
"Elapsed time [us] " << setw(8) << timer.usec_wall << endl);
82 DEBUG(
"Matrix A^-1" << endl);
85 NOTICE(
"Determinant A^-1 = " << B.getDeterminant() << endl);
91 DEBUG(
"Matrix A x A^-1" << endl);
94 NOTICE(
"Determinant (A x A^-1) = " <<
C.getDeterminant() << endl);
95 NOTICE(
"Determinant A x Determinant A^-1 = " << A.getDeterminant() * B.getDeterminant() << endl);
96 NOTICE(
"A x A^-1 = I ? " <<
C.isIdentity(precision) << endl);
98 if (!
C.isIdentity(precision)) {
99 ERROR(
"Matrix A x A^-1 /= I" << endl);
102 ASSERT (
C.isIdentity(precision));
104 const double big = 1.0e5;
106 for (
int i = 0; i != N; ++i) {
117 NOTICE(
"Elapsed time [us] " << setw(8) << timer.usec_wall << endl);
118 NOTICE(
"Pivot " << setw(2) << i <<
'+' << big <<
' ' << (JMatrixNS(A).mul(B).isIdentity(precision) ?
"okay" :
"error") << endl);
120 ASSERT(JMatrixNS(A).mul(B).isIdentity(precision));
128 catch (
const JException& error) {
129 FATAL(error << endl);
Utility class to parse command line options.
#define ASSERT(A)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define DEBUG(A)
Message macros.