26 TGDMLMatrix::TGDMLMatrix(const
char *name,
size_t rows,
size_t cols)
30 if ((rows <= 0) || (cols <= 0))
32 Fatal(
"TGDMLMatrix::TGDMLMatrix(rows,cols)",
"Wrong number of rows/cols");
37 fMatrix =
new Double_t[fNelem];
41 TGDMLMatrix::TGDMLMatrix(
const TGDMLMatrix& rhs)
42 : TNamed(rhs), fNelem(rhs.fNelem), fNrows(rhs.fNrows), fNcols(rhs.fNcols), fMatrix(nullptr)
47 fMatrix =
new Double_t[fNelem];
48 memcpy(fMatrix, rhs.fMatrix, fNelem *
sizeof(Double_t));
53 TGDMLMatrix& TGDMLMatrix::operator=(
const TGDMLMatrix& rhs)
56 if (
this == &rhs) {
return *
this; }
57 TNamed::operator=(rhs);
60 fNelem = fNrows * fNcols;
63 fMatrix =
new Double_t[fNelem];
64 memcpy(fMatrix, rhs.fMatrix, fNelem *
sizeof(Double_t));
70 void TGDMLMatrix::Set(
size_t r,
size_t c, Double_t a)
72 assert(r < fNrows && c < fNcols);
73 fMatrix[fNcols*r+c] = a;
77 Double_t TGDMLMatrix::Get(
size_t r,
size_t c)
const
79 assert(r < fNrows && c < fNcols);
80 return fMatrix[fNcols*r+c];
84 void TGDMLMatrix::Print(Option_t *)
const
87 printf(
"*** matrix: %-20s coldim = %zu rows = %zu\n", GetName(), fNcols, fNrows);
88 if (!fTitle.IsNull()) {
89 printf(
" %s\n", fTitle.Data());
92 for (
size_t row = 0; row < fNrows; ++row) {
94 for (
size_t col = 0; col < fNcols; ++col) {
95 printf(
"%8.3g", Get(row, col));