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
49  UT_PolyField &operator+=(const UT_PolyField &x);
51  {
52  return operator+=(x);
53  }
55  UT_PolyField &operator%=(const UT_PolyField &x);
56  UT_PolyField &operator^=(const UT_PolyField &x);
57  UT_PolyField &operator<<=(uint shift);
58  UT_PolyField &operator>>=(uint shift);
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:609
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:625
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
#define UT_API
Definition: UT_API.h:13
GLint y
Definition: glcorearb.h:102
png_uint_32 i
Definition: png.h:2877
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
GLfloat f
Definition: glcorearb.h:1925
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:635
ut_VeryLongValue * getValue()
Definition: UT_PolyField.h:99
bool operator<=(const TfRefPtr< T > &p, std::nullptr_t)
Definition: refPtr.h:1223
bool operator<(const GU_TetrahedronFacet &a, const GU_TetrahedronFacet &b)
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
const Vec2< S > & operator*=(Vec2< S > &v, const Matrix33< T > &m)
Definition: ImathMatrix.h:3322
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
bool operator>(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:219
unsigned int uint
Definition: SYS_Types.h:40
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)
GLint GLenum GLint x
Definition: glcorearb.h:408
const ut_VeryLongValue * getValue() const
Definition: UT_PolyField.h:100
bool operator>=(const TfRefPtr< T > &p, std::nullptr_t)
Definition: refPtr.h:1245
bool operator!=(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:165
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:308