File lapack.hpp

namespace boosting
template<typename T>
class Lapack
#include <lapack.hpp>

Allows to execute LAPACK routines.

Template Parameters:

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

Public Types

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

A function pointer to LAPACK’S SYSV routine.

Public Functions

Lapack(const Routines &routines)
Parameters:

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

int querySysvLworkParameter(T *tmpArray1, T *output, int n) const

Determines and returns the optimal value for the parameter “lwork” as used by LAPACK’S SYSV routine.

This function must be run before attempting to solve a linear system using the function sysv to determine the optimal value for the parameter “lwork”.

Parameters:
  • tmpArray1 – A pointer to an array of template type T, shape (n, n) that will be used by the function sysv to temporarily store values computed by the SYSV routine. May contain arbitrary values

  • output – A pointer to an array of template type T, shape (n), the solution of the system of linear equations should be written to by the function sysv. May contain arbitrary values

  • n – The number of equations in the linear system to be solved by the function sysv

Returns:

The optimal value for the parameter “lwork”

void sysv(T *tmpArray1, int *tmpArray2, T *tmpArray3, T *output, int n, int lwork) const

Computes and returns the solution to a linear system A * X = B using LAPACK’s DSYSV solver.

The function querySysvLworkParameter must be run beforehand to determine the optimal value for the parameter “lwork” and to allocate a temporary array depending on this value.

SYSV requires A to be a matrix with shape (n, n), representing the coefficients, and B to be a matrix with shape (n, nrhs), representing the ordinates. X is a matrix of unknowns with shape (n, nrhs).

SYSV will overwrite the matrices A and B. When terminated successfully, B will contain the solution to the system of linear equations. To retain their state, this function will copy the given arrays before invoking SYSV.

Furthermore, SYSV assumes the matrix of coefficients A to be symmetrical, i.e., it will only use the upper-right triangle of A, whereas the remaining elements are ignored. For reasons of space efficiency, this function expects the coefficients to be given as an array with shape n * (n + 1) / 2, representing the elements of the upper-right triangle of A, where the columns are appended to each other and unspecified elements are omitted. This function will implicitly convert the given array into a matrix that is suited for SYSV.

Parameters:
  • tmpArray1 – A pointer to an array of template type T, shape (n, n) that stores the coefficients in the matrix A. It will be used to temporarily store values computed by the SYSV routine

  • tmpArray2 – A pointer to an array of type int, shape (n) that will be used to temporarily store values computed by the SYSV routine. May contain arbitrary values

  • tmpArray3 – A pointer to an array of template type T, shape (lwork) that will be used to temporarily store values computed by the SYSV routine. May contain arbitrary values

  • output – A pointer to an array of template type T, shape (n) that stores the ordinates in the matrix A. The solution of the system of linear equations will be written to this array

  • n – The number of equations

  • lwork – The value for the parameter “lwork” to be used by the SYSV routine. Must have been determined using the function querySysvLworkParameter

Private Members

const SysvFunction sysv_
struct Routines
#include <lapack.hpp>

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

Public Functions

inline explicit Routines(SysvFunction sysv)
Parameters:

sysv – A function pointer to LAPACK’s SYSV routine

Public Members

const SysvFunction sysv

A function pointer to LAPACK’ SYSV routine.

class LapackFactory
#include <lapack.hpp>

A factory that allows to create instances of type Lapack.

Public Functions

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

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

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

Creates and returns an object of type Lapack that allows to execute LAPACK routines operating on 32-bit floating point arrays.

Returns:

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

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

Creates and returns an object of type Lapack that allows to execute LAPACK routines operating on 64-bit floating point arrays.

Returns:

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

Private Members

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