1 |
souaissa |
161 |
#include "sl_vecteur.h"
|
2 |
souaissa |
108 |
#include <vector.h>
|
3 |
|
|
#include <math.h>
|
4 |
|
|
//---------------------------------------------------------------------------
|
5 |
|
|
|
6 |
souaissa |
161 |
|
7 |
souaissa |
108 |
#ifndef matcrH
|
8 |
|
|
#define matcrH
|
9 |
|
|
//---------------------------------------------------------------------------
|
10 |
|
|
#ifdef WINDOWS_VERSION
|
11 |
|
|
#ifdef BUILT_DLL_SOLVEUR
|
12 |
|
|
#define DLLPORTSOLVEUR __declspec(dllexport)
|
13 |
|
|
#else
|
14 |
|
|
#define DLLPORTSOLVEUR __declspec(dllimport)
|
15 |
|
|
#endif
|
16 |
|
|
#else
|
17 |
|
|
#define DLLPORTSOLVEUR
|
18 |
|
|
#endif
|
19 |
|
|
|
20 |
|
|
|
21 |
souaissa |
161 |
class DLLPORTSOLVEUR vecteur;
|
22 |
souaissa |
108 |
|
23 |
|
|
class DLLPORTSOLVEUR MatCr {
|
24 |
|
|
public:
|
25 |
souaissa |
161 |
friend class DLLPORTSOLVEUR vecteur;
|
26 |
souaissa |
108 |
struct CRSMatrix {
|
27 |
|
|
int N ; // dimension de la matrice
|
28 |
|
|
int NNZ ; // nombre de coefficients non nuls
|
29 |
|
|
double* a ; // coefficients non nuls (tableau de taille NNZ)
|
30 |
|
|
int* col_ind ; // indices de colonnes (tableau de taille NNZ)
|
31 |
|
|
int* row_ptr ; // pointeurs de lignes (tableau de taille N+1)
|
32 |
|
|
double* diag ; // elements diagonaux (tableau de taille N)
|
33 |
|
|
} ;
|
34 |
|
|
struct Coeff {
|
35 |
|
|
Coeff() { }
|
36 |
|
|
Coeff(int j, double val) : index(j), a(val) { }
|
37 |
|
|
int index ;
|
38 |
|
|
double a ;
|
39 |
|
|
} ;
|
40 |
|
|
|
41 |
souaissa |
161 |
class Row : public std::vector<Coeff>
|
42 |
|
|
{
|
43 |
|
|
public:
|
44 |
|
|
void add(int index, double val) ;
|
45 |
|
|
double get(int j);
|
46 |
|
|
void set(int index, double val);
|
47 |
|
|
double row_max() ;
|
48 |
|
|
} ;
|
49 |
souaissa |
108 |
|
50 |
|
|
MatCr(int dim) ;
|
51 |
|
|
|
52 |
|
|
~MatCr();
|
53 |
|
|
|
54 |
|
|
// aij <- aij + val
|
55 |
|
|
void add(int i, int j, double val);
|
56 |
|
|
void set(int i, int j, double val);
|
57 |
|
|
double get(int i, int j) ;
|
58 |
|
|
void diag(double* tmp_diag);
|
59 |
|
|
void clear() ;
|
60 |
|
|
int nnz() const;
|
61 |
souaissa |
161 |
//void mul(double* y, const double* x);
|
62 |
souaissa |
108 |
void convert_to_CRS(const MatCr& M, CRSMatrix& M_CRS,int array_base);
|
63 |
|
|
void mult(double* y, CRSMatrix* M, double* x);
|
64 |
souaissa |
161 |
vecteur prod(MatCr& M, vecteur& x);
|
65 |
souaissa |
108 |
void pcg(double* b,double*x,double eps);
|
66 |
|
|
MatCr& Get_LU(int*perm,double&d) ;
|
67 |
|
|
void Get_Solution(int*perm,const double* b,double* r1);
|
68 |
|
|
double get_max();
|
69 |
souaissa |
161 |
get_norm(double*b,int n);
|
70 |
souaissa |
108 |
int dimension ;
|
71 |
|
|
Row* row ;
|
72 |
|
|
} ;
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
#endif
|