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>
62 for (
int i = 0; i < SIZE; ++i) {
73 template <
int src_size,
typename src_valtype>
75 static const int copyEnd = SIZE < src_size ? SIZE : src_size;
77 for (
int i = 0; i < copyEnd; ++i) {
80 for (
int i = copyEnd; i < SIZE; ++i) {
103 template <
typename S>
106 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);
155 template<
int SIZE,
typename T0,
typename T1>
159 for (
size_t i = 0; i < SIZE-1; ++i) {
162 return t0[SIZE-1] < t1[SIZE-1];
167 template<
int SIZE,
typename T0,
typename T1>
171 for (
size_t i = 0; i < SIZE-1; ++i) {
174 return t0[SIZE-1] > t1[SIZE-1];
182 template<
int SIZE,
typename T,
bool IsInteger>
187 for (
size_t i = 0; i < SIZE; ++i) result[i] = ::fabs(t[i]);
193 template<
int SIZE,
typename T>
198 for (
size_t i = 0; i < SIZE; ++i) result[i] = ::abs(t[i]);
205 template<
int SIZE,
typename T>
217 template <
int SIZE,
typename T>
218 std::ostream& operator<<(std::ostream& ostr, const Tuple<SIZE, T>& classname)
220 ostr << classname.str();
228 #endif // OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED