SAF
Loading...
Searching...
No Matches
saf_utility_veclib.c File Reference

Wrappers for optimised linear algebra routines, utilising CBLAS and LAPACK, and/or SIMD intrinsics. More...

#include "saf_utilities.h"
#include "saf_externals.h"

Go to the source code of this file.

Data Structures

struct  utility_ssvd_data
 Data structure for utility_ssvd() More...
 
struct  utility_csvd_data
 Data structure for utility_csvd() More...
 
struct  utility_sseig_data
 Data structure for utility_sseig() More...
 
struct  utility_cseig_data
 Data structure for utility_cseig() More...
 
struct  utility_ceigmp_data
 Data structure for utility_ceigmp() More...
 
struct  utility_zeigmp_data
 Data structure for utility_zeigmp() More...
 
struct  utility_ceig_data
 Data structure for utility_ceig() More...
 
struct  utility_zeig_data
 Data structure for utility_zeig() More...
 
struct  utility_sglslv_data
 Data structure for utility_sglslv() More...
 
struct  utility_cglslv_data
 Data structure for utility_cglslv() More...
 
struct  utility_dglslv_data
 Data structure for utility_dglslv() More...
 
struct  utility_zglslv_data
 Data structure for utility_zglslv() More...
 
struct  utility_sglslvt_data
 Data structure for utility_sglslvt() More...
 
struct  utility_sslslv_data
 Data structure for utility_sslslv() More...
 
struct  utility_cslslv_data
 Data structure for utility_cslslv() More...
 
struct  utility_spinv_data
 Data structure for utility_spinv() More...
 
struct  utility_cpinv_data
 Data structure for utility_cpinv() More...
 
struct  utility_dpinv_data
 Data structure for utility_dpinv() More...
 
struct  utility_zpinv_data
 Data structure for utility_zpinv() More...
 
struct  utility_schol_data
 Data structure for utility_schol() More...
 
struct  utility_cchol_data
 Data structure for utility_cchol() More...
 
struct  utility_sdet_data
 Data structure for utility_sdet() More...
 
struct  utility_ddet_data
 Data structure for utility_ddet() More...
 
struct  utility_sinv_data
 Data structure for utility_sinv() More...
 
struct  utility_dinv_data
 Data structure for utility_dinv() More...
 
struct  utility_cinv_data
 Data structure for utility_cinv() More...
 

Macros

#define SAF_VECLIB_USE_LAPACK_FORTRAN_INTERFACE
 LAPACK interface.
 
#define SAF_INTEL_MKL_VML_MODE   ( VML_LA | VML_FTZDAZ_ON )
 Taken from the Intel MKL VML developers reference documentation: The flag(s) that can be passed to Intel VML functions:
 

Typedefs

typedef MKL_INT veclib_int
 integer: 4-bytes
 
typedef float veclib_float
 real: 4-bytes
 
typedef double veclib_double
 real: 8-bytes
 
typedef MKL_Complex8 veclib_float_complex
 complex: 8-bytes
 
typedef MKL_Complex16 veclib_double_complex
 complex: 16-bytes
 

Functions

void utility_siminv (const float *a, const int len, int *index)
 Single-precision, index of minimum absolute value in a vector, i.e.
 
void utility_ciminv (const float_complex *a, const int len, int *index)
 Single-precision, complex, index of maximum absolute value in a vector, i.e.
 
void utility_diminv (const double *a, const int len, int *index)
 Double-precision, index of minimum absolute value in a vector, i.e.
 
void utility_ziminv (const double_complex *a, const int len, int *index)
 Double-precision, complex, index of maximum absolute value in a vector, i.e.
 
void utility_simaxv (const float *a, const int len, int *index)
 Single-precision, index of maximum absolute value in a vector, i.e.
 
void utility_cimaxv (const float_complex *a, const int len, int *index)
 Single-precision, complex, index of maximum absolute value in a vector, i.e.
 
void utility_dimaxv (const double *a, const int len, int *index)
 Double-precision, index of maximum absolute value in a vector, i.e.
 
