13 #ifndef __UT_FixedVector__
14 #define __UT_FixedVector__
26 static constexpr
struct ComponentFormType{}
CF{};
29 template<
typename T,ex
int SIZE,
bool INSTANTIATED=false>
53 template<
typename S,
bool S_INSTANTIATED>
94 template <
typename S,
bool S_INSTANTIATED>
107 template<
typename S,
bool S_INSTANTIATED>
118 template<
typename S,
bool S_INSTANTIATED>
124 result[i] =
vec[i] + that[i];
127 template<
typename S,
bool S_INSTANTIATED>
138 template<
typename S,
bool S_INSTANTIATED>
144 result[i] =
vec[i] - that[i];
147 template<
typename S,
bool S_INSTANTIATED>
153 template<
typename S,
bool S_INSTANTIATED>
159 result[i] =
vec[i] * that[i];
174 result[i] =
vec[i] * that;
177 template<
typename S,
bool S_INSTANTIATED>
183 template<
typename S,
bool S_INSTANTIATED>
189 result[i] =
vec[i] / that[i];
209 result[i] =
vec[i] * t;
226 template<
typename S,
bool S_INSTANTIATED>
231 if (
vec[i] !=
T(that[i]))
236 template<
typename S,
bool S_INSTANTIATED>
239 return !(*
this==that);
243 template<
typename S,
bool S_INSTANTIATED>
244 constexpr
SYS_FORCE_INLINE bool operator<(const UT_FixedVector<S,SIZE,S_INSTANTIATED> &that)
const noexcept
248 if (
vec[i] != that[i])
249 return (
vec[i] < that[i]);
251 return (
vec[SIZE-1] < that[SIZE-1]);
253 template<
typename S,
bool S_INSTANTIATED>
254 constexpr
SYS_FORCE_INLINE bool operator<=(const UT_FixedVector<S,SIZE,S_INSTANTIATED> &that)
const noexcept
258 if (
vec[i] != that[i])
259 return (
vec[i] < that[i]);
261 return (
vec[SIZE-1] <= that[SIZE-1]);
263 template<
typename S,
bool S_INSTANTIATED>
269 if (
vec[i] != that[i])
270 return (
vec[i] > that[i]);
272 return (
vec[SIZE-1] > that[SIZE-1]);
274 template<
typename S,
bool S_INSTANTIATED>
280 if (
vec[i] != that[i])
281 return (
vec[i] > that[i]);
283 return (
vec[SIZE-1] >= that[SIZE-1]);
318 if (!(
vec[i] >= -tol) || !(
vec[i] <= tol))
323 template<
typename S,
bool S_INSTANTIATED>
329 if (!(
vec[i] >= that[i]-tol) || !(
vec[i] <= that[i]+tol))
371 return SYSsqrt(len2);
373 template<
typename S,
bool S_INSTANTIATED>
377 TheType
result(TheType(
vec[0])*TheType(that[0]));
379 result += TheType(
vec[i])*TheType(that[i]);
382 template<
typename S,
bool S_INSTANTIATED>
386 TheType
v(TheType(
vec[0]) - TheType(that[0]));
390 v = TheType(
vec[i]) - TheType(that[i]);
395 template<
typename S,
bool S_INSTANTIATED>
399 return SYSsqrt(dist2);
420 template<
typename... AS >
436 template<
typename T,ex
int SIZE,
bool INSTANTIATED,
typename S>
442 result[i] = t * a[i];
446 template<
typename T, ex
int SIZE,
bool INSTANTIATED,
typename S,
bool S_INSTANTIATED>
462 template<
typename T,ex
int SIZE,
bool INSTANTIATED>
SYS_FORCE_INLINE T minComponent() const
constexpr UT_FixedVector(const CT::ComponentFormType, const AS...as) noexcept
Mat3< typename promote< S, T >::type > operator*(S scalar, const Mat3< T > &m)
Multiply each element of the given matrix by scalar and return the result.
constexpr SYS_FORCE_INLINE UT_FixedVector< T, SIZE > operator-() const noexcept
GLboolean GLboolean GLboolean b
#define SYS_STATIC_ASSERT(expr)
SYS_FORCE_INLINE bool isNan() const
constexpr SYS_FORCE_INLINE UT_FixedVector & operator=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) noexcept
constexpr SYS_FORCE_INLINE bool operator>(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const noexcept
SYS_FORCE_INLINE bool equalZero(T tol=T(SYS_FTOLERANCE)) const
SYS_FORCE_INLINE bool isZero() const noexcept
bool SYSisFinite(fpreal64 f)
UT_FixedVector< T, SIZE, INSTANTIATED > FixedVectorType
constexpr bool SYSisNan(const F f)
SYS_FORCE_INLINE MF length() const
static const exint TupleSize
constexpr SYS_FORCE_INLINE void operator/=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) noexcept
constexpr SYS_FORCE_INLINE UT_FixedVector< T, SIZE > operator*(T that) const noexcept
constexpr SYS_FORCE_INLINE void operator*=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) noexcept
constexpr SYS_FORCE_INLINE void operator-=(T that) noexcept
SYS_FORCE_INLINE UT_FixedVector()=default
constexpr SYS_FORCE_INLINE void operator+=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) noexcept
constexpr SYS_FORCE_INLINE T * data() noexcept
SYS_FORCE_INLINE MF normalize()
SYS_FORCE_INLINE UT_FixedVector(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) noexcept
SYS_FORCE_INLINE bool isFinite() const
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
constexpr SYS_FORCE_INLINE void operator/=(T that) noexcept
constexpr SYS_FORCE_INLINE UT_FixedVector< typename UT_StorageBetter< T, S >::Type, SIZE > operator*(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const noexcept
static constexpr struct UT_FixedVectorCT::ComponentFormType CF
constexpr SYS_FORCE_INLINE void operator*=(T that) noexcept
static const bool isVectorType
GLboolean GLboolean GLboolean GLboolean a
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, S >::Type distance2(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
constexpr SYS_FORCE_INLINE UT_FixedVector(const S that[SIZE]) noexcept
constexpr SYS_FORCE_INLINE UT_FixedVector(const T that) noexcept
Initializes every component to the same value.
SYS_FORCE_INLINE T maxComponent() const
constexpr SYS_FORCE_INLINE UT_FixedVector & operator=(const UT_FixedVector &that)=default
#define UT_ASSERT_EXPR_P(ZZ)
constexpr SYS_FORCE_INLINE UT_FixedVector< typename UT_StorageBetter< T, S >::Type, SIZE > operator+(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const noexcept
SYS_FORCE_INLINE UT_StorageNum< typename UT_StorageBetter< T, S >::Type >::MathFloat distance(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
constexpr SYS_FORCE_INLINE UT_FixedVector< typename UT_StorageBetter< T, S >::Type, SIZE > operator-(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const noexcept
constexpr SYS_FORCE_INLINE const UT_FixedVector & operator=(T that) noexcept
constexpr SYS_FORCE_INLINE bool operator==(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const noexcept
constexpr SYS_FORCE_INLINE void operator+=(T that) noexcept
constexpr SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, T >::Type length2() const noexcept
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, S >::Type dot(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const
typename SYS_SelectType< typename UT_StorageNum< typename UT_StorageBetter< T0, T1 >::Type >::AtLeast32Bit, T0, UT_StorageNum< typename UT_StorageBetter< T0, T1 >::Type >::theStorage==UT_Storage::INVALID >::type Type
constexpr SYS_FORCE_INLINE const T * data() const noexcept
static constexpr exint theSize
SYS_FORCE_INLINE bool isEqual(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that, S tol=S(SYS_FTOLERANCE)) const
UT_FixedVector< T, 1 > FixedVectorType
SYS_FORCE_INLINE UT_StorageAtLeast32Bit< T, S >::Type dot(const UT_FixedVector< T, SIZE, INSTANTIATED > &a, const UT_FixedVector< S, SIZE, S_INSTANTIATED > &b)
constexpr SYS_FORCE_INLINE void operator-=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) noexcept
typename UT_StorageNum< T >::MathFloat MF
constexpr SYS_FORCE_INLINE void negate() noexcept
SYS_FORCE_INLINE T avgComponent() const
constexpr SYS_FORCE_INLINE bool operator>=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const noexcept
constexpr SYS_FORCE_INLINE bool operator!=(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const noexcept
constexpr SYS_FORCE_INLINE const T & operator[](exint i) const noexcept
constexpr SYS_FORCE_INLINE UT_FixedVector< typename UT_StorageBetter< T, S >::Type, SIZE > operator/(const UT_FixedVector< S, SIZE, S_INSTANTIATED > &that) const noexcept
constexpr SYS_FORCE_INLINE UT_FixedVector< T, SIZE > operator/(T that) const noexcept
constexpr SYS_FORCE_INLINE T & operator[](exint i) noexcept