12#ifndef ROOT_TMatrixTSparse
13#define ROOT_TMatrixTSparse
21#include <vecLib/vBLAS.h>
34template<
class Element>
class TMatrixT;
83#if defined(__clang__) && __clang_major__ < 20
84#pragma clang diagnostic push
85#pragma clang diagnostic ignored "-Wshadow"
88#if defined(__clang__) && __clang_major__ < 20
89#pragma clang diagnostic pop
138 m.GetColUpb(),
m.GetNoElements()); }
150 Int_t *pRowIndex,
Int_t *pColIndex,Element *pData);
152 const Int_t *pRowIndex,
const Int_t *pColIndex,
const Element *pData)
const
155 const_cast<Int_t *
>(pRowIndex),
156 const_cast<Int_t *
>(pColIndex),
157 const_cast<Element *
>(pData))); }
159 Int_t *pRowIndex,
Int_t *pColIndex,Element *pData);
161 const Int_t *pRowIndex,
const Int_t *pColIndex,
const Element *pData)
const;
184 {
MayNotUse(
"NormByDiag");
return *
this; }
192 inline TMatrixTSparseRow <Element>
operator[](
Int_t rown) {
return TMatrixTSparseRow <Element>(*
this,rown); }
203 if (
this == &source)
APlusB (tmp,tmp,1);
204 else APlusB (tmp,source,1);
207 APlusB(tmp,source,1);
return *
this; }
209 if (
this == &source)
AMinusB (tmp,tmp,1);
213 AMinusB(tmp,source,1);
return *
this; }
215 if (
this == &source)
AMultB (tmp,tmp,1);
216 else AMultB (tmp,source,1);
244template <
class Element>
246 Int_t *pRowIndex,
Int_t *pColIndex,Element *pData)
247 {
return Use(0,nrows-1,0,ncols-1,nr_nonzeros,pRowIndex,pColIndex,pData); }
248template <
class Element>
250 const Int_t *pRowIndex,
const Int_t *pColIndex,
const Element *pData)
const
251 {
return Use(0,nrows-1,0,ncols-1,nr_nonzeros,pRowIndex,pColIndex,pData); }
252template <
class Element>
255 return Use(
a.GetRowLwb(),
a.GetRowUpb(),
a.GetColLwb(),
a.GetColUpb(),
256 a.GetNoElements(),
a.GetRowIndexArray(),
257 a.GetColIndexArray(),
a.GetMatrixArray()); }
258template <
class Element>
261 return Use(
a.GetRowLwb(),
a.GetRowUpb(),
a.GetColLwb(),
a.GetColUpb(),
262 a.GetNoElements(),
a.GetRowIndexArray(),
263 a.GetColIndexArray(),
a.GetMatrixArray()); }
265template <
class Element>
270 this->
GetSub(row_lwb,row_upb,col_lwb,col_upb,tmp,option);
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char).
#define ClassDefOverride(name, id)
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
TMatrixTSparse< Element > & ElementDiv(TMatrixTSparse< Element > &target, const TMatrixTSparse< Element > &source)
Divide target by the source, element-by-element.
TMatrixTSparse< Element > operator*(const TMatrixTSparse< Element > &source1, const TMatrixTSparse< Element > &source2)
TMatrixTSparse< Element > operator-(const TMatrixTSparse< Element > &source1, const TMatrixTSparse< Element > &source2)
Bool_t AreCompatible(const TMatrixTSparse< Element > &m1, const TMatrixTSparse< Element > &m2, Int_t verbose=0)
TMatrixTSparse< Element > & Add(TMatrixTSparse< Element > &target, Element scalar, const TMatrixTSparse< Element > &source)
Modify addition: target += scalar * source.
TMatrixTSparse< Element > operator+(const TMatrixTSparse< Element > &source1, const TMatrixTSparse< Element > &source2)
TMatrixTSparse< Element > & ElementMult(TMatrixTSparse< Element > &target, const TMatrixTSparse< Element > &source)
Multiply target by the source, element-by-element.
TClass instances represent classes, structs and namespaces in the ROOT type system.
TMatrixTBase< Element > & Randomize(Element alpha, Element beta, Double_t &seed) override
randomize matrix element values
TMatrixTSparse(const TMatrixTSparse< Element > &a, EMatrixCreatorsOp2 op, const TMatrixT< Element > &b)
Create a matrix applying a specific operation to two prototypes.
void AMinusB(const TMatrixT< Element > &a, const TMatrixTSparse< Element > &b, Int_t constr=0)
General matrix subtraction.
TMatrixTBase< Element > & SetMatrixArray(const Element *data, Option_t *="") override
Copy array data to matrix .
virtual TMatrixTBase< Element > & SetMatrixArray(Int_t nr_nonzeros, Int_t nrows, Int_t ncols, Int_t *irow, Int_t *icol, Element *data)
Int_t * GetRowIndexArray() override
TMatrixTSparse(const TMatrixTSparse< Element > &a, EMatrixCreatorsOp2 op, const TMatrixTSparse< Element > &b)
Create a matrix applying a specific operation to two prototypes.
Int_t ReduceSparseMatrix(Int_t nr, Int_t *row, Int_t *col, Element *data)
Sum matrix entries corresponding to the same matrix element (i,j).
Int_t * GetColIndexArray() override
TMatrixTBase< Element > & GetSub(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, TMatrixTBase< Element > &target, Option_t *option="S") const override
Get submatrix [row_lwb..row_upb][col_lwb..col_upb]; The indexing range of the returned matrix depends...
TMatrixTSparse< Element > & operator+=(Element val)
Add val to every element of the matrix.
TMatrixTBase< Element > & ResizeTo(const TMatrixTSparse< Element > &m)
TMatrixTSparse< Element > & SetSparseIndex(Int_t nelem_new)
Increase/decrease the number of non-zero elements to nelems_new.
~TMatrixTSparse() override
TMatrixTSparse< Element > & Use(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Int_t nr_nonzeros, Int_t *pRowIndex, Int_t *pColIndex, Element *pData)
TMatrixTBase< Element > & InsertRow(Int_t row, Int_t col, const Element *v, Int_t n=-1) override
Insert in row rown, n elements of array v at column coln.
void AMultBt(const TMatrixTSparse< Element > &a, const TMatrixT< Element > &b, Int_t constr=0)
General matrix multiplication.
virtual TMatrixTBase< Element > & SetMatrixArray(Int_t nr_nonzeros, Int_t *irow, Int_t *icol, Element *data)
Copy nr elements from row/col index and data array to matrix .
TMatrixTSparse< Element > & operator+=(const TMatrixTSparse< Element > &source)
Element ColNorm() const override
Column matrix norm, MAX{ SUM{ |M(i,j)|, over i}, over j}.
const Int_t * GetRowIndexArray() const override
TMatrixTSparse< Element > & operator-=(const TMatrixTSparse< Element > &source)
void AMinusB(const TMatrixTSparse< Element > &a, const TMatrixTSparse< Element > &b, Int_t constr=0)
General matrix subtraction.
TMatrixTSparse< Element > & operator*=(Element val)
Multiply every element of the matrix with val.
void AMultB(const TMatrixTSparse< Element > &a, const TMatrixTSparse< Element > &b, Int_t constr=0)
void AMultBt(const TMatrixTSparse< Element > &a, const TMatrixTSparse< Element > &b, Int_t constr=0)
void GetMatrix2Array(Element *data, Option_t *="") const override
Copy matrix data to array . It is assumed that array is of size >= fNelems.
void AMultBt(const TMatrixT< Element > &a, const TMatrixTSparse< Element > &b, Int_t constr=0)
General matrix multiplication.
TMatrixTSparse< Element > & Transpose(const TMatrixTSparse< Element > &source)
Transpose a matrix. Set the matrix to ncols x nrows if nrows != ncols.
TMatrixTSparse< Element > & operator*=(const TMatrixTSparse< Element > &source)
TMatrixTSparse< Element > & operator-=(Element val)
Subtract val from every element of the matrix.
TMatrixTSparse< Element > & operator+=(const TMatrixT< Element > &source)
TMatrixTSparse< Element > & SetSparseIndexAB(const TMatrixT< Element > &a, const TMatrixTSparse< Element > &b)
Set the row/column indices to the "sum" of matrices a and b It is checked that enough space has been ...
TMatrixTBase< Element > & SetColIndexArray(Int_t *data) override
void APlusB(const TMatrixT< Element > &a, const TMatrixTSparse< Element > &b, Int_t constr=0)
Int_t NonZeros() const override
Compute the number of elements != 0.0.
TMatrixTSparseRow< Element > operator[](Int_t rown)
TMatrixTSparse(EMatrixCreatorsOp1 op, const TMatrixTSparse< Element > &prototype)
Create a matrix applying a specific operation to the prototype.
TMatrixTSparse(const TMatrixT< Element > &a, EMatrixCreatorsOp2 op, const TMatrixTSparse< Element > &b)
Create a matrix applying a specific operation to two prototypes.
Element & operator()(Int_t rown, Int_t coln) override
void APlusB(const TMatrixTSparse< Element > &a, const TMatrixT< Element > &b, Int_t constr=0)
General matrix addition.
TMatrixTSparse< Element > & operator*=(const TMatrixT< Element > &source)
const TMatrixTSparse< Element > & Use(const TMatrixTSparse< Element > &a) const
TMatrixTBase< Element > & SetSub(Int_t row_lwb, Int_t col_lwb, const TMatrixTBase< Element > &source) override
Insert matrix source starting at [row_lwb][col_lwb], thereby overwriting the part [row_lwb....
TMatrixTSparse(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Int_t *rowptr, Int_t *col, Element *data)
Space is allocated for row/column indices and data.
void Allocate(Int_t nrows, Int_t ncols, Int_t row_lwb=0, Int_t col_lwb=0, Int_t init=0, Int_t nr_nonzeros=0)
Allocate new matrix.
TMatrixTSparse(const TMatrixTSparse< Element > &another)
void Clear(Option_t *="") override
TMatrixTSparse(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Int_t nr_nonzeros=0)
Space is allocated for row/column indices and data, but the sparse structure information has still to...
void AMinusB(const TMatrixTSparse< Element > &a, const TMatrixT< Element > &b, Int_t constr=0)
General matrix subtraction.
void AMultB(const TMatrixT< Element > &a, const TMatrixTSparse< Element > &b, Int_t constr=0)
const TMatrixTSparseRow_const< Element > operator[](Int_t rown) const
TMatrixTSparse(Int_t nrows, Int_t ncols)
Space is allocated for row/column indices and data, but the sparse structure information has still to...
TMatrixTBase< Element > & SetRowIndexArray(Int_t *data) override
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t nr_nonzeros=-1) override
Set size of the matrix to nrows x ncols with nr_nonzeros non-zero entries if nr_nonzeros > 0 .
void APlusB(const TMatrixTSparse< Element > &a, const TMatrixTSparse< Element > &b, Int_t constr=0)
General matrix addition.
const TMatrixTSparse< Element > & Use(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Int_t nr_nonzeros, const Int_t *pRowIndex, const Int_t *pColIndex, const Element *pData) const
virtual TMatrixTSparse< Element > & RandomizePD(Element alpha, Element beta, Double_t &seed)
randomize matrix element values but keep matrix symmetric positive definite
TMatrixTBase< Element > & Zero() override
Set matrix elements to zero.
TMatrixTSparse< Element > & operator=(const TMatrixTSparse< Element > &source)
Notice that the sparsity of the matrix is NOT changed : its fRowIndex/fColIndex are used !
TMatrixTSparse(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Int_t nr_nonzeros, Int_t *row, Int_t *col, Element *data)
Space is allocated for row/column indices and data.
TMatrixTSparse(const TMatrixT< Element > &another)
TMatrixTSparse< Element > & Use(TMatrixTSparse< Element > &a)
TMatrixTSparse< Element > & operator=(const TMatrixT< Element > &source)
Notice that the sparsity of the matrix is NOT changed : its fRowIndex/fColIndex are used !
TMatrixTBase< Element > & NormByDiag(const TVectorT< Element > &, Option_t *) override
option:
TMatrixTSparse< Element > & T()
TMatrixTSparse< Element > & SetSparseIndex(const TMatrixTBase< Element > &another)
Use non-zero data of matrix source to set the sparse structure.
const Int_t * GetColIndexArray() const override
void AMultB(const TMatrixTSparse< Element > &a, const TMatrixT< Element > &b, Int_t constr=0)
Element operator()(Int_t rown, Int_t coln) const override
const TMatrixTSparse< Element > & Use(Int_t nrows, Int_t ncols, Int_t nr_nonzeros, const Int_t *pRowIndex, const Int_t *pColIndex, const Element *pData) const
TMatrixTSparse< Element > & SetSparseIndexAB(const TMatrixTSparse< Element > &a, const TMatrixT< Element > &b)
TMatrixTSparse< Element > GetSub(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Option_t *option="S") const
void ExtractRow(Int_t row, Int_t col, Element *v, Int_t n=-1) const override
Store in array v, n matrix elements of row rown starting at column coln.
TMatrixTSparse< Element > & operator-=(const TMatrixT< Element > &source)
Bool_t IsSymmetric() const override
Check whether matrix is symmetric.
TMatrixTBase< Element > & ResizeTo(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Int_t nr_nonzeros=-1) override
Set size of the matrix to [row_lwb:row_upb] x [col_lwb:col_upb] with nr_nonzeros non-zero entries if ...
TMatrixTBase< Element > & UnitMatrix() override
Make a unit matrix (matrix need not be a square one).
void conservative_sparse_sparse_product_impl(const TMatrixTSparse< Element > &lhs, const TMatrixTSparse< Element > &rhs, Int_t constr=0)
General Sparse Matrix Multiplication (SpMM).
Element RowNorm() const override
Row matrix norm, MAX{ SUM{ |M(i,j)|, over j}, over i}.
TMatrixTSparse< Element > & SetSparseIndexAB(const TMatrixTSparse< Element > &a, const TMatrixTSparse< Element > &b)
Set the row/column indices to the "sum" of matrices a and b It is checked that enough space has been ...
void Mult(const TMatrixTSparse< Element > &a, const TMatrixTSparse< Element > &b)
const Element * GetMatrixArray() const override
Element * GetMatrixArray() override
TMatrixTSparse< Element > & Use(Int_t nrows, Int_t ncols, Int_t nr_nonzeros, Int_t *pRowIndex, Int_t *pColIndex, Element *pData)
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...