void utility_zimaxv (const double_complex *a, const int len, int *index)
 Double-precision, complex, index of maximum absolute value in a vector, i.e.
 
void utility_svabs (const float *a, const int len, float *c)
 Single-precision, absolute values of vector elements, i.e.
 
void utility_cvabs (const float_complex *a, const int len, float *c)
 Single-precision, complex, absolute values of vector elements, i.e.
 
void utility_svmod (const float *a, const float *b, const int len, float *c)
 Single-precision, modulus of vector elements, i.e.
 
void utility_svrecip (const float *a, const int len, float *c)
 Single-precision, vector-reciprocal/inversion, i.e.
 
void utility_cvconj (const float_complex *a, const int len, float_complex *c)
 Single-precision, complex, vector-conjugate, i.e.
 
void utility_zvconj (const double_complex *a, const int len, double_complex *c)
 Double-precision, complex, vector-conjugate, i.e.
 
void utility_svvcopy (const float *a, const int len, float *c)
 Single-precision, vector-vector copy, i.e.
 
void utility_cvvcopy (const float_complex *a, const int len, float_complex *c)
 Single-precision, complex, vector-vector copy, i.e.
 
void utility_dvvcopy (const double *a, const int len, double *c)
 double-precision, vector-vector copy, i.e.
 
void utility_zvvcopy (const double_complex *a, const int len, double_complex *c)
 double-precision, complex, vector-vector copy, i.e.
 
void utility_svvadd (const float *a, const float *b, const int len, float *c)
 Single-precision, vector-vector addition, i.e.
 
void utility_cvvadd (const float_complex *a, const float_complex *b, const int len, float_complex *c)
 Single-precision, complex, vector-vector addition, i.e.
 
void utility_dvvadd (const double *a, const double *b, const int len, double *c)
 Double-precision, vector-vector addition, i.e.
 
void utility_zvvadd (const double_complex *a, const double_complex *b, const int len, double_complex *c)
 Double-precision, complex, vector-vector addition, i.e.
 
void utility_svvsub (const float *a, const float *b, const int len, float *c)
 Single-precision, vector-vector subtraction, i.e.
 
void utility_cvvsub (const float_complex *a, const float_complex *b, const int len, float_complex *c)
 Single-precision, complex, vector-vector subtraction, i.e.
 
void utility_dvvsub (const double *a, const double *b, const int len, double *c)
 Double-precision, vector-vector subtraction, i.e.
 
void utility_zvvsub (const double_complex *a, const double_complex *b, const int len, double_complex *c)
 Double-precision, complex, vector-vector subtraction, i.e.
 
void utility_svvmul (const float *a, const float *b, const int len, float *c)
 Single-precision, element-wise vector-vector multiplication i.e.
 
void utility_cvvmul (const float_complex *a, const float_complex *b, const int len, float_complex *c)
 Single-precision, complex, element-wise vector-vector multiplication i.e.
 
void utility_svvdot (const float *a, const float *b, const int len, float *c)
 Single-precision, vector-vector dot product, i.e.
 
void utility_cvvdot (const float_complex *a, const float_complex *b, const int len, CONJ_FLAG flag, float_complex *c)
 Single-precision, complex, vector-vector dot product, i.e.
 
void utility_svsmul (float *a, const float *s, const int len, float *c)
 Single-precision, multiplies each element in vector 'a' with a scalar 's', i.e.
 
void utility_cvsmul (float_complex *a, const float_complex *s, const int len, float_complex *c)
 Single-precision, complex, multiplies each element in vector 'a' with a scalar 's', i.e.
 
void utility_dvsmul (double *a, const double *s, const int len, double *c)
 Double-precision, multiplies each element in vector 'a' with a scalar 's', i.e.
 
void utility_zvsmul (double_complex *a, const double_complex *s, const int len, double_complex *c)
 Double-precision, complex, multiplies each element in vector 'a' with a scalar 's', i.e.
 
