StructuredMatrix.h File Reference

Contains the structured matrix C interfaces, see StructuredMatrix.hpp for the C++ interface. More...

#include <stdint.h>
#include <complex.h>
#include "StrumpackConfig.hpp"
Include dependency graph for StructuredMatrix.h:

Go to the source code of this file.

Classes

struct  CSPOptions
 Structure containing options for structured matrix compression, to be used with the C interface. More...
 

Typedefs

typedef struct CSPOptions CSPOptions
 
typedef void * CSPStructMat
 Type representing a structured matrix in the C interface. More...
 

Enumerations

enum  SP_STRUCTURED_TYPE {
  SP_TYPE_HSS = 0 , SP_TYPE_BLR , SP_TYPE_HODLR , SP_TYPE_HODBF ,
  SP_TYPE_BUTTERFLY , SP_TYPE_LR , SP_TYPE_LOSSY , SP_TYPE_LOSSLESS
}
 

Functions

void SP_s_struct_default_options (CSPOptions *opts)
 
void SP_d_struct_default_options (CSPOptions *opts)
 
void SP_c_struct_default_options (CSPOptions *opts)
 
void SP_z_struct_default_options (CSPOptions *opts)
 
void SP_s_struct_destroy (CSPStructMat *S)
 
void SP_d_struct_destroy (CSPStructMat *S)
 
void SP_c_struct_destroy (CSPStructMat *S)
 
void SP_z_struct_destroy (CSPStructMat *S)
 
int SP_s_struct_rows (const CSPStructMat S)
 
int SP_d_struct_rows (const CSPStructMat S)
 
int SP_c_struct_rows (const CSPStructMat S)
 
int SP_z_struct_rows (const CSPStructMat S)
 
int SP_s_struct_cols (const CSPStructMat S)
 
int SP_d_struct_cols (const CSPStructMat S)
 
int SP_c_struct_cols (const CSPStructMat S)
 
int SP_z_struct_cols (const CSPStructMat S)
 
long long int SP_s_struct_memory (const CSPStructMat S)
 
long long int SP_d_struct_memory (const CSPStructMat S)
 
long long int SP_c_struct_memory (const CSPStructMat S)
 
long long int SP_z_struct_memory (const CSPStructMat S)
 
long long int SP_s_struct_nonzeros (const CSPStructMat S)
 
long long int SP_d_struct_nonzeros (const CSPStructMat S)
 
long long int SP_c_struct_nonzeros (const CSPStructMat S)
 
long long int SP_z_struct_nonzeros (const CSPStructMat S)
 
int SP_s_struct_rank (const CSPStructMat S)
 
int SP_d_struct_rank (const CSPStructMat S)
 
int SP_c_struct_rank (const CSPStructMat S)
 
int SP_z_struct_rank (const CSPStructMat S)
 
int SP_s_struct_from_dense (CSPStructMat *S, int rows, int cols, const float *A, int ldA, const CSPOptions *opts)
 
int SP_d_struct_from_dense (CSPStructMat *S, int rows, int cols, const double *A, int ldA, const CSPOptions *opts)
 
int SP_c_struct_from_dense (CSPStructMat *S, int rows, int cols, const float _Complex *A, int ldA, const CSPOptions *opts)
 
int SP_z_struct_from_dense (CSPStructMat *S, int rows, int cols, const double _Complex *A, int ldA, const CSPOptions *opts)
 
int SP_s_struct_from_elements (CSPStructMat *S, int rows, int cols, float(int i, int j), const CSPOptions *opts)
 
int SP_d_struct_from_elements (CSPStructMat *S, int rows, int cols, double(int i, int j), const CSPOptions *opts)
 
int SP_c_struct_from_elements (CSPStructMat *S, int rows, int cols, float _Complex(int i, int j), const CSPOptions *opts)
 
int SP_z_struct_from_elements (CSPStructMat *S, int rows, int cols, double _Complex(int i, int j), const CSPOptions *opts)
 
int SP_s_struct_mult (const CSPStructMat S, char trans, int m, const float *B, int ldB, float *C, int ldC)
 
int SP_d_struct_mult (const CSPStructMat S, char trans, int m, const double *B, int ldB, double *C, int ldC)
 
int SP_c_struct_mult (const CSPStructMat S, char trans, int m, const float _Complex *B, int ldB, float _Complex *C, int ldC)
 
int SP_z_struct_mult (const CSPStructMat S, char trans, int m, const double _Complex *B, int ldB, double _Complex *C, int ldC)
 
