Content

Using FLENS-BLAS

FLENS-BLAS is built on top of CXXBLAS and utilizes FLENS matrix/vector types. Main benefits are:

Toy Example

We use the same example as before, i.e. we compute \(y = \beta y + \alpha\,A^T x + z\) where \(\alpha, \beta\) are scalars, \(x, y, z\) are (dense) vectors and \(A\) is a (general) matrix (with full storage).

Using FLENS-BLAS for this task we

As long as you do not compile with -DNDEBUG the FLENS-BLAS layer also does some error-checking on its arguments.

Example Code

#include <flens/flens.cxx>
#include <iostream>

using namespace flens;
using namespace std;

int
main()
{
    typedef double                               T;
    typedef DenseVector<Array<T> >               DEVector;
    typedef GeMatrix<FullStorage<T, ColMajor> >  GEMatrix;

    const T  alpha = 1.5,
             beta = 2.5;

    DEVector x(3), y(3), z(3);
    x = 123;
    y = 234;
    z = 345;

    GEMatrix A(3,3);
    A = 123,
        567,
        543;

    blas::mv(Trans, alpha, A, x, beta, y);

    blas::axpy(T(1), z, y);

    cout << "y = " << y << endl;

    return 0;
}

Comments on Example Code

Compute \(y = \beta y + \alpha A^T x\)

    blas::mv(Trans, alpha, A, x, beta, y);

Compute the update \(y = y + z\)

    blas::axpy(T(1), z, y);

Compile and Run

$shell> cd flens/examples                                                         
$shell> g++ -Wall -std=c++11 -I../.. tut02-page02-example.cc                      
$shell> ./a.out                                                                   
y = 
           47           50.5             54