void utility_svsdiv (const float *a, const float *s, const int len, float *c)
 Single-precision, divides each element in vector 'a' with a scalar 's', i.e.
 
void utility_svsadd (float *a, const float *s, const int len, float *c)
 Single-precision, adds each element in vector 'a' with a scalar 's', i.e.
 
void utility_svssub (float *a, const float *s, const int len, float *c)
 Single-precision, subtracts each element in vector 'a' with a scalar 's', i.e.
 
void utility_ssv2cv_inds (const float *sv, const int *inds, const int len, float *cv)
 Single-precision, sparse-vector to compressed vector given known indices i.e.
 
void utility_csv2cv_inds (const float_complex *sv, const int *inds, const int len, float_complex *cv)
 Single-precision complex, sparse-vector to compressed vector given known indices.
 
void utility_dsv2cv_inds (const double *sv, const int *inds, const int len, double *cv)
 Double-precision, sparse-vector to compressed vector given known indices i.e.
 
void utility_zsv2cv_inds (const double_complex *sv, const int *inds, const int len, double_complex *cv)
 Double-precision complex, sparse-vector to compressed vector given known indices.
 
void utility_ssvd_create (void **const phWork, int maxDim1, int maxDim2)
 (Optional) Pre-allocate the working struct used by utility_ssvd()
 
void utility_ssvd_destroy (void **const phWork)
 De-allocate the working struct used by utility_ssvd()
 
void utility_ssvd (void *const hWork, const float *A, const int dim1, const int dim2, float *U, float *S, float *V, float *sing)
 Singular value decomposition: single precision, i.e.
 
void utility_csvd_create (void **const phWork, int maxDim1, int maxDim2)
 (Optional) Pre-allocate the working struct used by utility_csvd()
 
void utility_csvd_destroy (void **const phWork)
 De-allocate the working struct used by utility_csvd()
 
void utility_csvd (void *const hWork, const float_complex *A, const int dim1, const int dim2, float_complex *U, float_complex *S, float_complex *V, float *sing)
 Singular value decomposition: single precision complex, i.e.
 
void utility_sseig_create (void **const phWork, int maxDim)
 (Optional) Pre-allocate the working struct used by utility_sseig()
 
void utility_sseig_destroy (void **const phWork)
 De-allocate the working struct used by utility_sseig()
 
void utility_sseig (void *const hWork, const float *A, const int dim, int sortDecFLAG, float *V, float *D, float *eig)
 Eigenvalue decomposition of a SYMMETRIC matrix: single precision, i.e.
 
void utility_cseig_create (void **const phWork, int maxDim)
 (Optional) Pre-allocate the working struct used by utility_cseig()
 
void utility_cseig_destroy (void **const phWork)
 De-allocate the working struct used by utility_cseig()
 
void utility_cseig (void *const hWork, const float_complex *A, const int dim, int sortDecFLAG, float_complex *V, float_complex *D, float *eig)
 Eigenvalue decomposition of a SYMMETRIC/HERMITION matrix: single precision complex, i.e.
 
void utility_ceigmp_create (void **const phWork, int maxDim)
 (Optional) Pre-allocate the working struct used by utility_ceigmp()
 
void utility_ceigmp_destroy (void **const phWork)
 De-allocate the working struct used by utility_ceigmp()
 
void utility_ceigmp (void *const hWork, const float_complex *A, const float_complex *B, const int dim, float_complex *VL, float_complex *VR, float_complex *D)
 Computes eigenvalues of a matrix pair using the QZ method, single precision complex, i.e.
 
void utility_zeigmp_create (void **const phWork, int maxDim)
 (Optional) Pre-allocate the working struct used by utility_zeigmp()
 
void utility_zeigmp_destroy (void **const phWork)
 De-allocate the working struct used by utility_zeigmp()
 
void utility_zeigmp (void *const hWork, const double_complex *A, const double_complex *B, const int dim, double_complex *VL, double_complex *VR, double_complex *D)
 Computes eigenvalues of a matrix pair using the QZ method, double precision complex, i.e.
 
