7 #ifndef OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED 8 #define OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED 14 #include <type_traits> 28 template<
int SIZE,
typename T>
35 static const int size = SIZE;
37 #if OPENVDB_ABI_VERSION_NUMBER >= 8 50 for (
int i = 0; i < SIZE; ++i) {
60 for (
int i = 0; i < SIZE; ++i) {
74 template <
int src_size,
typename src_valtype>
76 enum { COPY_END = (SIZE < src_size ? SIZE : src_size) };
78 for (
int i = 0; i < COPY_END; ++i) {
81 for (
int i = COPY_END; i < SIZE; ++i) {
105 template <
typename S>
107 for (
int i = 0; i < SIZE; ++i) {
124 std::ostringstream buffer;
129 for (
unsigned j(0); j < SIZE; j++) {
130 if (j) buffer <<
", ";
139 void write(std::ostream& os)
const {
140 os.write(reinterpret_cast<const char*>(&mm),
sizeof(T)*SIZE);
143 is.read(reinterpret_cast<char*>(&mm),
sizeof(T)*SIZE);
148 for (
int i = 0; i < SIZE; ++i) {
156 for (
int i = 0; i < SIZE; ++i) {
164 for (
int i = 0; i < SIZE; ++i) {
172 for (
int i = 0; i < SIZE; ++i) {
187 template<
int SIZE,
typename T0,
typename T1>
191 for (
int i = 0; i < SIZE-1; ++i) {
194 return t0[SIZE-1] < t1[SIZE-1];
199 template<
int SIZE,
typename T0,
typename T1>
203 for (
int i = 0; i < SIZE-1; ++i) {
206 return t0[SIZE-1] > t1[SIZE-1];
214 template<
int SIZE,
typename T>
219 for (
int i = 0; i < SIZE; ++i) result[i] =
math::Abs(t[i]);
224 template<
int SIZE,
typename T>
228 template<
int SIZE,
typename T>
232 template<
int SIZE,
typename T>
236 template<
int SIZE,
typename T>
243 template <
int SIZE,
typename T>
244 std::ostream& operator<<(std::ostream& ostr, const Tuple<SIZE, T>& classname)
246 ostr << classname.str();
254 #endif // OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED T ValueType
Definition: Tuple.h:33
bool isNan() const
True if a Nan is present in this tuple.
Definition: Tuple.h:147
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:444
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Tuple(Tuple< src_size, src_valtype > const &src)
Conversion constructor.
Definition: Tuple.h:75
void write(std::ostream &os) const
Definition: Tuple.h:139
T & operator[](int i)
Definition: Tuple.h:94
void read(std::istream &is)
Definition: Tuple.h:142
value_type * asV()
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:113
bool isNan(const Tuple< SIZE, T > &t)
Return true if a Nan is present in the tuple.
Definition: Tuple.h:225
void toV(S *v) const
Copies this tuple into an array of a compatible type.
Definition: Tuple.h:106
std::string str() const
Definition: Tuple.h:123
bool isFinite() const
True if no Nan or Inf values are present.
Definition: Tuple.h:163
Dummy class for tag dispatch of conversion constructors.
Definition: Tuple.h:23
Definition: Exceptions.h:13
T mm[SIZE]
Definition: Tuple.h:179
value_type const * asV() const
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:117
bool isZero(const Tuple< SIZE, T > &t)
Return true if all elements are exactly equal to zero.
Definition: Tuple.h:237
Tuple< SIZE, T > Abs(const Tuple< SIZE, T > &t)
Definition: Tuple.h:216
bool operator>(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:201
auto PrintCast(const T &val) -> typename std::enable_if<!std::is_same< T, int8_t >::value &&!std::is_same< T, uint8_t >::value, const T & >::type
8-bit integer values print to std::ostreams as characters. Cast them so that they print as integers i...
Definition: Math.h:885
bool isInfinite(const Tuple< SIZE, T > &t)
Return true if an Inf is present in the tuple.
Definition: Tuple.h:229
bool isInfinite() const
True if an Inf is present in this tuple.
Definition: Tuple.h:155
bool isZero() const
True if all elements are exactly zero.
Definition: Tuple.h:171
T operator[](int i) const
Definition: Tuple.h:86
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202
T value_type
Definition: Tuple.h:32
bool isFinite(const Tuple< SIZE, T > &t)
Return true if no Nan or Inf values are present.
Definition: Tuple.h:233