int SP_s_struct_factor (CSPStructMat S)
 
int SP_d_struct_factor (CSPStructMat S)
 
int SP_c_struct_factor (CSPStructMat S)
 
int SP_z_struct_factor (CSPStructMat S)
 
int SP_s_struct_solve (const CSPStructMat S, int nrhs, float *B, int ldB)
 
int SP_d_struct_solve (const CSPStructMat S, int nrhs, double *B, int ldB)
 
int SP_c_struct_solve (const CSPStructMat S, int nrhs, float _Complex *B, int ldB)
 
int SP_z_struct_solve (const CSPStructMat S, int nrhs, double _Complex *B, int ldB)
 
int SP_s_struct_shift (CSPStructMat S, float s)
 
int SP_d_struct_shift (CSPStructMat S, double s)
 
int SP_c_struct_shift (CSPStructMat S, float _Complex s)
 
int SP_z_struct_shift (CSPStructMat S, double _Complex s)
 

Detailed Description

Contains the structured matrix C interfaces, see StructuredMatrix.hpp for the C++ interface.

Typedef Documentation

◆ CSPStructMat

typedef void* CSPStructMat

Type representing a structured matrix in the C interface.

See any of the SP_x_struct... routines. Internally this will be represented as a structured::StructuredMatrix object (implemented in C++).

Enumeration Type Documentation

◆ SP_STRUCTURED_TYPE

Enumeration of possible structured matrix types. See structured::Type

Function Documentation

◆ SP_c_struct_cols()

int SP_c_struct_cols ( const CSPStructMat  S)

Return number of cols in the structured matrix.

Returns
Number of cols of S.

◆ SP_c_struct_default_options()

void SP_c_struct_default_options ( CSPOptions opts)

Fill the options structure with default values. Use this for single precision, complex.

Parameters
optsPointer to CSPOptions structure

◆ SP_c_struct_destroy()

void SP_c_struct_destroy ( CSPStructMat S)

Destroy the structured matrix. Use this for a structured matrix created with one of the SP_c_struct_... routines, i.e., single precision, complex.

Parameters
SPointer to CSPStructMat object.

◆ SP_c_struct_factor()

int SP_c_struct_factor ( CSPStructMat  S)

Compute a factorization of the structured matrix. Factors are stored internally. This needs to be called before calling SP_c_struct_solve, and after constructing the structured matrix.

Parameters
Sstructured matrix
See also
SP_c_struct_solve

◆ SP_c_struct_from_dense()

int SP_c_struct_from_dense ( CSPStructMat S,
int  rows,
int  cols,
const float _Complex *  A,
int  ldA,
const CSPOptions opts 
)

Construct a structured matrix from a dense (column major) matrix. Use this for single precision, complex.

Parameters
SPointer to CSPStructMat object, which will be constructed.
rowsNumber of rows in A
colsNumber of columns in A
APointer to data of A, column major
ldAleading dimension of A
optsOptions structure, needs to be initialized by the user.
Returns
0 if successful
See also
SP_c_struct_destroy, SP_c_struct_default_options

◆ SP_c_struct_memory()

long long int SP_c_struct_memory ( const CSPStructMat  S)

Return the total amount of memory used by this matrix, in bytes.

Returns
Memory usage in bytes.
See also
nonzeros

◆ SP_c_struct_mult()

int SP_c_struct_mult ( const CSPStructMat  S,
char  trans,
int  m,
const float _Complex *  B,
int  ldB,
float _Complex *  C,
int  ldC 
)

Multiply a structured matrix with a dense matrix (or vector):

     C = S*B   if trans == 'N' or 'n'
     C = S^T*B if trans == 'T' or 't'
     C = S^C*B if trans == 'C' or 'c'

C should have rows(S) rows if trans == 'N'/'n', else cols(S). B should have cols(S) rows if trans == 'N'/'n', else rows(S).

Parameters
Sstructured matrix
trans(conjugate-)transpose of S?
mnumber of columns in B and C
Bpointer to data of B (column major)
ldBleading dimension for B
Cpointer to matrix C (column major)
ldCleading dimension for C

◆ SP_c_struct_nonzeros()

long long int SP_c_struct_nonzeros ( const CSPStructMat  S)

Return the total number of nonzeros stored by this matrix.

Returns
Nonzeros in the matrix representation.
See also
memory

◆ SP_c_struct_rank()

int SP_c_struct_rank ( const CSPStructMat  S)

Return the maximum rank of this matrix over all low-rank compressed blocks.

Returns
Maximum rank.

