MyraMath
Action.h
Go to the documentation of this file.
1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
6 #ifndef MYRAMATH_ITERATIVE_ACTION_H
7 #define MYRAMATH_ITERATIVE_ACTION_H
8 
14 #include <myramath/MYRAMATH_EXPORT.h>
16 
17 #include <utility>
18 
19 namespace myra {
20 
21 // Forward declarations.
22 template<class Number> class Vector;
23 template<class Number> class CVectorRange;
24 template<class Number> class VectorRange;
25 template<class Number> class Matrix;
26 template<class Number> class CMatrixRange;
27 template<class Number> class MatrixRange;
28 namespace detail { template<class Number> class ActionBase; }
29 template<class Number> class Action;
30 
32 // Contains/erases an underlying polymorphic ActionBase.
33 template<class Number> class MYRAMATH_EXPORT Action
34  {
35  public:
36 
37  // ------------------------------------ Value semantics.
38 
40  Action();
41 
44 
46  Action(const Action<Number>& that);
47 
49  void swap(Action<Number>& that);
50 
52  Action<Number>& operator= (Action<Number> that);
53 
55  ~Action();
56 
57  // ------------------------------------ Action API.
58 
60  std::pair<int,int> size() const;
61 
63  void multiply(const CMatrixRange<Number>& X, const MatrixRange<Number>& B, Number alpha, Number beta) const;
64 
66  void multiply(const CMatrixRange<Number>& X, const MatrixRange<Number>& B) const;
67 
69  // This matrix-vector multiply delegates to the corresponding matrix-matrix multiply.
70  void multiply(const CVectorRange<Number>& x, const VectorRange<Number>& b, Number alpha, Number beta) const;
71 
73  // This matrix-vector multiply delegates to the corresponding matrix-matrix multiply.
74  void multiply(const CVectorRange<Number>& x, const VectorRange<Number>& b) const;
75 
77  Matrix<Number> make_Matrix() const;
78 
79  private:
80 
81  // Underlying polymorphic instance, an ActionBase.
83 
84  };
85 
87 template<class Number> class ReflectNumber< Action<Number> >
88  { public: typedef Number type; };
89 
91 MYRAMATH_EXPORT Matrix<NumberS> operator * (const Action<NumberS>& A, const CMatrixRange<NumberS>& X);
93 MYRAMATH_EXPORT Matrix<NumberD> operator * (const Action<NumberD>& A, const CMatrixRange<NumberD>& X);
94 MYRAMATH_EXPORT Matrix<NumberC> operator * (const Action<NumberC>& A, const CMatrixRange<NumberC>& X);
95 MYRAMATH_EXPORT Matrix<NumberZ> operator * (const Action<NumberZ>& A, const CMatrixRange<NumberZ>& X);
97 
99 MYRAMATH_EXPORT Vector<NumberS> operator * (const Action<NumberS>& A, const CVectorRange<NumberS>& x);
101 MYRAMATH_EXPORT Vector<NumberD> operator * (const Action<NumberD>& A, const CVectorRange<NumberD>& x);
102 MYRAMATH_EXPORT Vector<NumberC> operator * (const Action<NumberC>& A, const CVectorRange<NumberC>& x);
103 MYRAMATH_EXPORT Vector<NumberZ> operator * (const Action<NumberZ>& A, const CVectorRange<NumberZ>& x);
105 
106 } // namespace myra
107 
108 #endif
Reflects Number trait for a Container, containers of Numbers (Matrix&#39;s, Vector&#39;s, etc) should special...
Definition: Number.h:55
Definition: Action.h:28
Tabulates an IxJ matrix. Allows random access, has column major layout to be compatible with BLAS/LAP...
Definition: bdsqr.h:20
Represents a mutable VectorRange.
Definition: axpy.h:21
Definition: syntax.dox:1
Represents a const MatrixRange.
Definition: bothcat.h:22
Definition: random.cpp:45
Various utility functions/classes related to scalar Number types.
Represents a mutable MatrixRange.
Definition: conjugate.h:26
Tabulates a vector of length N, allows random access.
Definition: conjugate.h:21
Applies the "Action" of a linear operator, b := A*x.
Definition: Action.h:29
Represents a const VectorRange.
Definition: axpy.h:20