00001 inline bool N::is_zero() const 00002 { 00003 return size == 0 && limb == 0; 00004 } 00005 00006 inline bool N::is_one() const 00007 { 00008 return size == 0 && limb == 1; 00009 } 00010 00011 inline int N::compare(const N& a) const 00012 { 00013 if(size) 00014 { 00015 if(a.size) 00016 { 00017 if(size == a.size) 00018 { 00019 return mpn_cmp(data, a.data, size + 1); 00020 } 00021 else 00022 { 00023 return (size < a.size) ? -1 : 1; 00024 } 00025 } 00026 else 00027 { 00028 return 1; 00029 } 00030 } 00031 else 00032 { 00033 if(a.size) 00034 { 00035 return -1; 00036 } 00037 else 00038 { 00039 if(limb == a.limb) 00040 { 00041 return 0; 00042 } 00043 else 00044 { 00045 return (limb < a.limb) ? -1 : 1; 00046 } 00047 } 00048 } 00049 } 00050 00051 inline int N::compare(const limb_t a) const 00052 { 00053 if(size) 00054 { 00055 return 1; 00056 } 00057 else 00058 { 00059 if(limb == a) 00060 { 00061 return 0; 00062 } 00063 else 00064 { 00065 return (limb < a) ? -1 : 1; 00066 } 00067 } 00068 } 00069 00070 // Comparisson operators 00071 inline bool operator==(const N& a, const N& b) 00072 { 00073 return a.compare(b) == 0; 00074 } 00075 00076 inline bool operator==(const N& a, const N::limb_t b) 00077 { 00078 return a.compare(b) == 0; 00079 } 00080 00081 inline bool operator==(const N::limb_t a, const N& b) 00082 { 00083 return b.compare(a) == 0; 00084 } 00085 00086 inline bool operator!=(const N& a, const N& b) 00087 { 00088 return a.compare(b) != 0; 00089 } 00090 00091 inline bool operator!=(const N& a, const N::limb_t b) 00092 { 00093 return a.compare(b) != 0; 00094 } 00095 00096 inline bool operator!=(const N::limb_t a, const N& b) 00097 { 00098 return b.compare(a) != 0; 00099 } 00100 00101 inline bool operator>(const N& a, const N& b) 00102 { 00103 return a.compare(b) > 0; 00104 } 00105 00106 inline bool operator>(const N& a, const N::limb_t b) 00107 { 00108 return a.compare(b) > 0; 00109 } 00110 00111 inline bool operator>(const N::limb_t a, const N& b) 00112 { 00113 return b.compare(a) < 0; 00114 } 00115 00116 inline bool operator>=(const N& a, const N& b) 00117 { 00118 return a.compare(b) >= 0; 00119 } 00120 00121 inline bool operator>=(const N& a, const N::limb_t b) 00122 { 00123 return a.compare(b) >= 0; 00124 } 00125 00126 inline bool operator>=(const N::limb_t a, const N& b) 00127 { 00128 return b.compare(a) >= 0; 00129 } 00130 00131 inline bool operator<(const N& a, const N& b) 00132 { 00133 return a.compare(b) < 0; 00134 } 00135 00136 inline bool operator<(const N& a, const N::limb_t b) 00137 { 00138 return a.compare(b) < 0; 00139 } 00140 00141 inline bool operator<(const N::limb_t a, const N& b) 00142 { 00143 return b.compare(a) > 0; 00144 } 00145 00146 inline bool operator<=(const N& a, const N& b) 00147 { 00148 return b.compare(a) <= 0; 00149 } 00150 00151 inline bool operator<=(const N& a, const N::limb_t b) 00152 { 00153 return a.compare(b) <= 0; 00154 } 00155 00156 inline bool operator<=(const N::limb_t a, const N& b) 00157 { 00158 return b.compare(a) >= 0; 00159 } 00160
Copyright © 2007-2008 Remco Bloemen.
Generated on Tue Jan 22 17:35:31 2008 for symbolism by doxygen 1.5.4