HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_PolyField.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: LM_PolyField.h ( LM Library, C++)
7  *
8  * COMMENTS: Polynomial field (used in ECC)
9  * The polynomial is basically (b0 + b1*x + b2*x^2...bn*x^n),
10  * where b0..bn are the bits of the long integer stored in here.
11  *
12  * Note: The code for this class can be found in UT_VeryLong.C
13  * where most of the support functions are.
14  *
15  * Note: This is a minimal set of operators on the polynomial
16  * field.
17  */
18 
19 #ifndef __UT_PolyField__
20 #define __UT_PolyField__
21 
22 #include "UT_API.h"
23 #include <SYS/SYS_Types.h>
24 class ut_VeryLongValue;
25 class UT_VeryLong;
26 class UT_PolyField;
27 class UT_BitStream;
28 
33 
34 class UT_API UT_PolyField // polynomial field.
35 {
36 public:
37  UT_PolyField(unsigned x=0);
38  UT_PolyField(const UT_PolyField &x);
39  UT_PolyField(const UT_VeryLong &x);
40  UT_PolyField(const unsigned *data, int nwords);
41  UT_PolyField(const char *string);
42  ~UT_PolyField();
43 
44  UT_PolyField &operator=(const UT_PolyField &x);
45  UT_PolyField &operator=(uint x);
46  UT_PolyField &operator=(const char *x);
47 
48  // Standard arithmetic operators
51  {
52  return operator+=(x);
53  }
59 
60  // Standard comparison operators
61  friend inline int operator !=(const UT_PolyField &x, const UT_PolyField &y)
62  { return x.cf(y) != 0; }
63 
64  friend inline int operator ==(const UT_PolyField &x, const UT_PolyField &y)
65  { return x.cf(y) == 0; }
66 
67  friend inline int operator >=(const UT_PolyField &x, const UT_PolyField &y)
68  { return x.cf(y) >= 0; }
69 
70  friend inline int operator <=(const UT_PolyField &x, const UT_PolyField &y)
71  { return x.cf(y) <= 0; }
72 
73  friend inline int operator > (const UT_PolyField &x, const UT_PolyField &y)
74  { return x.cf(y) > 0; }
75 
76  friend inline int operator < (const UT_PolyField &x, const UT_PolyField &y)
77  { return x.cf(y) < 0; }
78 
79  static void inverse(UT_PolyField &dest,
80  const UT_PolyField &a, const UT_PolyField &f);
81  static void multiply(UT_PolyField &dest,
82  const UT_PolyField &a, const UT_PolyField &b);
83  static void add(UT_PolyField &dest,
84  const UT_PolyField &a, const UT_PolyField &b);
85  static void modulo(UT_PolyField &dest,
86  const UT_PolyField &a, const UT_PolyField &f);
87  static void square(UT_PolyField &dest,
88  const UT_PolyField &a, const UT_PolyField &f,
89  const int basis[]);
90  static void reduce(UT_PolyField &dest,
91  const UT_PolyField &a, const UT_PolyField &f,
92  const int basis[]);
93 
94  int getNumBits() const;
95  int getBit(int i) const;
96 
97  int isZero() const;
98 
99  ut_VeryLongValue *getValue() { return myValue; }
100  const ut_VeryLongValue *getValue() const { return myValue; }
101 
102  //
103  // Duplicate methods in UT_VeryLong -- these share common code.
104  //
105  void printVariable(const char *name) const;
106  void print( const char *prefix=0,
107  int radix=16,
108  const char *suffix="\n" ) const;
109  // Bit stream radix should either be 6 or 16
110  void saveToBitStream(UT_BitStream &bs, int nbits);
111  void loadFromBitStream(UT_BitStream &bs, int nbits);
112 
113  const unsigned *getData(unsigned &len) const;
114  void setData(const unsigned *data, unsigned len);
115 
116 private:
117  int cf(const UT_PolyField &x) const;
118  void harden();
119 
120  ut_VeryLongValue *myValue;
121  friend class UT_VeryLong;
122 };
123 
124 #endif
Mat3< typename promote< S, T >::type > operator*(S scalar, const Mat3< T > &m)
Multiply each element of the given matrix by scalar and return the result.
Definition: Mat3.h:561
OIIO_FORCEINLINE const vint4 & operator>>=(vint4 &a, const unsigned int bits)
Definition: simd.h:4532
Mat3< typename promote< T0, T1 >::type > operator+(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Add corresponding elements of m0 and m1 and return the result.
Definition: Mat3.h:577
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
#define UT_API
Definition: UT_API.h:14
GLint y
Definition: glcorearb.h:103
OIIO_FORCEINLINE vbool4 operator>=(const vint4 &a, const vint4 &b)
Definition: simd.h:4577
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
OIIO_FORCEINLINE vbool4 operator>(const vint4 &a, const vint4 &b)
Definition: simd.h:4561
GLfloat f
Definition: glcorearb.h:1926
OIIO_FORCEINLINE vbool4 operator<=(const vint4 &a, const vint4 &b)
Definition: simd.h:4581
Mat3< typename promote< T0, T1 >::type > operator-(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Subtract corresponding elements of m0 and m1 and return the result.
Definition: Mat3.h:587
OIIO_FORCEINLINE const vint4 & operator+=(vint4 &a, const vint4 &b)
Definition: simd.h:4369
ut_VeryLongValue * getValue()
Definition: UT_PolyField.h:99
bool operator<(const GU_TetrahedronFacet &a, const GU_TetrahedronFacet &b)
GLuint const GLchar * name
Definition: glcorearb.h:786
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLint GLenum GLint x
Definition: glcorearb.h:409
IMATH_HOSTDEVICE const Vec2< S > & operator*=(Vec2< S > &v, const Matrix22< T > &m) IMATH_NOEXCEPT
Vector-matrix multiplication: v *= m.
Definition: ImathMatrix.h:4660
OIIO_FORCEINLINE const vint4 & operator<<=(vint4 &a, const unsigned int bits)
Definition: simd.h:4519
UT_PolyField & operator-=(const UT_PolyField &x)
Definition: UT_PolyField.h:50
UT_API UT_PolyField operator%(const UT_PolyField &x, const UT_PolyField &y)
const ut_VeryLongValue * getValue() const
Definition: UT_PolyField.h:100
std::enable_if< UT_EnableBitMask< T >::enable, T & >::type operator^=(T &lhs, T rhs)
Definition: UT_EnumHelper.h:76
ImageBuf OIIO_API add(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
bool operator!=(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:165
FMT_INLINE void print(format_string< T...> fmt, T &&...args)
Definition: core.h:2976
unsigned int uint
Definition: SYS_Types.h:45
uint64_t multiply(uint64_t lhs, uint64_t rhs)
Definition: format-inl.h:258
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:337
Definition: format.h:895
OIIO_FORCEINLINE const vint4 & operator%=(vint4 &a, const vint4 &b)
Definition: simd.h:4447