void utility_ceig_create (void **const phWork, int maxDim)
 (Optional) Pre-allocate the working struct used by utility_ceig()
 
void utility_ceig_destroy (void **const phWork)
 De-allocate the working struct used by utility_ceig()
 
void utility_ceig (void *const hWork, const float_complex *A, const int dim, float_complex *VL, float_complex *VR, float_complex *D, float_complex *eig)
 Eigenvalue decomposition of a NON-SYMMETRIC matrix: single precision complex, i.e.
 
void utility_zeig_create (void **const phWork, int maxDim)
 (Optional) Pre-allocate the working struct used by utility_zeig()
 
void utility_zeig_destroy (void **const phWork)
 De-allocate the working struct used by utility_zeig()
 
void utility_zeig (void *const hWork, const double_complex *A, const int dim, double_complex *VL, double_complex *VR, double_complex *D, double_complex *eig)
 Eigenvalue decomposition of a NON-SYMMETRIC matrix: double precision complex, i.e.
 
void utility_sglslv_create (void **const phWork, int maxDim, int maxNCol)
 (Optional) Pre-allocate the working struct used by utility_sglslv()
 
void utility_sglslv_destroy (void **const phWork)
 De-allocate the working struct used by utility_sglslv()
 
void utility_sglslv (void *const hWork, const float *A, const int dim, float *B, int nCol, float *X)
 General linear solver: single precision, i.e.
 
void utility_cglslv_create (void **const phWork, int maxDim, int maxNCol)
 (Optional) Pre-allocate the working struct used by utility_cglslv()
 
void utility_cglslv_destroy (void **const phWork)
 De-allocate the working struct used by utility_cglslv()
 
void utility_cglslv (void *const hWork, const float_complex *A, const int dim, float_complex *B, int nCol, float_complex *X)
 General linear solver: single precision complex, i.e.
 
void utility_dglslv_create (void **const phWork, int maxDim, int maxNCol)
 (Optional) Pre-allocate the working struct used by utility_dglslv()
 
void utility_dglslv_destroy (void **const phWork)
 De-allocate the working struct used by utility_dglslv()
 
void utility_dglslv (void *const hWork, const double *A, const int dim, double *B, int nCol, double *X)
 General linear solver: double precision, i.e.
 
void utility_zglslv_create (void **const phWork, int maxDim, int maxNCol)
 (Optional) Pre-allocate the working struct used by utility_zglslv()
 
void utility_zglslv_destroy (void **const phWork)
 De-allocate the working struct used by utility_zglslv()
 
void utility_zglslv (void *const hWork, const double_complex *A, const int dim, double_complex *B, int nCol, double_complex *X)
 General linear solver: double precision complex, i.e.
 
void utility_sglslvt_create (void **const phWork, int maxDim, int maxNCol)
 (Optional) Pre-allocate the working struct used by utility_sglslvt()
 
void utility_sglslvt_destroy (void **const phWork)
 De-allocate the working struct used by utility_sglslvt()
 
void utility_sglslvt (void *const hWork, const float *A, const int dim, float *B, int nCol, float *X)
 General linear solver (the other way): single precision, i.e.
 
void utility_sslslv_create (void **const phWork, int maxDim, int maxNCol)
 (Optional) Pre-allocate the working struct used by utility_sslslv()
 
void utility_sslslv_destroy (void **const phWork)
 De-allocate the working struct used by utility_sslslv()
 
void utility_sslslv (void *const hWork, const float *A, const int dim, float *B, int nCol, float *X)
 Linear solver for SYMMETRIC positive-definate 'A': single precision, i.e.
 
void utility_cslslv_create (void **const phWork, int maxDim, int maxNCol)
 (Optional) Pre-allocate the working struct used by utility_cslslv()
 
void utility_cslslv_destroy (void **const phWork)
 De-allocate the working struct used by utility_cslslv()
 
