VectorExpression.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: VectorExpression.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Base class for vector expression.
6 > Created Time: 2017/09/27
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_VECTOR_EXPRESSION_H
10 #define CUBBYFLOW_VECTOR_EXPRESSION_H
11 
12 #include <Core/Utils/Functors.h>
13 
14 #include <functional>
15 
16 namespace CubbyFlow
17 {
18  // MARK: VectorExpression
27  template <typename T, typename E>
29  {
30  public:
32  size_t size() const;
33 
35  const E& operator()() const;
36  };
37 
38  // MARK: VectorUnaryOp
49  template <typename T, typename E, typename Op>
50  class VectorUnaryOp : public VectorExpression<T, VectorUnaryOp<T, E, Op>>
51  {
52  public:
54  VectorUnaryOp(const E& u);
55 
57  size_t size() const;
58 
60  T operator[](size_t i) const;
61 
62  private:
63  const E& m_u;
64  Op m_op;
65  };
66 
67  // MARK: VectorUnaryOp Aliases
69  template <typename T, typename E, typename U>
71 
72  // MARK: VectorBinaryOp
84  template <typename T, typename E1, typename E2, typename Op>
85  class VectorBinaryOp : public VectorExpression<T, VectorBinaryOp<T, E1, E2, Op>>
86  {
87  public:
89  VectorBinaryOp(const E1& u, const E2& v);
90 
92  size_t size() const;
93 
95  T operator[](size_t i) const;
96 
97  private:
98  const E1& m_u;
99  const E2& m_v;
100  Op m_op;
101  };
102 
113  template <typename T, typename E, typename Op>
114  class VectorScalarBinaryOp : public VectorExpression<T, VectorScalarBinaryOp<T, E, Op>>
115  {
116  public:
118  VectorScalarBinaryOp(const E& u, const T& v);
119 
121  size_t size() const;
122 
124  T operator[](size_t i) const;
125 
126  private:
127  const E& m_u;
128  T m_v;
129  Op m_op;
130  };
131 
132  // MARK: VectorBinaryOp Aliases
134  template <typename T, typename E1, typename E2>
136 
138  template <typename T, typename E>
140 
142  template <typename T, typename E1, typename E2>
144 
146  template <typename T, typename E>
148 
150  template <typename T, typename E>
152 
154  template <typename T, typename E1, typename E2>
156 
158  template <typename T, typename E>
160 
162  template <typename T, typename E1, typename E2>
164 
166  template <typename T, typename E>
168 
170  template <typename T, typename E>
172 
173  // MARK: Global Functions
175  template <typename T, typename E>
177 
179  template <typename T, typename E>
181 
183  template <typename T, typename E1, typename E2>
185 
187  template <typename T, typename E>
189 
191  template <typename T, typename E>
193 
195  template <typename T, typename E1, typename E2>
197 
199  template <typename T, typename E>
201 
203  template <typename T, typename E>
205 
207  template <typename T, typename E1, typename E2>
209 
211  template <typename T, typename E>
213 
215  template <typename T, typename E>
217 
219  template <typename T, typename E1, typename E2>
221 }
222 
224 
225 #endif
const E & operator()() const
Returns actual implementation (the subclass).
Definition: VectorExpression-Impl.h:24
T operator[](size_t i) const
Returns vector element at i.
Definition: VectorExpression-Impl.h:43
T operator[](size_t i) const
Returns vector element at i.
Definition: VectorExpression-Impl.h:62
Matrix< T, 2, 2 > operator+(const Matrix< T, 2, 2 > &a, const Matrix< T, 2, 2 > &b)
Returns a + b (element-size).
Definition: Matrix2x2-Impl.h:660
size_t size() const
Size of the matrix.
Definition: VectorExpression-Impl.h:56
T operator[](size_t i) const
Returns vector element at i.
Definition: VectorExpression-Impl.h:80
Base class for vector expression.
Definition: VectorExpression.h:28
size_t size() const
Size of the matrix.
Definition: VectorExpression-Impl.h:37
VectorBinaryOp(const E1 &u, const E2 &v)
Constructs binary operation expression for given input vector expressions.
Definition: VectorExpression-Impl.h:50
Vector expression for unary operation.
Definition: VectorExpression.h:50
Vector expression for binary operation.
Definition: VectorExpression.h:85
VectorUnaryOp(const E &u)
Constructs unary operation expression for given input expression.
Definition: VectorExpression-Impl.h:31
Matrix< T, 2, 2 > operator/(const Matrix< T, 2, 2 > &a, T b)
Definition: Matrix2x2-Impl.h:720
Definition: pybind11Utils.h:24
size_t size() const
Size of the matrix.
Definition: VectorExpression-Impl.h:74
Matrix< T, 2, 2 > operator-(const Matrix< T, 2, 2 > &a)
Returns a matrix with opposite sign.
Definition: Matrix2x2-Impl.h:654
size_t size() const
Size of the vector.
Definition: VectorExpression-Impl.h:18
VectorScalarBinaryOp(const E &u, const T &v)
Constructs a binary expression for given vector and scalar.
Definition: VectorExpression-Impl.h:68
Vector< T, 3 > operator*(const Quaternion< T > &q, const Vector< T, 3 > &v)
Returns quaternion q * vector v.
Definition: Quaternion-Impl.h:481
Vector expression for matrix-scalar binary operation.
Definition: VectorExpression.h:114