24 template <
typename AReal>
 
   25 void TReference<AReal>::SumColumns(TMatrixT<AReal> &B, 
const TMatrixT<AReal> &A)
 
   28    for (Int_t i = 0; i < A.GetNrows(); i++) {
 
   29       for (Int_t j = 0; j < A.GetNcols(); j++) {
 
   36 template <
typename AReal>
 
   37 void TReference<AReal>::Hadamard(TMatrixT<AReal> &A, 
const TMatrixT<AReal> &B)
 
   39    for (Int_t i = 0; i < A.GetNrows(); i++) {
 
   40       for (Int_t j = 0; j < A.GetNcols(); j++) {
 
   47 template <
typename AReal>
 
   48 void TReference<AReal>::ConstAdd(TMatrixT<AReal> &A, AReal beta)
 
   50    for (Int_t i = 0; i < A.GetNrows(); i++) {
 
   51       for (Int_t j = 0; j < A.GetNcols(); j++) {
 
   58 template <
typename AReal>
 
   59 void TReference<AReal>::ConstMult(TMatrixT<AReal> &A, AReal beta)
 
   61    for (Int_t i = 0; i < A.GetNrows(); i++) {
 
   62       for (Int_t j = 0; j < A.GetNcols(); j++) {
 
   69 template <
typename AReal>
 
   70 void TReference<AReal>::ReciprocalElementWise(TMatrixT<AReal> &A)
 
   72    for (Int_t i = 0; i < A.GetNrows(); i++) {
 
   73       for (Int_t j = 0; j < A.GetNcols(); j++) {
 
   74          A(i, j) = 1.0 / A(i, j);
 
   80 template <
typename AReal>
 
   81 void TReference<AReal>::SquareElementWise(TMatrixT<AReal> &A)
 
   83    for (Int_t i = 0; i < A.GetNrows(); i++) {
 
   84       for (Int_t j = 0; j < A.GetNcols(); j++) {
 
   91 template <
typename AReal>
 
   92 void TReference<AReal>::SqrtElementWise(TMatrixT<AReal> &A)
 
   94    for (Int_t i = 0; i < A.GetNrows(); i++) {
 
   95       for (Int_t j = 0; j < A.GetNcols(); j++) {
 
   96          A(i, j) = sqrt(A(i, j));
 
  102 template<
typename AReal>
 
  103 void TReference<AReal>::AdamUpdate(TMatrixT<AReal> &A, 
const TMatrixT<AReal> & M, 
const TMatrixT<AReal> & V, AReal alpha, AReal eps)
 
  107    AReal * a = A.GetMatrixArray();
 
  108    const AReal * m = M.GetMatrixArray();
 
  109    const AReal * v = V.GetMatrixArray();
 
  110    for (
int index = 0; index < A.GetNoElements() ; ++index) {
 
  111       a[index] = a[index] - alpha * m[index]/( sqrt(v[index]) + eps);
 
  116 template<
typename AReal>
 
  117 void TReference<AReal>::AdamUpdateFirstMom(TMatrixT<AReal> &A, 
const TMatrixT<AReal> & B, AReal beta)
 
  121    AReal * a = A.GetMatrixArray();
 
  122    const AReal * b = B.GetMatrixArray();
 
  123    for (
int index = 0; index < A.GetNoElements() ; ++index) {
 
  124       a[index] = beta * a[index] + (1.-beta) * b[index];
 
  128 template<
typename AReal>
 
  129 void TReference<AReal>::AdamUpdateSecondMom(TMatrixT<AReal> &A, 
const TMatrixT<AReal> & B, AReal beta)
 
  133    AReal * a = A.GetMatrixArray();
 
  134    const AReal * b = B.GetMatrixArray();
 
  135    for (
int index = 0; index < A.GetNoElements() ; ++index) {
 
  136       a[index] = beta * a[index] + (1.-beta) * b[index] * b[index];