File blas.hpp

namespace boosting
template<typename T>
class Blas
#include <blas.hpp>

Allows to execute BLAS routines.

Template Parameters:

T – The type of the arrays on which the BLAS routines should operate

Public Types

using DotFunction = std::function<T(int*, T*, int*, T*, int*)>

A function pointer to BLAS’ DOT routine.

using SpmvFunction = std::function<void(char*, int*, T*, T*, T*, int*, T*, T*, int*)>

A function pointer to BLAS’ SPMV routine.

Public Functions

Blas(const Routines &routines)
Parameters:

routines – A reference to an object of type Blas::Routines that stores function pointers to all supported BLAS routines

T dot(T *x, T *y, int n) const

Computes and returns the dot product x * y of two vectors x and y using BLAS’ DDOT routine.

Parameters:
  • x – A pointer to an array of template type T, shape (n), representing the first vector x

  • y – A pointer to an array of template type T, shape (n), representing the second vector y

  • n – The number of elements in the arrays x and y

Returns:

A scalar of template type T, representing the result of the dot product x * y

void spmv(T *a, T *x, T *output, int n) const

Computes and returns the solution to the matrix-vector operation A * x using BLAS’ DSPMV routine.

SPMV expects the matrix A to be a symmetric matrix with shape (n, n) and x to be an array with shape (n). The matrix A must be supplied in packed form, i.e., as an array with shape (n * (n + 1) / 2 ) that consists of the columns of A appended to each other and omitting all unspecified elements.

Parameters:
  • a – A pointer to an array of template type T, shape (n * (n + 1) / 2), representing the elements in the upper-right triangle of the matrix A in a packed form

  • x – A pointer to an array of template type T, shape (n), representing the elements in the array x

  • output – A pointer to an array of template type T, shape (n), the result of the matrix-vector operation A * x should be written to. May contain arbitrary values

  • n – The number of elements in the arrays a and x

Private Members

const DotFunction dot_
const SpmvFunction spmv_
struct Routines
#include <blas.hpp>

A struct that stores function pointers to all supported BLAS routines.

Public Functions

inline Routines(DotFunction dot, SpmvFunction spmv)
Parameters:
  • dot – A function pointer to BLAS’ DOT routine

  • spmv – A function pointer to BLAS’ SPMV routine

Public Members

const DotFunction dot

A function pointer to BLAS’ DOT routine.

const SpmvFunction spmv

A function pointer to BLAS’ SPMV routine.

class BlasFactory
#include <blas.hpp>

A factory that allows to create instances of type Blas.

Public Functions

BlasFactory(const Blas<float32>::Routines &float32Routines, const Blas<float64>::Routines &float64Routines)
Parameters:
  • float32Routines – A reference to an object of type Blas::Routines that stores function pointers to all supported BLAS routines operating of 32-bit floating point values

  • float64Routines – A reference to an object of type Blas::Routines that stores function pointers to all supported BLAS routines operating of 64-bit floating point values

std::unique_ptr<Blas<float32>> create32Bit() const

Create and return an object of type Blas that allows to execute BLAS routines operating on 32-bit floating point arrays.

Returns:

An unique pointer to an object of type Blas that has been created

std::unique_ptr<Blas<float64>> create64Bit() const

Create and return an object of type Blas that allows to execute BLAS routines operating on 64-bit floating point arrays.

Returns:

An unique pointer to an object of type Blas that has been created

Private Members

const Blas<float32>::Routines float32Routines_
const Blas<float64>::Routines float64Routines_