op_dotext_meat.hpp
Go to the documentation of this file.
1 // Copyright (C) 2008-2010 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2010 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12 
13 
16 
17 
18 
19 template<typename eT>
20 inline
21 eT
23  (
24  const eT* A_mem,
25  const Mat<eT>& B,
26  const eT* C_mem
27  )
28  {
30 
31  const uword cost_AB = B.n_cols;
32  const uword cost_BC = B.n_rows;
33 
34  if(cost_AB <= cost_BC)
35  {
36  podarray<eT> tmp(B.n_cols);
37 
38  for(uword col=0; col<B.n_cols; ++col)
39  {
40  const eT* B_coldata = B.colptr(col);
41 
42  eT val = eT(0);
43  for(uword i=0; i<B.n_rows; ++i)
44  {
45  val += A_mem[i] * B_coldata[i];
46  }
47 
48  tmp[col] = val;
49  }
50 
51  return op_dot::direct_dot(B.n_cols, tmp.mem, C_mem);
52  }
53  else
54  {
55  podarray<eT> tmp(B.n_rows);
56 
57  for(uword row=0; row<B.n_rows; ++row)
58  {
59  eT val = eT(0);
60  for(uword col=0; col<B.n_cols; ++col)
61  {
62  val += B.at(row,col) * C_mem[col];
63  }
64 
65  tmp[row] = val;
66  }
67 
68  return op_dot::direct_dot(B.n_rows, A_mem, tmp.mem);
69  }
70 
71 
72  }
73 
74 
75 
76 template<typename eT>
77 inline
78 eT
80  (
81  const eT* A_mem,
82  const Mat<eT>& B,
83  const eT* C_mem
84  )
85  {
87 
88  const uword cost_AB = B.n_rows;
89  const uword cost_BC = B.n_cols;
90 
91  if(cost_AB <= cost_BC)
92  {
93  podarray<eT> tmp(B.n_rows);
94 
95  for(uword row=0; row<B.n_rows; ++row)
96  {
97  eT val = eT(0);
98 
99  for(uword i=0; i<B.n_cols; ++i)
100  {
101  val += A_mem[i] * B.at(row,i);
102  }
103 
104  tmp[row] = val;
105  }
106 
107  return op_dot::direct_dot(B.n_rows, tmp.mem, C_mem);
108  }
109  else
110  {
111  podarray<eT> tmp(B.n_cols);
112 
113  for(uword col=0; col<B.n_cols; ++col)
114  {
115  const eT* B_coldata = B.colptr(col);
116 
117  eT val = eT(0);
118 
119  for(uword i=0; i<B.n_rows; ++i)
120  {
121  val += B_coldata[i] * C_mem[i];
122  }
123 
124  tmp[col] = val;
125  }
126 
127  return op_dot::direct_dot(B.n_cols, A_mem, tmp.mem);
128  }
129 
130 
131  }
132 
133 
134 
135 template<typename eT>
136 inline
137 eT
139  (
140  const eT* A_mem,
141  const Mat<eT>& B,
142  const eT* C_mem
143  )
144  {
146 
147  eT val = eT(0);
148 
149  for(uword i=0; i<B.n_rows; ++i)
150  {
151  val += A_mem[i] * B.at(i,i) * C_mem[i];
152  }
153 
154  return val;
155  }
156 
157 
158 
159 template<typename eT>
160 inline
161 eT
163  (
164  const eT* A_mem,
165  const Mat<eT>& B,
166  const eT* C_mem
167  )
168  {
170 
171  eT val = eT(0);
172 
173  for(uword i=0; i<B.n_rows; ++i)
174  {
175  val += (A_mem[i] * C_mem[i]) / B.at(i,i);
176  }
177 
178  return val;
179  }
180 
181 
182 
183 template<typename eT>
184 inline
185 eT
187  (
188  const eT* A_mem,
189  const Mat<eT>& B,
190  const eT* C_mem
191  )
192  {
194 
195  const eT* B_mem = B.mem;
196 
197  eT val = eT(0);
198 
199  for(uword i=0; i<B.n_elem; ++i)
200  {
201  val += (A_mem[i] * C_mem[i]) / B_mem[i];
202  }
203 
204  return val;
205  }
206 
207 
208 
A lightweight array for POD types. If the amount of memory requested is small, the stack is used...
static eT direct_rowvec_invdiagvec_colvec(const eT *A_mem, const Mat< eT > &B, const eT *C_mem)
arma_hot static arma_pure arma_float_only< eT >::result direct_dot(const uword n_elem, const eT *const A, const eT *const B)
const uword n_cols
number of columns in the matrix (read-only)
Definition: Mat_bones.hpp:30
static eT direct_rowvec_invdiagmat_colvec(const eT *A_mem, const Mat< eT > &B, const eT *C_mem)
const uword n_elem
number of elements in the matrix (read-only)
Definition: Mat_bones.hpp:31
const uword n_rows
number of rows in the matrix (read-only)
Definition: Mat_bones.hpp:29
arma_inline arma_warn_unused eT * colptr(const uword in_col)
returns a pointer to array of eTs for a specified column; no bounds check
Definition: Mat_meat.hpp:4000
u32 uword
Definition: typedef.hpp:85
static eT direct_rowvec_diagmat_colvec(const eT *A_mem, const Mat< eT > &B, const eT *C_mem)
static eT direct_rowvec_transmat_colvec(const eT *A_mem, const Mat< eT > &B, const eT *C_mem)
arma_inline arma_warn_unused eT & at(const uword i)
linear element accessor (treats the matrix as a vector); no bounds check.
Definition: Mat_meat.hpp:3692
#define arma_extra_debug_sigprint
Definition: debug.hpp:1116
static eT direct_rowvec_mat_colvec(const eT *A_mem, const Mat< eT > &B, const eT *C_mem)
Dense matrix class.
arma_aligned const eT *const mem
pointer to the memory used by the matrix (memory is read-only)
Definition: Mat_bones.hpp:40
arma_aligned const eT *const mem
pointer to memory used by the object


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:58