Logo ROOT   6.10/09
Reference Guide
matrix_util.h
Go to the documentation of this file.
1 #ifndef MATRIX_UTIL_H
2 #define MATRIX_UTIL_H
3 
4 // utility functions to fill with random data
5 
6 template<class V>
7 void fillRandomVec(TRandom & r, V & v, unsigned int len, unsigned int start = 0, double offset = 1) {
8  for(unsigned int i = start; i < len+start; ++i)
9  v[i] = r.Rndm() + offset;
10 }
11 
12 template<class M>
13 void fillRandomMat(TRandom & r, M & m, unsigned int first, unsigned int second, unsigned int start = 0, double offset = 1) {
14  for(unsigned int i = start; i < first+start; ++i)
15  for(unsigned int j = start; j < second+start; ++j)
16  m(i,j) = r.Rndm() + offset;
17 }
18 
19 template<class M>
20 void fillRandomSym(TRandom & r, M & m, unsigned int first, unsigned int start = 0, double offset = 1) {
21  for(unsigned int i = start; i < first+start; ++i) {
22  for(unsigned int j = i; j < first+start; ++j) {
23  if ( i != j ) {
24  m(i,j) = r.Rndm() + offset;
25  m(j,i) = m(i,j);
26  }
27  else // add extra offset to make no singular when inverting
28  m(i,i) = r.Rndm() + 3*offset;
29  }
30  }
31 }
32 
33 #endif
void fillRandomSym(TRandom &r, M &m, unsigned int first, unsigned int start=0, double offset=1)
Definition: matrix_util.h:20
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:27
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandom.cxx:512
TRandom2 r(17)
SVector< double, 2 > v
Definition: Dict.h:5
TMarker * m
Definition: textangle.C:8
void fillRandomMat(TRandom &r, M &m, unsigned int first, unsigned int second, unsigned int start=0, double offset=1)
Definition: matrix_util.h:13
void fillRandomVec(TRandom &r, V &v, unsigned int len, unsigned int start=0, double offset=1)
Definition: matrix_util.h:7
Definition: first.py:1