Logo ROOT   6.08/07
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 template<typename AReal>
22 ROOT::TThreadExecutor TCpuMatrix<AReal>::fPool{};
23 template<typename AReal>
24 std::vector<AReal> TCpuMatrix<AReal>::fOnes{};
25 
26 //____________________________________________________________________________
27 template<typename AReal>
28 TCpuMatrix<AReal>::TCpuMatrix(size_t nRows, size_t nCols)
29  : fBuffer(nRows * nCols), fNCols(nCols), fNRows(nRows)
30 {
31  Initialize();
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 {
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 //____________________________________________________________________________
73 template<typename AReal>
75 {
76  if (fNRows > fOnes.size()) {
77  fOnes.reserve(fNRows);
78  for (size_t i = fOnes.size(); i < fNRows; i++) {
79  fOnes.push_back(1.0);
80  }
81  }
82 }
83 
84 // Explicit instantiations.
85 template class TCpuMatrix<Real_t>;
86 template class TCpuMatrix<Double_t>;
87 
88 } // namespace DNN
89 } // namespace TMVA
static double B[]
TCpuBuffer< AFloat > fBuffer
The buffer holding the matrix elements in column-major format.
Definition: CpuMatrix.h:53
The TCpuMatrix class.
Definition: CpuMatrix.h:46
size_t GetNcols() const
Definition: CpuMatrix.h:94
static ROOT::TThreadExecutor fPool
Definition: CpuMatrix.h:50
TCpuBuffer.
Definition: CpuBuffer.h:43
TMarker * m
Definition: textangle.C:8
TCpuMatrix(size_t nRows, size_t nCols)
Construct matrix and allocate space for its elements.
Definition: CpuMatrix.cxx:28
Abstract ClassifierFactory template that handles arbitrary types.
size_t GetNrows() const
Definition: CpuMatrix.h:93
const Int_t n
Definition: legend1.C:16
static std::vector< AFloat > fOnes
Vector filled with ones used for BLAS calls.
Definition: CpuMatrix.h:51