StructuredMatrix.h
Go to the documentation of this file.
1 /*
2  * STRUMPACK -- STRUctured Matrices PACKage, Copyright (c) 2014, The
3  * Regents of the University of California, through Lawrence Berkeley
4  * National Laboratory (subject to receipt of any required approvals
5  * from the U.S. Dept. of Energy). All rights reserved.
6  *
7  * If you have questions about your rights to use or distribute this
8  * software, please contact Berkeley Lab's Technology Transfer
9  * Department at TTD@lbl.gov.
10  *
11  * NOTICE. This software is owned by the U.S. Department of Energy. As
12  * such, the U.S. Government has been granted for itself and others
13  * acting on its behalf a paid-up, nonexclusive, irrevocable,
14  * worldwide license in the Software to reproduce, prepare derivative
15  * works, and perform publicly and display publicly. Beginning five
16  * (5) years after the date permission to assert copyright is obtained
17  * from the U.S. Department of Energy, and subject to any subsequent
18  * five (5) year renewals, the U.S. Government is granted for itself
19  * and others acting on its behalf a paid-up, nonexclusive,
20  * irrevocable, worldwide license in the Software to reproduce,
21  * prepare derivative works, distribute copies to the public, perform
22  * publicly and display publicly, and to permit others to do so.
23  *
24  * Developers: Pieter Ghysels, Francois-Henry Rouet, Xiaoye S. Li.
25  * (Lawrence Berkeley National Lab, Computational Research
26  * Division).
27  *
28  */
33 #ifndef STRUMPACK_STRUCTURED_C_H
34 #define STRUMPACK_STRUCTURED_C_H
35 
36 #include <stdint.h>
37 #include <complex.h>
38 #undef I
39 
40 #include "StrumpackConfig.hpp"
41 
42 #if defined(STRUMPACK_USE_MPI)
43 #define OMPI_SKIP_MPICXX 1
44 #include "mpi.h"
45 #endif
46 
51 typedef enum {
52  SP_TYPE_HSS = 0,
53  SP_TYPE_BLR,
54  SP_TYPE_HODLR,
55  SP_TYPE_HODBF,
56  SP_TYPE_BUTTERFLY,
57  SP_TYPE_LR,
58  SP_TYPE_LOSSY,
59  SP_TYPE_LOSSLESS
61 
62 
73 typedef struct CSPOptions {
74  SP_STRUCTURED_TYPE type;
75  double rel_tol;
76  double abs_tol;
77  int leaf_size;
78  int max_rank;
79  int verbose;
80 } CSPOptions;
81 
82 
90 typedef void* CSPStructMat;
91 
92 
93 #ifdef __cplusplus
94 extern "C" {
95 #endif
96 
97  // TODO:
98  // - query statistics: memory usage, levels, rank, ...
99  // - more construction routines, matvec, ..
100  // - pass clustertree?
101  // - in HODLR/HODBF store the MPIComm instead of a pointer!!
102 
127 
128 
157 
158 
179 
180 
201 
202 
209  long long int SP_s_struct_memory(const CSPStructMat S);
216  long long int SP_d_struct_memory(const CSPStructMat S);
223  long long int SP_c_struct_memory(const CSPStructMat S);
230  long long int SP_z_struct_memory(const CSPStructMat S);
231 
232 
238  long long int SP_s_struct_nonzeros(const CSPStructMat S);
244  long long int SP_d_struct_nonzeros(const CSPStructMat S);
250  long long int SP_c_struct_nonzeros(const CSPStructMat S);
256  long long int SP_z_struct_nonzeros(const CSPStructMat S);
257 
258 
283 
284 
300  int SP_s_struct_from_dense(CSPStructMat* S, int rows, int cols,
301  const float* A, int ldA,
302  const CSPOptions* opts);
318  int SP_d_struct_from_dense(CSPStructMat* S, int rows, int cols,
319  const double* A, int ldA,
320  const CSPOptions* opts);
336  int SP_c_struct_from_dense(CSPStructMat* S, int rows, int cols,
337  const float _Complex* A, int ldA,
338  const CSPOptions* opts);
354  int SP_z_struct_from_dense(CSPStructMat* S, int rows, int cols,
355  const double _Complex* A, int ldA,
356  const CSPOptions* opts);
357 
358 
359  int SP_s_struct_from_elements(CSPStructMat* S, int rows, int cols,
360  float(int i, int j),
361  const CSPOptions* opts);
362  int SP_d_struct_from_elements(CSPStructMat* S, int rows, int cols,
363  double(int i, int j),
364  const CSPOptions* opts);
365  int SP_c_struct_from_elements(CSPStructMat* S, int rows, int cols,
366  float _Complex(int i, int j),
367  const CSPOptions* opts);
368  int SP_z_struct_from_elements(CSPStructMat* S, int rows, int cols,
369  double _Complex(int i, int j),
370  const CSPOptions* opts);
371 
372 
373 #if defined(STRUMPACK_USE_MPI)
374  int SP_s_struct_from_dense2d(CSPStructMat* S, const MPI_Comm comm,
375  int rows, int cols, const float* A,
376  int IA, int JA, int* DESCA,
377  const CSPOptions* opts);
378  int SP_d_struct_from_dense2d(CSPStructMat* S, const MPI_Comm comm,
379  int rows, int cols, const double* A,
380  int IA, int JA, int* DESCA,
381  const CSPOptions* opts);
382  int SP_c_struct_from_dense2d(CSPStructMat* S, const MPI_Comm comm,
383  int rows, int cols, const float _Complex* A,
384  int IA, int JA, int* DESCA,
385  const CSPOptions* opts);
386  int SP_z_struct_from_dense2d(CSPStructMat* S, const MPI_Comm comm,
387  int rows, int cols, const double _Complex* A,
388  int IA, int JA, int* DESCA,
389  const CSPOptions* opts);
390 
391 
408  int SP_s_struct_from_elements_mpi(CSPStructMat* S, const MPI_Comm comm,
409  int rows, int cols,
410  float A(int i, int j),
411  const CSPOptions* opts);
428  int SP_d_struct_from_elements_mpi(CSPStructMat* S, const MPI_Comm comm,
429  int rows, int cols,
430  double A(int i, int j),
431  const CSPOptions* opts);
448  int SP_c_struct_from_elements_mpi(CSPStructMat* S, const MPI_Comm comm,
449  int rows, int cols,
450  float _Complex A(int i, int j),
451  const CSPOptions* opts);
468  int SP_z_struct_from_elements_mpi(CSPStructMat* S, const MPI_Comm comm,
469  int rows, int cols,
470  double _Complex A(int i, int j),
471  const CSPOptions* opts);
472 
473 
498 
499 
524 
525 #endif
526 
527 
546  int SP_s_struct_mult(const CSPStructMat S, char trans, int m,
547  const float* B, int ldB,
548  float* C, int ldC);
567  int SP_d_struct_mult(const CSPStructMat S, char trans, int m,
568  const double* B, int ldB,
569  double* C, int ldC);
588  int SP_c_struct_mult(const CSPStructMat S, char trans, int m,
589  const float _Complex* B, int ldB,
590  float _Complex* C, int ldC);
609  int SP_z_struct_mult(const CSPStructMat S, char trans, int m,
610  const double _Complex* B, int ldB,
611  double _Complex* C, int ldC);
612 
613 
654 
655 
669  int SP_s_struct_solve(const CSPStructMat S, int nrhs,
670  float* B, int ldB);
684  int SP_d_struct_solve(const CSPStructMat S, int nrhs,
685  double* B, int ldB);
699  int SP_c_struct_solve(const CSPStructMat S, int nrhs,
700  float _Complex* B, int ldB);
714  int SP_z_struct_solve(const CSPStructMat S, int nrhs,
715  double _Complex* B, int ldB);
716 
717 
739  int SP_d_struct_shift(CSPStructMat S, double s);
750  int SP_c_struct_shift(CSPStructMat S, float _Complex s);
761  int SP_z_struct_shift(CSPStructMat S, double _Complex s);
762 
763 #ifdef __cplusplus
764 }
765 #endif
766 
767 #endif
void SP_s_struct_default_options(CSPOptions *opts)
void SP_s_struct_destroy(CSPStructMat *S)
int SP_d_struct_from_dense(CSPStructMat *S, int rows, int cols, const double *A, int ldA, const CSPOptions *opts)
void SP_c_struct_destroy(CSPStructMat *S)
int SP_s_struct_begin_row(const CSPStructMat S)
void SP_c_struct_default_options(CSPOptions *opts)
int SP_c_struct_cols(const CSPStructMat S)
int SP_z_struct_from_dense(CSPStructMat *S, int rows, int cols, const double _Complex *A, int ldA, const CSPOptions *opts)
int SP_d_struct_rank(const CSPStructMat S)
int SP_c_struct_rows(const CSPStructMat S)
int SP_d_struct_factor(CSPStructMat S)
void SP_z_struct_destroy(CSPStructMat *S)
long long int SP_c_struct_memory(const CSPStructMat S)
int SP_s_struct_solve(const CSPStructMat S, int nrhs, float *B, int ldB)
int SP_s_struct_factor(CSPStructMat S)
int SP_c_struct_local_rows(const CSPStructMat S)
int SP_d_struct_cols(const CSPStructMat S)
long long int SP_s_struct_memory(const CSPStructMat S)
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_local_rows(const CSPStructMat S)
long long int SP_z_struct_memory(const CSPStructMat S)
SP_STRUCTURED_TYPE
Definition: StructuredMatrix.h:51
int SP_s_struct_local_rows(const CSPStructMat S)
int SP_z_struct_begin_row(const CSPStructMat S)
int SP_z_struct_cols(const CSPStructMat S)
int SP_c_struct_from_dense(CSPStructMat *S, int rows, int cols, const float _Complex *A, int ldA, 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_z_struct_solve(const CSPStructMat S, int nrhs, double _Complex *B, int ldB)
int SP_d_struct_begin_row(const CSPStructMat S)
void SP_d_struct_destroy(CSPStructMat *S)
int SP_d_struct_local_rows(const CSPStructMat S)
long long int SP_d_struct_nonzeros(const CSPStructMat S)
int SP_d_struct_shift(CSPStructMat S, double s)
int SP_d_struct_mult(const CSPStructMat S, char trans, int m, const double *B, int ldB, double *C, int ldC)
int SP_z_struct_from_elements_mpi(CSPStructMat *S, const MPI_Comm comm, int rows, int cols, double _Complex A(int i, int j), const CSPOptions *opts)
int SP_s_struct_rows(const CSPStructMat S)
int SP_c_struct_from_elements_mpi(CSPStructMat *S, const MPI_Comm comm, int rows, int cols, float _Complex A(int i, int j), const CSPOptions *opts)
int SP_z_struct_rank(const CSPStructMat S)
int SP_z_struct_rows(const CSPStructMat S)
int SP_c_struct_rank(const CSPStructMat S)
int SP_d_struct_from_elements_mpi(CSPStructMat *S, const MPI_Comm comm, int rows, int cols, double A(int i, int j), const CSPOptions *opts)
long long int SP_s_struct_nonzeros(const CSPStructMat S)
int SP_d_struct_rows(const CSPStructMat S)
long long int SP_z_struct_nonzeros(const CSPStructMat S)
int SP_c_struct_shift(CSPStructMat S, float _Complex s)
void SP_d_struct_default_options(CSPOptions *opts)
void * CSPStructMat
Type representing a structured matrix in the C interface.
Definition: StructuredMatrix.h:90
int SP_s_struct_cols(const CSPStructMat S)
int SP_c_struct_begin_row(const CSPStructMat S)
int SP_d_struct_solve(const CSPStructMat S, int nrhs, double *B, int ldB)
int SP_s_struct_from_dense(CSPStructMat *S, int rows, int cols, const float *A, int ldA, const CSPOptions *opts)
int SP_c_struct_solve(const CSPStructMat S, int nrhs, float _Complex *B, int ldB)
long long int SP_d_struct_memory(const CSPStructMat S)
int SP_z_struct_factor(CSPStructMat S)
int SP_z_struct_shift(CSPStructMat S, double _Complex s)
long long int SP_c_struct_nonzeros(const CSPStructMat S)
int SP_c_struct_factor(CSPStructMat S)
int SP_s_struct_rank(const CSPStructMat S)
int SP_s_struct_from_elements_mpi(CSPStructMat *S, const MPI_Comm comm, int rows, int cols, float A(int i, int j), const CSPOptions *opts)
int SP_z_struct_mult(const CSPStructMat S, char trans, int m, const double _Complex *B, int ldB, double _Complex *C, int ldC)
void SP_z_struct_default_options(CSPOptions *opts)
int SP_s_struct_shift(CSPStructMat S, float s)
Structure containing options for structured matrix compression, to be used with the C interface.
Definition: StructuredMatrix.h:73