24 template<const
bool do_trans_A=false, const
bool do_trans_B=false, const
bool use_alpha=false, const
bool use_beta=false>
29 template<
typename out_eT,
typename in_eT1,
typename in_eT2>
39 const out_eT alpha = out_eT(1),
40 const out_eT beta = out_eT(0)
51 if( (do_trans_A ==
false) && (do_trans_B ==
false) )
54 in_eT1* A_rowdata = tmp.
memptr();
56 for(
uword row_A=0; row_A < A_n_rows; ++row_A)
60 for(
uword col_B=0; col_B < B_n_cols; ++col_B)
62 const in_eT2* B_coldata = B.
colptr(col_B);
64 out_eT acc = out_eT(0);
65 for(
uword i=0; i < B_n_rows; ++i)
70 if( (use_alpha ==
false) && (use_beta ==
false) )
72 C.
at(row_A,col_B) = acc;
75 if( (use_alpha ==
true) && (use_beta ==
false) )
77 C.
at(row_A,col_B) = alpha * acc;
80 if( (use_alpha ==
false) && (use_beta ==
true) )
82 C.
at(row_A,col_B) = acc + beta*C.
at(row_A,col_B);
85 if( (use_alpha ==
true) && (use_beta ==
true) )
87 C.
at(row_A,col_B) = alpha*acc + beta*C.
at(row_A,col_B);
94 if( (do_trans_A ==
true) && (do_trans_B ==
false) )
96 for(
uword col_A=0; col_A < A_n_cols; ++col_A)
100 const in_eT1* A_coldata = A.
colptr(col_A);
102 for(
uword col_B=0; col_B < B_n_cols; ++col_B)
104 const in_eT2* B_coldata = B.
colptr(col_B);
106 out_eT acc = out_eT(0);
107 for(
uword i=0; i < B_n_rows; ++i)
112 if( (use_alpha ==
false) && (use_beta ==
false) )
114 C.
at(col_A,col_B) = acc;
117 if( (use_alpha ==
true) && (use_beta ==
false) )
119 C.
at(col_A,col_B) = alpha * acc;
122 if( (use_alpha ==
false) && (use_beta ==
true) )
124 C.
at(col_A,col_B) = acc + beta*C.
at(col_A,col_B);
127 if( (use_alpha ==
true) && (use_beta ==
true) )
129 C.
at(col_A,col_B) = alpha*acc + beta*C.
at(col_A,col_B);
136 if( (do_trans_A ==
false) && (do_trans_B ==
true) )
145 if( (do_trans_A ==
true) && (do_trans_B ==
true) )
155 in_eT2* B_rowdata = tmp.
memptr();
157 for(
uword row_B=0; row_B < B_n_rows; ++row_B)
161 for(
uword col_A=0; col_A < A_n_cols; ++col_A)
163 const in_eT1* A_coldata = A.
colptr(col_A);
165 out_eT acc = out_eT(0);
166 for(
uword i=0; i < A_n_rows; ++i)
171 if( (use_alpha ==
false) && (use_beta ==
false) )
173 C.
at(col_A,row_B) = acc;
176 if( (use_alpha ==
true) && (use_beta ==
false) )
178 C.
at(col_A,row_B) = alpha * acc;
181 if( (use_alpha ==
false) && (use_beta ==
true) )
183 C.
at(col_A,row_B) = acc + beta*C.
at(col_A,row_B);
186 if( (use_alpha ==
true) && (use_beta ==
true) )
188 C.
at(col_A,row_B) = alpha*acc + beta*C.
at(col_A,row_B);
204 template<const
bool do_trans_A=false, const
bool do_trans_B=false, const
bool use_alpha=false, const
bool use_beta=false>
209 template<
typename out_eT,
typename in_eT1,
typename in_eT2>
219 const out_eT alpha = out_eT(1),
220 const out_eT beta = out_eT(0)
231 if( (do_trans_A ==
false) && (do_trans_B ==
false) )
233 for(
uword row_A = 0; row_A < A_n_rows; ++row_A)
235 for(
uword col_B = 0; col_B < B_n_cols; ++col_B)
237 const in_eT2* B_coldata = B.
colptr(col_B);
239 out_eT acc = out_eT(0);
240 for(
uword i = 0; i < B_n_rows; ++i)
248 if( (use_alpha ==
false) && (use_beta ==
false) )
250 C.
at(row_A,col_B) = acc;
253 if( (use_alpha ==
true) && (use_beta ==
false) )
255 C.
at(row_A,col_B) = alpha * acc;
258 if( (use_alpha ==
false) && (use_beta ==
true) )
260 C.
at(row_A,col_B) = acc + beta*C.
at(row_A,col_B);
263 if( (use_alpha ==
true) && (use_beta ==
true) )
265 C.
at(row_A,col_B) = alpha*acc + beta*C.
at(row_A,col_B);
271 if( (do_trans_A ==
true) && (do_trans_B ==
false) )
273 for(
uword col_A=0; col_A < A_n_cols; ++col_A)
277 const in_eT1* A_coldata = A.
colptr(col_A);
279 for(
uword col_B=0; col_B < B_n_cols; ++col_B)
281 const in_eT2* B_coldata = B.
colptr(col_B);
283 out_eT acc = out_eT(0);
284 for(
uword i=0; i < B_n_rows; ++i)
289 if( (use_alpha ==
false) && (use_beta ==
false) )
291 C.
at(col_A,col_B) = acc;
294 if( (use_alpha ==
true) && (use_beta ==
false) )
296 C.
at(col_A,col_B) = alpha * acc;
299 if( (use_alpha ==
false) && (use_beta ==
true) )
301 C.
at(col_A,col_B) = acc + beta*C.
at(col_A,col_B);
304 if( (use_alpha ==
true) && (use_beta ==
true) )
306 C.
at(col_A,col_B) = alpha*acc + beta*C.
at(col_A,col_B);
313 if( (do_trans_A ==
false) && (do_trans_B ==
true) )
315 for(
uword row_A = 0; row_A < A_n_rows; ++row_A)
317 for(
uword row_B = 0; row_B < B_n_rows; ++row_B)
319 out_eT acc = out_eT(0);
320 for(
uword i = 0; i < B_n_cols; ++i)
325 if( (use_alpha ==
false) && (use_beta ==
false) )
327 C.
at(row_A,row_B) = acc;
330 if( (use_alpha ==
true) && (use_beta ==
false) )
332 C.
at(row_A,row_B) = alpha * acc;
335 if( (use_alpha ==
false) && (use_beta ==
true) )
337 C.
at(row_A,row_B) = acc + beta*C.
at(row_A,row_B);
340 if( (use_alpha ==
true) && (use_beta ==
true) )
342 C.
at(row_A,row_B) = alpha*acc + beta*C.
at(row_A,row_B);
348 if( (do_trans_A ==
true) && (do_trans_B ==
true) )
350 for(
uword row_B=0; row_B < B_n_rows; ++row_B)
353 for(
uword col_A=0; col_A < A_n_cols; ++col_A)
355 const in_eT1* A_coldata = A.
colptr(col_A);
357 out_eT acc = out_eT(0);
358 for(
uword i=0; i < A_n_rows; ++i)
363 if( (use_alpha ==
false) && (use_beta ==
false) )
365 C.
at(col_A,row_B) = acc;
368 if( (use_alpha ==
true) && (use_beta ==
false) )
370 C.
at(col_A,row_B) = alpha * acc;
373 if( (use_alpha ==
false) && (use_beta ==
true) )
375 C.
at(col_A,row_B) = acc + beta*C.
at(col_A,row_B);
378 if( (use_alpha ==
true) && (use_beta ==
true) )
380 C.
at(col_A,row_B) = alpha*acc + beta*C.
at(col_A,row_B);
398 template<const
bool do_trans_A=false, const
bool do_trans_B=false, const
bool use_alpha=false, const
bool use_beta=false>
404 template<
typename out_eT,
typename in_eT1,
typename in_eT2>
413 const out_eT alpha = out_eT(1),
414 const out_eT beta = out_eT(0)
435 const Mat<in_eT1>& AA = (predo_trans_A ==
false) ? A : tmp_A;
436 const Mat<in_eT2>& BB = (predo_trans_B ==
false) ? B : tmp_B;
arma_hot void copy_row(const Mat< eT > &A, const uword row)
A lightweight array for POD types. If the amount of memory requested is small, the stack is used...
Matrix multplication where the matrices have differing element types. Uses caching for speedup...
const uword n_cols
number of columns in the matrix (read-only)
const uword n_elem
number of elements in the matrix (read-only)
const uword n_rows
number of rows in the matrix (read-only)
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
static arma_hot void apply(Mat< out_eT > &C, const Mat< in_eT1 > &A, const Mat< in_eT2 > &B, const out_eT alpha=out_eT(1), const out_eT beta=out_eT(0))
arma_inline arma_warn_unused eT & at(const uword i)
linear element accessor (treats the matrix as a vector); no bounds check.
static arma_inline void apply_noalias(Mat< eT > &out, const Mat< eT > &A, const typename arma_not_cx< eT >::result *junk=0)
Matrix multplication where the matrices have differing element types.
static arma_inline promote_type< T1, T2 >::result apply(const T1 x)
#define arma_extra_debug_sigprint
arma_inline eT * memptr()
static void apply_noalias(Mat< eT > &out, const Mat< eT > &A)
Immediate transpose of a dense matrix.