xc
ExpressionMatrix.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 //ExpressionMatrix.h
22 //Matrix of expressions
23 
24 #ifndef EXPRESSIONMATRIX_H
25 #define EXPRESSIONMATRIX_H
26 
27 #include "ZMatrix.h"
28 #include "utility/functions/algebra/ExprAlgebra.h"
29 #include "m_double.h"
30 
32 
34  {
35  friend class MExpressionMatrix;
36 
37  void eval(void);
38  void eval(const char *palabra,const ExprAlgebra &a);
39  void eval(const char *palabra,const double &d);
40  public:
41  ExpressionMatrix(size_type n_rows=1,size_type cols=1,const ExprAlgebra &val=ExprAlgebra())
42  : expression_matrix(n_rows,cols,val) {}
43  ExpressionMatrix(const ExpressionMatrix &other) : expression_matrix(other) {}
44  ExpressionMatrix &operator=(const ExpressionMatrix &m)
45  {
46  expression_matrix::operator=(m);
47  return *this;
48  }
49  explicit ExpressionMatrix(const m_double &m);
50  static LexAlgebra &LexA(void)
51  { return ExprAlgebra::LexA(); }
52  ExpressionMatrix &Trn(void);
53  ExpressionMatrix GetTrn(void) const;
54  bool Evaluable(void) const;
55  ExpressionMatrix Eval(void) const;
56  ExpressionMatrix Eval(const char *palabra,const ExprAlgebra &a);
57  ExpressionMatrix Eval(const char *palabra,const double &d);
58  m_double ToNum(void) const;
59  m_double ToNum(const char *palabra,const double &d) const;
60  ExpressionMatrix &operator*=(const double &d);
61  ExpressionMatrix &operator*=(const ExpressionMatrix &m);
62  friend ExpressionMatrix operator*(const ExpressionMatrix &m1,const ExpressionMatrix &m2);
63  friend ExpressionMatrix operator*(const m_double &m,const ExpressionMatrix &mE)
64  {
65  ExpressionMatrix retval= mE*ExpressionMatrix(m);
66  return retval;
67  }
68  friend ExpressionMatrix operator*(const ExpressionMatrix &mE, const m_double &m)
69  { return m*mE; }
70  };
71 
72 
73 ExpressionMatrix string_to_expression_matrix(const std::string &str);
74 
75 #endif
MatrixByBoxes< TBOX > GetTrn(void) const
Return transposed.
Definition: matrix_by_boxes.h:206
Matrix which element type has estructura de anillo respecto a las operaciones + y *...
Definition: ZMatrix.h:37
Definition: ExpressionMatrix.h:33
Léxico para expresiones algebraicas.
Definition: LexAlgebra.h:33
Expresión algebraica.
Definition: ExprAlgebra.h:32
Definition: MExpressionMatrix.h:34
static LexAlgebra & LexA(void)
Devuelve una referencia al léxico.
Definition: ProtoExpr.cc:36
MatrixByBoxes< TBOX > & Trn(void)
Transpose the matrix.
Definition: matrix_by_boxes.h:197