xc
MMatrix.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. PĂ©rez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //MMatrix.h
22 //Matrix of matrices (or by boxes)
23 #ifndef MMATRIX_H
24 #define MMATRIX_H
25 
26 #include "m_double.h"
27 #include "matrix_by_boxes.h"
28 
30 
31 class vcolM;
32 
33 class MMatrix: public m_matrix
34  {
35  public:
37  MMatrix(void) : m_matrix(1,1) {}
39  MMatrix(size_type n_rows,size_type cols) : m_matrix(n_rows,cols) {}
41  MMatrix(size_type n_rows,size_type cols,const m_double &val)
42  : m_matrix(n_rows,cols,val) {}
43  MMatrix(const std::vector<size_t> &dim);
44  MMatrix(const std::vector<size_t> &dim_rows,const std::vector<size_t> &dim_cols);
46  MMatrix(const MMatrix &other) : m_matrix(other) {}
47  MMatrix& operator=(const MMatrix &m)
48  {
50  return *this;
51  }
52  MMatrix GetTrn(void) const;
53  MMatrix &operator*=(const m_double &m);
54  MMatrix &operator*=(const double &d);
55  MMatrix &operator*=(const MMatrix &m);
56  MMatrix &operator*=(const vcolM &M);
57  friend MMatrix operator+(const MMatrix &m1,const MMatrix &m2)
58  {
59  MMatrix retval(m1);
60  retval+=m2;
61  return retval;
62  }
63  friend MMatrix operator-(const MMatrix &m1,const MMatrix &m2)
64  {
65  MMatrix retval(m1);
66  retval-=m2;
67  return retval;
68  }
69  friend MMatrix operator*(const MMatrix &m,const double &d)
70  {
71  MMatrix retval(m);
72  retval*=d;
73  return retval;
74  }
75  friend MMatrix operator*(const double &d,const MMatrix &m)
76  { return m*d; }
77  friend MMatrix operator*(const MMatrix &m1,const MMatrix &m2);
78  friend MMatrix operator*(const m_double &m,const MMatrix &mM)
79  {
80  MMatrix retval(mM); retval*=m;
81  return retval;
82  }
83  friend MMatrix operator*(const MMatrix &mM, const m_double &m)
84  { return m*mM; }
85  friend MMatrix to_boxes(const MMatrix &Sample,const m_double &a);
86  friend MMatrix to_boxes(const std::vector<size_t> dim_n_rows,const std::vector<size_t> dim_n_columns,const m_double &a);
87  };
88 
89 #endif
MMatrix(const MMatrix &other)
Constructor de copia.
Definition: MMatrix.h:46
Matrix made of boxes.
Definition: matrix_by_boxes.h:31
MatrixByBoxes & operator=(const MatrixByBoxes &m)
Assignment operator.
Definition: matrix_by_boxes.h:112
MMatrix(size_type n_rows, size_type cols)
Constructor.
Definition: MMatrix.h:39
friend MMatrix to_boxes(const MMatrix &Sample, const m_double &a)
Convert the argument matrix in a block matrix.
Definition: MMatrix.cc:117
column vector with components are matrix.
Definition: vcolM.h:30
MMatrix GetTrn(void) const
Return the transposed matrix.
Definition: MMatrix.cc:73
MMatrix(void)
Constructor.
Definition: MMatrix.h:37
MMatrix(size_type n_rows, size_type cols, const m_double &val)
Constructor.
Definition: MMatrix.h:41
MMatrix & operator*=(const m_double &m)
Operador *=.
Definition: MMatrix.cc:39
Definition: MMatrix.h:33
Definition: Sample.h:28