[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 70 2013-01-10 10:24:23Z 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 |
|
---|
[70] | 59 | /// @todo Documentation
|
---|
[3] | 60 | matrice &operator+=(const matrice &m); //m+=m1
|
---|
[70] | 61 | /// @todo Documentation
|
---|
[3] | 62 | matrice &operator-=(const matrice &m); //m-=m1
|
---|
| 63 |
|
---|
[70] | 64 | /// @todo Documentation
|
---|
[3] | 65 | matrice operator+(const matrice &m1) const; //m=m1+m2
|
---|
[70] | 66 | /// @todo Documentation
|
---|
[3] | 67 | matrice operator-(const matrice &m1) const; //m=m1-m2
|
---|
[70] | 68 | /// @todo Documentation
|
---|
[3] | 69 | matrice operator*(const matrice &m1) const; //m=m1*m2
|
---|
| 70 |
|
---|
[70] | 71 | /// @todo Documentation
|
---|
[3] | 72 | matrice &operator+=(double x); //m+=x
|
---|
[70] | 73 | /// @todo Documentation
|
---|
[3] | 74 | matrice &operator-=(double x); //m-=x
|
---|
| 75 |
|
---|
[70] | 76 | /// @todo Documentation
|
---|
[3] | 77 | matrice operator+(double x)const; //m+x
|
---|
[70] | 78 | /// @todo Documentation
|
---|
[3] | 79 | matrice operator-(double x)const; //m-x
|
---|
[70] | 80 | /// @todo Documentation
|
---|
[3] | 81 | matrice operator*(double x)const; //m*x
|
---|
[70] | 82 | /// @todo Documentation
|
---|
[3] | 83 | matrice operator/(double x)const; //m/x
|
---|
| 84 |
|
---|
[70] | 85 | /// @todo Documentation
|
---|
[3] | 86 | friend matrice operator+(double x,matrice m1) {return m1+x ;} // x+m ;
|
---|
[70] | 87 | /// @todo Documentation
|
---|
[3] | 88 | friend matrice operator-(double x,matrice m1) {return m1-x ;} // x-m ;
|
---|
[70] | 89 | /// @todo Documentation
|
---|
[3] | 90 | friend matrice operator*(double x,matrice m1) {return m1*x ;} // x*m ;
|
---|
| 91 |
|
---|
[70] | 92 | /// Matrix transpose.
|
---|
| 93 | matrice T();
|
---|
| 94 | /// Matrix inverse.
|
---|
| 95 | matrice I();
|
---|
[3] | 96 |
|
---|
[70] | 97 | /// @todo Documentation
|
---|
[3] | 98 | double &operator()(unsigned short int i, unsigned short int j); // ecriture m(i,j)=x
|
---|
[70] | 99 | /// @todo Documentation
|
---|
[3] | 100 | double operator()(unsigned short int i, unsigned short int j) const; //lecture x=m(i,j)
|
---|
[70] | 101 | /// @todo Documentation
|
---|
[3] | 102 | double &operator()(unsigned short int i); // ecriture m(i)=x
|
---|
[70] | 103 | /// @todo Documentation
|
---|
[3] | 104 | double operator()(unsigned short int i) const; //lecture x=m(i)
|
---|
| 105 |
|
---|
[70] | 106 | /// @todo Documentation
|
---|
[3] | 107 | void print(const char *nom);
|
---|
| 108 | };
|
---|
| 109 |
|
---|
| 110 | #endif // MATRIX_H
|
---|