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 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 26 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 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 34 of file gemv.hpp.

References Mat< eT >::at(), Mat< eT >::colptr(), Mat< eT >::n_cols, and Mat< eT >::n_rows.

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