Go to the documentation of this file.
10 #ifndef vtk_m_VectorAnalysis_h
11 #define vtk_m_VectorAnalysis_h
31 template <
typename ValueType,
typename WeightType>
33 const ValueType& value1,
34 const WeightType& weight)
36 using ScalarType =
typename detail::FloatingPointReturnType<ValueType>::Type;
37 return static_cast<ValueType
>((WeightType(1) - weight) *
static_cast<ScalarType
>(value0) +
38 weight *
static_cast<ScalarType
>(value1));
40 template <
typename ValueType, vtkm::IdComponent N,
typename WeightType>
43 const WeightType& weight)
45 return (WeightType(1) - weight) * value0 + weight * value1;
47 template <
typename ValueType, vtkm::IdComponent N>
53 return (One - weight) * value0 + weight * value1;
66 using U =
typename detail::FloatingPointReturnType<T>::Type;
67 return static_cast<U
>(vtkm::Dot(x, x));
74 VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type MagnitudeTemplate(
78 return static_cast<typename detail::FloatingPointReturnType<T>::Type
>(vtkm::Abs(x));
82 VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type MagnitudeTemplate(
108 template <
typename T>
109 VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type RMagnitudeTemplate(
113 return T(1) / vtkm::Abs(x);
116 template <
typename T>
117 VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type RMagnitudeTemplate(
130 template <
typename T>
139 template <
typename T>
142 return vtkm::CopySign(T(1), x);
145 template <
typename T>
156 template <
typename T>
167 template <
typename T>
176 template <
typename T>
198 template <
typename T>
213 template <
typename T,
int N>
216 T uu = vtkm::Dot(u, u);
217 T uv = vtkm::Dot(u, v);
230 template <
typename T,
int N>
233 T uu = vtkm::Dot(u, u);
234 T uv = vtkm::Dot(u, v);
253 template <
typename T,
int N>
256 T tol =
static_cast<T
>(1e-6))
258 T tolsqr = tol * tol;
261 for (
int i = 0; i < N; ++i)
264 for (
int k = 0; k < j; ++k)
269 if (magsqr <= tolsqr)
274 outputs[j] = vtkm::RSqrt(magsqr) * u[j];
277 for (
int i = j; i < N; ++i)
286 #endif //vtk_m_VectorAnalysis_h
VTKM_EXEC_CONT vtkm::Float32 Sqrt(vtkm::Float32 x)
Compute the square root of x.
Definition: Math.h:958
VTKM_EXEC_CONT detail::FloatingPointReturnType< T >::Type MagnitudeSquared(const T &x)
Returns the square of the magnitude of a vector.
Definition: VectorAnalysis.h:64
Groups connected points that have the same field value.
Definition: Atomic.h:19
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
VTKM_EXEC_CONT detail::FloatingPointReturnType< T >::Type RMagnitude(const T &x)
Returns the reciprocal magnitude of a vector.
Definition: VectorAnalysis.h:131
VTKM_EXEC_CONT void Normalize(T &x)
Changes a vector to be normal.
Definition: VectorAnalysis.h:168
VTKM_EXEC_CONT detail::FloatingPointReturnType< T >::Type Magnitude(const T &x)
Returns the magnitude of a vector.
Definition: VectorAnalysis.h:100
VTKM_EXEC_CONT int Orthonormalize(const vtkm::Vec< vtkm::Vec< T, N >, N > &inputs, vtkm::Vec< vtkm::Vec< T, N >, N > &outputs, T tol=static_cast< T >(1e-6))
Perform Gram-Schmidt orthonormalization for 3-D vectors.
Definition: VectorAnalysis.h:254
VTKM_EXEC_CONT T Normal(const T &x)
Returns a normalized version of the given vector.
Definition: VectorAnalysis.h:157
VTKM_EXEC_CONT vtkm::Vec< typename detail::FloatingPointReturnType< T >::Type, 3 > Cross(const vtkm::Vec< T, 3 > &x, const vtkm::Vec< T, 3 > &y)
Find the cross product of two vectors.
Definition: VectorAnalysis.h:177
VTKM_EXEC_CONT T ProjectedDistance(const vtkm::Vec< T, N > &v, const vtkm::Vec< T, N > &u)
Project a vector onto another vector, returning only the projected distance.
Definition: VectorAnalysis.h:231
VTKM_EXEC_CONT T DifferenceOfProducts(T a, T b, T c, T d)
Definition: Math.h:2728
VTKM_EXEC_CONT vtkm::Vec< typename detail::FloatingPointReturnType< T >::Type, 3 > TriangleNormal(const vtkm::Vec< T, 3 > &a, const vtkm::Vec< T, 3 > &b, const vtkm::Vec< T, 3 > &c)
Find the normal of a triangle.
Definition: VectorAnalysis.h:200
VTKM_EXEC_CONT ValueType Lerp(const ValueType &value0, const ValueType &value1, const WeightType &weight)
Returns the linear interpolation of two values based on weight.
Definition: VectorAnalysis.h:32
Tag used to identify types that aren't Real, Integer, Scalar or Vector.
Definition: TypeTraits.h:20
Tag used to identify 0 dimensional types (scalars).
Definition: TypeTraits.h:44
Tag used to identify 1 dimensional types (vectors).
Definition: TypeTraits.h:51
A short fixed-length array.
Definition: Types.h:767
VTKM_EXEC_CONT vtkm::Vec< T, N > Project(const vtkm::Vec< T, N > &v, const vtkm::Vec< T, N > &u)
Project a vector onto another vector.
Definition: VectorAnalysis.h:214