16#ifndef vtkVectorOperators_h
17#define vtkVectorOperators_h
25template <
typename A,
int Size>
29 for (
int i = 0; i < Size; ++i)
38template <
typename A,
int Size>
42 for (
int i = 0; i < Size; ++i)
44 ret[i] = v1[i] + v2[i];
51template <
typename T,
int Size>
55 for (
int dim = 0; dim < Size; ++dim)
65template <
typename A,
int Size>
69 for (
int i = 0; i < Size; ++i)
71 ret[i] = v1[i] - v2[i];
78template <
typename T,
int Size>
82 for (
int dim = 0; dim < Size; ++dim)
92template <
typename A,
int Size>
96 for (
int i = 0; i < Size; ++i)
98 ret[i] = v1[i] * v2[i];
105template <
typename A,
typename B,
int Size>
109 for (
int i = 0; i < Size; ++i)
111 ret[i] = v1[i] * scalar;
118template <
typename A,
int Size>
122 for (
int i = 0; i < Size; ++i)
124 ret[i] = v1[i] / v2[i];
131#define vtkVectorOperatorNegate(vectorType, type, size) \
132 inline vectorType operator-(const vectorType& v) \
134 return vectorType((-static_cast<vtkVector<type, size>>(v)).GetData()); \
136#define vtkVectorOperatorPlus(vectorType, type, size) \
137 inline vectorType operator+(const vectorType& v1, const vectorType& v2) \
140 (static_cast<vtkVector<type, size>>(v1) + static_cast<vtkVector<type, size>>(v2)) \
143#define vtkVectorOperatorMinus(vectorType, type, size) \
144 inline vectorType operator-(const vectorType& v1, const vectorType& v2) \
147 (static_cast<vtkVector<type, size>>(v1) - static_cast<vtkVector<type, size>>(v2)) \
150#define vtkVectorOperatorMultiply(vectorType, type, size) \
151 inline vectorType operator*(const vectorType& v1, const vectorType& v2) \
154 (static_cast<vtkVector<type, size>>(v1) * static_cast<vtkVector<type, size>>(v2)) \
157#define vtkVectorOperatorMultiplyScalar(vectorType, type, size) \
158 template <typename B> \
159 inline vectorType operator*(const vectorType& v1, const B& scalar) \
161 return vectorType((static_cast<vtkVector<type, size>>(v1) * scalar).GetData()); \
163#define vtkVectorOperatorMultiplyScalarPre(vectorType, type, size) \
164 template <typename B> \
165 inline vectorType operator*(const B& scalar, const vectorType& v1) \
167 return vectorType((static_cast<vtkVector<type, size>>(v1) * scalar).GetData()); \
169#define vtkVectorOperatorDivide(vectorType, type, size) \
170 inline vectorType operator/(const vectorType& v1, const vectorType& v2) \
173 (static_cast<vtkVector<type, size>>(v1) / static_cast<vtkVector<type, size>>(v2)) \
177#define vtkVectorOperatorMacro(vectorType, type, size) \
178 vtkVectorOperatorNegate(vectorType, type, size); \
179 vtkVectorOperatorPlus(vectorType, type, size); \
180 vtkVectorOperatorMinus(vectorType, type, size); \
181 vtkVectorOperatorMultiply(vectorType, type, size); \
182 vtkVectorOperatorMultiplyScalar(vectorType, type, size); \
183 vtkVectorOperatorMultiplyScalarPre(vectorType, type, size); \
184 vtkVectorOperatorDivide(vectorType, type, size)
Some derived classes for the different vectors commonly used.
templated base type for storage of vectors.
#define vtkVectorOperatorMacro(vectorType, type, size)
vtkVector< A, Size > operator/(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
vtkVector< A, Size > operator+(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
vtkVector< T, Size > operator-=(vtkVector< T, Size > &a, const vtkVector< T, Size > &b)
vtkVector< T, Size > operator+=(vtkVector< T, Size > &a, const vtkVector< T, Size > &b)
vtkVector< A, Size > operator*(const vtkVector< A, Size > &v1, const vtkVector< A, Size > &v2)
vtkVector< A, Size > operator-(const vtkVector< A, Size > &v)