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

#include <fglmvec.h>

Public Member Functions

 fglmVector ()
 
 fglmVector (int size)
 
 fglmVector (int size, int basis)
 
 fglmVector (const fglmVector &v)
 
 ~fglmVector ()
 
int size () const
 
int numNonZeroElems () const
 
void nihilate (const number fac1, const number fac2, const fglmVector v)
 
fglmVectoroperator= (const fglmVector &v)
 
int operator== (const fglmVector &)
 
int operator!= (const fglmVector &)
 
int isZero ()
 
int elemIsZero (int i)
 
fglmVectoroperator+= (const fglmVector &)
 
fglmVectoroperator-= (const fglmVector &)
 
fglmVectoroperator*= (const number &)
 
fglmVectoroperator/= (const number &)
 
number getconstelem (int i) const
 
number & getelem (int i)
 
void setelem (int i, number &n)
 
number gcd () const
 
number clearDenom ()
 

Protected Member Functions

void makeUnique ()
 
 fglmVector (fglmVectorRep *rep)
 

Protected Attributes

fglmVectorReprep
 

Friends

fglmVector operator- (const fglmVector &v)
 
fglmVector operator+ (const fglmVector &lhs, const fglmVector &rhs)
 
fglmVector operator- (const fglmVector &lhs, const fglmVector &rhs)
 
fglmVector operator* (const fglmVector &v, const number n)
 
fglmVector operator* (const number n, const fglmVector &v)
 

Detailed Description

Definition at line 18 of file fglmvec.h.

Constructor & Destructor Documentation

◆ fglmVector() [1/5]

fglmVector::fglmVector ( fglmVectorRep r)
protected

Implementation of class fglmVector

Definition at line 152 of file fglmvec.cc.

152 :rep (r)
153{
154}
fglmVectorRep * rep
Definition: fglmvec.h:21

◆ fglmVector() [2/5]

fglmVector::fglmVector ( )

Definition at line 156 of file fglmvec.cc.

156 :rep (new fglmVectorRep ())
157{
158}

◆ fglmVector() [3/5]

fglmVector::fglmVector ( int  size)

Definition at line 160 of file fglmvec.cc.

160 :rep (new fglmVectorRep (size))
161{
162}
int size() const
Definition: fglmvec.cc:207

◆ fglmVector() [4/5]

fglmVector::fglmVector ( int  size,
int  basis 
)

Definition at line 164 of file fglmvec.cc.

164 :rep (new fglmVectorRep (size))
165{
166 rep->setelem (basis, nInit (1));
167}
void setelem(int i, number n)
Definition: fglmvec.cc:121
#define nInit(i)
Definition: numbers.h:24

◆ fglmVector() [5/5]

fglmVector::fglmVector ( const fglmVector v)

Definition at line 169 of file fglmvec.cc.

170{
171 rep = v.rep->copyObject ();
172}
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39

◆ ~fglmVector()

fglmVector::~fglmVector ( )

Definition at line 174 of file fglmvec.cc.

175{
176 if(rep->deleteObject ())
177 delete rep;
178}
BOOLEAN deleteObject()
Definition: fglmvec.cc:78

Member Function Documentation

◆ clearDenom()

number fglmVector::clearDenom ( )

Definition at line 502 of file fglmvec.cc.

