My Project
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Friends
Number Class Reference

#include <Number.h>

Public Member Functions

number as_number () const
 
Numberoperator= (const Number &n2)
 
Number operator- ()
 
Numberoperator+= (const Number &n2)
 
Numberoperator*= (const Number &n2)
 
Numberoperator-= (const Number &n2)
 
Numberoperator/= (const Number &n2)
 
Numberoperator= (int n2)
 
Numberoperator+= (int n2)
 
Numberoperator*= (int n2)
 
Numberoperator-= (int n2)
 
Numberoperator/= (int n2)
 
 Number ()
 
 Number (const Number &n)
 
 Number (number n, ring r)
 
 Number (int n, ring r)
 
 Number (int n, intrusive_ptr< ip_sring > r)
 
 Number (int n)
 
void write () const
 
 ~Number ()
 
ring getRing () const
 

Protected Attributes

number n
 
intrusive_ptr< ip_sringr
 

Friends

class Poly
 
class Vector
 
template<poly_variant , class , class >
class PolyBase
 
class PolyImpl
 
Number operator+ (const Number &n1, const Number &n2)
 
Number operator- (const Number &n1, const Number &n2)
 
Number operator/ (const Number &n1, const Number &n2)
 
Number operator* (const Number &n1, const Number &n2)
 
bool operator== (const Number &n1, const Number &n2)
 
Number operator+ (const Number &n1, int n2)
 
Number operator- (const Number &n1, int n2)
 
Number operator/ (const Number &n1, int n2)
 
Number operator* (const Number &n1, int n2)
 
bool operator== (const Number &n1, int n2)
 
Number operator+ (int n1, const Number &n2)
 
Number operator- (int n1, const Number &n2)
 
Number operator/ (int n1, const Number &n2)
 
Number operator* (int n1, const Number &n2)
 
bool operator== (int n1, const Number &n2)
 

Detailed Description

Definition at line 33 of file Number.h.

Constructor & Destructor Documentation

◆ Number() [1/6]

Number::Number ( )
inline

Definition at line 169 of file Number.h.

170 {
171 r=currRing;
172 if (r.get()!=NULL)
173 n=n_Init(0,r.get()->cf);
174 else
175 n=(number) NULL;
176 }
intrusive_ptr< ip_sring > r
Definition: Number.h:218
number n
Definition: Number.h:217
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:535
#define NULL
Definition: omList.c:12
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13

◆ Number() [2/6]

Number::Number ( const Number n)
inline

Definition at line 177 of file Number.h.

178 {
179 r=n.r;
180 this->n=n_Copy(n.n,r.get()->cf);
181 }
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:448

◆ Number() [3/6]

Number::Number ( number  n,
ring  r 
)
inline

Definition at line 182 of file Number.h.

183 {
184 this->n=n_Copy(n,r->cf);
185 this->r=r;
186 }

◆ Number() [4/6]

Number::Number ( int  n,
ring  r 
)
inline

Definition at line 187 of file Number.h.

188 {
189 this->r=r;
190 this->n=n_Init(n,r->cf);
191 }

◆ Number() [5/6]

Number::Number ( int  n,
intrusive_ptr< ip_sring r 
)
inline

Definition at line 192 of file Number.h.

193 {
194 this->r=r;
195 this->n=n_Init(n,r.get()->cf);
196 }

◆ Number() [6/6]

Number::Number ( int  n)
inlineexplicit

Definition at line 197 of file Number.h.

198 {
199 r=currRing;
200 this->n=n_Init(n,r.get()->cf);
201 }

◆ ~Number()

Number::~Number ( )
inline

Definition at line 207 of file Number.h.

208 {
209 if (r!=NULL)
210 n_Delete(&n,r.get()->cf);
211 }
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:452

Member Function Documentation

◆ as_number()

number Number::as_number ( ) const
inline

Definition at line 59 of file Number.h.

60 {
61 return n_Copy(n,r.get()->cf);
62 }

◆ getRing()

ring Number::getRing ( ) const
inline

Definition at line 212 of file Number.h.

213 {
214 return r.get();
215 }

◆ operator*=() [1/2]

Number & Number::operator*= ( const Number n2)
inline

Definition at line 91 of file Number.h.

