| 1 | // This file is part of the PACPUS framework distributed under the
|
|---|
| 2 | // CECILL-C License, Version 1.0.
|
|---|
| 3 | //
|
|---|
| 4 | /// @file
|
|---|
| 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 |
|
|---|
| 13 | #ifndef MATRIX_H
|
|---|
| 14 | #define MATRIX_H
|
|---|
| 15 |
|
|---|
| 16 | typedef enum
|
|---|
| 17 | {
|
|---|
| 18 | ONES,
|
|---|
| 19 | ZEROS,
|
|---|
| 20 | IDENTITY
|
|---|
| 21 | } t_m;
|
|---|
| 22 |
|
|---|
| 23 | /// Simple matrix.
|
|---|
| 24 | /// @todo Documentation
|
|---|
| 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:
|
|---|
| 33 | /// Ctor
|
|---|
| 34 | matrice();
|
|---|
| 35 | /// Ctor
|
|---|
| 36 | matrice(unsigned short int nl, unsigned short int nc);
|
|---|
| 37 | /// Ctor
|
|---|
| 38 | matrice(unsigned short int nl, unsigned short int nc,t_m type);
|
|---|
| 39 | /// Copy ctor
|
|---|
| 40 | matrice(const matrice &source); //constructeur par copie
|
|---|
| 41 | /// Dtor
|
|---|
| 42 | virtual ~matrice(void);
|
|---|
| 43 |
|
|---|
| 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
|
|---|
| 49 | matrice &operator=(const matrice &m);//m=m1
|
|---|
| 50 | /// Assignment operator for scalar operand
|
|---|
| 51 | matrice &operator=(double x); //m=x
|
|---|
| 52 | /// Conversion operator to double
|
|---|
| 53 | /// @todo FIXME
|
|---|
| 54 | operator double() const
|
|---|
| 55 | {
|
|---|
| 56 | return **lignes;
|
|---|
| 57 | }
|
|---|
| 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
|
|---|