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 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) {
104 template <
typename S>
107 for (
int i = 0; i < SIZE; ++i) {
117 value_type
const *
asV()
const {
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 (
int i = 0; i < SIZE-1; ++i) {
163 return t0[SIZE-1] < t1[SIZE-1];
168 template<
int SIZE,
typename T0,
typename T1>
172 for (
int i = 0; i < SIZE-1; ++i) {
175 return t0[SIZE-1] > t1[SIZE-1];
183 template<
int SIZE,
typename T>
188 for (
int i = 0; i < SIZE; ++i) result[i] =
math::Abs(t[i]);
197 template <
int SIZE,
typename T>
198 std::ostream& operator<<(std::ostream& ostr, const Tuple<SIZE, T>& classname)
200 ostr << classname.
str();
208 #endif // OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED
Tuple()
Definition: Tuple.h:59
T ValueType
Definition: Tuple.h:53
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
void write(std::ostream &os) const
Definition: Tuple.h:140
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:407
value_type * asV()
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:113
value_type const * asV() const
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:117
T operator[](int i) const
Definition: Tuple.h:86
void toV(S *v) const
Copies this tuple into an array of a compatible type.
Definition: Tuple.h:106
bool operator>(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:170
Tuple(Tuple< src_size, src_valtype > const &src)
Definition: Tuple.h:75
#define OPENVDB_VERSION_NAME
Definition: version.h:43
Tuple(Tuple const &src)
Copy constructor. Used when the class signature matches exactly.
Definition: Tuple.h:62
Definition: Exceptions.h:39
T mm[SIZE]
Definition: Tuple.h:148
Tuple< SIZE, T > Abs(const Tuple< SIZE, T > &t)
Definition: Tuple.h:185
void read(std::istream &is)
Definition: Tuple.h:143
T value_type
Definition: Tuple.h:52
T & operator[](int i)
Definition: Tuple.h:94
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
std::string str() const
Definition: Tuple.h:124