92 {
93 if (r!=n2.r)
94 {
95 WerrorS("not the same ring");
96 return *this;
97 }
98 number nv=n_Mult(n,n2.n,r.get()->cf);
99 n_Delete(&n,r.get()->cf);
100 n=nv;
101 return *this;
102 }
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:633
void WerrorS(const char *s)
Definition: feFopen.cc:24

◆ operator*=() [2/2]

Number & Number::operator*= ( int  n2)
inline

Definition at line 142 of file Number.h.

143 {
144 number n2n=n_Init(n2,r.get()->cf);
145 number nv=n_Mult(n,n2n,r.get()->cf);
146 n_Delete(&n,r.get()->cf);
147 n_Delete(&n2n,r.get()->cf);
148 n=nv;
149 return *this;
150 }

◆ operator+=() [1/2]

Number & Number::operator+= ( const Number n2)
inline

Definition at line 79 of file Number.h.

80 {
81 if (r!=n2.r)
82 {
83 WerrorS("not the same ring");
84 return *this;
85 }
86 number nv=n_Add(n,n2.n,r.get()->cf);
87 n_Delete(&n,r.get()->cf);
88 n=nv;
89 return *this;
90 }
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:647

◆ operator+=() [2/2]

Number & Number::operator+= ( int  n2)
inline

Definition at line 133 of file Number.h.

134 {
135 number n2n=n_Init(n2,r.get()->cf);
136 number nv=n_Add(n,n2n,r.get()->cf);
137 n_Delete(&n,r.get()->cf);
138 n_Delete(&n2n,r.get()->cf);
139 n=nv;
140 return *this;
141 }

◆ operator-()

Number Number::operator- ( )
inline

Definition at line 72 of file Number.h.

73 {
74 Number t(*this);
75 //t.n=n_Copy(n,r);
76 t.n=n_InpNeg(t.n,r.get()->cf);
77 return t;
78 }
Definition: Number.h:34
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:554

◆ operator-=() [1/2]

Number & Number::operator-= ( const Number n2)
inline

Definition at line 103 of file Number.h.

104 {
105 if (r!=n2.r)
106 {
107 WerrorS("not the same ring");
108 return *this;
109 }
110 number nv=n_Sub(n,n2.n,r.get()->cf);
111 n_Delete(&n,r.get()->cf);
112 n=nv;
113 return *this;
114 }
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition: coeffs.h:652

◆ operator-=() [2/2]

Number & Number::operator-= ( int  n2)
inline

Definition at line 151 of file Number.h.

152 {
153 number n2n=n_Init(n2,r.get()->cf);
154 number nv=n_Sub(n,n2n,r.get()->cf);
155 n_Delete(&n,r.get()->cf);
156 n_Delete(&n2n,r.get()->cf);
157 n=nv;
158 return *this;
159 }

◆ operator/=() [1/2]

Number & Number::operator/= ( const Number n2)
inline

Definition at line 115 of file Number.h.

116 {
117 if (r!=n2.r)
118 {
119 WerrorS("not the same ring");
120 return *this;
121 }
122 number nv=n_Div(n,n2.n,r.get()->cf);
123 n_Delete(&n,r.get()->cf);
124 n=nv;
125 return *this;
126 }
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition: coeffs.h:612

◆ operator/=() [2/2]

Number & Number::operator/= ( int  n2)
inline

Definition at line 160 of file Number.h.

161 {
162 number n2n=n_Init(n2,r.get()->cf);
163 number nv=n_Div(n,n2n,r.get()->cf);
164 n_Delete(&n,r.get()->cf);
165 n_Delete(&n2n,r.get()->cf);
166 n=nv;
167 return *this;
168 }

◆ operator=() [1/2]

Number & Number::operator= ( const Number n2)
inline

Definition at line 63 of file Number.h.

64 {
65 //durch Reihenfolge Selbstzuweisungen ber�cksichtigt
66 number nc=n_Copy(n2.n,n2.r.get()->cf);
67 n_Delete(&n,r.get()->cf);
68 r=n2.r;
69 n=nc;
70 return *this;
71 }

◆ operator=() [2/2]

Number & Number::operator= ( int  n2)
inline

Definition at line 127 of file Number.h.

128 {
129 n_Delete(&n,r.get()->cf);
130 n=n_Init(n2,r.get()->cf);
131 return *this;
132 }

◆ write()

void Number::write ( ) const
inline

Definition at line 202 of file Number.h.

