[76] | 1 | // %pacpus:license{
|
---|
[62] | 2 | // This file is part of the PACPUS framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[76] | 4 | // %pacpus:license}
|
---|
[66] | 5 | /// @file
|
---|
[62] | 6 | /// @author Firstname Surname <firstname.surname@utc.fr>
|
---|
| 7 | /// @date Month, Year
|
---|
| 8 | /// @version $Id: matrice.h 76 2013-01-10 17:05:10Z kurdejma $
|
---|
| 9 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 10 | /// @brief Matrix algebra functions.
|
---|
| 11 | ///
|
---|
| 12 | /// Detailed description.
|
---|
| 13 |
|
---|
[3] | 14 | #ifndef MATRIX_H
|
---|
| 15 | #define MATRIX_H
|
---|
| 16 |
|
---|
| 17 | typedef enum
|
---|
| 18 | {
|
---|
| 19 | ONES,
|
---|
| 20 | ZEROS,
|
---|
| 21 | IDENTITY
|
---|
| 22 | } t_m;
|
---|
| 23 |
|
---|
[69] | 24 | /// Simple matrix.
|
---|
| 25 | /// @todo Documentation
|
---|
[3] | 26 | class matrice
|
---|
| 27 | {
|
---|
| 28 | typedef double *ligne;
|
---|
| 29 | ligne *lignes;
|
---|
| 30 | unsigned short int n; // Nombre de lignes (1erparamètre).
|
---|
| 31 | unsigned short int m; // Nombre de colonnes (2èmeparamètre).
|
---|
| 32 |
|
---|
| 33 | public:
|
---|
[69] | 34 | /// Ctor
|
---|
[3] | 35 | matrice();
|
---|
[69] | 36 | /// Ctor
|
---|
[3] | 37 | matrice(unsigned short int nl, unsigned short int nc);
|
---|
[69] | 38 | /// Ctor
|
---|
[3] | 39 | matrice(unsigned short int nl, unsigned short int nc,t_m type);
|
---|
[69] | 40 | /// Copy ctor
|
---|
[3] | 41 | matrice(const matrice &source); //constructeur par copie
|
---|
[69] | 42 | /// Dtor
|
---|
[3] | 43 | virtual ~matrice(void);
|
---|
| 44 |
|
---|
[69] | 45 | /// Allocates matrix data
|
---|
| 46 | /// @todo Rename
|
---|
| 47 | void Alloue(unsigned short int nl, unsigned short int nc);
|
---|
| 48 |
|
---|
| 49 | /// Assignment operator for matrix operand
|
---|
[3] | 50 | matrice &operator=(const matrice &m);//m=m1
|
---|
[69] | 51 | /// Assignment operator for scalar operand
|
---|
[3] | 52 | matrice &operator=(double x); //m=x
|
---|
[69] | 53 | /// Conversion operator to double
|
---|
| 54 | /// @todo FIXME
|
---|
| 55 | operator double() const
|
---|
| 56 | {
|
---|
| 57 | return **lignes;
|
---|
| 58 | }
|
---|
[3] | 59 |
|
---|
[70] | 60 | /// @todo Documentation
|
---|
[3] | 61 | matrice &operator+=(const matrice &m); //m+=m1
|
---|
[70] | 62 | /// @todo Documentation
|
---|
[3] | 63 | matrice &operator-=(const matrice &m); //m-=m1
|
---|
| 64 |
|
---|
[70] | 65 | /// @todo Documentation
|
---|
[3] | 66 | matrice operator+(const matrice &m1) const; //m=m1+m2
|
---|
[70] | 67 | /// @todo Documentation
|
---|
[3] | 68 | matrice operator-(const matrice &m1) const; //m=m1-m2
|
---|
[70] | 69 | /// @todo Documentation
|
---|
[3] | 70 | matrice operator*(const matrice &m1) const; //m=m1*m2
|
---|
| 71 |
|
---|
[70] | 72 | /// @todo Documentation
|
---|
[3] | 73 | matrice &operator+=(double x); //m+=x
|
---|
[70] | 74 | /// @todo Documentation
|
---|
[3] | 75 | matrice &operator-=(double x); //m-=x
|
---|
| 76 |
|
---|
[70] | 77 | /// @todo Documentation
|
---|
[3] | 78 | matrice operator+(double x)const; //m+x
|
---|
[70] | 79 | /// @todo Documentation
|
---|
[3] | 80 | matrice operator-(double x)const; //m-x
|
---|
[70] | 81 | /// @todo Documentation
|
---|
[3] | 82 | matrice operator*(double x)const; //m*x
|
---|
[70] | 83 | /// @todo Documentation
|
---|
[3] | 84 | matrice operator/(double x)const; //m/x
|
---|
| 85 |
|
---|
[70] | 86 | /// @todo Documentation
|
---|
[3] | 87 | friend matrice operator+(double x,matrice m1) {return m1+x ;} // x+m ;
|
---|
[70] | 88 | /// @todo Documentation
|
---|
[3] | 89 | friend matrice operator-(double x,matrice m1) {return m1-x ;} // x-m ;
|
---|
[70] | 90 | /// @todo Documentation
|
---|
[3] | 91 | friend matrice operator*(double x,matrice m1) {return m1*x ;} // x*m ;
|
---|
| 92 |
|
---|
[70] | 93 | /// Matrix transpose.
|
---|
| 94 | matrice T();
|
---|
| 95 | /// Matrix inverse.
|
---|
| 96 | matrice I();
|
---|
[3] | 97 |
|
---|
[70] | 98 | /// @todo Documentation
|
---|
[3] | 99 | double &operator()(unsigned short int i, unsigned short int j); // ecriture m(i,j)=x
|
---|
[70] | 100 | /// @todo Documentation
|
---|
[3] | 101 | double operator()(unsigned short int i, unsigned short int j) const; //lecture x=m(i,j)
|
---|
[70] | 102 | /// @todo Documentation
|
---|
[3] | 103 | double &operator()(unsigned short int i); // ecriture m(i)=x
|
---|
[70] | 104 | /// @todo Documentation
|
---|
[3] | 105 | double operator()(unsigned short int i) const; //lecture x=m(i)
|
---|
| 106 |
|
---|
[70] | 107 | /// @todo Documentation
|
---|
[3] | 108 | void print(const char *nom);
|
---|
| 109 | };
|
---|
| 110 |
|
---|
| 111 | #endif // MATRIX_H
|
---|