503{
504 number theLcm = nInit (1);
506 int i;
507 for(i = size (); i > 0; i--)
508 {
509 if(!nIsZero (rep->getconstelem (i)))
510 {
511 isZero = FALSE;
512 number temp = n_NormalizeHelper (theLcm, rep->getconstelem (i), currRing->cf);
513 nDelete (&theLcm);
514 theLcm = temp;
515 }
516 }
517 if(isZero)
518 {
519 nDelete (&theLcm);
520 theLcm = nInit (0);
521 }
522 else
523 {
524 if(!nIsOne (theLcm))
525 {
526 *this *= theLcm;
527 for(i = size (); i > 0; i--)
528 {
529 nNormalize (rep->getelem (i));
530 }
531 }
532 }
533 return theLcm;
534}
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int i
Definition: cfEzgcd.cc:132
number getconstelem(int i) const
Definition: fglmvec.cc:139
number & getelem(int i)
Definition: fglmvec.cc:134
int isZero()
Definition: fglmvec.cc:295
static FORCE_INLINE number n_NormalizeHelper(number a, number b, const coeffs r)
assume that r is a quotient field (otherwise, return 1) for arguments (a1/a2,b1/b2) return (lcm(a1,...
Definition: coeffs.h:692
#define nDelete(n)
Definition: numbers.h:16
#define nIsZero(n)
Definition: numbers.h:19
#define nIsOne(n)
Definition: numbers.h:25
#define nNormalize(n)
Definition: numbers.h:30
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13

◆ elemIsZero()

int fglmVector::elemIsZero ( int  i)

Definition at line 300 of file fglmvec.cc.

301{
302 return nIsZero (rep->getconstelem (i));
303}

◆ gcd()

number fglmVector::gcd ( ) const

Definition at line 458 of file fglmvec.cc.

459{
460 int i = rep->size ();
462 BOOLEAN gcdIsOne = FALSE;
463 number theGcd;
464 number current;
465 while(i > 0 && !found)
466 {
467 current = rep->getconstelem (i);
468 if(!nIsZero (current))
469 {
470 theGcd = nCopy (current);
471 found = TRUE;
472 if(!nGreaterZero (theGcd))
473 {
474 theGcd = nInpNeg (theGcd);
475 }
476 if(nIsOne (theGcd))
477 gcdIsOne = TRUE;
478 }
479 i--;
480 }
481 if(found)
482 {
483 while(i > 0 && !gcdIsOne)
484 {
485 current = rep->getconstelem (i);
486 if(!nIsZero (current))
487 {
488 number temp = n_SubringGcd (theGcd, current, currRing->cf);
489 nDelete (&theGcd);
490 theGcd = temp;
491 if(nIsOne (theGcd))
492 gcdIsOne = TRUE;
493 }
494 i--;
495 }
496 }
497 else
498 theGcd = nInit (0);
499 return theGcd;
500}
int size() const
Definition: fglmvec.cc:96
static FORCE_INLINE number n_SubringGcd(number a, number b, const coeffs r)
Definition: coeffs.h:663
bool found
Definition: facFactorize.cc:55
#define nInpNeg(n)
Definition: numbers.h:21
#define nCopy(n)
Definition: numbers.h:15
#define nGreaterZero(n)
Definition: numbers.h:27

◆ getconstelem()

number fglmVector::getconstelem ( int  i) const

Definition at line 446 of file fglmvec.cc.

447{
448 return rep->getconstelem (i);
449}

◆ getelem()

number & fglmVector::getelem ( int  i)

Definition at line 440 of file fglmvec.cc.

441{
442 makeUnique ();
443 return rep->getelem (i);
444}
void makeUnique()
Definition: fglmvec.cc:198

◆ isZero()

int fglmVector::isZero ( )

Definition at line 295 of file fglmvec.cc.

296{
297 return rep->isZero ();
298}
int isZero() const
Definition: fglmvec.cc:100

◆ makeUnique()

void fglmVector::makeUnique ( )
protected

Definition at line 198 of file fglmvec.cc.

199{
200 if(rep->refcount () != 1)
201 {
202 rep->deleteObject ();
203 rep = rep->clone ();
204 }
205}
int refcount() const
Definition: fglmvec.cc:87
fglmVectorRep * clone() const
Definition: fglmvec.cc:65

◆ nihilate()

void fglmVector::nihilate ( const number  fac1,
const number  fac2,
const fglmVector  v 
)

Definition at line 218 of file fglmvec.cc.

220{
221 int i;
222 int vsize = v.size ();
223 number term1, term2;
224 fglmASSERT (vsize <= rep->size (), "v has to be smaller or equal");
225 if(rep->isUnique ())
226 {
227 for(i = vsize; i > 0; i--)
228 {
229 term1 = nMult (fac1, rep->getconstelem (i));
230 term2 = nMult (fac2, v.rep->getconstelem (i));
231 rep->setelem (i, nSub (term1, term2));
232 nDelete (&term1);
233 nDelete (&term2);
234 }
235 for(i = rep->size (); i > vsize; i--)
236 {
237 rep->setelem (i, nMult (fac1, rep->getconstelem (i)));
238 }
239 }
240 else
241 {
242 number *newelems;
243 newelems = (number *) omAlloc (rep->size () * sizeof (number));
244 for(i = vsize; i > 0; i--)
245 {
246 term1 = nMult (fac1, rep->getconstelem (i));
247 term2 = nMult (fac2, v.rep->getconstelem (i));
248 newelems[i - 1] = nSub (term1, term2);
249 nDelete (&term1);
250 nDelete (&term2);
251 }
252 for(i = rep->size (); i > vsize; i--)
253 {
254 newelems[i - 1] = nMult (fac1, rep->getconstelem (i));
255 }
256 rep->deleteObject ();
257 rep = new fglmVectorRep (rep->size (), newelems);
258 }
259}
BOOLEAN isUnique() const
Definition: fglmvec.cc:91
#define fglmASSERT(ignore1, ignore2)
Definition: fglm.h:23
#define nSub(n1, n2)
Definition: numbers.h:22
#define nMult(n1, n2)
Definition: numbers.h:17
#define omAlloc(size)
Definition: omAllocDecl.h:210

◆ numNonZeroElems()

int fglmVector::numNonZeroElems ( ) const

Definition at line 212 of file fglmvec.cc.

213{
214 return rep->numNonZeroElems ();
215}
int numNonZeroElems() const
Definition: fglmvec.cc:110

◆ operator!=()

int fglmVector::operator!= ( const fglmVector v)

Definition at line 290 of file fglmvec.cc.

291{
292 return !(*this == v);
293}

◆ operator*=()

fglmVector & fglmVector::operator*= ( const number &  n)

Definition at line 350 of file fglmvec.cc.

351{
352 int s = rep->size ();
353 int i;
354 if(!rep->isUnique ())
355 {
356 number *temp;
357 temp = (number *) omAlloc (s * sizeof (number));
358 for(i = s; i > 0; i--)
359 temp[i - 1] = nMult (rep->getconstelem (i), n);
360 rep->deleteObject ();
361 rep = new fglmVectorRep (s, temp);
362 }
363 else
364 {
365 for(i = s; i > 0; i--)
366 rep->setelem (i, nMult (rep->getconstelem (i), n));
367 }
368 return *this;
369}
const CanonicalForm int s
Definition: facAbsFact.cc:51

◆ operator+=()

fglmVector & fglmVector::operator+= ( const fglmVector v)

Definition at line 305 of file fglmvec.cc.

306{
307 fglmASSERT (size () == v.size (), "incompatible vectors");
308 // ACHTUNG : Das Verhalten hier mit gcd genau ueberpruefen!
309 int i;
310 if(rep->isUnique ())
311 {
312 for(i = rep->size (); i > 0; i--)
313 rep->setelem (i, nAdd (rep->getconstelem (i), v.rep->getconstelem (i)));
314 }
315 else
316 {
317 int n = rep->size ();
318 number *newelems;
319 newelems = (number *) omAlloc (n * sizeof (number));
320 for(i = n; i > 0; i--)
321 newelems[i - 1] = nAdd (rep->getconstelem (i), v.rep->getconstelem (i));
322 rep->deleteObject ();
323 rep = new fglmVectorRep (n, newelems);
324 }
325 return *this;
326}
#define nAdd(n1, n2)
Definition: numbers.h:18

◆ operator-=()

fglmVector & fglmVector::operator-= ( const fglmVector v)

Definition at line 328 of file fglmvec.cc.

329{
330 fglmASSERT (size () == v.size (), "incompatible vectors");
331 int i;
332 if(rep->isUnique ())
333 {
334 for(i = rep->size (); i > 0; i--)
335 rep->setelem (i, nSub (rep->getconstelem (i), v.rep->getconstelem (i)));
336 }
337 else
338 {
339 int n = rep->size ();
340 number *newelems;
341 newelems = (number *) omAlloc (n * sizeof (number));
342 for(i = n; i > 0; i--)
343 newelems[i - 1] = nSub (rep->getconstelem (i), v.rep->getconstelem (i));
344 rep->deleteObject ();
345 rep = new fglmVectorRep (n, newelems);
346 }
347 return *this;
348}

◆ operator/=()

fglmVector & fglmVector::operator/= ( const number &  n)

Definition at line 371 of file fglmvec.cc.

372{
373 int s = rep->size ();
374 int i;
375 if(!rep->isUnique ())
376 {
377 number *temp;
378 temp = (number *) omAlloc (s * sizeof (number));
379 for(i = s; i > 0; i--)
380 {
381 temp[i - 1] = nDiv (rep->getconstelem (i), n);
382 nNormalize (temp[i - 1]);
383 }
384 rep->deleteObject ();
385 rep = new fglmVectorRep (s, temp);
386 }
387 else
388 {
389 for(i = s; i > 0; i--)
390 {
391 rep->setelem (i, nDiv (rep->getconstelem (i), n));
392 nNormalize (rep->getelem (i));
393 }
394 }
395 return *this;
396}
#define nDiv(a, b)
Definition: numbers.h:32

◆ operator=()

fglmVector & fglmVector::operator= ( const fglmVector v)

Definition at line 261 of file fglmvec.cc.

262{
263 if(this != &v)
264 {
265 if(rep->deleteObject ())
266 delete rep;
267 rep = v.rep->copyObject ();
268 }
269 return *this;
270}

◆ operator==()

int fglmVector::operator== ( const fglmVector v)

Definition at line 272 of file fglmvec.cc.

273{
274 if(rep->size () == v.rep->size ())
275 {
276 if(rep == v.rep)
277 return 1;
278 else
279 {
280 int i;
281 for(i = rep->size (); i > 0; i--)
282 if(!nEqual (rep->getconstelem (i), v.rep->getconstelem (i)))
283 return 0;
284 return 1;
285 }
286 }
287 return 0;
288}
#define nEqual(n1, n2)
Definition: numbers.h:20

◆ setelem()

void fglmVector::setelem ( int  i,
number &  n 
)

Definition at line 451 of file fglmvec.cc.

452{
453 makeUnique ();
454 rep->setelem (i, n);
455 n = n_Init (0, currRing->cf);
456}
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

◆ size()

int fglmVector::size ( ) const

Definition at line 207 of file fglmvec.cc.

208{
209 return rep->size ();
210}

Friends And Related Function Documentation

◆ operator* [1/2]

fglmVector operator* ( const fglmVector v,
const number  n 
)
friend

Definition at line 426 of file fglmvec.cc.

427{
428 fglmVector temp = v;
429 temp *= n;
430 return temp;
431}

◆ operator* [2/2]

fglmVector operator* ( const number  n,
const fglmVector v 
)
friend

Definition at line 433 of file fglmvec.cc.

434{
435 fglmVector temp = v;
436 temp *= n;
437 return temp;
438}

◆ operator+

fglmVector operator+ ( const fglmVector lhs,
const fglmVector rhs 
)
friend

Definition at line 412 of file fglmvec.cc.

413{
414 fglmVector temp = lhs;
415 temp += rhs;
416 return temp;
417}

◆ operator- [1/2]

fglmVector operator- ( const fglmVector lhs,
const fglmVector rhs 
)
friend

Definition at line 419 of file fglmvec.cc.

420{
421 fglmVector temp = lhs;
422 temp -= rhs;
423 return temp;
424}

◆ operator- [2/2]

fglmVector operator- ( const fglmVector v)
friend

Definition at line 398 of file fglmvec.cc.

399{
400 fglmVector temp (v.size ());
401 int i;
402 number n;
403 for(i = v.size (); i > 0; i--)
404 {
405 n = nCopy (v.getconstelem (i));
406 n = nInpNeg (n);
407 temp.setelem (i, n);
408 }
409 return temp;
410}

Field Documentation

◆ rep

fglmVectorRep* fglmVector::rep
protected

Definition at line 21 of file fglmvec.h.


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