◆ SP_c_struct_rows()

int SP_c_struct_rows ( const CSPStructMat  S)

Return number of rows in the structured matrix.

Returns
Number of rows of S.

◆ SP_c_struct_shift()

int SP_c_struct_shift ( CSPStructMat  S,
float _Complex  s 
)

Apply a shift to the diagonal of this matrix. Ie, S += s*I, with I the identity matrix. If this is called after calling factor, then the factors are not updated. To solve a linear system with the shifted matrix, you need to call factor again.

Parameters
Sstructured matrix
sShift to be applied to the diagonal.

◆ SP_c_struct_solve()

int SP_c_struct_solve ( const CSPStructMat  S,
int  nrhs,
float _Complex *  B,
int  ldB 
)

Solve a system of linear equations with a structured matrix, with possibly multiple right-hand sides (column major). The solution overwrites the right-hand side. This should be called after SP_c_struct_factor. This can be called multiple times.

Parameters
Sstructured matrix
nrhsnumber of right-hand sides, columns in B
Bright-hand side, will be overwritten by the solution
ldBleading dimension of B
See also
SP_c_struct_factor

◆ SP_d_struct_cols()

int SP_d_struct_cols ( const CSPStructMat  S)

Return number of cols in the structured matrix.

Returns
Number of cols of S.

◆ SP_d_struct_default_options()

void SP_d_struct_default_options ( CSPOptions opts)

Fill the options structure with default values. Use this for double precision, real.

Parameters
optsPointer to CSPOptions structure

◆ SP_d_struct_destroy()

void SP_d_struct_destroy ( CSPStructMat S)

Destroy the structured matrix. Use this for a structured matrix created with one of the SP_d_struct_... routines, i.e., double precision, real.

Parameters
SPointer to CSPStructMat object.

◆ SP_d_struct_factor()

int SP_d_struct_factor ( CSPStructMat  S)

Compute a factorization of the structured matrix. Factors are stored internally. This needs to be called before calling SP_d_struct_solve, and after constructing the structured matrix.

Parameters
Sstructured matrix
See also
SP_d_struct_solve

◆ SP_d_struct_from_dense()

int SP_d_struct_from_dense ( CSPStructMat S,
int  rows,
int  cols,
const double *  A,
int  ldA,
const CSPOptions opts 
)

Construct a structured matrix from a dense (column major) matrix. Use this for double precision, real.

Parameters
SPointer to CSPStructMat object, which will be constructed.
rowsNumber of rows in A
colsNumber of columns in A
APointer to data of A, column major
ldAleading dimension of A
optsOptions structure, needs to be initialized by the user.
Returns
0 if successful
See also
SP_d_struct_destroy, SP_d_struct_default_options

◆ SP_d_struct_memory()

long long int SP_d_struct_memory ( const CSPStructMat  S)

Return the total amount of memory used by this matrix, in bytes.

Returns
Memory usage in bytes.
See also
nonzeros

◆ SP_d_struct_mult()

int SP_d_struct_mult ( const CSPStructMat  S,
char  trans,
int  m,
const double *  B,
int  ldB,
double *  C,
int  ldC 
)

Multiply a structured matrix with a dense matrix (or vector):

     C = S*B   if trans == 'N' or 'n'
     C = S^T*B if trans == 'T' or 't'
     C = S^C*B if trans == 'C' or 'c'

C should have rows(S) rows if trans == 'N'/'n', else cols(S). B should have cols(S) rows if trans == 'N'/'n', else rows(S).

Parameters
Sstructured matrix
trans(conjugate-)transpose of S?
mnumber of columns in B and C
Bpointer to data of B (column major)
ldBleading dimension for B
Cpointer to matrix C (column major)
ldCleading dimension for C

◆ SP_d_struct_nonzeros()

long long int SP_d_struct_nonzeros ( const CSPStructMat  S)

Return the total number of nonzeros stored by this matrix.

Returns
Nonzeros in the matrix representation.
See also
memory

◆ SP_d_struct_rank()

int SP_d_struct_rank ( const CSPStructMat  S)

Return the maximum rank of this matrix over all low-rank compressed blocks.

Returns
Maximum rank.

◆ SP_d_struct_rows()

int SP_d_struct_rows ( const CSPStructMat  S)

Return number of rows in the structured matrix.

Returns
Number of rows of S.

◆ SP_d_struct_shift()

int SP_d_struct_shift ( CSPStructMat  S,
double  s 
)