void utility_cslslv (void *const hWork, const float_complex *A, const int dim, float_complex *B, int nCol, float_complex *X)
 Linear solver for HERMITIAN positive-definate 'A': single precision complex, i.e.
 
void utility_spinv_create (void **const phWork, int maxDim1, int maxDim2)
 (Optional) Pre-allocate the working struct used by utility_spinv()
 
void utility_spinv_destroy (void **const phWork)
 De-allocate the working struct used by utility_spinv()
 
void utility_spinv (void *const hWork, const float *inM, const int dim1, const int dim2, float *outM)
 General matrix pseudo-inverse (the svd way): single precision, i.e.
 
void utility_cpinv_create (void **const phWork, int maxDim1, int maxDim2)
 (Optional) Pre-allocate the working struct used by utility_cpinv()
 
void utility_cpinv_destroy (void **const phWork)
 De-allocate the working struct used by utility_cpinv()
 
void utility_cpinv (void *const hWork, const float_complex *inM, const int dim1, const int dim2, float_complex *outM)
 General matrix pseudo-inverse (the svd way): single precision complex, i.e.
 
void utility_dpinv_create (void **const phWork, int maxDim1, int maxDim2)
 (Optional) Pre-allocate the working struct used by utility_dpinv()
 
void utility_dpinv_destroy (void **const phWork)
 De-allocate the working struct used by utility_dpinv()
 
void utility_dpinv (void *const hWork, const double *inM, const int dim1, const int dim2, double *outM)
 General matrix pseudo-inverse (the svd way): double precision, i.e.
 
void utility_zpinv_create (void **const phWork, int maxDim1, int maxDim2)
 (Optional) Pre-allocate the working struct used by utility_zpinv()
 
void utility_zpinv_destroy (void **const phWork)
 De-allocate the working struct used by utility_zpinv()
 
void utility_zpinv (void *const hWork, const double_complex *inM, const int dim1, const int dim2, double_complex *outM)
 General matrix pseudo-inverse (the svd way): double precision complex, i.e.
 
void utility_schol_create (void **const phWork, int maxDim)
 (Optional) Pre-allocate the working struct used by utility_schol()
 
void utility_schol_destroy (void **const phWork)
 De-allocate the working struct used by utility_schol()
 
void utility_schol (void *const hWork, const float *A, const int dim, float *X)
 Cholesky factorisation of a symmetric matrix positive-definate matrix: single precision, i.e.
 
void utility_cchol_create (void **const phWork, int maxDim)
 (Optional) Pre-allocate the working struct used by utility_cchol()
 
void utility_cchol_destroy (void **const phWork)
 De-allocate the working struct used by utility_cchol()
 
void utility_cchol (void *const hWork, const float_complex *A, const int dim, float_complex *X)
 Cholesky factorisation of a hermitian positive-definate matrix: single precision complex, i.e.
 
void utility_sdet_create (void **const phWork, int maxN)
 (Optional) Pre-allocate the working struct used by utility_sdet()
 
void utility_sdet_destroy (void **const phWork)
 De-allocate the working struct used by utility_sdet()
 
float utility_sdet (void *const hWork, float *A, int N)
 Determinant of a Matrix, single precision, i,e.
 
void utility_ddet_create (void **const phWork, int maxN)
 (Optional) Pre-allocate the working struct used by utility_ddet()
 
void utility_ddet_destroy (void **const phWork)
 De-allocate the working struct used by utility_ddet()
 
double utility_ddet (void *const hWork, double *A, int N)
 Determinant of a Matrix, double precision, i,e.
 
void utility_sinv_create (void **const phWork, int maxN)
 (Optional) Pre-allocate the working struct used by utility_sinv()
 
void utility_sinv_destroy (void **const phWork)
 De-allocate the working struct used by utility_sinv()
 
void utility_sinv (void *const hWork, float *A, float *B, const int N)
 Matrix inversion: single precision, i.e.
 
void utility_dinv_create (void **const phWork, int maxN)
 (Optional) Pre-allocate the working struct used by utility_dinv()
 
