20 template<const
bool do_trans_A=false, const
bool use_alpha=false, const
bool use_beta=false>
36 const eT alpha = eT(1),
65 template<const
bool do_trans_A=false, const
bool do_trans_B=false, const
bool use_alpha=false, const
bool use_beta=false>
80 const eT alpha = eT(1),
92 if( (do_trans_A ==
false) && (do_trans_B ==
false) )
95 eT* A_rowdata = tmp.memptr();
97 for(
uword row_A=0; row_A < A_n_rows; ++row_A)
99 tmp.copy_row(A, row_A);
101 for(
uword col_B=0; col_B < B_n_cols; ++col_B)
105 if( (use_alpha ==
false) && (use_beta ==
false) )
107 C.
at(row_A,col_B) = acc;
110 if( (use_alpha ==
true) && (use_beta ==
false) )
112 C.
at(row_A,col_B) = alpha * acc;
115 if( (use_alpha ==
false) && (use_beta ==
true) )
117 C.
at(row_A,col_B) = acc + beta*C.
at(row_A,col_B);
120 if( (use_alpha ==
true) && (use_beta ==
true) )
122 C.
at(row_A,col_B) = alpha*acc + beta*C.
at(row_A,col_B);
129 if( (do_trans_A ==
true) && (do_trans_B ==
false) )
131 for(
uword col_A=0; col_A < A_n_cols; ++col_A)
135 const eT* A_coldata = A.
colptr(col_A);
137 for(
uword col_B=0; col_B < B_n_cols; ++col_B)
141 if( (use_alpha ==
false) && (use_beta ==
false) )
143 C.
at(col_A,col_B) = acc;
146 if( (use_alpha ==
true) && (use_beta ==
false) )
148 C.
at(col_A,col_B) = alpha * acc;
151 if( (use_alpha ==
false) && (use_beta ==
true) )
153 C.
at(col_A,col_B) = acc + beta*C.
at(col_A,col_B);
156 if( (use_alpha ==
true) && (use_beta ==
true) )
158 C.
at(col_A,col_B) = alpha*acc + beta*C.
at(col_A,col_B);
165 if( (do_trans_A ==
false) && (do_trans_B ==
true) )
173 if( (do_trans_A ==
true) && (do_trans_B ==
true) )
183 eT* B_rowdata = tmp.memptr();
185 for(
uword row_B=0; row_B < B_n_rows; ++row_B)
187 tmp.copy_row(B, row_B);
189 for(
uword col_A=0; col_A < A_n_cols; ++col_A)
193 if( (use_alpha ==
false) && (use_beta ==
false) )
195 C.
at(col_A,row_B) = acc;
198 if( (use_alpha ==
true) && (use_beta ==
false) )
200 C.
at(col_A,row_B) = alpha * acc;
203 if( (use_alpha ==
false) && (use_beta ==
true) )
205 C.
at(col_A,row_B) = acc + beta*C.
at(col_A,row_B);
208 if( (use_alpha ==
true) && (use_beta ==
true) )
210 C.
at(col_A,row_B) = alpha*acc + beta*C.
at(col_A,row_B);
223 template<const
bool do_trans_A=false, const
bool do_trans_B=false, const
bool use_alpha=false, const
bool use_beta=false>
229 template<
typename eT>
239 const eT alpha = eT(1),
240 const eT beta = eT(0),
253 if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) && (A_n_rows == B_n_rows) && (B_n_rows == B_n_cols) )
255 if(do_trans_B ==
false)
261 Mat<eT> BB(A_n_rows, A_n_rows);
275 template<
typename eT>
285 const eT alpha = eT(1),
286 const eT beta = eT(0),
308 const Mat<eT>& AA = (do_trans_A ==
false) ? A : tmp_A;
309 const Mat<eT>& BB = (do_trans_B ==
false) ? B : tmp_B;
317 if( (A_n_rows <= 4) && (A_n_rows == A_n_cols) && (A_n_rows == B_n_rows) && (B_n_rows == B_n_cols) )
335 template<const
bool do_trans_A=false, const
bool do_trans_B=false, const
bool use_alpha=false, const
bool use_beta=false>
340 template<
typename eT>
354 #if defined(ARMA_USE_ATLAS) 358 atlas::cblas_gemm<eT>
360 atlas::CblasColMajor,
366 (use_alpha) ? alpha : eT(1),
371 (use_beta) ? beta : eT(0),
376 #elif defined(ARMA_USE_BLAS) 387 const eT local_alpha = (use_alpha) ? alpha : eT(1);
389 const blas_int lda = (do_trans_A) ? k : m;
390 const blas_int ldb = (do_trans_B) ? n : k;
392 const eT local_beta = (use_beta) ? beta : eT(0);
425 template<
typename eT>
444 const float alpha =
float(1),
445 const float beta =
float(0)
461 const double alpha =
double(1),
462 const double beta =
double(0)
475 Mat< std::complex<float> >& C,
476 const Mat< std::complex<float> >& A,
477 const Mat< std::complex<float> >& B,
478 const std::complex<float> alpha = std::complex<float>(1),
479 const std::complex<float> beta = std::complex<float>(0)
492 Mat< std::complex<double> >& C,
493 const Mat< std::complex<double> >& A,
494 const Mat< std::complex<double> >& B,
495 const std::complex<double> alpha = std::complex<double>(1),
496 const std::complex<double> beta = std::complex<double>(0)
arma_inline arma_warn_unused eT * memptr()
returns a pointer to array of eTs used by the matrix
A lightweight array for POD types. If the amount of memory requested is small, the stack is used...
for tiny square matrices, size <= 4x4
static arma_hot void apply(Mat< eT > &C, const Mat< eT > &A, const Mat< eT > &B, const eT alpha=eT(1), const eT beta=eT(0))
const uword n_cols
number of columns in the matrix (read-only)
static arma_hot void apply(Mat< eT > &C, const Mat< eT > &A, const Mat< eT > &B, const eT alpha=eT(1), const eT beta=eT(0), const typename arma_not_cx< eT >::result *junk=0)
static void apply_noalias_tinysq(Mat< eT > &out, const Mat< eT > &A)
for tiny square matrices (size <= 4x4)
const uword n_elem
number of elements in the matrix (read-only)
const uword n_rows
number of rows in the matrix (read-only)
static arma_hot void apply(eT *y, const Mat< eT > &A, const eT *x, const eT alpha=eT(1), const eT beta=eT(0))
static arma_hot void apply(Mat< eT > &C, const Mat< eT > &A, const Mat< eT > &B, const eT alpha=eT(1), const eT beta=eT(0))
#define arma_extra_debug_print
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
Wrapper for ATLAS/BLAS dgemm function, using template arguments to control the arguments passed to dg...
arma_inline arma_warn_unused eT & at(const uword i)
linear element accessor (treats the matrix as a vector); no bounds check.
#define arma_ignore(variable)
static void apply(Mat< eT > &C, const Mat< eT > &A, const Mat< eT > &B, const eT alpha=eT(1), const eT beta=eT(0))
immediate multiplication of matrices A and B, storing the result in C
static void apply_blas_type(Mat< eT > &C, const Mat< eT > &A, const Mat< eT > &B, const eT alpha=eT(1), const eT beta=eT(0))
static arma_inline void apply_noalias(Mat< eT > &out, const Mat< eT > &A, const typename arma_not_cx< eT >::result *junk=0)
#define arma_extra_debug_sigprint
arma_aligned const eT *const mem
pointer to the memory used by the matrix (memory is read-only)
static void apply_noalias(Mat< eT > &out, const Mat< eT > &A)
Immediate transpose of a dense matrix.
arma_hot static arma_pure eT direct_dot_arma(const uword n_elem, const eT *const A, const eT *const B)