ROOT 6.13/01 Reference Guide |
Template class of Vectors in the linear algebra package
Unless otherwise specified, vector indices always start with 0, spanning up to the specified limit-1.
For (n) vectors where n <= kSizeMax (5 currently) storage space is available on the stack, thus avoiding expensive allocation/ deallocation of heap space . However, this introduces of course kSizeMax overhead for each vector object . If this is an issue recompile with a new appropriate value (>=0) for kSizeMax
Another way to assign and store vector data is through Use see for instance stressLinear.cxx file .
Note that Constructors/assignments exists for all different matrix views
For usage examples see $ROOTSYS/test/stressLinear.cxx
Definition at line 77 of file TMatrixTBase.h.
Public Member Functions | |
TVectorT () | |
TVectorT (Int_t n) | |
Constructor n-vector. More... | |
TVectorT (Int_t lwb, Int_t upb) | |
Constructor [lwb..upb]-vector. More... | |
TVectorT (Int_t n, const Element *elements) | |
Constructor n-vector with data copied from array elements. More... | |
TVectorT (Int_t lwb, Int_t upb, const Element *elements) | |
Constructor [lwb..upb]-vector with data copied from array elements. More... | |
TVectorT (const TVectorT< Element > &another) | |
Copy constructor. More... | |
TVectorT (const TMatrixTRow_const< Element > &mr) | |
Constructor : create vector from matrix row. More... | |
TVectorT (const TMatrixTColumn_const< Element > &mc) | |
Constructor : create vector from matrix column. More... | |
TVectorT (const TMatrixTDiag_const< Element > &md) | |
Constructor : create vector from matrix diagonal. More... | |
template<class Element2 > | |
TVectorT (const TVectorT< Element2 > &another) | |
TVectorT (Int_t lwb, Int_t upb, Double_t iv1,...) | |
Make a vector and assign initial values. More... | |
virtual | ~TVectorT () |
TVectorT< Element > & | Abs () |
Take an absolute value of a vector, i.e. apply Abs() to each element. More... | |
void | Add (const TVectorT< Element > &v) |
Add vector v to this vector. More... | |
void | Add (const TVectorT< Element > &v1, const TVectorT< Element > &v2) |
Set this vector to v1+v2. More... | |
void | AddSomeConstant (Element val, const TVectorT< Element > &select) |
Add to vector elements as selected through array select the value val. More... | |
TVectorT< Element > & | Apply (const TElementActionT< Element > &action) |
Apply action to each element of the vector. More... | |
TVectorT< Element > & | Apply (const TElementPosActionT< Element > &action) |
Apply action to each element of the vector. More... | |
void | Clear (Option_t *="") |
void | Draw (Option_t *option="") |
Draw this vector The histogram is named "TVectorT" by default and no title. More... | |
Int_t | GetLwb () const |
Element * | GetMatrixArray () |
const Element * | GetMatrixArray () const |
Int_t | GetNoElements () const |
Int_t | GetNrows () const |
TVectorT< Element > & | GetSub (Int_t row_lwb, Int_t row_upb, TVectorT< Element > &target, Option_t *option="S") const |
Get subvector [row_lwb..row_upb]; The indexing range of the returned vector depends on the argument option: More... | |
TVectorT< Element > | GetSub (Int_t row_lwb, Int_t row_upb, Option_t *option="S") const |
Int_t | GetUpb () const |
void | Invalidate () |
TVectorT< Element > & | Invert () |
v[i] = 1/v[i] More... | |
Bool_t | IsOwner () const |
Bool_t | IsValid () const |
void | MakeValid () |
Bool_t | MatchesNonZeroPattern (const TVectorT< Element > &select) |
Check if vector elements as selected through array select are non-zero. More... | |
Element | Max () const |
return maximum vector element value More... | |
Element | Min () const |
return minimum vector element value More... | |
Int_t | NonZeros () const |
Compute the number of elements != 0.0. More... | |
Element | Norm1 () const |
Compute the 1-norm of the vector SUM{ |v[i]| }. More... | |
Element | Norm2Sqr () const |
Compute the square of the 2-norm SUM{ v[i]^2 }. More... | |
Element | NormInf () const |
Compute the infinity-norm of the vector MAX{ |v[i]| }. More... | |
Bool_t | operator!= (Element val) const |
Are all vector elements not equal to val? More... | |
const Element & | operator() (Int_t index) const |
Element & | operator() (Int_t index) |
TVectorT< Element > & | operator*= (Element val) |
Multiply every element of the vector with val. More... | |
TVectorT< Element > & | operator*= (const TMatrixT< Element > &a) |
"Inplace" multiplication target = A*target. More... | |
TVectorT< Element > & | operator*= (const TMatrixTSym< Element > &a) |
"Inplace" multiplication target = A*target. More... | |
TVectorT< Element > & | operator*= (const TMatrixTSparse< Element > &a) |
"Inplace" multiplication target = A*target. More... | |
TVectorT< Element > & | operator+= (Element val) |
Add val to every element of the vector. More... | |
TVectorT< Element > & | operator+= (const TVectorT< Element > &source) |
Add vector source. More... | |
TVectorT< Element > & | operator-= (Element val) |
Subtract val from every element of the vector. More... | |
TVectorT< Element > & | operator-= (const TVectorT< Element > &source) |
Subtract vector source. More... | |
Bool_t | operator< (Element val) const |
Are all vector elements < val? More... | |
Bool_t | operator<= (Element val) const |
Are all vector elements <= val? More... | |
TVectorT< Element > & | operator= (const TVectorT< Element > &source) |
Notice that this assignment does NOT change the ownership : if the storage space was adopted, source is copied to this space . More... | |
TVectorT< Element > & | operator= (const TMatrixTRow_const< Element > &mr) |
Assign a matrix row to a vector. More... | |
TVectorT< Element > & | operator= (const TMatrixTColumn_const< Element > &mc) |
Assign a matrix column to a vector. More... | |
TVectorT< Element > & | operator= (const TMatrixTDiag_const< Element > &md) |
Assign the matrix diagonal to a vector. More... | |
TVectorT< Element > & | operator= (const TMatrixTSparseRow_const< Element > &md) |
Assign a sparse matrix row to a vector. More... | |
TVectorT< Element > & | operator= (const TMatrixTSparseDiag_const< Element > &md) |
Assign a sparse matrix diagonal to a vector. More... | |
template<class Element2 > | |
TVectorT< Element > & | operator= (const TVectorT< Element2 > &source) |
TVectorT< Element > & | operator= (Element val) |
Assign val to every element of the vector. More... | |
Bool_t | operator== (Element val) const |
Are all vector elements equal to val? More... | |
Bool_t | operator> (Element val) const |
Are all vector elements > val? More... | |
Bool_t | operator>= (Element val) const |
Are all vector elements >= val? More... | |
const Element & | operator[] (Int_t index) const |
Element & | operator[] (Int_t index) |
void | Print (Option_t *option="") const |
Print the vector as a list of elements. More... | |
void | Randomize (Element alpha, Element beta, Double_t &seed) |
randomize vector elements value More... | |
TVectorT< Element > & | ResizeTo (Int_t lwb, Int_t upb) |
Resize the vector to [lwb:upb] . More... | |
TVectorT< Element > & | ResizeTo (Int_t n) |
TVectorT< Element > & | ResizeTo (const TVectorT< Element > &v) |
TVectorT< Element > & | SelectNonZeros (const TVectorT< Element > &select) |
Keep only element as selected through array select non-zero. More... | |
void | SetElements (const Element *elements) |
TVectorT< Element > & | SetSub (Int_t row_lwb, const TVectorT< Element > &source) |
Insert vector source starting at [row_lwb], thereby overwriting the part [row_lwb..row_lwb+nrows_source];. More... | |
TVectorT< Element > & | Shift (Int_t row_shift) |
Bool_t | SomePositive (const TVectorT< Element > &select) |
Check if vector elements as selected through array select are all positive. More... | |
TVectorT< Element > & | Sqr () |
Square each element of the vector. More... | |
TVectorT< Element > & | Sqrt () |
Take square root of all elements. More... | |
Element | Sum () const |
Compute sum of elements. More... | |
TVectorT< Element > & | Use (Int_t lwb, Int_t upb, Element *data) |
Use the array data to fill the vector lwb..upb]. More... | |
const TVectorT< Element > & | Use (Int_t lwb, Int_t upb, const Element *data) const |
TVectorT< Element > & | Use (Int_t n, Element *data) |
const TVectorT< Element > & | Use (Int_t n, const Element *data) const |
TVectorT< Element > & | Use (TVectorT< Element > &v) |
const TVectorT< Element > & | Use (const TVectorT< Element > &v) const |
TVectorT< Element > & | Zero () |
Set vector elements to zero. More... | |
Protected Types | |
enum | { kSizeMax = 5 } |
enum | { kWorkMax = 100 } |
enum | EVectorStatusBits { kStatus = BIT(14) } |
Protected Member Functions | |
void | Allocate (Int_t nrows, Int_t row_lwb=0, Int_t init=0) |
Allocate new vector. More... | |
void | Delete_m (Int_t size, Element *&) |
Delete data pointer m, if it was assigned on the heap. More... | |
Int_t | Memcpy_m (Element *newp, const Element *oldp, Int_t copySize, Int_t newSize, Int_t oldSize) |
Copy copySize doubles from *oldp to *newp . More... | |
Element * | New_m (Int_t size) |
default kTRUE, when Use array kFALSE More... | |
Protected Attributes | |
Element | fDataStack [kSizeMax] |
Element * | fElements {nullptr} |
Bool_t | fIsOwner {kTRUE} |
data container More... | |
Int_t | fNrows {0} |
Int_t | fRowLwb {0} |
#include <TMatrixTBase.h>
|
protected |
Enumerator | |
---|---|
kSizeMax |
Definition at line 34 of file TVectorT.h.
|
protected |
Enumerator | |
---|---|
kWorkMax |
Definition at line 35 of file TVectorT.h.
|
protected |
Enumerator | |
---|---|
kStatus |
Definition at line 47 of file TVectorT.h.
Definition at line 53 of file TVectorT.h.
Constructor n-vector.
Definition at line 175 of file TVectorT.cxx.
Constructor [lwb..upb]-vector.
Definition at line 184 of file TVectorT.cxx.
Constructor n-vector with data copied from array elements.
Definition at line 193 of file TVectorT.cxx.
TVectorT< Element >::TVectorT | ( | Int_t | lwb, |
Int_t | upb, | ||
const Element * | elements | ||
) |
Constructor [lwb..upb]-vector with data copied from array elements.
Definition at line 203 of file TVectorT.cxx.
Copy constructor.
Definition at line 213 of file TVectorT.cxx.
TVectorT< Element >::TVectorT | ( | const TMatrixTRow_const< Element > & | mr | ) |
Constructor : create vector from matrix row.
Definition at line 224 of file TVectorT.cxx.
TVectorT< Element >::TVectorT | ( | const TMatrixTColumn_const< Element > & | mc | ) |
Constructor : create vector from matrix column.
Definition at line 236 of file TVectorT.cxx.
TVectorT< Element >::TVectorT | ( | const TMatrixTDiag_const< Element > & | md | ) |
Constructor : create vector from matrix diagonal.
Definition at line 248 of file TVectorT.cxx.
|
inline |
Definition at line 62 of file TVectorT.h.
Make a vector and assign initial values.
Argument list should contain Element values to assign to vector elements. The list must be terminated by the string "END". Example: TVectorT foo(1,3,0.0,1.0,1.5,"END");
Definition at line 263 of file TVectorT.cxx.
Definition at line 71 of file TVectorT.h.
Take an absolute value of a vector, i.e. apply Abs() to each element.
Definition at line 462 of file TVectorT.cxx.
Add vector v to this vector.
Definition at line 82 of file TVectorT.cxx.
void TVectorT< Element >::Add | ( | const TVectorT< Element > & | v1, |
const TVectorT< Element > & | v2 | ||
) |
Set this vector to v1+v2.
Definition at line 100 of file TVectorT.cxx.
void TVectorT< Element >::AddSomeConstant | ( | Element | val, |
const TVectorT< Element > & | select | ||
) |
Add to vector elements as selected through array select the value val.
Definition at line 1282 of file TVectorT.cxx.
|
protected |
Allocate new vector.
Arguments are number of rows and row lowerbound (0 default).
Definition at line 149 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::Apply | ( | const TElementActionT< Element > & | action | ) |
Apply action to each element of the vector.
Definition at line 1320 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::Apply | ( | const TElementPosActionT< Element > & | action | ) |
Apply action to each element of the vector.
In action the location of the current element is known.
Definition at line 1333 of file TVectorT.cxx.
|
inline |
Definition at line 174 of file TVectorT.h.
|
protected |
Delete data pointer m, if it was assigned on the heap.
Definition at line 51 of file TVectorT.cxx.
void TVectorT< Element >::Draw | ( | Option_t * | option = "" | ) |
Draw this vector The histogram is named "TVectorT" by default and no title.
Definition at line 1351 of file TVectorT.cxx.
|
inline |
Definition at line 73 of file TVectorT.h.
|
inline |
Definition at line 78 of file TVectorT.h.
|
inline |
Definition at line 79 of file TVectorT.h.
|
inline |
Definition at line 76 of file TVectorT.h.
|
inline |
Definition at line 75 of file TVectorT.h.
TVectorT< Element > & TVectorT< Element >::GetSub | ( | Int_t | row_lwb, |
Int_t | row_upb, | ||
TVectorT< Element > & | target, | ||
Option_t * | option = "S" |
||
) | const |
Get subvector [row_lwb..row_upb]; The indexing range of the returned vector depends on the argument option:
option == "S" : return [0..row_upb-row_lwb+1] (default) else : return [row_lwb..row_upb]
Definition at line 371 of file TVectorT.cxx.
|
inline |
Definition at line 206 of file TVectorT.h.
|
inline |
Definition at line 74 of file TVectorT.h.
|
inline |
Definition at line 81 of file TVectorT.h.
v[i] = 1/v[i]
Definition at line 520 of file TVectorT.cxx.
|
inline |
Definition at line 84 of file TVectorT.h.
|
inline |
Definition at line 83 of file TVectorT.h.
|
inline |
Definition at line 82 of file TVectorT.h.
Bool_t TVectorT< Element >::MatchesNonZeroPattern | ( | const TVectorT< Element > & | select | ) |
Check if vector elements as selected through array select are non-zero.
Definition at line 1236 of file TVectorT.cxx.
Element TVectorT< Element >::Max | ( | ) | const |
return maximum vector element value
Definition at line 664 of file TVectorT.cxx.
|
protected |
Copy copySize doubles from *oldp to *newp .
However take care of the situation where both pointers are assigned to the same stack space
Definition at line 122 of file TVectorT.cxx.
Element TVectorT< Element >::Min | ( | ) | const |
return minimum vector element value
Definition at line 652 of file TVectorT.cxx.
|
protected |
default kTRUE, when Use array kFALSE
Return data pointer .
if requested size <= kSizeMax, assign pointer to the stack space
Definition at line 65 of file TVectorT.cxx.
Int_t TVectorT< Element >::NonZeros | ( | ) | const |
Compute the number of elements != 0.0.
Definition at line 618 of file TVectorT.cxx.
Element TVectorT< Element >::Norm1 | ( | ) | const |
Compute the 1-norm of the vector SUM{ |v[i]| }.
Definition at line 565 of file TVectorT.cxx.
Element TVectorT< Element >::Norm2Sqr | ( | ) | const |
Compute the square of the 2-norm SUM{ v[i]^2 }.
Definition at line 582 of file TVectorT.cxx.
Element TVectorT< Element >::NormInf | ( | ) | const |
Compute the infinity-norm of the vector MAX{ |v[i]| }.
Definition at line 601 of file TVectorT.cxx.
Bool_t TVectorT< Element >::operator!= | ( | Element | val | ) | const |
Are all vector elements not equal to val?
Definition at line 1151 of file TVectorT.cxx.
|
inline |
Definition at line 213 of file TVectorT.h.
|
inline |
Definition at line 226 of file TVectorT.h.
Multiply every element of the vector with val.
Definition at line 893 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::operator*= | ( | const TMatrixT< Element > & | a | ) |
"Inplace" multiplication target = A*target.
A needn't be a square one If target has to be resized, it should own the storage: fIsOwner = kTRUE
Definition at line 950 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::operator*= | ( | const TMatrixTSym< Element > & | a | ) |
"Inplace" multiplication target = A*target.
A is symmetric . vector size will not change
Definition at line 1080 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::operator*= | ( | const TMatrixTSparse< Element > & | a | ) |
"Inplace" multiplication target = A*target.
A needn't be a square one If target has to be resized, it should own the storage: fIsOwner = kTRUE
Definition at line 1017 of file TVectorT.cxx.
Add val to every element of the vector.
Definition at line 861 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::operator+= | ( | const TVectorT< Element > & | source | ) |
Add vector source.
Definition at line 909 of file TVectorT.cxx.
Subtract val from every element of the vector.
Definition at line 877 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::operator-= | ( | const TVectorT< Element > & | source | ) |
Subtract vector source.
Definition at line 929 of file TVectorT.cxx.
Bool_t TVectorT< Element >::operator< | ( | Element | val | ) | const |
Are all vector elements < val?
Definition at line 1168 of file TVectorT.cxx.
Bool_t TVectorT< Element >::operator<= | ( | Element | val | ) | const |
Are all vector elements <= val?
Definition at line 1185 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::operator= | ( | const TVectorT< Element > & | source | ) |
Notice that this assignment does NOT change the ownership : if the storage space was adopted, source is copied to this space .
Definition at line 678 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::operator= | ( | const TMatrixTRow_const< Element > & | mr | ) |
Assign a matrix row to a vector.
Definition at line 696 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::operator= | ( | const TMatrixTColumn_const< Element > & | mc | ) |
Assign a matrix column to a vector.
Definition at line 727 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::operator= | ( | const TMatrixTDiag_const< Element > & | md | ) |
Assign the matrix diagonal to a vector.
Definition at line 758 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::operator= | ( | const TMatrixTSparseRow_const< Element > & | mr | ) |
Assign a sparse matrix row to a vector.
The matrix row is implicitly transposed to allow the assignment in the strict sense.
Definition at line 790 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::operator= | ( | const TMatrixTSparseDiag_const< Element > & | md | ) |
Assign a sparse matrix diagonal to a vector.
Definition at line 821 of file TVectorT.cxx.
|
inline |
Definition at line 130 of file TVectorT.h.
Assign val to every element of the vector.
Definition at line 845 of file TVectorT.cxx.
Bool_t TVectorT< Element >::operator== | ( | Element | val | ) | const |
Are all vector elements equal to val?
Definition at line 1134 of file TVectorT.cxx.
Bool_t TVectorT< Element >::operator> | ( | Element | val | ) | const |
Are all vector elements > val?
Definition at line 1202 of file TVectorT.cxx.
Bool_t TVectorT< Element >::operator>= | ( | Element | val | ) | const |
Are all vector elements >= val?
Definition at line 1219 of file TVectorT.cxx.
|
inline |
Definition at line 121 of file TVectorT.h.
|
inline |
Definition at line 122 of file TVectorT.h.
void TVectorT< Element >::Print | ( | Option_t * | option = "" | ) | const |
Print the vector as a list of elements.
Definition at line 1361 of file TVectorT.cxx.
void TVectorT< Element >::Randomize | ( | Element | alpha, |
Element | beta, | ||
Double_t & | seed | ||
) |
randomize vector elements value
Definition at line 1303 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::ResizeTo | ( | Int_t | lwb, |
Int_t | upb | ||
) |
Resize the vector to [lwb:upb] .
New dynamic elemenst are created, the overlapping part of the old ones are copied to the new structures, then the old elements are deleted.
Definition at line 292 of file TVectorT.cxx.
Definition at line 89 of file TVectorT.h.
|
inline |
Definition at line 90 of file TVectorT.h.
TVectorT< Element > & TVectorT< Element >::SelectNonZeros | ( | const TVectorT< Element > & | select | ) |
Keep only element as selected through array select non-zero.
Definition at line 542 of file TVectorT.cxx.
|
inline |
Definition at line 85 of file TVectorT.h.
TVectorT< Element > & TVectorT< Element >::SetSub | ( | Int_t | row_lwb, |
const TVectorT< Element > & | source | ||
) |
Insert vector source starting at [row_lwb], thereby overwriting the part [row_lwb..row_lwb+nrows_source];.
Definition at line 420 of file TVectorT.cxx.
Definition at line 87 of file TVectorT.h.
Bool_t TVectorT< Element >::SomePositive | ( | const TVectorT< Element > & | select | ) |
Check if vector elements as selected through array select are all positive.
Definition at line 1259 of file TVectorT.cxx.
Square each element of the vector.
Definition at line 480 of file TVectorT.cxx.
Take square root of all elements.
Definition at line 498 of file TVectorT.cxx.
Element TVectorT< Element >::Sum | ( | ) | const |
Compute sum of elements.
Definition at line 635 of file TVectorT.cxx.
TVectorT< Element > & TVectorT< Element >::Use | ( | Int_t | lwb, |
Int_t | upb, | ||
Element * | data | ||
) |
Use the array data to fill the vector lwb..upb].
Definition at line 347 of file TVectorT.cxx.
|
inline |
Definition at line 93 of file TVectorT.h.
|
inline |
Definition at line 194 of file TVectorT.h.
|
inline |
Definition at line 195 of file TVectorT.h.
|
inline |
Definition at line 196 of file TVectorT.h.
|
inline |
Definition at line 201 of file TVectorT.h.
Set vector elements to zero.
Definition at line 451 of file TVectorT.cxx.
Definition at line 37 of file TVectorT.h.
|
protected |
Definition at line 32 of file TVectorT.h.
|
protected |
data container
Definition at line 38 of file TVectorT.h.
|
protected |
Definition at line 30 of file TVectorT.h.
|
protected |
Definition at line 31 of file TVectorT.h.