8#include "CLHEP/Matrix/defs.h"
9#include "CLHEP/Random/Random.h"
10#include "CLHEP/Vector/ThreeVector.h"
11#include "CLHEP/Matrix/Vector.h"
12#include "CLHEP/Matrix/Matrix.h"
13#include "CLHEP/Utility/thread_local.h"
15#ifdef HEP_DEBUG_INLINE
16#include "CLHEP/Matrix/Vector.icc"
23#define SIMPLE_UOP(OPER) \
24 HepGenMatrix::mIter a=m.begin(); \
25 HepGenMatrix::mIter e=m.begin()+num_size(); \
26 for(;a<e; a++) (*a) OPER t;
28#define SIMPLE_BOP(OPER) \
30 mcIter b=hm2.m.begin(); \
31 mcIter e=m.begin()+num_size(); \
32 for(;a<e; a++, b++) (*a) OPER (*b);
34#define SIMPLE_TOP(OPER) \
35 HepGenMatrix::mcIter a=hm1.m.begin(); \
36 HepGenMatrix::mcIter b=hm2.m.begin(); \
37 HepGenMatrix::mIter t=mret.m.begin(); \
38 HepGenMatrix::mcIter e=hm1.m.begin()+hm1.num_size(); \
39 for( ;a<e; a++, b++, t++) (*t) = (*a) OPER (*b);
41#define CHK_DIM_2(r1,r2,c1,c2,fun) \
42 if (r1!=r2 || c1!=c2) { \
43 HepGenMatrix::error("Range error in Vector function " #fun "(1)."); \
46#define CHK_DIM_1(c1,r2,fun) \
48 HepGenMatrix::error("Range error in Vector function " #fun "(2)."); \
69 mIter e = m.begin() + nrow;
70 for (
mIter i=m.begin(); i<e; i++) *i = 1.0;
75 error(
"Vector: initialization must be either 0 or 1.");
84 for(;a<b;a++) *a = r();
106 : m(hm1.nrow), nrow(hm1.nrow)
109 error(
"Vector::Vector(Matrix) : Matrix is not Nx1");
122#ifdef MATRIX_BOUND_CHECK
125 if( col!=1 || row<1 || row>nrow)
126 error(
"Range error in HepVector::operator(i,j)");
132 return *(m.begin()+(row-1));
135#ifdef MATRIX_BOUND_CHECK
138 if( col!=1 || row<1 || row>nrow)
139 error(
"Range error in HepVector::operator(i,j)");
145 return *(m.begin()+(row-1));
151#ifdef HEP_GNU_OPTIMIZED_RETURN
152return vret(max_row-min_row+1);
159 error(
"HepVector::sub: Index out of range");
163 for(;a<e;) *(a++) = *(b++);
171 error(
"HepVector::sub: Index out of range");
175 for(;a<e;) *(a++) = *(b++);
182 error(
"HepVector::sub: Index out of range");
186 for(;a<e;) *(b++) = *(a++);
195#ifdef HEP_GNU_OPTIMIZED_RETURN
213#ifdef HEP_GNU_OPTIMIZED_RETURN
223 for(;a<e; a++, b++) (*b) = -(*a);
230#ifdef HEP_GNU_OPTIMIZED_RETURN
243#ifdef HEP_GNU_OPTIMIZED_RETURN
256#ifdef HEP_GNU_OPTIMIZED_RETURN
273#ifdef HEP_GNU_OPTIMIZED_RETURN
287#ifdef HEP_GNU_OPTIMIZED_RETURN
300#ifdef HEP_GNU_OPTIMIZED_RETURN
319#ifdef HEP_GNU_OPTIMIZED_RETURN
331#ifdef HEP_GNU_OPTIMIZED_RETURN
343#ifdef HEP_GNU_OPTIMIZED_RETURN
355#ifdef HEP_GNU_OPTIMIZED_RETURN
367 for(hm1p=hm1.m.begin();hm1p<hm1.m.begin()+hm1.
num_row()*hm1.
num_col();hm1p=hm2p)
373 temp+=(*(hm2p++))*(*(vp++));
380#ifdef HEP_GNU_OPTIMIZED_RETURN
391 for(hm1p=hm1.m.begin();hm1p<hm1.m.begin()+hm1.
num_row();hm1p++)
392 for(hm2p=hm2.m.begin();hm2p<hm2.m.begin()+hm2.
num_col();hm2p++)
393 *(mrp++)=*hm1p*(*hm2p);
457 if(hm1.nrow != size_)
482 error(
"Vector::operator=(Matrix) : Matrix is not Nx1");
518 if(os.flags() & std::ios::fixed)
519 width = os.precision()+3;
521 width = os.precision()+7;
522 for(
int irow = 1; irow<= q.
num_row(); irow++)
525 os << q(irow) << std::endl;
531#ifdef HEP_GNU_OPTIMIZED_RETURN
550 for(;a<e;) d += (*(a++)) * (*(b++));
555apply(
double (*
f)(
double,
int))
const
556#ifdef HEP_GNU_OPTIMIZED_RETURN
565 for(
int ir=1;ir<=
num_row();ir++) {
566 *(b++) = (*
f)(*(a++), ir);
571void HepVector::invert(
int &) {
572 error(
"HepVector::invert: You cannot invert a Vector");
576#ifdef HEP_GNU_OPTIMIZED_RETURN
583 static CLHEP_THREAD_LOCAL
int max_array = 20;
584 static CLHEP_THREAD_LOCAL
int *ir =
new int [max_array+1];
595 ir =
new int [max_array+1];
599 int i = mt.dfact_matrix(det, ir);
601 for (i=1;i<=n;i++) vret(i) = 0;
607 for (
int hmm=1;hmm<=nxch;hmm++) {
616 vret(1) = mt(1,1) * vret(1);
620 for (
int j=1;j<i;j++) {
621 s21 += mt(i,j) * vret(j);
623 vret(i) = -mt(i,i)*s21;
628 for (
int j=1;j<=i;j++) {
629 s22 += mt(nmi,n-j+1) * vret(n-j+1);
#define CHK_DIM_2(r1, r2, c1, c2, fun)
#define CHK_DIM_1(c1, r2, fun)
std::vector< double, Alloc< double, 25 > >::const_iterator mcIter
std::vector< double, Alloc< double, 25 > >::iterator mIter
static void error(const char *s)
HepMatrix & operator=(const HepMatrix &)
virtual int num_col() const
virtual int num_row() const
HepMatrix & operator+=(const HepMatrix &)
HepMatrix & operator-=(const HepMatrix &)
HepVector & operator/=(double t)
HepVector sub(int min_row, int max_row) const
HepVector & operator-=(const HepMatrix &v2)
virtual int num_size() const
virtual int num_col() const
HepVector apply(double(*f)(double, int)) const
HepVector operator-() const
virtual int num_row() const
friend double dot(const HepVector &v1, const HepVector &v2)
friend HepVector solve(const HepMatrix &a, const HepVector &v)
const double & operator()(int row) const
HepVector & operator=(const HepVector &hm2)
friend HepVector operator*(const HepSymMatrix &hm1, const HepVector &hm2)
friend HepVector operator+(const HepVector &v1, const HepVector &v2)
HepVector & operator*=(double t)
HepVector & operator+=(const HepMatrix &v2)
std::ostream & operator<<(std::ostream &s, const HepDiagMatrix &q)
HepDiagMatrix dsum(const HepDiagMatrix &s1, const HepDiagMatrix &s2)