The BLASFEO API in BLASFEO is always exported.

The BLASFEO API defines C structures for matrices and vectors.
These structures are used to abstract from the actual memory layout of matrices and vectors.

As an example, in case the `LA`

backend is given by the High-Performance version, the matrices are stored in a cache-optimized format, called panel-major matrix format.

Packing and unpacking routines are provided to convert to/from column/row-major matrix format and the BLASFEO matrix structure (similarly for vectors).

All BLASFEO linear algebra routines operate on the matrix (`blasfeo_dmat`

and `blasfeo_smat`

) and vector (`blasfeo_dmat`

and `blasfeo_smat`

) structures.

BLASFEO routine API can be obtained from standard BLAS and LAPACK API using the following rules:

- the routine name begins with
`blasfeo_`

- the char options are hard-coded at the end of the routine name.
- all BLASFEO routines are non-destructive, and then they take one extra argument reserved for the output (e.g. the BLAS
`dgemm`

routine call`C = C + A * B`

becomes`D = C + A * B`

in BLASFEO); the C and D matrices can alias. - in case of matrix operands,
`double *A, int lda`

is substituted with`blasfeo_dmat *sA, int ai, int aj`

where`sA`

is a pointer to a BLASFEO matrix structure,`ai`

and`aj`

are the row- and column-indexes of the work sub-matrix. - in case of vector operands,
`double *x, int incx`

is substituted with`blasfeo_dvec *sx, int xi`

where`sx`

is a pointer to a BLASFEO vector structure,`xi`

is the indexes of the work sub-vector; vector operands can not operate on rows or columns of matrices. - in case of scalar operands (both integers and real), input scalar operands are passed by value and not by reference.

As an example, standard BLAS API of the routine `dgemv`

void dgemv_(char *ta, int *n, int *m, double *alpha, double *a, int *lda, double *x, int *incx, double *beta, double *y, int *incy);

translates in the BLASFEO API routines

void blasfeo_dgemv_n(int n, int m, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi);

or

void blasfeo_dgemv_t(int n, int m, double alpha, struct blasfeo_dmat *sA, int ai, int aj, struct blasfeo_dvec *sx, int xi, double beta, struct blasfeo_dvec *sy, int yi, struct blasfeo_dvec *sz, int zi);

depending on the value of `ta`

.