My Project
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Friends
fglmVectorRep Class Reference

Public Member Functions

 fglmVectorRep ()
 
 fglmVectorRep (int n, number *e)
 
 fglmVectorRep (int n)
 
 ~fglmVectorRep ()
 
fglmVectorRepclone () const
 
BOOLEAN deleteObject ()
 
fglmVectorRepcopyObject ()
 
int refcount () const
 
BOOLEAN isUnique () const
 
int size () const
 
int isZero () const
 
int numNonZeroElems () const
 
void setelem (int i, number n)
 
number ejectelem (int i, number n)
 
number & getelem (int i)
 
number getconstelem (int i) const
 

Private Attributes

int ref_count
 
int N
 
number * elems
 

Friends

class fglmVector
 

Detailed Description

Definition at line 30 of file fglmvec.cc.

Constructor & Destructor Documentation

◆ fglmVectorRep() [1/3]

fglmVectorRep::fglmVectorRep ( )
inline

Definition at line 37 of file fglmvec.cc.

37 :ref_count (1), N (0), elems (0)
38 {
39 }
int ref_count
Definition: fglmvec.cc:33
number * elems
Definition: fglmvec.cc:35

◆ fglmVectorRep() [2/3]

fglmVectorRep::fglmVectorRep ( int  n,
number *  e 
)
inline

Definition at line 40 of file fglmvec.cc.

40 :ref_count (1), N (n), elems (e)
41 {
42 }

◆ fglmVectorRep() [3/3]

fglmVectorRep::fglmVectorRep ( int  n)
inline

Definition at line 43 of file fglmvec.cc.

43 :ref_count (1), N (n)
44 {
45 fglmASSERT (N >= 0, "illegal Vector representation");
46 if(N == 0)
47 elems = 0;
48 else
49 {
50 elems = (number *) omAlloc (N * sizeof (number));
51 for(int i = N - 1; i >= 0; i--)
52 elems[i] = nInit (0);
53 }
54 }
int i
Definition: cfEzgcd.cc:132
#define fglmASSERT(ignore1, ignore2)
Definition: fglmvec.cc:28
#define nInit(i)
Definition: numbers.h:24
#define omAlloc(size)
Definition: omAllocDecl.h:210

◆ ~fglmVectorRep()

fglmVectorRep::~fglmVectorRep ( )
inline

Definition at line 55 of file fglmvec.cc.

56 {
57 if(N > 0)
58 {
59 for(int i = N - 1; i >= 0; i--)
60 nDelete (elems + i);
61 omFreeSize ((ADDRESS) elems, N * sizeof (number));
62 }
63 }
void * ADDRESS
Definition: auxiliary.h:119
#define nDelete(n)
Definition: numbers.h:16
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260

Member Function Documentation

◆ clone()

fglmVectorRep * fglmVectorRep::clone ( ) const
inline

Definition at line 65 of file fglmvec.cc.

66 {
67 if(N > 0)
68 {
69 number *elems_clone;
70 elems_clone = (number *) omAlloc (N * sizeof (number));
71 for(int i = N - 1; i >= 0; i--)
72 elems_clone[i] = nCopy (elems[i]);
73 return new fglmVectorRep (N, elems_clone);
74 }
75 else
76 return new fglmVectorRep (N, 0);
77 }
#define nCopy(n)
Definition: numbers.h:15

◆ copyObject()

fglmVectorRep * fglmVectorRep::copyObject ( )
inline

Definition at line 82 of file fglmvec.cc.

83 {
84 ref_count++;
85 return this;
86 }

◆ deleteObject()

BOOLEAN fglmVectorRep::deleteObject ( )
inline

Definition at line 78 of file fglmvec.cc.

79 {
80 return --ref_count == 0;
81 }

◆ ejectelem()

number fglmVectorRep::ejectelem ( int  i,
number  n 
)
inline

Definition at line 127 of file fglmvec.cc.

128 {
129 fglmASSERT (isUnique (), "should only be called if unique!");
130 number temp = elems[i - 1];
131 elems[i - 1] = n;
132 return temp;
133 }
BOOLEAN isUnique() const
Definition: fglmvec.cc:91

◆ getconstelem()

number fglmVectorRep::getconstelem ( int  i) const
inline

Definition at line 139 of file fglmvec.cc.

140 {
141 fglmASSERT (0 < i && i <= N, "getconstelem: wrong index");
142 return elems[i - 1];
143 }

◆ getelem()

number & fglmVectorRep::getelem ( int  i)
inline

Definition at line 134 of file fglmvec.cc.

135 {
136 fglmASSERT (0 < i && i <= N, "getelem: wrong index");
137 return elems[i - 1];
138 }

◆ isUnique()

BOOLEAN fglmVectorRep::isUnique ( ) const
inline

Definition at line 91 of file fglmvec.cc.

92 {
93 return ref_count == 1;
94 }

◆ isZero()

int fglmVectorRep::isZero ( ) const
inline

Definition at line 100 of file fglmvec.cc.

101 {
102 int k;
103 for(k = N; k > 0; k--)
104 {
105 if(!nIsZero (getconstelem (k)))
106 return 0;
107 }
108 return 1;
109 }
int k
Definition: cfEzgcd.cc:99
number getconstelem(int i) const
Definition: fglmvec.cc:139
#define nIsZero(n)
Definition: numbers.h:19

◆ numNonZeroElems()

int fglmVectorRep::numNonZeroElems ( ) const
inline

Definition at line 110 of file fglmvec.cc.

111 {
112 int num = 0;
113 int k;
114 for(k = N; k > 0; k--)
115 {
116 if(!nIsZero (getconstelem (k)))
117 num++;
118 }
119 return num;
120 }
CanonicalForm num(const CanonicalForm &f)

◆ refcount()

int fglmVectorRep::refcount ( ) const
inline

Definition at line 87 of file fglmvec.cc.

88 {
89 return ref_count;
90 }

◆ setelem()

void fglmVectorRep::setelem ( int  i,
number  n 
)
inline

Definition at line 121 of file fglmvec.cc.

122 {
123 fglmASSERT (0 < i && i <= N, "setelem: wrong index");
124 nDelete (elems + i - 1);
125 elems[i - 1] = n;
126 }

◆ size()

int fglmVectorRep::size ( ) const
inline

Definition at line 96 of file fglmvec.cc.

97 {
98 return N;
99 }

Friends And Related Function Documentation

◆ fglmVector

friend class fglmVector
friend

Definition at line 144 of file fglmvec.cc.

Field Documentation

◆ elems

number* fglmVectorRep::elems
private

Definition at line 35 of file fglmvec.cc.

◆ N

int fglmVectorRep::N
private

Definition at line 34 of file fglmvec.cc.

◆ ref_count

int fglmVectorRep::ref_count
private

Definition at line 33 of file fglmvec.cc.


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