Commit d5d188e7 authored by Dmitry Bagaev's avatar Dmitry Bagaev
Browse files

K3 interface improvements

parent d64fd943
...@@ -6,3 +6,9 @@ build*/ ...@@ -6,3 +6,9 @@ build*/
*.iml *.iml
*.xml *.xml
Source/Solver/solver_fcbiilu2/fcbiilu2.cpp
Source/Solver/solver_k3biilu2/k3d.cpp
Source/Solver/solver_k3biilu2/k3d.h
#include "SolverK3BIILU2.h" #include "SolverK3BIILU2.h"
#include "solver_k3biilu2.h"
namespace INMOST { namespace INMOST {
SolverK3BIILU2::SolverK3BIILU2() { SolverK3BIILU2::SolverK3BIILU2() {
solver_data = NULL;
matrix_data = NULL;
} }
SolverInterface *SolverK3BIILU2::Copy(const SolverInterface *other) { SolverInterface *SolverK3BIILU2::Copy(const SolverInterface *other) {
...@@ -47,7 +49,7 @@ namespace INMOST { ...@@ -47,7 +49,7 @@ namespace INMOST {
void SolverK3BIILU2::Setup(int *argc, char ***argv, SolverParameters &p) { void SolverK3BIILU2::Setup(int *argc, char ***argv, SolverParameters &p) {
SolverInitDataK3biilu2(&solver_data, communicator, p.solverPrefix.c_str()); SolverInitDataK3biilu2(&solver_data, communicator, p.solverPrefix.c_str());
SolverInitializeK3biilu2(argc, argv, p.internalFile); SolverInitializeK3biilu2(solver_data, argc, argv, p.internalFile.c_str());
} }
void SolverK3BIILU2::SetMatrix(Sparse::Matrix &A, bool ModifiedPattern, bool OldPreconditioner) { void SolverK3BIILU2::SetMatrix(Sparse::Matrix &A, bool ModifiedPattern, bool OldPreconditioner) {
...@@ -122,8 +124,8 @@ namespace INMOST { ...@@ -122,8 +124,8 @@ namespace INMOST {
bool SolverK3BIILU2::Solve(INMOST::Sparse::Vector &RHS, INMOST::Sparse::Vector &SOL) { bool SolverK3BIILU2::Solve(INMOST::Sparse::Vector &RHS, INMOST::Sparse::Vector &SOL) {
INMOST_DATA_ENUM_TYPE vbeg, vend; INMOST_DATA_ENUM_TYPE vbeg, vend;
RHS.GetInterval(vbeg, vend); RHS.GetInterval(vbeg, vend);
void *rhs_data = NULL; vector_k3biilu2 *rhs_data = NULL;
void *solution_data = NULL; vector_k3biilu2 *solution_data = NULL;
VectorInitDataK3biilu2(&rhs_data, RHS.GetCommunicator(), RHS.GetName().c_str()); VectorInitDataK3biilu2(&rhs_data, RHS.GetCommunicator(), RHS.GetName().c_str());
VectorPreallocateK3biilu2(rhs_data, local_size); VectorPreallocateK3biilu2(rhs_data, local_size);
...@@ -161,8 +163,9 @@ namespace INMOST { ...@@ -161,8 +163,9 @@ namespace INMOST {
} }
void SolverK3BIILU2::SetParameter(std::string name, std::string value) { void SolverK3BIILU2::SetParameter(std::string name, std::string value) {
std::cout << "SolverK3BIILU2::SetParameter unsupported operation" << std::endl; const char *val = value.c_str();
//throw INMOST::SolverUnsupportedOperation; if (name == "msglev") solver_data->pParIter->msglev = atoi(val);
else std::cout << "Parameter " << name << " is unknown" << std::endl;
} }
const INMOST_DATA_ENUM_TYPE SolverK3BIILU2::Iterations() const { const INMOST_DATA_ENUM_TYPE SolverK3BIILU2::Iterations() const {
......
...@@ -8,8 +8,8 @@ namespace INMOST { ...@@ -8,8 +8,8 @@ namespace INMOST {
class SolverK3BIILU2 : public SolverInterface { class SolverK3BIILU2 : public SolverInterface {
private: private:
void *solver_data; bcg_k3biilu2 *solver_data;
void *matrix_data; matrix_k3biilu2 *matrix_data;
INMOST_DATA_ENUM_TYPE local_size, global_size; INMOST_DATA_ENUM_TYPE local_size, global_size;
public: public:
SolverK3BIILU2(); SolverK3BIILU2();
......
...@@ -14,91 +14,65 @@ ...@@ -14,91 +14,65 @@
//TODO: ncycle niter_cycle niter_cycle2 ncoef nit->maxit //TODO: ncycle niter_cycle niter_cycle2 ncoef nit->maxit
typedef struct
{
int ittype; // 0 - BiCGStab; 1,2,3 - GMRES(niter_cycle); 2 - +Poly(ncoef)_BiCGStab; 3 - +Poly(ncoef)_GMRESb(niter_cycle2)
int niter_cycle; // outer GMRES cycle (=kgmr by IEK); 1 - BiCGStab
int ncoef; // polynomial degree (=kdeg by IEK); ittype=2,3
int niter_cycle2; // internal GMRES cycle size for ittype=3
double eps; // the residual precision: ||r|| < eps * ||b||; eps=1e-6
int maxit; // number of iterations permitted; maxit=999
int ichk; // number of skipped iterations to check the convergence
int msglev; // messages level; msglev=0 for silent; msglev>0 to output solution statistics
} ParIter;
static k3d::SSolverParams parPrec; // preconditioner construction parameters
static ParIter parIter; // iterative solver parameters
static k3d::CSolver<int,double,double> k3_solver; // the solver object
void ParIterDefault ()
{
parIter.ittype = 0; // 0 - BiCGStab; 1,2,3 - GMRES(niter_cycle); 2 - +Poly(ncoef)_BiCGStab; 3 - +Poly(ncoef)_GMRESb(niter_cycle2)
parIter.niter_cycle = 30; // outer GMRES cycle (=kgmr by IEK); 1 - BiCGStab
parIter.ncoef = 5; // polynomial degree (=kdeg by IEK); ittype=2,3
parIter.niter_cycle2 = 4; // internal GMRES cycle size for ittype=3
parIter.eps = 1e-6; // the residual precision: ||r|| < eps * ||b||; eps=1e-6
parIter.maxit = 999; // number of iterations permitted; maxit=999
parIter.ichk = 5; // number of skipped iterations to check the convergence
parIter.msglev = 2; // messages level; msglev=0 for silent; msglev>0 to output solution statistics
}
/* BiCGStab solver structure */
typedef struct
{
int n; // local number of unknowns at the local processor
int nproc; // total number of processors
int * ibl; // block splitting: ibl[0]=0; ibl[nproc]=nglob
int * ia; // row pointers: ia[0]=0; ia[nloc]=nzloc
int * ja; // global column numbers (NOTE: starting from 0 or 1); ja[nzloc]
double * a; // nonzero coefficients of local matrix A; a[nzloc]
k3d::SSolverParams *pParams; // preconditioner construction parameters
ParIter *pParIter; // preconditioner construction parameters
k3d::CSolver<int,double,double> *pSolver; // pointer to the solver structure
int ierr; // error flag on return; ierr=0 for success
int istat[16]; // integer statistics array on return
double dstat[16]; // double statistics array on return
double RESID; // residual norm
int ITER; // number of BiCGStab iterations performed
} bcg;
typedef struct
{
int n; // local number of unknowns at the local processor
int nproc; // total number of processors
int * ibl; // block splitting: ibl[0]=0; ibl[nproc]=nglob
int * ia; // row pointers: ia[0]=0; ia[nloc]=nzloc
int * ja; // global column numbers (NOTE: starting from 0 or 1); ja[nzloc]
double * A; // nonzero coefficients of local matrix A; a[nzloc]
} matrix;
typedef struct
{
int n; // local number of unknowns at the local processor
double * v; // local data vector
} Vector;
/*****************************************************************************/ /*****************************************************************************/
#include <stdlib.h> // for malloc() #include <stdlib.h> // for malloc()
#if defined (USE_MPI) #if defined (USE_MPI)
#include <mpi.h> // for MPI_COMM_WORLD etc. #include <mpi.h> // for MPI_COMM_WORLD etc.
#endif #endif
//getline(is, s); //1 skip iext
//getline(is, s); //2 skip mtx filename
//getline(is, s); //3 skip rhs filename
//getline(is, s);
//sscanf(s.c_str(), "%lg", &parIter.eps); //4 eps
//getline(is, s);
//sscanf(s.c_str(), "%d", &parIter.maxit); //5 maxit
//getline(is, s);
//sscanf(s.c_str(), "%d", &parIter.niter_cycle); //6 kgmr
//getline(is, s);
//sscanf(s.c_str(), "%d", &parIter.ncoef); //7 kdeg
//getline(is, s);
//sscanf(s.c_str(), "%d", &parPrec.ncycle); //8 kovl
//getline(is, s);
//sscanf(s.c_str(), "%lg", &parPrec.tau1); //9 tau
//parPrec.tau2 = -1.0;
//parIter.ittype = (parIter.niter_cycle > 1) ? 1 : 0;
////? msglev
void ParametersDefault(ParIter &parIter, k3d::SParams &parPrec) {
parIter.ittype = 0; // 0 - BiCGStab; 1,2,3 - GMRES(niter_cycle); 2 - +Poly(ncoef)_BiCGStab; 3 - +Poly(ncoef)_GMRESb(niter_cycle2)
parIter.niter_cycle = 1; // outer GMRES cycle (=kgmr by IEK); 1 - BiCGStab
parIter.ncoef = 1; // polynomial degree (=kdeg by IEK); ittype=2,3
parIter.niter_cycle2 = 4; // internal GMRES cycle size for ittype=3
parIter.eps = 1e-6; // the residual precision: ||r|| < eps * ||b||; eps=1e-6
parIter.maxit = 999; // number of iterations permitted; maxit=999
parIter.ichk = 5; // number of skipped iterations to check the convergence
parIter.msglev = 2; // messages level; msglev=0 for silent; msglev>0 to output solution statistics
parPrec.ncycle = 3;
parPrec.tau1 = 3e-3;
parPrec.tau2 = -1.0;
}
// Solve the linear system A X = B by // Solve the linear system A X = B by
// k3biilu2_bcg solver with working memory allocations and statistics output // k3biilu2_bcg solver with working memory allocations and statistics output
int k3biilu2_bcg ( int k3biilu2_bcg(
int *ibl, // block splitting: ibl[0]=0; ibl[nproc]=n int *ibl, // block splitting: ibl[0]=0; ibl[nproc]=n
int *ia, // row pointers: ia[0]=0; ia[nloc]=nzloc int *ia, // row pointers: ia[0]=0; ia[nloc]=nzloc
int *ja, // column numbers (NOTE: starting from 0 or 1); ja[nzloc] int *ja, // column numbers (NOTE: starting from 0 or 1); ja[nzloc]
double *a, // matrix A coefficients; a[nzloc] double *a, // matrix A coefficients; a[nzloc]
double *b, // right-hand side B; b[nloc] double *b, // right-hand side B; b[nloc]
double *x, // initial guess to the solution X on entry; solution X on return; x[nloc] double *x, // initial guess to the solution X on entry; solution X on return; x[nloc]
int job, // job number: 0 - construct preconditioner; 1 - use the previously constructed one int job, // job number: 0 - construct preconditioner; 1 - use the previously constructed one
int maxit, // number of iterations permitted; maxit=999; if(maxit==0) preconditioner construction only; it is more important than one in pParIter int maxit, // number of iterations permitted; maxit=999; if(maxit==0) preconditioner construction only; it is more important than one in pParIter
k3d::SSolverParams *pParams, // preconditioner construction parameters k3d::SParams *pParams, // preconditioner construction parameters
ParIter *pParIter, // iterative solver parameters ParIter *pParIter, // iterative solver parameters
k3d::CSolver<int,double,double> *pSolver, // pointer to the solver structure k3d::CK3D_Solver<int, double, double> *pSolver, // pointer to the solver structure
int *ierr, // error flag on return; ierr=0 for success int *ierr, // error flag on return; ierr=0 for success
int *istat, //[16], // integer statistics array on return int *istat, //[16], // integer statistics array on return
double *dstat) //[16]); // double statistics array on return double *dstat) //[16]); // double statistics array on return
// //
// Here, in notation: // Here, in notation:
...@@ -115,40 +89,42 @@ int k3biilu2_bcg ( ...@@ -115,40 +89,42 @@ int k3biilu2_bcg (
{ {
// Initialize MPI variables // Initialize MPI variables
INMOST_MPI_Comm comm = INMOST_MPI_COMM_WORLD; INMOST_MPI_Comm comm = INMOST_MPI_COMM_WORLD;
int np=1, mp=0; int np = 1, mp = 0;
#if defined (USE_MPI) #if defined (USE_MPI)
MPI_Comm_size(MPI_COMM_WORLD, &np); MPI_Comm_size(MPI_COMM_WORLD, &np);
MPI_Comm_rank(MPI_COMM_WORLD, &mp); MPI_Comm_rank(MPI_COMM_WORLD, &mp);
#endif #endif
std::vector<long long> blks (np+1); std::vector<long long> blks(np + 1);
std::vector<int> blk2cpu (np+1); std::vector<int> blk2cpu(np + 1);
long long *pblks = &blks[0]; long long *pblks = &blks[0];
int *pblk2cpu = &blk2cpu[0]; int *pblk2cpu = &blk2cpu[0];
for (int i=0; i<=np; i++) pblks[i] = ibl[i]; for (int i = 0; i <= np; i++) pblks[i] = ibl[i];
for (int i=0; i<np; i++) pblk2cpu[i] = i; for (int i = 0; i < np; i++) pblk2cpu[i] = i;
T(cout<<"HHHHH pSolver = "<<pSolver<<"\n";)//DB! T(cout << "HHHHH pSolver = " << pSolver << "\n";)//DB!
if (mp != 0) pParIter->msglev = 0; if (mp != 0) pParIter->msglev = 0;
if (job == 0) { if (job == 0) {
} else { } else {
T(cout<<"HHHHH k3biilu2_bcg: job == 0\n";)//DB! T(cout << "HHHHH k3biilu2_bcg: job == 0\n";)//DB!
if (pParams->tau2 < -0.01) pParams->tau2 = pParams->tau1 * pParams->tau1; if (pParams->tau2 < -0.01) pParams->tau2 = pParams->tau1 * pParams->tau1;
int nmodif; int nmodif;
double prec_extend, density, scpiv_min, scpiv_max, piv_min, piv_max, dtime_fct; double prec_extend, density, scpiv_min, scpiv_max, piv_min, piv_max, dtime_fct;
bool b_store_matrix = true; bool b_store_matrix = true;
//if (maxit > 0) b_store_matrix = true; //if (maxit > 0) b_store_matrix = true;
//TODO PIVMIN??? -> AUX = 0 <vars> / AUX //TODO PIVMIN??? -> AUX = 0 <vars> / AUX
//pParams->pivmin=0.0; //pParams->pivmin=0.0;
pSolver->PrepareSolver ((void *)&comm, pParams, np, pblks, pblk2cpu, pSolver->PrepareSolver((void *) &comm, pParams, np, pblks, pblk2cpu,
b_store_matrix, ia, ja, a, b_store_matrix, ia, ja, a,
prec_extend, density, scpiv_min, scpiv_max, nmodif, piv_min, piv_max, dtime_fct); prec_extend, density, scpiv_min, scpiv_max, nmodif, piv_min, piv_max, dtime_fct);
if (pParIter->msglev > 0) std::cout << " K3: prec_extend=" << prec_extend << " density=" << density << " scpiv_min=" << scpiv_min << " scpiv_max=" << scpiv_max << " nmodif=" << nmodif << " piv_min=" << piv_min << " piv_max=" << piv_max << " dtime_fct=" << dtime_fct << endl; if (pParIter->msglev > 0)
std::cout << " K3: prec_extend=" << prec_extend << " density=" << density << " scpiv_min=" << scpiv_min << " scpiv_max=" << scpiv_max
<< " nmodif=" << nmodif << " piv_min=" << piv_min << " piv_max=" << piv_max << " dtime_fct=" << dtime_fct << endl;
dstat[0] = density; dstat[0] = density;
// } else { // } else {
// T(cout<<"HHHHH k3biilu2_bcg: else (job == 0)\n";)//DB! // T(cout<<"HHHHH k3biilu2_bcg: else (job == 0)\n";)//DB!
...@@ -157,474 +133,436 @@ int k3biilu2_bcg ( ...@@ -157,474 +133,436 @@ int k3biilu2_bcg (
} }
if (maxit > 0) { if (maxit > 0) {
T(cout<<"HHHHH k3biilu2_bcg: 0<maxit="<<maxit<<"\n";)//DB! T(cout << "HHHHH k3biilu2_bcg: 0<maxit=" << maxit << "\n";)//DB!
ofstream *pfout = NULL; ofstream *pfout = NULL;
int niter, nmvm; int niter, nmvm;
double rhs_norm, res_ini, res_fin, dtime_iter; double rhs_norm, res_ini, res_fin, dtime_iter;
pSolver->SolveIter (pParIter->ittype, maxit, pParIter->niter_cycle, pParIter->ncoef, pParIter->niter_cycle2, pSolver->SolveIter(pParIter->ittype, maxit, pParIter->niter_cycle, pParIter->ncoef, pParIter->niter_cycle2,
pParIter->eps, pParIter->ichk, pParIter->msglev, pfout, pParIter->eps, pParIter->ichk, pParIter->msglev, pfout,
b, x, b, x,
rhs_norm, res_ini, niter, nmvm, res_fin, dtime_iter); rhs_norm, res_ini, niter, nmvm, res_fin, dtime_iter);
if (pParIter->msglev > 0) std::cout << " K3: rhs_norm=" << rhs_norm << " res_ini=" << res_ini << " niter=" << niter << " nmvm=" << nmvm << " res_fin=" << res_fin << " dtime_iter=" << dtime_iter << endl; if (pParIter->msglev > 0)
std::cout << " K3: rhs_norm=" << rhs_norm << " res_ini=" << res_ini << " niter=" << niter << " nmvm=" << nmvm << " res_fin=" << res_fin
<< " dtime_iter=" << dtime_iter << endl;
istat[2] = niter; istat[2] = niter;
dstat[2] = (rhs_norm == 0e0) ? res_fin : res_fin/rhs_norm; dstat[2] = (rhs_norm == 0e0) ? res_fin : res_fin / rhs_norm;
pSolver->CleanMvmA(); //? prec iter iter pSolver->CleanMvmA(); //? prec iter iter
} }
*ierr = 0; //TODO correct error status of construction or convergence *ierr = 0; //TODO correct error status of construction or convergence
return *ierr; return *ierr;
} }
/*****************************************************************************/
/* Initialize bcg solver */
static int initbcg(bcg *s, matrix *A, double eps);
/* Reinitialize solver preconditioner with new matrix A */
static int renewbcg(bcg *s, double *A);
/* Solve linear system */
/*static*/ int solvebcg(bcg *s, Vector *b, Vector *x);
/* Free memory used by solver */
static void freebcg(bcg *s);
/*****************************************************************************/
/* Initialize solver with new matrix A */ /* Initialize solver with new matrix A */
static int newmatrixbcg(bcg *s, matrix *A, bool same_precond) int newmatrixbcg_k3(bcg_k3biilu2 *s, matrix_k3biilu2 *A, bool same_precond) {
{ if (s->n != A->n && same_precond) throw INMOST::CannotReusePreconditionerOfDifferentSize;
if( s->n != A->n && same_precond ) throw INMOST::CannotReusePreconditionerOfDifferentSize; s->n = A->n;
s->n = A->n;
s->nproc = A->nproc; s->nproc = A->nproc;
s->ibl = A->ibl; s->ibl = A->ibl;
s->ia = A->ia; s->ia = A->ia;
s->ja = A->ja; s->ja = A->ja;
if( !same_precond ) if (!same_precond) {
{ //do nothing...
//do nothing... T(std::cout << "##### inside newmatrixbcg bef. renewbcg \n";)//db!
T(std::cout<<"##### inside newmatrixbcg bef. renewbcg \n";)//db! return renewbcg_k3(s, A->A);
return renewbcg(s, A->A); } else return 0;
}
else return 0;
} }
/* solver */ /* solver */
/* Initialize bcg solver */ /* Initialize bcg solver */
int initbcg(bcg *s, matrix *A, double eps) int initbcg_k3(bcg_k3biilu2 *s, matrix_k3biilu2 *A, double eps) {
{ s->pParIter->eps = eps;
parIter.eps = eps; T(std::cout << "##### inside initbcg bef. newmatrixbcg eps=" << eps << " \n";)//db!
T(std::cout<<"##### inside initbcg bef. newmatrixbcg eps="<<eps<<" \n";)//db! return newmatrixbcg_k3(s, A, false);
return newmatrixbcg(s, A, false);
} }
/* Reinitialize solver preconditioner with new matrix A */ /* Reinitialize solver preconditioner with new matrix A */
int renewbcg(bcg *s, double *A) int renewbcg_k3(bcg_k3biilu2 *s, double *A) {
{
//reinitialize matrix values //reinitialize matrix values
s->a = A; s->a = A;
//BIILU2 preconditioner construction... //BIILU2 preconditioner construction...
s->pParams = &parPrec;
s->pParIter = &parIter;
int job = 0; int job = 0;
int maxit = 0; int maxit = 0;
T(cout<<"HHHHH bef. Clean in renewbcg\n";)//DB! T(cout << "HHHHH bef. Clean in renewbcg\n";)//DB!
s->pSolver->Clean(); s->pSolver->Clean();
int ierr = 0; int ierr = 0;
T(std::cout<<"##### inside renewbcg bef. k3biilu2_bcg\n";)//db! T(std::cout << "##### inside renewbcg bef. k3biilu2_bcg\n";)//db!
k3biilu2_bcg (s->ibl, s->ia, s->ja, s->a, k3biilu2_bcg(s->ibl, s->ia, s->ja, s->a,
NULL, NULL, NULL, NULL,
job, maxit, s->pParams, s->pParIter, s->pSolver, job, maxit, s->pParams, s->pParIter, s->pSolver,
&ierr, s->istat, s->dstat); &ierr, s->istat, s->dstat);
T(std::cout<<"##### inside renewbcg aft. k3biilu2_bcg ierr="<<ierr<<"\n";)//db! T(std::cout << "##### inside renewbcg aft. k3biilu2_bcg ierr=" << ierr << "\n";)//db!
if (ierr) std::cout << "initialization of k3biilu2 failed, ierr=" << ierr << endl; //TODO: myid if (ierr) std::cout << "initialization of k3biilu2 failed, ierr=" << ierr << endl; //TODO: myid
return ierr; return ierr;
} }
/* Solve linear system */ /* Solve linear system */
int solvebcg(bcg *s, Vector *b, Vector *x) int solvebcg_k3(bcg_k3biilu2 *s, vector_k3biilu2 *b, vector_k3biilu2 *x) {
{ int job = 1;
s->pParams = &parPrec; int maxit = s->pParIter->maxit;
s->pParIter = &parIter;
int job = 1;
int maxit = s->pParIter->maxit;
int ierr = 0; int ierr = 0;
T(std::cout<<"##### inside solvebcg bef. k3biilu2_bcg\n";)//db! T(std::cout << "##### inside solvebcg bef. k3biilu2_bcg\n";)//db!
k3biilu2_bcg (s->ibl, s->ia, s->ja, s->a, b->v, x->v, k3biilu2_bcg(s->ibl, s->ia, s->ja, s->a, b->v, x->v,
job, maxit, s->pParams, s->pParIter, s->pSolver, job, maxit, s->pParams, s->pParIter, s->pSolver,
&ierr, s->istat, s->dstat); &ierr, s->istat, s->dstat);
T(std::cout<<"##### inside solvebcg aft. k3biilu2_bcg\n";)//db! T(std::cout << "##### inside solvebcg aft. k3biilu2_bcg\n";)//db!
if (ierr) std::cout << "linear system solution by k3biilu2 failed, ierr=" << ierr << endl; //TODO: myid if (ierr) std::cout << "linear system solution by k3biilu2 failed, ierr=" << ierr << endl; //TODO: myid
s->ITER = s->istat[2]; s->ITER = s->istat[2];
s->RESID = s->dstat[2]; s->RESID = s->dstat[2];
return ierr; return ierr;
} }
/* Free memory used by solver */ /* Free memory used by solver */
void freebcg(bcg *s) void freebcg_k3(bcg_k3biilu2 *s) {
{ T(std::cout << "##### inside freebcg bef. clean\n";)//db!
T(std::cout<<"##### inside freebcg bef. clean\n";)//db!
s->pSolver->Clean(); s->pSolver->Clean();
delete s->pSolver;
delete s->pParams;
delete s->pParIter;
} }
/*****************************************************************************/ /*****************************************************************************/
void MatrixCopyDataK3biilu2(void ** ppA, void * pB) void MatrixCopyDataK3biilu2(matrix_k3biilu2 **ppA, matrix_k3biilu2 *pB) {
{ matrix_k3biilu2 *B = pB;
matrix * B = (matrix *)pB; if (ppA == NULL || pB == NULL) throw INMOST::DataCorruptedInSolver;
if( ppA == NULL || pB == NULL ) throw INMOST::DataCorruptedInSolver; *ppA = (matrix_k3biilu2 *) malloc(sizeof(matrix_k3biilu2));
*ppA = malloc(sizeof(matrix)); matrix_k3biilu2 *A = *ppA;
matrix * A = (matrix *)ppA; A->n = B->n;
A->n = B->n; if (B->n != 0) {
if( B->n != 0 ) int nnz = B->ia[B->n] - B->ia[0];
{ A->nproc = B->nproc;
int nnz = B->ia[B->n] - B->ia[0]; A->ibl = (int *) malloc(sizeof(int) * (A->nproc + 1));
A->nproc = B->nproc; memcpy(A->ibl, B->ibl, sizeof(int) * (A->nproc + 1));
A->ibl = (int *) malloc(sizeof(int)*(A->nproc+1)); A->ia = (int *) malloc(sizeof(int) * (A->n + 1));
memcpy(A->ibl,B->ibl,sizeof(int)*(A->nproc+1)); memcpy(A->ia, B->ia, sizeof(int) * (A->n + 1));
A->ia = (int *) malloc(sizeof(int)*(A->n+1)); A->ja = (int *) malloc(sizeof(int) * nnz);
memcpy(A->ia,B->ia,sizeof(int)*(A->n+1)); memcpy(A->ja, B->ja, sizeof(int) * nnz);
A->ja = (int *) malloc(sizeof(int)*nnz); A->A = (double *) malloc(sizeof(double) * nnz);
memcpy(A->ja,B->ja,sizeof(int)*nnz); memcpy(A->A, B->A, sizeof(double) * nnz);
A->A = (double *) malloc(sizeof(double)*nnz); }
memcpy(A->A,B->A,sizeof(double)*nnz); }
}
} void MatrixAssignDataK3biilu2(matrix_k3biilu2 *pA, matrix_k3biilu2 *pB) {
matrix_k3biilu2 *A = pA;
void MatrixAssignDataK3biilu2(void * pA, void * pB) matrix_k3biilu2 *B = pB;
{ if (A == NULL || B == NULL) throw INMOST::DataCorruptedInSolver;
matrix * A = (matrix *)pA; if (A != B) {
matrix * B = (matrix *)pB; if (A->n != 0) {
if( A == NULL || B == NULL ) throw INMOST::DataCorruptedInSolver; free(A->ibl);
if( A != B ) free(A->ia);