Go to the documentation of this file.
7 #ifndef OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED
8 #define OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED
27 template<
int SIZE,
typename T>
33 static const int size = SIZE;
42 for (
int i = 0; i < SIZE; ++i) {
52 for (
int i = 0; i < SIZE; ++i) {
65 template <
int src_size,
typename src_valtype>
67 enum { COPY_END = (SIZE < src_size ? SIZE : src_size) };
69 for (
int i = 0; i < COPY_END; ++i) {
72 for (
int i = COPY_END; i < SIZE; ++i) {
97 void toV(S *v)
const {
98 for (
int i = 0; i < SIZE; ++i) {
115 std::ostringstream buffer;
120 for (
unsigned j(0); j < SIZE; j++) {
121 if (j) buffer <<
", ";
130 void write(std::ostream& os)
const {
131 os.write(
reinterpret_cast<const char*
>(&mm),
sizeof(T)*SIZE);
134 is.read(
reinterpret_cast<char*
>(&mm),
sizeof(T)*SIZE);
139 for (
int i = 0; i < SIZE; ++i) {
147 for (
int i = 0; i < SIZE; ++i) {
155 for (
int i = 0; i < SIZE; ++i) {
163 for (
int i = 0; i < SIZE; ++i) {
178 template<
int SIZE,
typename T0,
typename T1>
182 for (
int i = 0; i < SIZE-1; ++i) {
185 return t0[SIZE-1] < t1[SIZE-1];
190 template<
int SIZE,
typename T0,
typename T1>
194 for (
int i = 0; i < SIZE-1; ++i) {
197 return t0[SIZE-1] > t1[SIZE-1];
205 template<
int SIZE,
typename T>
210 for (
int i = 0; i < SIZE; ++i) result[i] =
math::Abs(t[i]);
215 template<
int SIZE,
typename T>
219 template<
int SIZE,
typename T>
223 template<
int SIZE,
typename T>
227 template<
int SIZE,
typename T>
234 template <
int SIZE,
typename T>
237 ostr << classname.
str();
245 #endif // OPENVDB_MATH_TUPLE_HAS_BEEN_INCLUDED
bool operator<(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:180
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:830
bool isInfinite() const
True if an Inf is present in this tuple.
Definition: Tuple.h:146
bool isZero() const
True if all elements are exactly zero.
Definition: Tuple.h:162
Tuple(Tuple< src_size, src_valtype > const &src)
Conversion constructor.
Definition: Tuple.h:66
value_type * asV()
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:104
std::ostream & operator<<(std::ostream &ostr, const Tuple< SIZE, T > &classname)
Write a Tuple to an output stream.
Definition: Tuple.h:235
Dummy class for tag dispatch of conversion constructors.
Definition: Tuple.h:22
const value_type * asV() const
Exposes the internal array. Be careful when using this function.
Definition: Tuple.h:108
void toV(S *v) const
Copies this tuple into an array of a compatible type.
Definition: Tuple.h:97
Tuple & operator=(Tuple const &src)
Assignment operator.
Definition: Tuple.h:50
Tuple< SIZE, T > Abs(const Tuple< SIZE, T > &t)
Definition: Tuple.h:207
T operator[](int i) const
Definition: Tuple.h:77
Tuple(Tuple const &src)
Copy constructor. Used when the class signature matches exactly.
Definition: Tuple.h:41
T ValueType
Definition: Tuple.h:31
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
bool isFinite() const
True if no Nan or Inf values are present.
Definition: Tuple.h:154
bool operator>(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:192
T mm[SIZE]
Copies this tuple into an array of a compatible type.
Definition: Tuple.h:170
T value_type
Definition: Tuple.h:30
T & operator[](int i)
Definition: Tuple.h:85
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
void read(std::istream &is)
Copies this tuple into an array of a compatible type.
Definition: Tuple.h:133
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:388
bool isFinite(const Tuple< SIZE, T > &t)
Return true if no Nan or Inf values are present.
Definition: Tuple.h:224
#define OPENVDB_VERSION_NAME
Definition: version.h:108
void write(std::ostream &os) const
Copies this tuple into an array of a compatible type.
Definition: Tuple.h:130
std::string str() const
Definition: Tuple.h:114
Definition: Exceptions.h:13
bool isZero(const Tuple< SIZE, T > &t)
Return true if all elements are exactly equal to zero.
Definition: Tuple.h:228
bool isNan() const
True if a Nan is present in this tuple.
Definition: Tuple.h:138
Tuple()
Default ctor. Does nothing.
Definition: Tuple.h:38
bool isInfinite(const Tuple< SIZE, T > &t)
Return true if an Inf is present in the tuple.
Definition: Tuple.h:220
bool isNan(const Tuple< SIZE, T > &t)
Return true if a Nan is present in the tuple.
Definition: Tuple.h:216