Logo ROOT   6.10/09
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 }
28 
29 //____________________________________________________________________________
30 template<typename AReal>
32  : fBuffer(B.GetNoElements()), fNCols(B.GetNcols()), fNRows(B.GetNrows())
33 {
34  Initialize();
35  for (size_t j = 0; j < fNCols; j++) {
36  for (size_t i = 0; i < fNRows; i++) {
37  (*this)(i,j) = B(i,j);
38  }
39  }
40 }
41 
42 //____________________________________________________________________________
43 template<typename AReal>
45  size_t m,
46  size_t n)
47  : fBuffer(buffer), fNCols(n), fNRows(m)
48 {
49  Initialize();
50 }
51 
52 //____________________________________________________________________________
53 template<typename AReal>
55 {
57 
58  for (size_t j = 0; j < fNCols; j++) {
59  for (size_t i = 0; i < fNRows; i++) {
60  B(i,j) = (*this)(i, j);
61  }
62  }
63  return B;
64 }
65 
66 
67 //____________________________________________________________________________
68 template<typename AReal>
70 {
71  if (fNRows > fOnes.size()) {
72  fOnes.reserve(fNRows);
73  for (size_t i = fOnes.size(); i < fNRows; i++) {
74  fOnes.push_back(1.0);
75  }
76  }
77 }
78 
79 // Explicit instantiations.
80 template class TCpuMatrix<Real_t>;
81 template class TCpuMatrix<Double_t>;
82 
83 } // namespace DNN
84 } // 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 std::vector< AFloat > fOnes
Vector filled with ones used for BLAS calls.
Definition: CpuMatrix.h:51
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:23
Abstract ClassifierFactory template that handles arbitrary types.
size_t GetNrows() const
Definition: CpuMatrix.h:93
const Int_t n
Definition: legend1.C:16