operations.hh

Go to the documentation of this file.
1 
6 #ifndef operations_hh
7 #define operations_hh
8 
9 #include "basics/typedefs.hh"
11 
12 namespace concepts {
13 
14  template<class F>
15  F& inverse(F& f) { f = 1.0 / f; return f; }
16 
17  template<class F>
18  F inverse(const F& f) { return 1.0 / f; }
19 
20  template<class F, uint dim>
21  Mapping<F,dim>& inverse(Mapping<F,dim>& m) { m = m.inverse(); return m; }
22 
23  template<class F, uint dim>
24  Mapping<F,dim> inverse(const Mapping<F,dim>& m) { return m.inverse(); }
25 
26  template<class F, uint dim>
27  F determinant(const Mapping<F,dim>& m) { return m.determinant(); }
28 
29  template<class F, uint dim>
30  Mapping<F,dim>& adjugate(Mapping<F,dim>& m) { m = m.adjugate(); return m; }
31 
32  template<class F, uint dim>
33  Mapping<F,dim> adjugate(const Mapping<F,dim>& m) { return m.adjugate(); }
34 
35  template<class F, class G>
36  G& product(const F& m, G& v) {
37  v = m * v; return v;
38  }
39 
40  template<class F, class G>
41  G product(const F& m, const G& v) {
42  return m * v;
43  }
44 
45  template<class F, uint dim>
47  { m = m.prodTranspose(); return m; }
48 
49  template<class F, uint dim>
51  { return m.prodTranspose(); }
52 
53  template<class F, uint dim>
55  { m = m.transpose(); return m; }
56 
57  template<class F, uint dim>
59  { return m.transpose(); }
60 
61 
62  template <class F, class G, class H>
63  class multiplies : public std::binary_function<F, G, H>,
64  public OutputOperator
65  {
66  public:
67  H operator()(const F& x, const G& y) const { return x * y; }
68  protected:
69  virtual std::ostream& info(std::ostream& os) const {
70  return os << "*";
71  }
72  };
73 
74 } // namespace concepts
75 
76 namespace std {
77 
83  inline const concepts::Real conj(const concepts::Real& v) { return v; }
84 
90  inline const concepts::Real norm(const concepts::Real& v) {
91  return v * v;
92  }
93 
94  // Returns the absolute value of an unsigned integer
95  inline uint abs(const uint& v) {
96  return v;
97  }
98 
99 } // namespace std
100 
101 #endif // operations_hh
Mapping< F, DimX, DimY > inverse() const
Returns the inverse of the matrix.
F determinant() const
Returns the determinant of the matrix (only valid for square matrices)
const concepts::Real conj(const concepts::Real &v)
Returns the conjugate complex of a real value.
Definition: operations.hh:83
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: operations.hh:69
const concepts::Real norm(const concepts::Real &v)
Returns the square of a real value.
Definition: operations.hh:90
G & product(const F &m, G &v)
Definition: operations.hh:36
F & inverse(F &f)
Definition: operations.hh:15
Mapping< F, DimY, DimY > prodTranspose() const
Returns the product with the transpose of the matrix.
Mapping< F, DimX, DimY > transpose() const
Returns the transpose of the matrix.
H operator()(const F &x, const G &y) const
Definition: operations.hh:67
Mapping< F, dim > & prodTranspose(Mapping< F, dim > &m)
Definition: operations.hh:46
Mapping< F, dim > & transpose(Mapping< F, dim > &m)
Definition: operations.hh:54
Mapping< F, DimY, DimX > adjugate() const
Returns the adjugate of the matrix (only valid for square matrices) [f \mbox{adj}(M) = M^{-1}\det(M) ...
uint abs(const uint &v)
Definition: operations.hh:95
F determinant(const Mapping< F, dim > &m)
Definition: operations.hh:27
Class providing an output operator.
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Mapping< F, dim > & adjugate(Mapping< F, dim > &m)
Definition: operations.hh:30
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich