34 #ifndef OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED
35 #define OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED
38 #include <boost/type_traits/is_integral.hpp>
49 template<
int SIZE,
typename T>
55 static const int size = SIZE;
63 for (
int i = 0; i < SIZE; ++i) {
74 template <
int src_size,
typename src_valtype>
76 static const int copyEnd = SIZE < src_size ? SIZE : src_size;
78 for (
int i = 0; i < copyEnd; ++i) {
81 for (
int i = copyEnd; i < SIZE; ++i) {
104 template <
typename S>
107 for (
int i = 0; i < SIZE; ++i) {
125 std::ostringstream buffer;
130 for (
unsigned j(0); j < SIZE; j++) {
131 if (j) buffer <<
", ";
140 void write(std::ostream& os)
const {
141 os.write(reinterpret_cast<const char*>(&mm),
sizeof(T)*SIZE);
144 is.read(reinterpret_cast<char*>(&mm),
sizeof(T)*SIZE);
156 template<
int SIZE,
typename T0,
typename T1>
160 for (
size_t i = 0; i < SIZE-1; ++i) {
163 return t0[SIZE-1] < t1[SIZE-1];
168 template<
int SIZE,
typename T0,
typename T1>
172 for (
size_t i = 0; i < SIZE-1; ++i) {
175 return t0[SIZE-1] > t1[SIZE-1];
183 template<
int SIZE,
typename T,
bool IsInteger>
188 for (
size_t i = 0; i < SIZE; ++i) result[i] = ::fabs(t[i]);
194 template<
int SIZE,
typename T>
199 for (
size_t i = 0; i < SIZE; ++i) result[i] = ::abs(t[i]);
206 template<
int SIZE,
typename T>
218 template <
int SIZE,
typename T>
219 std::ostream& operator<<(std::ostream& ostr, const Tuple<SIZE, T>& classname)
221 ostr << classname.str();
229 #endif // OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED
std::string str() const
Definition: Tuple.h:124
Tuple()
Definition: Tuple.h:59
void toV(S *v) const
Copies this tuple into an array of a compatible type.
Definition: Tuple.h:106
T ValueType
Definition: Tuple.h:53
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
value_type const * asV() const
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:117
int32_t Abs(int32_t i)
Return the absolute value of the given quantity.
Definition: Math.h:253
bool operator>(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:170
Tuple(Tuple const &src)
Copy constructor. Used when the class signature matches exactly.
Definition: Tuple.h:62
static Tuple< SIZE, T > absVal(const Tuple< SIZE, T > &t)
Definition: Tuple.h:196
void write(std::ostream &os) const
Definition: Tuple.h:140
#define OPENVDB_VERSION_NAME
Definition: version.h:45
value_type * asV()
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:113
Helper class to compute the absolute value of a Tuple.
Definition: Tuple.h:184
T operator[](int i) const
Definition: Tuple.h:86
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:360
void read(std::istream &is)
Definition: Tuple.h:143
Tuple(Tuple< src_size, src_valtype > const &src)
Definition: Tuple.h:75
T mm[SIZE]
Definition: Tuple.h:148
T value_type
Definition: Tuple.h:52
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:67
static Tuple< SIZE, T > absVal(const Tuple< SIZE, T > &t)
Definition: Tuple.h:185
T & operator[](int i)
Definition: Tuple.h:94