JWS C Library
C language utility library
|
Definitions for a C interface to the functions from BLAS levels 1, 2, and 3. More...
#include <jwsc/config.h>
#include <stdlib.h>
#include <assert.h>
#include <Accelerate/Accelerate.h>
#include "jwsc/math/complex.h"
#include "jwsc/math/blas.h"
Go to the source code of this file.
Functions | |
[sdcz]swap | |
Swaps the elements of two vectors. | |
void | blas_sswap (int n, float *x, int inc_x, float *y, int inc_y) |
Single precision. | |
void | blas_dswap (int n, double *x, int inc_x, double *y, int inc_y) |
Double precision. | |
void | blas_cswap (int n, Complex_f *x, int inc_x, Complex_f *y, int inc_y) |
Complex single precision. | |
void | blas_zswap (int n, Complex_d *x, int inc_x, Complex_d *y, int inc_y) |
Complex double precision. | |
[sdcz]scal | |
Multiplies a vector by a scalar. | |
void | blas_sscal (int n, float a, float *x, int inc_x) |
Single precision. | |
void | blas_dscal (int n, double a, double *x, int inc_x) |
Double precision vector by a scalar. | |
void | blas_cscal (int n, Complex_f a, Complex_f *x, int inc_x) |
Complex single precision. | |
void | blas_zscal (int n, Complex_d a, Complex_d *x, int inc_x) |
Complex double precision. | |
[sdcz]copy | |
Copies a vector into another. | |
void | blas_scopy (int n, const float *x, int inc_x, float *y, int inc_y) |
Single precision. | |
void | blas_dcopy (int n, const double *x, int inc_x, double *y, int inc_y) |
Double precision. | |
void | blas_ccopy (int n, const Complex_f *x, int inc_x, Complex_f *y, int inc_y) |
Complex single precision. | |
void | blas_zcopy (int n, const Complex_d *x, int inc_x, Complex_d *y, int inc_y) |
Complex double precision. | |
[sdcz]axpy | |
Constant times a vector plus a vector. | |
void | blas_saxpy (int n, float a, const float *x, int inc_x, float *y, int inc_y) |
Single precision. | |
void | blas_daxpy (int n, double a, const double *x, int inc_x, double *y, int inc_y) |
Double precision. | |
void | blas_caxpy (int n, Complex_f a, const Complex_f *x, int inc_x, Complex_f *y, int inc_y) |
Complex single precision. | |
void | blas_zaxpy (int n, Complex_d a, const Complex_d *x, int inc_x, Complex_d *y, int inc_y) |
Complex double precision. | |
[sd]dot | |
Vector dot (inner) product. | |
float | blas_sdot (int n, const float *x, int inc_x, const float *y, int inc_y) |
Single precision. | |
double | blas_ddot (int n, const double *x, int inc_x, const double *y, int inc_y) |
Double precision. | |
[sd]nrm2 | |
Vector magnitude (Euclidean norm). | |
float | blas_snrm2 (int n, const float *x, int inc_x) |
Single precision. | |
double | blas_dnrm2 (int n, const double *x, int inc_x) |
Double precision. | |
[sd]asum | |
Sum of the magnitudes of the elements of a vector. | |
float | blas_sasum (int n, const float *x, int inc_x) |
Single precision. | |
double | blas_dasum (int n, const double *x, int inc_x) |
Double precision. | |
i[sdcz]amax | |
Maximum absolute value in a vector. | |
int | blas_isamax (int n, const float *x, int inc_x) |
Single precision. | |
int | blas_idamax (int n, const double *x, int inc_x) |
Double precision. | |
int | blas_icamax (int n, const Complex_f *x, int inc_x) |
Complex single precision. | |
int | blas_izamax (int n, const Complex_d *x, int inc_x) |
Complex double precision. | |
[sdcz]gemv | |
General matrix-vector multiplication. | |
void | blas_sgemv (char trans, int m, int n, float alpha, const float *A, int lda, const float *x, int inc_x, float beta, float *y, int inc_y) |
Single precision. | |
void | blas_dgemv (char trans, int m, int n, double alpha, const double *A, int lda, const double *x, int inc_x, double beta, double *y, int inc_y) |
Double precision. | |
void | blas_cgemv (char trans, int m, int n, Complex_f alpha, const Complex_f *A, int lda, const Complex_f *x, int inc_x, Complex_f beta, Complex_f *y, int inc_y) |
Complex single precision. | |
void | blas_zgemv (char trans, int m, int n, Complex_d alpha, const Complex_d *A, int lda, const Complex_d *x, int inc_x, Complex_d beta, Complex_d *y, int inc_y) |
Complex double precision. | |
[sdcz]gemm | |
General matrix multiplication. | |
void | blas_sgemm (char trans_a, char trans_b, int m, int n, int k, float alpha, const float *A, int lda, const float *B, int ldb, float beta, float *C, int ldc) |
Single precision. | |
void | blas_dgemm (char trans_a, char trans_b, int m, int n, int k, double alpha, const double *A, int lda, const double *B, int ldb, double beta, double *C, int ldc) |
Double precision. | |
void | blas_cgemm (char trans_a, char trans_b, int m, int n, int k, Complex_f alpha, const Complex_f *A, int lda, const Complex_f *B, int ldb, Complex_f beta, Complex_f *C, int ldc) |
Complex single precision. | |
void | blas_zgemm (char trans_a, char trans_b, int m, int n, int k, Complex_d alpha, const Complex_d *A, int lda, const Complex_d *B, int ldb, Complex_d beta, Complex_d *C, int ldc) |
Complex double precision. |
Definitions for a C interface to the functions from BLAS levels 1, 2, and 3.
Wraps levels 1, 2, and 3 of the BLAS library (standard) from netlib. Not all functions are wrapped, just the ones I find useful.
Manipulates the transpose parameters so that all matrices can be passed as row-major ordered.
Definition in file blas.c.
void blas_sswap | ( | int | n, |
float * | x, | ||
int | inc_x, | ||
float * | y, | ||
int | inc_y | ||
) |
void blas_dswap | ( | int | n, |
double * | x, | ||
int | inc_x, | ||
double * | y, | ||
int | inc_y | ||
) |
void blas_sscal | ( | int | n, |
float | a, | ||
float * | x, | ||
int | inc_x | ||
) |
void blas_dscal | ( | int | n, |
double | a, | ||
double * | x, | ||
int | inc_x | ||
) |
void blas_scopy | ( | int | n, |
const float * | x, | ||
int | inc_x, | ||
float * | y, | ||
int | inc_y | ||
) |
void blas_dcopy | ( | int | n, |
const double * | x, | ||
int | inc_x, | ||
double * | y, | ||
int | inc_y | ||
) |
void blas_saxpy | ( | int | n, |
float | a, | ||
const float * | x, | ||
int | inc_x, | ||
float * | y, | ||
int | inc_y | ||
) |
void blas_daxpy | ( | int | n, |
double | a, | ||
const double * | x, | ||
int | inc_x, | ||
double * | y, | ||
int | inc_y | ||
) |
float blas_sdot | ( | int | n, |
const float * | x, | ||
int | inc_x, | ||
const float * | y, | ||
int | inc_y | ||
) |
double blas_ddot | ( | int | n, |
const double * | x, | ||
int | inc_x, | ||
const double * | y, | ||
int | inc_y | ||
) |
float blas_snrm2 | ( | int | n, |
const float * | x, | ||
int | inc_x | ||
) |
double blas_dnrm2 | ( | int | n, |
const double * | x, | ||
int | inc_x | ||
) |
float blas_sasum | ( | int | n, |
const float * | x, | ||
int | inc_x | ||
) |
double blas_dasum | ( | int | n, |
const double * | x, | ||
int | inc_x | ||
) |
int blas_isamax | ( | int | n, |
const float * | x, | ||
int | inc_x | ||
) |
int blas_idamax | ( | int | n, |
const double * | x, | ||
int | inc_x | ||
) |
int blas_icamax | ( | int | n, |
const Complex_f * | x, | ||
int | inc_x | ||
) |
int blas_izamax | ( | int | n, |
const Complex_d * | x, | ||
int | inc_x | ||
) |
void blas_sgemv | ( | char | trans, |
int | m, | ||
int | n, | ||
float | alpha, | ||
const float * | A, | ||
int | lda, | ||
const float * | x, | ||
int | inc_x, | ||
float | beta, | ||
float * | y, | ||
int | inc_y | ||
) |
Single precision.
Performs the matrix-vector operation
y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y
trans | Set to 'N', or 'T' for no transpose or transpose of A. |
m | Number of rows in A (before applying trans). |
n | Number of columns in A (before applying trans). |
alpha | Scalar for A. |
A | Matrix. |
lda | Number of columns in A (before applying trans). Also referred to as the leading dimension of A. |
x | Array of length (1 + (n - 1)*abs(INCX)) if trans == 'N'; (1 + (m - 1)*abs(INCX)) otherwise. |
inc_x | Increment for x, usually 1. |
beta | Scalar for y. If set to zero, y is not added to the operation. |
y | Array of length (1 + (m - 1)*abs(INCX)) if trans == 'N'; (1 + (m - 1)*abs(INCX)) otherwise. |
inc_y | Increment for y, usually 1. |
void blas_dgemv | ( | char | trans, |
int | m, | ||
int | n, | ||
double | alpha, | ||
const double * | A, | ||
int | lda, | ||
const double * | x, | ||
int | inc_x, | ||
double | beta, | ||
double * | y, | ||
int | inc_y | ||
) |
Double precision.
Performs the matrix-vector operation
y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y
trans | Set to 'N', or 'T' for no transpose or transpose of A. |
m | Number of rows in A (before applying trans). |
n | Number of columns in A (before applying trans). |
alpha | Scalar for A. |
A | Matrix. |
lda | Number of columns in A (before applying trans). Also referred to as the leading dimension of A. |
x | Array of length (1 + (n - 1)*abs(INCX)) if trans == 'N'; (1 + (m - 1)*abs(INCX)) otherwise. |
inc_x | Increment for x, usually 1. |
beta | Scalar for y. If set to zero, y is not added to the operation. |
y | Array of length (1 + (m - 1)*abs(INCX)) if trans == 'N'; (1 + (m - 1)*abs(INCX)) otherwise. |
inc_y | Increment for y, usually 1. |
void blas_cgemv | ( | char | trans, |
int | m, | ||
int | n, | ||
Complex_f | alpha, | ||
const Complex_f * | A, | ||
int | lda, | ||
const Complex_f * | x, | ||
int | inc_x, | ||
Complex_f | beta, | ||
Complex_f * | y, | ||
int | inc_y | ||
) |
Complex single precision.
Performs the matrix-vector operation
y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y
trans | Set to 'N', or 'T' for no transpose or transpose of A. |
m | Number of rows in A (before applying trans). |
n | Number of columns in A (before applying trans). |
alpha | Scalar for A. |
A | Matrix. |
lda | Number of columns in A (before applying trans). Also referred to as the leading dimension of A. |
x | Array of length (1 + (n - 1)*abs(INCX)) if trans == 'N'; (1 + (m - 1)*abs(INCX)) otherwise. |
inc_x | Increment for x, usually 1. |
beta | Scalar for y. If set to zero, y is not added to the operation. |
y | Array of length (1 + (m - 1)*abs(INCX)) if trans == 'N'; (1 + (m - 1)*abs(INCX)) otherwise. |
inc_y | Increment for y, usually 1. |
void blas_zgemv | ( | char | trans, |
int | m, | ||
int | n, | ||
Complex_d | alpha, | ||
const Complex_d * | A, | ||
int | lda, | ||
const Complex_d * | x, | ||
int | inc_x, | ||
Complex_d | beta, | ||
Complex_d * | y, | ||
int | inc_y | ||
) |
Complex double precision.
Performs the matrix-vector operation
y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y
trans | Set to 'N', or 'T' for no transpose or transpose of A. |
m | Number of rows in A (before applying trans). |
n | Number of columns in A (before applying trans). |
alpha | Scalar for A. |
A | Matrix. |
lda | Number of columns in A (before applying trans). Also referred to as the leading dimension of A. |
x | Array of length (1 + (n - 1)*abs(INCX)) if trans == 'N'; (1 + (m - 1)*abs(INCX)) otherwise. |
inc_x | Increment for x, usually 1. |
beta | Scalar for y. If set to zero, y is not added to the operation. |
y | Array of length (1 + (m - 1)*abs(INCX)) if trans == 'N'; (1 + (m - 1)*abs(INCX)) otherwise. |
inc_y | Increment for y, usually 1. |
void blas_sgemm | ( | char | trans_a, |
char | trans_b, | ||
int | m, | ||
int | n, | ||
int | k, | ||
float | alpha, | ||
const float * | A, | ||
int | lda, | ||
const float * | B, | ||
int | ldb, | ||
float | beta, | ||
float * | C, | ||
int | ldc | ||
) |
Single precision.
Performs the matrix operation
C := alpha*op( A )*op( B ) + beta*C
where op( X ) is one of
op( X ) = X or op( X ) = X'
trans_a | Set to 'N', or 'T' for no transpose or transpose of A. |
trans_b | Set to 'N', or 'T' for no transpose or transpose of B. |
m | Number of rows in A (after applying trans_a). |
n | Number of columns in B (after applying trans_b). |
k | Number of columns in A and number of rows in B (after applying trans_a and trans_b). |
alpha | Scalar for op( A )*op( B ). |
A | Matrix. |
lda | Number of columns in A (after applying trans_a). Also referred to as the leading dimension of A. |
B | Matrix. |
ldb | Number of columns in B (after applying trans_b). Also referred to as the leading dimension of B. |
beta | Scalar for C. If set to zero, C is not added to the operation. |
C | Matrix. |
ldc | Number of columns in C. Also referred to as the leading dimension of C. |
void blas_dgemm | ( | char | trans_a, |
char | trans_b, | ||
int | m, | ||
int | n, | ||
int | k, | ||
double | alpha, | ||
const double * | A, | ||
int | lda, | ||
const double * | B, | ||
int | ldb, | ||
double | beta, | ||
double * | C, | ||
int | ldc | ||
) |
Double precision.
Performs the matrix operation
C := alpha*op( A )*op( B ) + beta*C
where op( X ) is one of
op( X ) = X or op( X ) = X'
trans_a | Set to 'N', or 'T' for no transpose or transpose of A. |
trans_b | Set to 'N', or 'T' for no transpose or transpose of B. |
m | Number of rows in A (after applying trans_a). |
n | Number of columns in B (after applying trans_b). |
k | Number of columns in A and number of rows in B (after applying trans_a and trans_b). |
alpha | Scalar for op( A )*op( B ). |
A | Matrix. |
lda | Number of columns in A (after applying trans_a). Also referred to as the leading dimension of A. |
B | Matrix. |
ldb | Number of columns in B (after applying trans_b). Also referred to as the leading dimension of B. |
beta | Scalar for C. If set to zero, C is not added to the operation. |
C | Matrix. |
ldc | Number of columns in C. Also referred to as the leading dimension of C. |
void blas_cgemm | ( | char | trans_a, |
char | trans_b, | ||
int | m, | ||
int | n, | ||
int | k, | ||
Complex_f | alpha, | ||
const Complex_f * | A, | ||
int | lda, | ||
const Complex_f * | B, | ||
int | ldb, | ||
Complex_f | beta, | ||
Complex_f * | C, | ||
int | ldc | ||
) |
Complex single precision.
Performs the matrix operation
C := alpha*op( A )*op( B ) + beta*C
where op( X ) is one of
op( X ) = X or op( X ) = X'
trans_a | Set to 'N', or 'T' for no transpose or transpose of A. |
trans_b | Set to 'N', or 'T' for no transpose or transpose of B. |
m | Number of rows in A (after applying trans_a). |
n | Number of columns in B (after applying trans_b). |
k | Number of columns in A and number of rows in B (after applying trans_a and trans_b). |
alpha | Scalar for op( A )*op( B ). |
A | Matrix. |
lda | Number of columns in A (after applying trans_a). Also referred to as the leading dimension of A. |
B | Matrix. |
ldb | Number of columns in B (after applying trans_b). Also referred to as the leading dimension of B. |
beta | Scalar for C. If set to zero, C is not added to the operation. |
C | Matrix. |
ldc | Number of columns in C. Also referred to as the leading dimension of C. |
void blas_zgemm | ( | char | trans_a, |
char | trans_b, | ||
int | m, | ||
int | n, | ||
int | k, | ||
Complex_d | alpha, | ||
const Complex_d * | A, | ||
int | lda, | ||
const Complex_d * | B, | ||
int | ldb, | ||
Complex_d | beta, | ||
Complex_d * | C, | ||
int | ldc | ||
) |
Complex double precision.
Performs the matrix operation
C := alpha*op( A )*op( B ) + beta*C
where op( X ) is one of
op( X ) = X or op( X ) = X'
trans_a | Set to 'N', or 'T' for no transpose or transpose of A. |
trans_b | Set to 'N', or 'T' for no transpose or transpose of B. |
m | Number of rows in A (after applying trans_a). |
n | Number of columns in B (after applying trans_b). |
k | Number of columns in A and number of rows in B (after applying trans_a and trans_b). |
alpha | Scalar for op( A )*op( B ). |
A | Matrix. |
lda | Number of columns in A (after applying trans_a). Also referred to as the leading dimension of A. |
B | Matrix. |
ldb | Number of columns in B (after applying trans_b). Also referred to as the leading dimension of B. |
beta | Scalar for C. If set to zero, C is not added to the operation. |
C | Matrix. |
ldc | Number of columns in C. Also referred to as the leading dimension of C. |