~ubuntu-branches/ubuntu/saucy/gfan/saucy-proposed

« back to all changes in this revision

Viewing changes to field.cpp

  • Committer: Package Import Robot
  • Author(s): Cédric Boutillier
  • Date: 2013-07-09 10:44:01 UTC
  • mfrom: (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130709104401-5q66ozz5j5af0dak
Tags: 0.5+dfsg-3
* Upload to unstable.
* modify remove_failing_tests_on_32bits.patch to replace command of
  0009RenderStairCase test with an empty one instead of deleting it.
* remove lintian override about spelling error

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
#include <memory>
4
4
#include <assert.h>
 
5
#include <cstdio> /* Always include cstdio before gmp.h.*/
5
6
#include <gmp.h>
6
7
 
7
8
#include "printer.h"
48
49
}
49
50
 
50
51
 
 
52
double FieldElement::floatingPointApproximation()const
 
53
{
 
54
        mpq_t const *p=getGmpRationalTemporaryPointer();
 
55
 
 
56
        return mpq_get_d(*p);//LEAK??
 
57
}
 
58
 
 
59
 
 
60
bool FieldElement::isInteger()const
 
61
{
 
62
  return implementingObject->isInteger();
 
63
}
 
64
 
51
65
FieldElement::~FieldElement()
52
66
{
53
67
  if(implementingObject && 0==(--(implementingObject->refCount)))
101
115
}
102
116
 
103
117
 
104
 
bool FieldElement::isZero()
 
118
bool FieldElement::isZero()const
105
119
{
106
120
  assert(implementingObject);
107
121
  return implementingObject->isZero();
140
154
  return FieldElement(implementingObject->inverse());
141
155
}
142
156
 
 
157
int FieldElement::sign()const
 
158
{
 
159
  assert(implementingObject);
 
160
  return implementingObject->sign();
 
161
}
 
162
 
 
163
 
 
164
int FieldElement::pAdicValuation(int p)const
 
165
{
 
166
  assert(implementingObject);
 
167
  return implementingObject->pAdicValuation(p);
 
168
}
 
169
 
 
170
 
 
171
FieldElement FieldElement::pAdicRemainder(class Field const &ZModPZ)const
 
172
{
 
173
  assert(implementingObject);
 
174
  return FieldElement(implementingObject->pAdicRemainder(ZModPZ));
 
175
}
 
176
 
 
177
 
 
178
int FieldElement::integerRepresentative()const
 
179
{
 
180
  assert(implementingObject);
 
181
  return implementingObject->integerRepresentative();
 
182
}
 
183
 
143
184
std::string FieldElement::toString(bool writeIfOne, bool alwaysWriteSign, bool latexMode) const
144
185
{
145
186
  assert(implementingObject);
146
187
  return implementingObject->toString(writeIfOne,alwaysWriteSign,latexMode);
147
188
}
 
189
 
 
190
 
148
191
void FieldElement::operator*=(const FieldElement &a)
149
192
{
150
193
  assert(a.implementingObject);
155
198
      implementingObject=implementingObject->copy();
156
199
    }
157
200
  (*implementingObject)*=(*a.implementingObject);
158
 
  
159
 
}
 
201
}
 
202
 
 
203
 
 
204
void FieldElement::operator+=(const FieldElement &a)
 
205
{
 
206
  assert(a.implementingObject);
 
207
  assert(implementingObject);
 
208
  if(implementingObject->refCount!=1)
 
209
    {
 
210
      implementingObject->refCount--;
 
211
      implementingObject=implementingObject->copy();
 
212
    }
 
213
  (*implementingObject)+=(*a.implementingObject);
 
214
}
 
215
 
 
216
 
 
217
void FieldElement::madd(const FieldElement &a, const FieldElement &b)
 
218
{
 
219
  assert(a.implementingObject);
 
220
  assert(b.implementingObject);
 
221
  assert(implementingObject);
 
222
  if(implementingObject->refCount!=1)
 
223
    {
 
224
      implementingObject->refCount--;
 
225
      implementingObject=implementingObject->copy();
 
226
    }
 
227
  (*implementingObject).madd(*a.implementingObject,*b.implementingObject);
 
228
}
 
229
 
160
230
 
161
231
FieldElement operator*(const FieldElement &a,const FieldElement &b)
162
232
{
209
279
const char *Field::name()
210
280
{
211
281
  return implementingObject->name();
212
 
};
 
282
}
 
283
 
 
284
 
 
285
bool Field::isRationals()const
 
286
{
 
287
  return implementingObject->isRationals();
 
288
}
213
289
 
214
290
std::string Field::toString()const{
215
291
  return implementingObject->toString();
330
406
{
331
407
  fprintf(Stderr,"test");
332
408
  //  checkInitialized();
333
 
  return currentField->zHomomorphism(n); 
 
409
  return currentField->zHomomorphism(n);
334
410
  }*/
335
411
 
336
412