#include <stdio.h>
#include <iostream>
#include <float.h>
+#include <string.h>
//
#include <TClass.h>
#include <TMath.h>
AliSymMatrix::AliSymMatrix()
: fElems(0),fElemsAdd(0)
{
+ // default constructor
fSymmetric = kTRUE;
fgCopyCnt++;
}
AliSymMatrix::AliSymMatrix(Int_t size)
: AliMatrixSq(),fElems(0),fElemsAdd(0)
{
- //
+ //constructor for matrix with defined size
fNrows = 0;
fNrowIndex = fNcols = fRowLwb = size;
fElems = new Double_t[fNcols*(fNcols+1)/2];
AliSymMatrix::AliSymMatrix(const AliSymMatrix &src)
: AliMatrixSq(src),fElems(0),fElemsAdd(0)
{
+ // copy constructor
fNrowIndex = fNcols = src.GetSize();
fNrows = 0;
fRowLwb = src.GetSizeUsed();
//___________________________________________________________
AliSymMatrix& AliSymMatrix::operator=(const AliSymMatrix& src)
{
- //
+ // assignment operator
if (this != &src) {
TObject::operator=(src);
if (GetSizeBooked()!=src.GetSizeBooked() && GetSizeAdded()!=src.GetSizeAdded()) {
//___________________________________________________________
AliSymMatrix& AliSymMatrix::operator+=(const AliSymMatrix& src)
{
- //
+ // add operator
if (GetSizeUsed() != src.GetSizeUsed()) {
AliError("Matrix sizes are different");
return *this;
//___________________________________________________________
void AliSymMatrix::Clear(Option_t*)
{
+ // clear dynamic part
if (fElems) {delete[] fElems; fElems = 0;}
//
if (fElemsAdd) {
//___________________________________________________________
void AliSymMatrix::Print(Option_t* option) const
{
+ // print itself
printf("Symmetric Matrix: Size = %d (%d rows added dynamically), %d used\n",GetSize(),GetSizeAdded(),GetSizeUsed());
TString opt = option; opt.ToLower();
if (opt.IsNull()) return;
//___________________________________________________________
void AliSymMatrix::AddRows(int nrows)
{
+ // add empty rows
if (nrows<1) return;
Double_t **pnew = new Double_t*[nrows+fNrows];
for (int ir=0;ir<fNrows;ir++) pnew[ir] = fElemsAdd[ir]; // copy old extra rows
//___________________________________________________________
Double_t* AliSymMatrix::GetRow(Int_t r)
{
+ // get pointer on the row
if (r>=GetSize()) {
int nn = GetSize();
AddRows(r-GetSize()+1);
/* */
/**********************************************************************************************/
-#include <string.h>
-#include <TObject.h>
#include <TVectorD.h>
#include "AliMatrixSq.h"
//
Double_t* GetRow(Int_t r);
//
- void Print(Option_t* option="") const;
+ void Print(const Option_t* option="") const;
void AddRows(int nrows=1);
void SetSizeUsed(Int_t sz) {fRowLwb = sz;}
//
void Scale(Double_t coeff);
void MultiplyByVec(Double_t* vecIn, Double_t* vecOut) const;
void MultiplyByVec(TVectorD &vecIn, TVectorD &vecOut) const;
- void AddToRow(Int_t r, Double_t *valc,Int_t *indc,Int_t n);
+ void AddToRow(Int_t r, Double_t *valc, Int_t *indc,Int_t n);
//
// ---------------------------------- Dummy methods of MatrixBase
virtual const Double_t *GetMatrixArray () const {return fElems;};
}
//___________________________________________________________
-inline void AliSymMatrix::AddToRow(Int_t r, Double_t *valc,Int_t *indc,Int_t n)
+inline void AliSymMatrix::AddToRow(Int_t r, Double_t *valc, Int_t *indc,Int_t n)
{
for (int i=n;i--;) (*this)(indc[i],r) += valc[i];
}