Apply a shift to the diagonal of this matrix. Ie, S += s*I, with I the identity matrix. If this is called after calling factor, then the factors are not updated. To solve a linear system with the shifted matrix, you need to call factor again.

Parameters
Sstructured matrix
sShift to be applied to the diagonal.

◆ SP_d_struct_solve()

int SP_d_struct_solve ( const CSPStructMat  S,
int  nrhs,
double *  B,
int  ldB 
)

Solve a system of linear equations with a structured matrix, with possibly multiple right-hand sides (column major). The solution overwrites the right-hand side. This should be called after SP_d_struct_factor. This can be called multiple times.

Parameters
Sstructured matrix
nrhsnumber of right-hand sides, columns in B
Bright-hand side, will be overwritten by the solution
ldBleading dimension of B
See also
SP_d_struct_factor

◆ SP_s_struct_cols()

int SP_s_struct_cols ( const CSPStructMat  S)

Return number of cols in the structured matrix.

Returns
Number of cols of S.

◆ SP_s_struct_default_options()

void SP_s_struct_default_options ( CSPOptions opts)

Fill the options structure with default values. Use this for single precision, real.

Parameters
optsPointer to CSPOptions structure

◆ SP_s_struct_destroy()

void SP_s_struct_destroy ( CSPStructMat S)

Destroy the structured matrix. Use this for a structured matrix created with one of the SP_s_struct_... routines, i.e., single precision, real.

Parameters
SPointer to CSPStructMat object.

◆ SP_s_struct_factor()

int SP_s_struct_factor ( CSPStructMat  S)

Compute a factorization of the structured matrix. Factors are stored internally. This needs to be called before calling SP_s_struct_solve, and after constructing the structured matrix.

Parameters
Sstructured matrix
See also
SP_s_struct_solve

◆ SP_s_struct_from_dense()

int SP_s_struct_from_dense ( CSPStructMat S,
int  rows,
int  cols,
const float *  A,
int  ldA,
const CSPOptions opts 
)

Construct a structured matrix from a dense (column major) matrix. Use this for single precision, real.

Parameters
SPointer to CSPStructMat object, which will be constructed.
rowsNumber of rows in A
colsNumber of columns in A
APointer to data of A, column major
ldAleading dimension of A
optsOptions structure, needs to be initialized by the user.
Returns
0 if successful
See also
SP_s_struct_destroy, SP_s_struct_default_options

◆ SP_s_struct_memory()

long long int SP_s_struct_memory ( const CSPStructMat  S)

Return the total amount of memory used by this matrix, in bytes.

Returns
Memory usage in bytes.
See also
nonzeros

◆ SP_s_struct_mult()

int SP_s_struct_mult ( const CSPStructMat  S,
char  trans,
int  m,
const float *  B,
int  ldB,
float *  C,
int  ldC 
)

Multiply a structured matrix with a dense matrix (or vector):

     C = S*B   if trans == 'N' or 'n'
     C = S^T*B if trans == 'T' or 't'
     C = S^C*B if trans == 'C' or 'c'

C should have rows(S) rows if trans == 'N'/'n', else cols(S). B should have cols(S) rows if trans == 'N'/'n', else rows(S).

Parameters
Sstructured matrix
trans(conjugate-)transpose of S?
mnumber of columns in B and C
Bpointer to data of B (column major)
ldBleading dimension for B
Cpointer to matrix C (column major)
ldCleading dimension for C

◆ SP_s_struct_nonzeros()

long long int SP_s_struct_nonzeros ( const CSPStructMat  S)

Return the total number of nonzeros stored by this matrix.

Returns
Nonzeros in the matrix representation.
See also
memory

◆ SP_s_struct_rank()

int SP_s_struct_rank ( const CSPStructMat  S)

Return the maximum rank of this matrix over all low-rank compressed blocks.

Returns
Maximum rank.

◆ SP_s_struct_rows()

int SP_s_struct_rows ( const CSPStructMat  S)

Return number of rows in the structured matrix.

Returns
Number of rows of S.

◆ SP_s_struct_shift()

int SP_s_struct_shift ( CSPStructMat  S,
float  s 
)

Apply a shift to the diagonal of this matrix. Ie, S += s*I, with I the identity matrix. If this is called after calling factor, then the factors are not updated. To solve a linear system with the shifted matrix, you need to call factor again.

Parameters
Sstructured matrix
sShift to be applied to the diagonal.

◆ SP_s_struct_solve()

int SP_s_struct_solve ( const CSPStructMat  S,
int  nrhs,
float *  B,
int  ldB 
)

