Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Diff of /trunk/gadget/matrix.h
[mareframe] / trunk / gadget / matrix.h Repository:
ViewVC logotype

Diff of /trunk/gadget/matrix.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 12, Fri Jul 24 18:36:24 2015 UTC revision 13, Wed Jul 29 17:33:41 2015 UTC
# Line 1  Line 1 
1  #ifndef matrix_h  #ifndef matrix_h
2  #define matrix_h  #define matrix_h
3    
 //#include "doublevector.h"  
4  #include "intvector.h"  #include "intvector.h"
5  #include "doublematrix.h"  #include "doublematrix.h"
 //TODO doc all  
6  /**  /**
7   * \class Matrix   * \class Matrix
8   * \brief This class implements a Matrix   * \brief This class implements a Matrix of doubles, composed of an array of nc*nr doubles
9   */   */
10  class Matrix {  class Matrix {
11  public:  public:
12          /**          /**
13           * \brief This is the default DoubleMatrix constructor           * \brief This is the default Matrix constructor
14           */           */
15          Matrix() {          Matrix() {
16                  nrow = 0;                  nrow = 0;
# Line 21  Line 19 
19          }          }
20          ;          ;
21          /**          /**
22           * \brief This is the DoubleMatrix constructor for a specified size           * \brief This is the Matrix constructor for a specified size
23           * \param nr is the size of the vector to be created           * \param nr is the length of each row of the matrix
24           * \param nc is the length of each row to be created (ie. the size of the DoubleVector to be created for each row)           * \param nc is the length of each column of the matrix
25           * \param initial is the initial value for all the entries of the vector           * \param initial is the initial value for all the entries of the matrix
26           */           */
27          Matrix(int nr, int nc, double initial);          Matrix(int nr, int nc, double initial);
28          /**          /**
29           * \brief This is the DoubleMatrix constructor that creates a copy of an existing DoubleMatrix           * \brief This is the Matrix destructor
30           * \param initial is the DoubleMatrix to copy           * \note This will free all the memory allocated to all the elements of the matrix
          */  
         //TODO OJO  
         //Matrix(const DoubleMatrix& initial);  
         /**  
          * \brief This is the DoubleMatrix destructor  
          * \note This will free all the memory allocated to all the elements of the vector  
31           */           */
32          ~Matrix();          ~Matrix();
33          /**          /**
34           * \brief This will return the number of columns in row i of the vector           * \brief This will return the number of rows of the matrix
35           * \param i is the row of the vector to have the number of columns counted           * \return the number of rows of the matrix
          * \return the number of columns in row i of the vector  
          * \note This is the number of entries in the DoubleVector that is entry i of the DoubleMatrix  
          */  
 //  int Ncol(int i = 0) const { return v[i]->Size(); };  
         /**  
          * \brief This will return the number of rows of the vector  
          * \return the number of rows of the vector  
36           */           */
37          int Nrow() const {          int Nrow() const {
38                  return nrow;                  return nrow;
39          }          }
40          ;          ;
41          /**          /**
42           * \brief This will return the value of an element of the vector           * \brief This will return the number of columns of the matrix
43           * \param pos is the element of the vector to be returned           * \return the number of columns of the matrix
          * \return the value of the specified element  
44           */           */
   
45          int Ncol() const {          int Ncol() const {
46                  return ncol;                  return ncol;
47          }          }
48          ;          ;
49            /**
50  //  double** GetMatrix () const { return m;};           * \brief This will return the pointer to the row i of the matrix
51             * \param i is the row to be returned
52             * \return the pointer to the part of the array where the specified row begins
53             */
54    double* operator [] (int i) { return m + (i*ncol); };    double* operator [] (int i) { return m + (i*ncol); };
55            /**
56             * \brief This will return the pointer to the row i of the matrix
57             * \param i is the row to be returned
58             * \return the pointer to the part of the array where the specified row begins
59             */
60    const double* operator [] (int i) const { return m + (i*ncol); };    const double* operator [] (int i) const { return m + (i*ncol); };
61          /**          /**
62           * \brief This will return the value of an element of the vector           * \brief This will add new entries to the matrix
63           * \param pos is the element of the vector to be returned           * \param add is the number of new entries to the matrix
64           * \return the value of the specified element           * \param length is the number of entries to the Matrix that is created
          */  
 //  const DoubleVector& operator [] (int pos) const { return *v[pos]; };  
         /**  
          * \brief This will add new entries to the vector  
          * \param add is the number of new entries to the vector  
          * \param length is the number of entries to the DoubleVector that is created  
65           * \param value is the value that will be entered for the new entries           * \param value is the value that will be entered for the new entries
66           */           */
67          void AddRows(int add, int length, double value);          void AddRows(int add, int length, double value);
68          /**          /**
69           * \brief This will delete an entry from the vector           * \brief This will reset the matrix
70           * \param pos is the element of the vector to be deleted           * \note This will delete every entry from the matrix and set the number of rows and columns to zero
          * \note This will free the memory allocated to the deleted element of the vector  
71           */           */
72  //  void Delete(int pos);          void Reset();
73          /**          /**
74           * \brief This will reset the vector           * \brief This is will initialize the matrix to a specified size with a initial value
75           * \note This will delete every entry from the vector and set the number of rows to zero           * \param nr is the length of each row of the matrix
76             * \param nc is the length of each column of the matrix
77             * \param initial is the initial value for all the entries of the matrix
78           */           */
         void Reset();  
   
         //FIXME: doc  
79          void Initialize(int nr, int nc, double initial);          void Initialize(int nr, int nc, double initial);
80          /**          /**
81           * \brief This function will set all of the entries of the vector to zero           * \brief This function will set all of the entries of the matrix to zero
82           */           */
83          void setToZero();          void setToZero();
84          /**          /**
85           * \brief This function will print the data stored in the vector           * \brief This function will print the data stored in the matrix
86           * \param outfile is the ofstream that all the model information gets sent to           * \param outfile is the ofstream that all the model information gets sent to
87           */           */
88          void Print(ofstream& outfile) const;          void Print(ofstream& outfile) const;
         /**  
          * \brief This operator will set the vector equal to an existing DoubleMatrix  
          * \param d is the DoubleMatrix to copy  
          */  
 //  Matrix& operator = (const Matrix& d);  
 //      double GetValue(int i, int j) const {  
 //              return m[i * ncol + j];  
 //      }  
 //      ;  
 //  
 //      void SetValue(int i, int j, double value) const {  
 //              m[i * ncol + j] = value;  
 //      }  
 //      ;  
   
89  protected:  protected:
90          /**          /**
91           * \brief This is number of rows of the vector           * \brief This is number of rows of the matrix
92           */           */
93          int nrow;          int nrow;
94            /**
95             * \brief This is number of columns of the matrix
96             */
97          int ncol;          int ncol;
   
         //FIXME: doc  
98          /**          /**
99           * \brief This is the vector of DoubleVector values           * \brief This is the array of nr*nc doubles that represents the matrix
100           */           */
         //DoubleVector** v;  
         //double** v;  
101          double *m;          double *m;
102  };  };
103    

Legend:
Removed from v.12  
changed lines
  Added in v.13

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge