//! Partial emulation of ATLAS/BLAS gemv(). //! 'y' is assumed to have been set to the correct size (i.e. taking into account the transpose) More...
#include <gemv.hpp>
Static Public Member Functions | |
| template<typename eT > | |
| static arma_hot void | apply (eT *y, const Mat< eT > &A, const eT *x, const eT alpha=eT(1), const eT beta=eT(0)) |
//! Partial emulation of ATLAS/BLAS gemv(). //! 'y' is assumed to have been set to the correct size (i.e. taking into account the transpose)
Definition at line 27 of file gemv.hpp.
| static arma_hot void gemv_arma< do_trans_A, use_alpha, use_beta >::apply | ( | eT * | y, | |
| const Mat< eT > & | A, | |||
| const eT * | x, | |||
| const eT | alpha = eT(1), |
|||
| const eT | beta = eT(0) | |||
| ) | [inline, static] |
Definition at line 36 of file gemv.hpp.
References Mat< eT >::at(), Mat< eT >::colptr(), Mat< eT >::n_cols, and Mat< eT >::n_rows.
{
arma_extra_debug_sigprint();
const u32 A_n_rows = A.n_rows;
const u32 A_n_cols = A.n_cols;
if(do_trans_A == false)
{
for(u32 row=0; row < A_n_rows; ++row)
{
eT acc = eT(0);
for(u32 col=0; col < A_n_cols; ++col)
{
acc += A.at(row,col) * x[col];
}
if( (use_alpha == false) && (use_beta == false) )
{
y[row] = acc;
}
else
if( (use_alpha == true) && (use_beta == false) )
{
y[row] = alpha * acc;
}
else
if( (use_alpha == false) && (use_beta == true) )
{
y[row] = acc + beta*y[row];
}
else
if( (use_alpha == true) && (use_beta == true) )
{
y[row] = alpha*acc + beta*y[row];
}
}
}
else
if(do_trans_A == true)
{
for(u32 col=0; col < A_n_cols; ++col)
{
// col is interpreted as row when storing the results in 'y'
const eT* A_coldata = A.colptr(col);
eT acc = eT(0);
for(u32 row=0; row < A_n_rows; ++row)
{
acc += A_coldata[row] * x[row];
}
if( (use_alpha == false) && (use_beta == false) )
{
y[col] = acc;
}
else
if( (use_alpha == true) && (use_beta == false) )
{
y[col] = alpha * acc;
}
else
if( (use_alpha == false) && (use_beta == true) )
{
y[col] = acc + beta*y[col];
}
else
if( (use_alpha == true) && (use_beta == true) )
{
y[col] = alpha*acc + beta*y[col];
}
}
}
}