1 |
francois |
1158 |
//####//------------------------------------------------------------ |
2 |
|
|
//####//------------------------------------------------------------ |
3 |
|
|
//####// MAGiC |
4 |
|
|
//####// Jean Christophe Cuilliere et Vincent FRANCOIS |
5 |
|
|
//####// Departement de Genie Mecanique - UQTR |
6 |
|
|
//####//------------------------------------------------------------ |
7 |
|
|
//####// MAGIC est un projet de recherche de l equipe ERICCA |
8 |
|
|
//####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres |
9 |
|
|
//####// http://www.uqtr.ca/ericca |
10 |
|
|
//####// http://www.uqtr.ca/ |
11 |
|
|
//####//------------------------------------------------------------ |
12 |
|
|
//####//------------------------------------------------------------ |
13 |
|
|
//####// |
14 |
|
|
//####// matcreuse.h |
15 |
|
|
//####// |
16 |
|
|
//####//------------------------------------------------------------ |
17 |
|
|
//####//------------------------------------------------------------ |
18 |
|
|
//####// COPYRIGHT 2000-2024 |
19 |
|
|
//####// jeu 13 jun 2024 11:58:57 EDT |
20 |
|
|
//####//------------------------------------------------------------ |
21 |
|
|
//####//------------------------------------------------------------ |
22 |
souaissa |
161 |
#include "sl_vecteur.h"
|
23 |
souaissa |
108 |
#include <vector.h>
|
24 |
|
|
#include <math.h>
|
25 |
|
|
|
26 |
souaissa |
161 |
|
27 |
souaissa |
108 |
#ifndef matcrH
|
28 |
|
|
#define matcrH
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
francois |
1158 |
class vecteur;
|
33 |
|
|
|
34 |
|
|
class MatCr {
|
35 |
souaissa |
108 |
public:
|
36 |
francois |
1158 |
friend class vecteur;
|
37 |
souaissa |
108 |
struct CRSMatrix {
|
38 |
|
|
int N ; // dimension de la matrice
|
39 |
|
|
int NNZ ; // nombre de coefficients non nuls
|
40 |
|
|
double* a ; // coefficients non nuls (tableau de taille NNZ)
|
41 |
|
|
int* col_ind ; // indices de colonnes (tableau de taille NNZ)
|
42 |
|
|
int* row_ptr ; // pointeurs de lignes (tableau de taille N+1)
|
43 |
|
|
double* diag ; // elements diagonaux (tableau de taille N)
|
44 |
|
|
} ;
|
45 |
|
|
struct Coeff {
|
46 |
|
|
Coeff() { }
|
47 |
|
|
Coeff(int j, double val) : index(j), a(val) { }
|
48 |
|
|
int index ;
|
49 |
|
|
double a ;
|
50 |
|
|
} ;
|
51 |
|
|
|
52 |
souaissa |
161 |
class Row : public std::vector<Coeff>
|
53 |
|
|
{
|
54 |
|
|
public:
|
55 |
|
|
void add(int index, double val) ;
|
56 |
|
|
double get(int j);
|
57 |
|
|
void set(int index, double val);
|
58 |
|
|
double row_max() ;
|
59 |
|
|
} ;
|
60 |
souaissa |
108 |
|
61 |
|
|
MatCr(int dim) ;
|
62 |
|
|
|
63 |
|
|
~MatCr();
|
64 |
|
|
|
65 |
|
|
void add(int i, int j, double val);
|
66 |
|
|
void set(int i, int j, double val);
|
67 |
|
|
double get(int i, int j) ;
|
68 |
|
|
void diag(double* tmp_diag);
|
69 |
|
|
void clear() ;
|
70 |
|
|
int nnz() const;
|
71 |
|
|
void convert_to_CRS(const MatCr& M, CRSMatrix& M_CRS,int array_base);
|
72 |
|
|
void mult(double* y, CRSMatrix* M, double* x);
|
73 |
souaissa |
161 |
vecteur prod(MatCr& M, vecteur& x);
|
74 |
souaissa |
108 |
void pcg(double* b,double*x,double eps);
|
75 |
|
|
MatCr& Get_LU(int*perm,double&d) ;
|
76 |
|
|
void Get_Solution(int*perm,const double* b,double* r1);
|
77 |
|
|
double get_max();
|
78 |
souaissa |
161 |
get_norm(double*b,int n);
|
79 |
souaissa |
108 |
int dimension ;
|
80 |
|
|
Row* row ;
|
81 |
|
|
} ;
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
#endif
|