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"
40double neg(
double f,
int,
int) {
44double absf(
double f,
int,
int) {
61 cout <<
"Starting Matrix tests" << endl;
71 cout <<
"4x5 matrix initialized to zero " << b;
73 cout <<
"3x3 matrix initialized to identity " << c;
81 cout <<
"3x3 matrix initialized with Random " << a;
84 cout <<
"matrix initialized to the previous matrix " << b;
93 cout <<
"8x5 matrix" << a;
94 cout <<
"sub matrix (2-6 x 3-5 of the previous matrix." << b;
97 cout <<
"embedding sub matrix at 4,3" << a;
100 cout <<
"dsum" <<
dsum(a,d);
111 cout <<
"a += b" << (a+=b);
114 cout <<
"a + b" << c;
127 cout <<
"End of Matrix tests" << endl;
141 cout <<
"4x4 Symmetric matrix initialuzed to zero " << b;
143 cout <<
"3x3 Symmetric matrix initialized to identity "<< c;
151 cout <<
"3x3 symmetric matrix initialized with Random " << a << endl;
154 cout <<
"symmetric matrix initialized to the previous matrix " << b;
156 cout <<
"matrix initialized to the previous symmetric matrix "
163 cout << c(1,1) <<
" " << c[0][0] << endl;
170 cout << d(1,1) <<
" " << d[0][0] << endl;
180 cout <<
"5x5 sym matrix" << a;
181 cout <<
"sub sym matrix (2-5 x 2-5 of the previous sub matrix." << b;
184 cout <<
"embedding sub matrix at 2" << a;
193 cout <<
"b(sym)" << b;
194 cout <<
"a += b" << (a+=b);
196 cout <<
"a + b" << c;
241 cout <<
"c\t" << c << endl;
244 cout <<
"End of SymMatrix tests" << endl;
258 cout <<
"4x4 diagonal matrix initialized to zero " << b;
260 cout <<
"3x3 diagonal matrix initialized to identity " << c;
268 cout <<
"3x3 diagonal matrix initialized to Random " << a;
271 cout <<
"diagonal matrix initialized to the previous matrix " << b;
273 cout <<
"matrix initialized to the previous diagonal matrix "
276 cout <<
"Symmetric matrix initialized to the previous diagonal matrix "
286 cout <<
"8x8 diag matrix" << a;
287 cout <<
"sub diag matrix (2-5 x 2-5 of the previous diag matrix." << b;
290 cout <<
"embedding sub matrix at 2" << a;
299 cout <<
"b(diag)" << b;
300 cout <<
"a += b" << (a+=b);
302 cout <<
"a + b" << c;
305 cout <<
"End of DiagMatrix tests" << endl;
318 cout <<
"4 vector initialized to zero "<< b;
320 cout <<
"3 vector initialized to identity " << c;
328 cout <<
"3 vector initialized to Random " << a;
331 cout <<
"Vector initialized to the previous vector " << b;
333 cout <<
"matrix initialized to the previous vector "
336 cout <<
"Vector initialized to the previous matrix "
346 cout <<
"8 vector" << a;
347 cout <<
"sub vector (2-5 of the previous vector." << b;
350 cout <<
"embedding sub vector at 2 " << a;
359 cout <<
"b(vector)" << b;
360 cout <<
"a += b" << (a+=b);
362 cout <<
"a + b" << c;
365 cout <<
"End of Vector tests" << endl;
372 cout << std::setiosflags(std::ios::fixed) << std::setw(10);
412 cout <<
"nraw=" << b.
num_row() <<
" ncol=" << b.
num_col() << endl;
415 cout <<
"b(1,1)=" << b(1,1) <<
" b(2,1)=" << b(2,1) << endl;
456 cout <<
"Dm=" << dm <<
" d = " << d << endl;
475 cout <<
"nraw=" << sr.
num_row() <<
" ncol=" << sr.
num_col() << endl;
478 cout <<
"sr(1,1)=" << sr(1,1) <<
" sr(2,1)=" << sr(2,1) << endl;
486 cout <<
"d=" << d <<
"s=" << s << endl;
539 cout <<
"dr(1,1)=" << dr(1,1) << endl;
580 cout <<
"vz=" << vz <<
"vi=" << vi << endl;
587 cout <<
"Nr=" << vr.
num_row() << endl;
590 cout <<
"vr(3)=" << vr(3) << endl;
617 cout <<
"Normsq=" << vc.
normsq() <<
"Norm=" << vc.
norm() << endl;
707 cout <<
"Inv=" << inv << endl;
712 cout <<
"a*m=" << am.apply(
absf) <<
"m*a=" << ma.
apply(
absf) << endl;
720 cout <<
"m*vt=" << m*vt <<
"v=" << v << endl;
728 cout <<
"Inv=" << inv << endl;
738 cout <<
"Before diag:ss=" << ss << endl;
743 cout <<
"m=" << m << endl;
746 cout <<
"ss=" << ss << endl;
749 cout <<
"Diff" << diff.
apply(
absf) << endl;
759 cout <<
"Norm 1 =" <<
norm1(m) << endl;
762 cout <<
"Norm 2 =" <<
norm(m) << endl;
770 cout <<
"m=" << m << endl;
774 cout <<
"a=" << a <<
"m=" << m << endl;
777 cout <<
"a*m=" << a*m << endl;
784 cout <<
"v=" << v <<
" m*vt=" << m*vt << endl;
791 cout <<
"v=" << a <<
" m*b=" << m*b << endl;
794 cout <<
"Test was successful" << endl;
815 double psq = p[i].
normsq();
816 sp(1,1) += psq - p[i](1)*p[i](1);
817 sp(2,2) += psq - p[i](2)*p[i](2);
818 sp(3,3) += psq - p[i](3)*p[i](3);
819 sp(2,1) -= p[i](2)*p[i](1);
820 sp(3,1) -= p[i](3)*p[i](1);
821 sp(3,2) -= p[i](3)*p[i](2);
824 cout <<
"sp=" << sp <<
" spd=" << spd << endl;
827 cout <<
"condition = " <<
condition(spps) << endl;
830 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
virtual int num_col() const =0
HepMatrix sub(int min_row, int max_row, int min_col, int max_col) const
HepMatrix apply(double(*f)(double, int, int)) const
virtual int num_col() const
virtual int num_row() const
HepMatrix inverse(int &ierr) const
static void setTheSeed(long seed, int lxr=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)
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)