void utility_dinv_destroy (void **const phWork)
 De-allocate the working struct used by utility_dinv()
 
void utility_dinv (void *const hWork, double *A, double *B, const int N)
 Matrix inversion: double precision, i.e.
 
void utility_cinv_create (void **const phWork, int maxN)
 (Optional) Pre-allocate the working struct used by utility_cinv()
 
void utility_cinv_destroy (void **const phWork)
 De-allocate the working struct used by utility_cinv()
 
void utility_cinv (void *const hWork, float_complex *A, float_complex *B, const int N)
 Matrix inversion: double precision complex, i.e.
 

Detailed Description

Wrappers for optimised linear algebra routines, utilising CBLAS and LAPACK, and/or SIMD intrinsics.

Dependencies

A performance library comprising CBLAS and LAPACK routines is required by the module and, thus, also by SAF as a whole. Add one of the following FLAGS to your project's preprocessor definitions list in order to enable one of these suitable performance libraries, which must also be correctly linked to your project.

  • SAF_USE_INTEL_MKL_LP64: to enable Intel's Math Kernel Library with the Fortran LAPACK interface
  • SAF_USE_INTEL_MKL_ILP64 same as SAF_USE_INTEL_MKL except using int64 and LAPACKE interface
  • SAF_USE_OPENBLAS_WITH_LAPACKE: to enable OpenBLAS with the LAPACKE interface
  • SAF_USE_APPLE_ACCELERATE: to enable the Accelerate framework with the Fortran LAPACK interface
  • SAF_USE_ATLAS: to enable ATLAS BLAS routines and ATLAS's CLAPACK interface
See also
More information can be found here: https://github.com/leomccormack/Spatial_Audio_Framework/docs
Author
Leo McCormack
Date
11.07.2016
License
ISC

Definition in file saf_utility_veclib.c.

Macro Definition Documentation

◆ SAF_INTEL_MKL_VML_MODE

#define SAF_INTEL_MKL_VML_MODE   ( VML_LA | VML_FTZDAZ_ON )

Taken from the Intel MKL VML developers reference documentation: The flag(s) that can be passed to Intel VML functions:

  • Faster processing of denormalized inputs: VML_FTZDAZ_ON || VML_FTZDAZ_OFF
  • High Accuracy (VML_HA), the default mode
  • Low Accuracy (VML_LA), which improves performance by reducing accuracy of the two least significant bits
  • Enhanced Performance (VML_EP), which provides better performance at the cost of significantly reduced accuracy. Approximately half of the bits in the mantissa are correct

Note that using the EP mode does not guarantee accurate processing of corner cases and special values. Although the default accuracy is HA, LA is sufficient in most cases. For applications that require less accuracy (for example, media applications, some Monte Carlo simulations, etc.), the EP mode may be sufficient.

Note that this default SAF_INTEL_MKL_VML_MODE value can be overriden.

Definition at line 92 of file saf_utility_veclib.c.

◆ SAF_VECLIB_USE_LAPACK_FORTRAN_INTERFACE

#define SAF_VECLIB_USE_LAPACK_FORTRAN_INTERFACE

LAPACK interface.

Definition at line 54 of file saf_utility_veclib.c.

Typedef Documentation

◆ veclib_double

typedef double veclib_double

real: 8-bytes

Definition at line 110 of file saf_utility_veclib.c.

◆ veclib_double_complex

typedef MKL_Complex16 veclib_double_complex

complex: 16-bytes

Definition at line 112 of file saf_utility_veclib.c.

◆ veclib_float

typedef float veclib_float

real: 4-bytes

Definition at line 109 of file saf_utility_veclib.c.

◆ veclib_float_complex

typedef MKL_Complex8 veclib_float_complex

complex: 8-bytes

Definition at line 111 of file saf_utility_veclib.c.

◆ veclib_int

typedef MKL_INT veclib_int

integer: 4-bytes

Definition at line 105 of file saf_utility_veclib.c.