Solve a system of linear equations with a structured matrix, with possibly multiple right-hand sides (column major). The solution overwrites the right-hand side. This should be called after SP_s_struct_factor. This can be called multiple times.

Parameters
Sstructured matrix
nrhsnumber of right-hand sides, columns in B
Bright-hand side, will be overwritten by the solution
ldBleading dimension of B
See also
SP_s_struct_factor

◆ SP_z_struct_cols()

int SP_z_struct_cols ( const CSPStructMat  S)

Return number of cols in the structured matrix.

Returns
Number of cols of S.

◆ SP_z_struct_default_options()

void SP_z_struct_default_options ( CSPOptions opts)

Fill the options structure with default values. Use this for double precision, complex.

Parameters
optsPointer to CSPOptions structure

◆ SP_z_struct_destroy()

void SP_z_struct_destroy ( CSPStructMat S)

Destroy the structured matrix. Use this for a structured matrix created with one of the SP_z_struct_... routines, i.e., double precision, complex.

Parameters
SPointer to CSPStructMat object.

◆ SP_z_struct_factor()

int SP_z_struct_factor ( CSPStructMat  S)

Compute a factorization of the structured matrix. Factors are stored internally. This needs to be called before calling SP_z_struct_solve, and after constructing the structured matrix.

Parameters
Sstructured matrix
See also
SP_z_struct_solve

◆ SP_z_struct_from_dense()

int SP_z_struct_from_dense ( CSPStructMat S,
int  rows,
int  cols,
const double _Complex *  A,
int  ldA,
const CSPOptions opts 
)

Construct a structured matrix from a dense (column major) matrix. Use this for double precision, complex.

Parameters
SPointer to CSPStructMat object, which will be constructed.
rowsNumber of rows in A
colsNumber of columns in A
APointer to data of A, column major
ldAleading dimension of A
optsOptions structure, needs to be initialized by the user.
Returns
0 if successful
See also
SP_z_struct_destroy, SP_z_struct_default_options

◆ SP_z_struct_memory()

long long int SP_z_struct_memory ( const CSPStructMat  S)

Return the total amount of memory used by this matrix, in bytes.

Returns
Memory usage in bytes.
See also
nonzeros

◆ SP_z_struct_mult()

int SP_z_struct_mult ( const CSPStructMat  S,
char  trans,
int  m,
const double _Complex *  B,
int  ldB,
double _Complex *  C,
int  ldC 
)

Multiply a structured matrix with a dense matrix (or vector):

     C = S*B   if trans == 'N' or 'n'
     C = S^T*B if trans == 'T' or 't'
     C = S^C*B if trans == 'C' or 'c'

C should have rows(S) rows if trans == 'N'/'n', else cols(S). B should have cols(S) rows if trans == 'N'/'n', else rows(S).

Parameters
Sstructured matrix
trans(conjugate-)transpose of S?
mnumber of columns in B and C
Bpointer to data of B (column major)
ldBleading dimension for B
Cpointer to matrix C (column major)
ldCleading dimension for C

◆ SP_z_struct_nonzeros()

long long int SP_z_struct_nonzeros ( const CSPStructMat  S)

Return the total number of nonzeros stored by this matrix.

Returns
Nonzeros in the matrix representation.
See also
memory

◆ SP_z_struct_rank()

int SP_z_struct_rank ( const CSPStructMat  S)

Return the maximum rank of this matrix over all low-rank compressed blocks.

Returns
Maximum rank.

◆ SP_z_struct_rows()

int SP_z_struct_rows ( const CSPStructMat  S)

Return number of rows in the structured matrix.

Returns
Number of rows of S.

◆ SP_z_struct_shift()

int SP_z_struct_shift ( CSPStructMat  S,
double _Complex  s 
)

Apply a shift to the diagonal of this matrix. Ie, S += s*I, with I the identity matrix. If this is called after calling factor, then the factors are not updated. To solve a linear system with the shifted matrix, you need to call factor again.

Parameters
Sstructured matrix
sShift to be applied to the diagonal.

◆ SP_z_struct_solve()

int SP_z_struct_solve ( const CSPStructMat  S,
int  nrhs,
double _Complex *  B,
int  ldB 
)

Solve a system of linear equations with a structured matrix, with possibly multiple right-hand sides (column major). The solution overwrites the right-hand side. This should be called after SP_z_struct_factor. This can be called multiple times.

Parameters
Sstructured matrix
nrhsnumber of right-hand sides, columns in B
Bright-hand side, will be overwritten by the solution
ldBleading dimension of B
See also
SP_z_struct_factor