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