203 {
204 number towrite=n;
205 n_Write(towrite,r.get()->cf);
206 }
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition: coeffs.h:588

Friends And Related Function Documentation

◆ operator* [1/3]

Number operator* ( const Number n1,
const Number n2 
)
friend

Definition at line 227 of file Number.h.

228{
229 Number erg(n1);
230 erg*=n2;
231 return erg;
232}

◆ operator* [2/3]

Number operator* ( const Number n1,
int  n2 
)
friend

Definition at line 257 of file Number.h.

258{
259 Number erg(n1);
260 erg*=Number(n2,n1.r);
261 return erg;
262}
Number()
Definition: Number.h:169

◆ operator* [3/3]

Number operator* ( int  n1,
const Number n2 
)
friend

Definition at line 294 of file Number.h.

295{
296 Number erg(n2);
297 return erg*=Number(n1,n2.r);
298}

◆ operator+ [1/3]

Number operator+ ( const Number n1,
const Number n2 
)
friend

Definition at line 221 of file Number.h.

222{
223 Number erg(n1);
224 erg+=n2;
225 return erg;
226}

◆ operator+ [2/3]

Number operator+ ( const Number n1,
int  n2 
)
friend

Definition at line 251 of file Number.h.

252{
253 Number erg(n1);
254 erg+=Number(n2,n1.r);
255 return erg;
256}

◆ operator+ [3/3]

Number operator+ ( int  n1,
const Number n2 
)
friend

Definition at line 279 of file Number.h.

280{
281 Number erg(n2);
282 return erg+=Number(n1,n2.r);
283}

◆ operator- [1/3]

Number operator- ( const Number n1,
const Number n2 
)
friend

Definition at line 233 of file Number.h.

234{
235 Number erg(n1);
236 erg-=n2;
237 return erg;
238}

◆ operator- [2/3]

Number operator- ( const Number n1,
int  n2 
)
friend

Definition at line 263 of file Number.h.

264{
265 Number erg(n1);
266 erg-=Number(n2,n1.r);
267 return erg;
268}

◆ operator- [3/3]

Number operator- ( int  n1,
const Number n2 
)
friend

Definition at line 284 of file Number.h.

285{
286 Number erg(n1,n2.r);
287 return erg-=n2;
288}

◆ operator/ [1/3]

Number operator/ ( const Number n1,
const Number n2 
)
friend

Definition at line 239 of file Number.h.

240{
241 Number erg(n1);
242 erg/=n2;
243 return erg;
244}

◆ operator/ [2/3]

Number operator/ ( const Number n1,
int  n2 
)
friend

Definition at line 269 of file Number.h.

270{
271 Number erg(n1);
272 erg/=Number(n2,n1.r);
273 return erg;
274}

◆ operator/ [3/3]

Number operator/ ( int  n1,
const Number n2 
)
friend

Definition at line 289 of file Number.h.

290{
291 Number erg(n1,n2.r);
292 return erg/=n2;
293}

◆ operator== [1/3]

bool operator== ( const Number n1,
const Number n2 
)
friend

Definition at line 245 of file Number.h.

246{
247 if(n1.r!=n2.r)
248 return false;
249 return n_Equal(n1.n,n2.n,n1.r.get()->cf);
250}
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition: coeffs.h:457

◆ operator== [2/3]

bool operator== ( const Number n1,
int  n2 
)
friend

Definition at line 275 of file Number.h.

276{
277 return n_Equal(n1.n,Number(n2,n1.r).n,n1.r.get()->cf);
278}

◆ operator== [3/3]

bool operator== ( int  n1,
const Number n2 
)
friend

Definition at line 299 of file Number.h.

300{
301 return n2==Number(n1,n2.r);
302}

◆ Poly

friend class Poly
friend

Definition at line 51 of file Number.h.

◆ PolyBase

template<poly_variant , class , class >
friend class PolyBase
friend

Definition at line 57 of file Number.h.

◆ PolyImpl

friend class PolyImpl
friend

Definition at line 58 of file Number.h.

◆ Vector

friend class Vector
friend

Definition at line 52 of file Number.h.

Field Documentation

◆ n

number Number::n
protected

Definition at line 217 of file Number.h.

◆ r

intrusive_ptr<ip_sring> Number::r
protected

Definition at line 218 of file Number.h.


The documentation for this class was generated from the following file: