|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TLIN_SUPERLU_WRAP
|
|
Toshihiro Shimizu |
890ddd |
#define TLIN_SUPERLU_WRAP
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tcommon.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TNZEXT_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tlin_matrix.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tlin_sparsemat.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
EXPLANATION:
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
The tlin_superlu_wrap files implement wrappers to the SuperLU library.
|
|
Toshihiro Shimizu |
890ddd |
They are used to provide utility interfaces to SuperLU from tlin, and
|
|
Toshihiro Shimizu |
890ddd |
overcome name collisions (in particular, SuperLU is pure C - no
|
|
Toshihiro Shimizu |
890ddd |
namespaces, and redefines DOUBLES and such already defined
|
|
Toshihiro Shimizu |
890ddd |
from <windows.h>...)</windows.h>
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//================================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace tlin {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Forward declarations
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
The following structs are heirs of the actual SuperLU counterparts - this is
|
|
Toshihiro Shimizu |
890ddd |
necessary due to the "typedef struct {..} _Name" syntax that prevents forward
|
|
Toshihiro Shimizu |
890ddd |
declaration of "_Name" (different base types).
|
|
Toshihiro Shimizu |
890ddd |
No member is added to the original type - so they are accessible exactly the
|
|
Toshihiro Shimizu |
890ddd |
same way.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
struct SuperMatrix;
|
|
Toshihiro Shimizu |
890ddd |
struct superlu_options_t;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
struct SuperFactors {
|
|
Shinya Kitaoka |
120a6e |
SuperMatrix *L;
|
|
Shinya Kitaoka |
120a6e |
SuperMatrix *U;
|
|
Shinya Kitaoka |
120a6e |
int *perm_c;
|
|
Shinya Kitaoka |
120a6e |
int *perm_r;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// SuperLU-specific routines
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DVAPI allocS(SuperMatrix *&A, int rows, int cols,
|
|
Shinya Kitaoka |
120a6e |
int nnz); //!< Allocates A in NC (sparse) format
|
|
Shinya Kitaoka |
120a6e |
void DVAPI allocD(SuperMatrix *&A, int rows,
|
|
Shinya Kitaoka |
120a6e |
int cols); //!< Allocates A in DN (dense) format
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Allocates A with externally supplied initializer values
|
|
Shinya Kitaoka |
120a6e |
void DVAPI allocS(SuperMatrix *&A, int rows, int cols, int nnz, int *colptr,
|
|
Shinya Kitaoka |
120a6e |
int *rowind, double *values);
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI allocD(SuperMatrix *&A, int rows, int cols, int lda, double *values);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DVAPI freeS(SuperMatrix *A); //!< Frees A allocated with allocS
|
|
Shinya Kitaoka |
120a6e |
void DVAPI freeD(SuperMatrix *A); //!< Frees A allocated with allocD
|
|
Shinya Kitaoka |
120a6e |
void DVAPI freeF(SuperFactors *F); //!< Frees F returned by factorize
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Initializes a local SuperMatrix (ie created on stack).
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI createS(SuperMatrix &A, int rows, int cols, int nnz);
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI createD(SuperMatrix &A, int rows, int cols);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Initializes a local SuperMatrix with externally supplied data.
|
|
Shinya Kitaoka |
120a6e |
void DVAPI createS(SuperMatrix &A, int rows, int cols, int nnz, int *colptr,
|
|
Shinya Kitaoka |
120a6e |
int *rowind, double *values);
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI createD(SuperMatrix &A, int rows, int cols, int lda, double *values);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! Destroys A. To be used when A is local (ie with create). Can be told to
|
|
Shinya Kitaoka |
120a6e |
//! spare data deallocation.
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI destroyS(SuperMatrix &A, bool destroyData = true);
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI destroyD(SuperMatrix &A, bool destroyData = true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void DVAPI readDN(SuperMatrix *A, int &lda,
|
|
Shinya Kitaoka |
120a6e |
double *&values); //!< Reads values ptr from A
|
|
Shinya Kitaoka |
120a6e |
void DVAPI readNC(SuperMatrix *A, int &nnz, int *&colptr, int *&rowind,
|
|
Shinya Kitaoka |
120a6e |
double *&values); //!< Reads array ptrs from A
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! Copies m's content to A. A could be either 0 or an already initialized
|
|
Shinya Kitaoka |
120a6e |
//! SuperMatrix.
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI traduceS(tlin::sparse_matrix<double> &m, SuperMatrix *&A);</double>
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI traduceD(const tlin::matrix<double> &m, SuperMatrix *&A);</double>
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI traduceD(const tlin::sparse_matrix<double> &m, SuperMatrix *&A);</double>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns A's factorization F, or 0 if the factorization failed (due to A's
|
|
Shinya Kitaoka |
120a6e |
singularity,
|
|
Toshihiro Shimizu |
890ddd |
or memory shortage - see SuperLU docs for details).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
void DVAPI factorize(SuperMatrix *A, SuperFactors *&F,
|
|
Shinya Kitaoka |
120a6e |
superlu_options_t *opt = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI solve(SuperFactors *F, SuperMatrix *BX, superlu_options_t *opt = 0);
|
|
Shinya Kitaoka |
120a6e |
void DVAPI solve(SuperFactors *F, SuperMatrix *B, SuperMatrix *&X,
|
|
Shinya Kitaoka |
120a6e |
superlu_options_t *opt = 0);
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI solve(SuperMatrix *A, SuperMatrix *BX, superlu_options_t *opt = 0);
|
|
Shinya Kitaoka |
120a6e |
void DVAPI solve(SuperMatrix *A, SuperMatrix *B, SuperMatrix *&X,
|
|
Shinya Kitaoka |
120a6e |
superlu_options_t *opt = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI solve(SuperFactors *F, double *bx, superlu_options_t *opt = 0);
|
|
Shinya Kitaoka |
120a6e |
void DVAPI solve(SuperFactors *F, double *b, double *&x,
|
|
Shinya Kitaoka |
120a6e |
superlu_options_t *opt = 0);
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI solve(SuperMatrix *A, double *bx, superlu_options_t *opt = 0);
|
|
Shinya Kitaoka |
120a6e |
void DVAPI solve(SuperMatrix *A, double *b, double *&x,
|
|
Shinya Kitaoka |
120a6e |
superlu_options_t *opt = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// BLAS-related routines
|
|
Toshihiro Shimizu |
890ddd |
//*****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI multiplyS(const SuperMatrix *A, const double *v, double *&Av);
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI multiplyD(const SuperMatrix *A, const double *v, double *&Av);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace tlin
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // TLIN_SUPERLU_WRAP
|