Logo ROOT  
Reference Guide
CpuMatrix.cxx
Go to the documentation of this file.
1 // @(#)root/tmva/tmva/dnn:$Id$
2 // Author: Simon Pfreundschuh 19/07/16
3 
4 /*************************************************************************
5  * Copyright (C) 2016, Simon Pfreundschuh *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /////////////////////////////////////////////
13 // Implementation of the TCpuMatrix class. //
14 /////////////////////////////////////////////
15 
17 
18 namespace TMVA {
19 namespace DNN {
20 
21 //____________________________________________________________________________
22 template<typename AReal>
23 TCpuMatrix<AReal>::TCpuMatrix(size_t nRows, size_t nCols)
24  : fBuffer(nRows * nCols), fNCols(nCols), fNRows(nRows)
25 {
26  Initialize();
27  for (size_t j = 0; j < fNCols; j++) {
28  for (size_t i = 0; i < fNRows; i++) {
29  (*this)(i, j) = 0;
30  }
31  }
32 }
33 
34 //____________________________________________________________________________
35 template<typename AReal>
37  : fBuffer(B.GetNoElements()), fNCols(B.GetNcols()), fNRows(B.GetNrows())
38 {
39  Initialize();
40  for (size_t j = 0; j < fNCols; j++) {
41  for (size_t i = 0; i < fNRows; i++) {
42  (*this)(i,j) = B(i,j);
43  }
44  }
45 }
46 
47 //____________________________________________________________________________
48 template<typename AReal>
50  size_t m,
51  size_t n)
52  : fBuffer(buffer), fNCols(n), fNRows(m)
53 {
54  Initialize();
55 }
56 
57 //____________________________________________________________________________
58 template<typename AReal>
60 {
61  TMatrixT<AReal> B(fNRows, fNCols);
62 
63  for (size_t j = 0; j < fNCols; j++) {
64  for (size_t i = 0; i < fNRows; i++) {
65  B(i,j) = (*this)(i, j);
66  }
67  }
68  return B;
69 }
70 
71 //____________________________________________________________________________
72 template <typename AReal>
73 TCpuMatrix<AReal> & TCpuMatrix<AReal>::operator=(const TMatrixT<AReal> &B)
74 {
75  for (size_t j = 0; j < fNCols; j++) {
76  for (size_t i = 0; i < fNRows; i++) {
77  (*this)(i, j) = B(i, j);
78  }
79  }
80  return *this;
81 }
82 
83 //____________________________________________________________________________
84 template<typename AReal>
86 {
87  if (fNRows > fOnes.size()) {
88  fOnes.reserve(fNRows);
89  size_t ifirst = fOnes.size();
90  for (size_t i = ifirst; i < fNRows; i++) {
91  fOnes.push_back(1.0);
92  }
93  }
94 }
95 
96 //____________________________________________________________________________
97 template<typename AReal>
99 {
100  if (n > fOnes.size()) {
101  fOnes.reserve(n);
102  size_t ifirst = fOnes.size();
103  for (size_t i = ifirst; i < n; i++) {
104  fOnes.push_back(1.0);
105  }
106  }
107 }
108 
109 // Explicit instantiations.
110 template class TCpuMatrix<Float_t>;
111 template class TCpuMatrix<Double_t>;
112 
113 } // namespace DNN
114 } // namespace TMVA
m
auto * m
Definition: textangle.C:8
n
const Int_t n
Definition: legend1.C:16
TMVA::DNN::TCpuMatrix::Initialize
void Initialize()
Definition: CpuMatrix.cxx:97
TMVA::DNN::TCpuMatrix
The TCpuMatrix class.
Definition: CpuMatrix.h:86
fBuffer
std::string fBuffer
Definition: DeclareConverters.h:140
TMatrixT< AReal >
TMVA::DNN::TCpuMatrix::operator=
TCpuMatrix< AFloat > & operator=(const TMatrixT< AFloat > &)
copy from a TMAtrixT .
TMVA::DNN::TCpuMatrix::InitializeOneVector
static void InitializeOneVector(size_t n)
Definition: CpuMatrix.cxx:110
TMVA::TMVAGlob::Initialize
void Initialize(Bool_t useTMVAStyle=kTRUE)
Definition: tmvaglob.cxx:176
CpuMatrix.h
TMVA::DNN::TCpuMatrix::TCpuMatrix
TCpuMatrix()
Definition: CpuMatrix.h:116
TMVA::DNN::TCpuMatrix::fNCols
size_t fNCols
Definition: CpuMatrix.h:94
ROOT::Math::Cephes::B
static double B[]
Definition: SpecFuncCephes.cxx:178
TMVA::DNN::TCpuMatrix::fNRows
size_t fNRows
Definition: CpuMatrix.h:95
TMVA::DNN::TCpuBuffer
TCpuBuffer.
Definition: CpuBuffer.h:55
TMVA
create variable transformations
Definition: GeneticMinimizer.h:22