34 #ifndef OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED 35 #define OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED 53 template<
int SIZE,
typename T>
59 static const int size = SIZE;
68 for (
int i = 0; i < SIZE; ++i) {
78 for (
int i = 0; i < SIZE; ++i) {
91 template <
int src_size,
typename src_valtype>
93 enum { COPY_END = (SIZE < src_size ? SIZE : src_size) };
95 for (
int i = 0; i < COPY_END; ++i) {
98 for (
int i = COPY_END; i < SIZE; ++i) {
121 template <
typename S>
124 for (
int i = 0; i < SIZE; ++i) {
134 value_type
const *
asV()
const {
141 std::ostringstream buffer;
146 for (
unsigned j(0); j < SIZE; j++) {
147 if (j) buffer <<
", ";
156 void write(std::ostream& os)
const {
157 os.write(reinterpret_cast<const char*>(&mm),
sizeof(T)*SIZE);
160 is.read(reinterpret_cast<char*>(&mm),
sizeof(T)*SIZE);
165 for (
int i = 0; i < SIZE; ++i) {
166 if (std::isnan(mm[i]))
return true;
173 for (
int i = 0; i < SIZE; ++i) {
174 if (std::isinf(mm[i]))
return true;
181 for (
int i = 0; i < SIZE; ++i) {
182 if (!std::isfinite(mm[i]))
return false;
189 for (
int i = 0; i < SIZE; ++i) {
190 if (!
isZero(mm[i]))
return false;
204 template<
int SIZE,
typename T0,
typename T1>
208 for (
int i = 0; i < SIZE-1; ++i) {
211 return t0[SIZE-1] < t1[SIZE-1];
216 template<
int SIZE,
typename T0,
typename T1>
220 for (
int i = 0; i < SIZE-1; ++i) {
223 return t0[SIZE-1] > t1[SIZE-1];
231 template<
int SIZE,
typename T>
236 for (
int i = 0; i < SIZE; ++i) result[i] =
math::Abs(t[i]);
241 template<
int SIZE,
typename T>
245 template<
int SIZE,
typename T>
249 template<
int SIZE,
typename T>
253 template<
int SIZE,
typename T>
260 template <
int SIZE,
typename T>
261 std::ostream& operator<<(std::ostream& ostr, const Tuple<SIZE, T>& classname)
263 ostr << classname.str();
271 #endif // OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED T value_type
Definition: Tuple.h:56
bool isFinite() const
True if no Nan or Inf values are present.
Definition: Tuple.h:180
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:391
Tuple()
Default ctor. Does nothing.
Definition: Tuple.h:64
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
std::string str() const
Definition: Tuple.h:140
bool isNan() const
True if a Nan is present in this tuple.
Definition: Tuple.h:164
bool isInfinite(const Tuple< SIZE, T > &t)
Return true if an Inf is present in the tuple.
Definition: Tuple.h:246
T ValueType
Definition: Tuple.h:57
Tuple(Tuple< src_size, src_valtype > const &src)
Conversion constructor.
Definition: Tuple.h:92
bool isZero(const Tuple< SIZE, T > &t)
Return true if all elements are exactly equal to zero.
Definition: Tuple.h:254
bool operator>(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:218
bool isInfinite() const
True if an Inf is present in this tuple.
Definition: Tuple.h:172
T & operator[](int i)
Definition: Tuple.h:111
void toV(S *v) const
Copies this tuple into an array of a compatible type.
Definition: Tuple.h:123
bool isFinite(const Tuple< SIZE, T > &t)
Return true if no Nan or Inf values are present.
Definition: Tuple.h:250
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
void read(std::istream &is)
Definition: Tuple.h:159
value_type * asV()
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:130
Definition: Exceptions.h:39
Tuple & operator=(Tuple const &src)
Assignment operator.
Definition: Tuple.h:76
Tuple< SIZE, T > Abs(const Tuple< SIZE, T > &t)
Definition: Tuple.h:233
bool isZero() const
True if all elements are exactly zero.
Definition: Tuple.h:188
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:833
void write(std::ostream &os) const
Definition: Tuple.h:156
value_type const * asV() const
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:134
T mm[SIZE]
Definition: Tuple.h:196
Dummy class for tag dispatch of conversion constructors.
Definition: Tuple.h:48
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
bool isNan(const Tuple< SIZE, T > &t)
Return true if a Nan is present in the tuple.
Definition: Tuple.h:242
T operator[](int i) const
Definition: Tuple.h:103
Tuple(Tuple const &src)
Copy constructor. Used when the class signature matches exactly.
Definition: Tuple.h:67