9#include "CLHEP/Matrix/defs.h"
10#include "CLHEP/Matrix/Matrix.h"
11#include "CLHEP/Matrix/SymMatrix.h"
12#include "CLHEP/Matrix/DiagMatrix.h"
13#include "CLHEP/Matrix/Vector.h"
14#include "CLHEP/Random/Random.h"
15#include "CLHEP/Random/JamesRandom.h"
16#include "CLHEP/Random/RandFlat.h"
39double neg(
double f,
int,
int) {
43double absf(
double f,
int,
int) {
60 cout <<
"Starting Matrix tests" << endl;
70 cout <<
"4x5 matrix initialized to zero " <<
b;
72 cout <<
"3x3 matrix initialized to identity " << c;
80 cout <<
"3x3 matrix initialized with Random " <<
a;
83 cout <<
"matrix initialized to the previous matrix " <<
b;
92 cout <<
"8x5 matrix" <<
a;
93 cout <<
"sub matrix (2-6 x 3-5 of the previous matrix." <<
b;
96 cout <<
"embedding sub matrix at 4,3" <<
a;
99 cout <<
"dsum" <<
dsum(
a,d);
110 cout <<
"a += b" << (
a+=
b);
113 cout <<
"a + b" << c;
126 cout <<
"End of Matrix tests" << endl;
140 cout <<
"4x4 Symmetric matrix initialuzed to zero " <<
b;
142 cout <<
"3x3 Symmetric matrix initialized to identity "<< c;
150 cout <<
"3x3 symmetric matrix initialized with Random " <<
a << endl;
153 cout <<
"symmetric matrix initialized to the previous matrix " <<
b;
155 cout <<
"matrix initialized to the previous symmetric matrix "
162 cout << c(1,1) <<
" " << c[0][0] << endl;
169 cout << d(1,1) <<
" " << d[0][0] << endl;
179 cout <<
"5x5 sym matrix" <<
a;
180 cout <<
"sub sym matrix (2-5 x 2-5 of the previous sub matrix." <<
b;
183 cout <<
"embedding sub matrix at 2" <<
a;
192 cout <<
"b(sym)" <<
b;
193 cout <<
"a += b" << (
a+=
b);
195 cout <<
"a + b" << c;
236 double c =
b.similarity(
a);
240 cout <<
"c\t" << c << endl;
243 cout <<
"End of SymMatrix tests" << endl;
257 cout <<
"4x4 diagonal matrix initialized to zero " <<
b;
259 cout <<
"3x3 diagonal matrix initialized to identity " << c;
267 cout <<
"3x3 diagonal matrix initialized to Random " <<
a;
270 cout <<
"diagonal matrix initialized to the previous matrix " <<
b;
272 cout <<
"matrix initialized to the previous diagonal matrix "
275 cout <<
"Symmetric matrix initialized to the previous diagonal matrix "
285 cout <<
"8x8 diag matrix" <<
a;
286 cout <<
"sub diag matrix (2-5 x 2-5 of the previous diag matrix." <<
b;
289 cout <<
"embedding sub matrix at 2" <<
a;
298 cout <<
"b(diag)" <<
b;
299 cout <<
"a += b" << (
a+=
b);
301 cout <<
"a + b" << c;
304 cout <<
"End of DiagMatrix tests" << endl;
317 cout <<
"4 vector initialized to zero "<<
b;
319 cout <<
"3 vector initialized to identity " << c;
327 cout <<
"3 vector initialized to Random " <<
a;
330 cout <<
"Vector initialized to the previous vector " <<
b;
332 cout <<
"matrix initialized to the previous vector "
335 cout <<
"Vector initialized to the previous matrix "
345 cout <<
"8 vector" <<
a;
346 cout <<
"sub vector (2-5 of the previous vector." <<
b;
349 cout <<
"embedding sub vector at 2 " <<
a;
358 cout <<
"b(vector)" <<
b;
359 cout <<
"a += b" << (
a+=
b);
361 cout <<
"a + b" << c;
364 cout <<
"End of Vector tests" << endl;
371 cout << std::setiosflags(std::ios::fixed) << std::setw(10);
411 cout <<
"nraw=" <<
b.num_row() <<
" ncol=" <<
b.num_col() << endl;
414 cout <<
"b(1,1)=" <<
b(1,1) <<
" b(2,1)=" <<
b(2,1) << endl;
455 cout <<
"Dm=" << dm <<
" d = " << d << endl;
474 cout <<
"nraw=" << sr.
num_row() <<
" ncol=" << sr.
num_col() << endl;
477 cout <<
"sr(1,1)=" << sr(1,1) <<
" sr(2,1)=" << sr(2,1) << endl;
485 cout <<
"d=" << d <<
"s=" << s << endl;
538 cout <<
"dr(1,1)=" << dr(1,1) << endl;
579 cout <<
"vz=" << vz <<
"vi=" << vi << endl;
586 cout <<
"Nr=" << vr.
num_row() << endl;
589 cout <<
"vr(3)=" << vr(3) << endl;
616 cout <<
"Normsq=" << vc.
normsq() <<
"Norm=" << vc.
norm() << endl;
706 cout <<
"Inv=" << inv << endl;
711 cout <<
"a*m=" << am.apply(
absf) <<
"m*a=" << ma.
apply(
absf) << endl;
719 cout <<
"m*vt=" << m*vt <<
"v=" << v << endl;
727 cout <<
"Inv=" << inv << endl;
737 cout <<
"Before diag:ss=" << ss << endl;
742 cout <<
"m=" << m << endl;
745 cout <<
"ss=" << ss << endl;
748 cout <<
"Diff" << diff.
apply(
absf) << endl;
758 cout <<
"Norm 1 =" <<
norm1(m) << endl;
761 cout <<
"Norm 2 =" <<
norm(m) << endl;
769 cout <<
"m=" << m << endl;
773 cout <<
"a=" <<
a <<
"m=" << m << endl;
776 cout <<
"a*m=" <<
a*m << endl;
783 cout <<
"v=" << v <<
" m*vt=" << m*vt << endl;
790 cout <<
"v=" <<
a <<
" m*b=" << m*
b << endl;
793 cout <<
"Test was successful" << endl;
814 double psq = p[i].
normsq();
815 sp(1,1) += psq - p[i](1)*p[i](1);
816 sp(2,2) += psq - p[i](2)*p[i](2);
817 sp(3,3) += psq - p[i](3)*p[i](3);
818 sp(2,1) -= p[i](2)*p[i](1);
819 sp(3,1) -= p[i](3)*p[i](1);
820 sp(3,2) -= p[i](3)*p[i](2);
823 cout <<
"sp=" << sp <<
" spd=" << spd << endl;
826 cout <<
"condition = " <<
condition(spps) << endl;
829 cout <<
"spps=" << spps <<
"sppss - sim = " << sppssdiff.
apply(
absf)
double & fast(int row, int col)
HepDiagMatrix sub(int min_row, int max_row) const
void assign(const HepMatrix &hm2)
HepSymMatrix similarityT(const HepMatrix &hm1) const
HepSymMatrix similarity(const HepMatrix &hm1) const
HepDiagMatrix apply(double(*f)(double, int, int)) const
HepMatrix sub(int min_row, int max_row, int min_col, int max_col) const
HepMatrix apply(double(*f)(double, int, int)) const
static void setTheSeed(long seed, int lux=3)
void assign(const HepMatrix &hm2)
HepSymMatrix apply(double(*f)(double, int, int)) const
HepSymMatrix similarityT(const HepMatrix &hm1) const
HepSymMatrix sub(int min_row, int max_row) const
HepSymMatrix inverse(int &ifail) const
HepSymMatrix similarity(const HepMatrix &hm1) const
const double & fast(int row, int col) const
HepVector sub(int min_row, int max_row) const
HepVector apply(double(*f)(double, int)) const
virtual int num_row() const
HepVector qr_solve(const HepMatrix &A, const HepVector &b)
HepSymMatrix vT_times_v(const HepVector &v)
double norm(const HepGenMatrix &m)
HepMatrix qr_inverse(const HepMatrix &A)
void qr_decomp(HepMatrix *A, HepMatrix *hsm)
void swap(shared_ptr< P > &, shared_ptr< P > &)
double norm1(const HepGenMatrix &m)
HepDiagMatrix dsum(const HepDiagMatrix &s1, const HepDiagMatrix &s2)
double norm_infinity(const HepGenMatrix &m)
double condition(const HepSymMatrix &m)
HepMatrix diagonalize(HepSymMatrix *s)
HepVector solve(const HepMatrix &, const HepVector &)
double absf(double f, int, int)
void matrix_test2(const HepSymMatrix &m, HepSymMatrix &n)
double neg(double f, int, int)
double negv(double f, int)
int matrix_test1(const HepGenMatrix &m)