gemv_arma< do_trans_A, use_alpha, use_beta > Class Template Reference
[Gemv]

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>

List of all members.

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))

Detailed Description

template<const bool do_trans_A = false, const bool use_alpha = false, const bool use_beta = false>
class gemv_arma< do_trans_A, use_alpha, use_beta >

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.


Member Function Documentation

template<const bool do_trans_A = false, const bool use_alpha = false, const bool use_beta = false>
template<typename eT >
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.

00037     {
00038     arma_extra_debug_sigprint();
00039     
00040     const u32 A_n_rows = A.n_rows;
00041     const u32 A_n_cols = A.n_cols;
00042     
00043     if(do_trans_A == false)
00044       {
00045       for(u32 row=0; row < A_n_rows; ++row)
00046         {
00047         
00048         eT acc = eT(0);
00049         for(u32 col=0; col < A_n_cols; ++col)
00050           {
00051           acc += A.at(row,col) * x[col];
00052           }
00053           
00054         if( (use_alpha == false) && (use_beta == false) )
00055           {
00056           y[row] = acc;
00057           }
00058         else
00059         if( (use_alpha == true) && (use_beta == false) )
00060           {
00061           y[row] = alpha * acc;
00062           }
00063         else
00064         if( (use_alpha == false) && (use_beta == true) )
00065           {
00066           y[row] = acc + beta*y[row];
00067           }
00068         else
00069         if( (use_alpha == true) && (use_beta == true) )
00070           {
00071           y[row] = alpha*acc + beta*y[row];
00072           }
00073         }
00074       }
00075     else
00076     if(do_trans_A == true)
00077       {
00078       for(u32 col=0; col < A_n_cols; ++col)
00079         {
00080         // col is interpreted as row when storing the results in 'y'
00081         
00082         const eT* A_coldata = A.colptr(col);
00083         
00084         eT acc = eT(0);
00085         for(u32 row=0; row < A_n_rows; ++row)
00086           {
00087           acc += A_coldata[row] * x[row];
00088           }
00089       
00090         if( (use_alpha == false) && (use_beta == false) )
00091           {
00092           y[col] = acc;
00093           }
00094         else
00095         if( (use_alpha == true) && (use_beta == false) )
00096           {
00097           y[col] = alpha * acc;
00098           }
00099         else
00100         if( (use_alpha == false) && (use_beta == true) )
00101           {
00102           y[col] = acc + beta*y[col];
00103           }
00104         else
00105         if( (use_alpha == true) && (use_beta == true) )
00106           {
00107           y[col] = alpha*acc + beta*y[col];
00108           }
00109         
00110         }
00111       }
00112     }