Changeset 58aa457 in git


Ignore:
Timestamp:
May 10, 2010, 3:56:38 PM (14 years ago)
Author:
Andreas Steenpass <steenpass@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
f945d2b0105e7e765829a443b2044990186c9f2e
Parents:
e3c02d2b15d64dbff4ac5fe4ef2227cbaeb5a216
git-author:
Andreas Steenpass <steenpass@mathematik.uni-kl.de>2010-05-10 15:56:38+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:52:54+01:00
Message:
gnumpfl (not yet finished)
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • .gitignore

    re3c02d2 r58aa457  
    55*.og
    66*.exe
     7*.swp
    78depend
    89tags
     
    1112config.status
    1213config.log
     14tags
    1315stamp-h
    1416ix86-Linux/*
  • coeffs/gnumpfl.cc

    re3c02d2 r58aa457  
    99*/
    1010
    11 #include <kernel/mod2.h>
    12 #include <kernel/structs.h>
    13 #include <kernel/febase.h>
    14 #include <omalloc/omalloc.h>
    15 #include <kernel/numbers.h>
    16 #include <kernel/modulop.h>
    17 #include <kernel/longrat.h>
    18 
    19 #include <kernel/gnumpfl.h>
    20 #include <kernel/mpr_complex.h>
     11#include "config.h"
     12#include "coeffs.h"
     13#include <output.h>
     14#include <omalloc.h>
     15#include "numbers.h"
     16#include "modulop.h"
     17#include "longrat.h"
     18
     19#include <gnumpfl.h>
     20#include <mpr_complex.h>
    2121
    2222extern size_t gmp_output_digits;
    23 ring ngfMapRing; // to be used also in gnumpc.cc
    24 
    25 static number ngfMapP(number from)
    26 {
    27   return ngfInit(npInt(from,ngfMapRing), currRing);
    28 }
    29 number ngfMapQ(number from)
     23//ring ngfMapRing; // to be used also in gnumpc.cc
     24
     25static number ngfMapP(number from, const coeffs src, const coeffs dst)
     26{
     27  return ngfInit(npInt(from,src), dst);
     28}
     29number ngfMapQ(number from, const coeffs src, const coeffs dst)
    3030{
    3131  gmp_float *res=new gmp_float(numberFieldToFloat(from,QTOF));
     
    4141  number N() const {return _n;}
    4242};
    43 static number ngfMapR(number from)
     43static number ngfMapR(number from, const coeffs src, const coeffs dst)
    4444{
    4545  gmp_float *res=new gmp_float((double)nf(from).F());
    4646  return (number)res;
    4747}
    48 static number ngfMapC(number from)
     48static number ngfMapC(number from, const coeffs src, const coeffs dst)
    4949{
    5050  gmp_float *res=new gmp_float(((gmp_complex*)from)->real());
     
    8181* n := i
    8282*/
    83 number ngfInit (int i, const ring r)
     83number ngfInit (int i, const coeffs r)
    8484{
    8585  gmp_float* n= new gmp_float( (double)i );
     
    9090* convert number to int
    9191*/
    92 int ngfInt(number &i, const ring r)
     92int ngfInt(number &i, const coeffs r)
    9393{
    9494  double d=(double)*(gmp_float*)i;
     
    9999}
    100100
    101 int ngfSize(number n)
    102 {
    103   int i = ngfInt(n, currRing);
     101int ngfSize(number n, const coeffs r)
     102{
     103  int i = ngfInt(n, r);
    104104  /* basically return the largest integer in n;
    105105     only if this happens to be zero although n != 0,
     
    113113* delete a
    114114*/
    115 void ngfDelete (number * a, const ring r)
     115void ngfDelete (number * a, const coeffs r)
    116116{
    117117  if ( *a != NULL )
     
    125125* copy a to b
    126126*/
    127 number ngfCopy(number a)
     127number ngfCopy(number a, const coeffs r)
    128128{
    129129  gmp_float* b= new gmp_float( *(gmp_float*)a );
     
    131131}
    132132
    133 number ngf_Copy(number a, ring r)
    134 {
    135   gmp_float* b= new gmp_float( *(gmp_float*)a );
    136   return (number)b;
    137 }
    138 
    139133/*2
    140134* za:= - za
    141135*/
    142 number ngfNeg (number a)
     136number ngfNeg (number a, const coeffs r)
    143137{
    144138  *(gmp_float*)a= -(*(gmp_float*)a);
     
    149143* 1/a
    150144*/
    151 number ngfInvers(number a)
     145number ngfInvers(number a, const coeffs R)
    152146{
    153147  gmp_float* r= NULL;
     
    158152  else
    159153  {
    160     r= new gmp_float( (gmp_float)1 / (*(gmp_float*)a) );
    161   }
    162   return (number)r;
     154    f= new gmp_float( gmp_float(1) / (*(gmp_float*)a) );
     155  }
     156  return (number)f;
    163157}
    164158
     
    166160* u:= a + b
    167161*/
    168 number ngfAdd (number a, number b)
     162number ngfAdd (number a, number b, const coeffs R)
    169163{
    170164  gmp_float* r= new gmp_float( (*(gmp_float*)a) + (*(gmp_float*)b) );
     
    175169* u:= a - b
    176170*/
    177 number ngfSub (number a, number b)
     171number ngfSub (number a, number b, const coeffs R)
    178172{
    179173  gmp_float* r= new gmp_float( (*(gmp_float*)a) - (*(gmp_float*)b) );
     
    184178* u := a * b
    185179*/
    186 number ngfMult (number a, number b)
     180number ngfMult (number a, number b, const coeffs R)
    187181{
    188182  gmp_float* r= new gmp_float( (*(gmp_float*)a) * (*(gmp_float*)b) );
     
    193187* u := a / b
    194188*/
    195 number ngfDiv (number a, number b)
     189number ngfDiv (number a, number b, const coeffs r)
    196190{
    197191  if ( ((gmp_float*)b)->isZero() )
     
    201195    return NULL;
    202196  }
    203   gmp_float* r= new gmp_float( (*(gmp_float*)a) / (*(gmp_float*)b) );
    204   return (number)r;
     197  gmp_float* f= new gmp_float( (*(gmp_float*)a) / (*(gmp_float*)b) );
     198  return (number)f;
    205199}
    206200
     
    208202* u:= x ^ exp
    209203*/
    210 void ngfPower ( number x, int exp, number * u )
     204number ngfPower (number x, int exp, const coeffs r)
    211205{
    212206  if ( exp == 0 )
     
    218212  else if ( ngfIsZero(x) ) // 0^e, e>0
    219213  {
    220     *u=ngfInit(0, currRing);
     214    *u=ngfInit(0, r);
    221215    return;
    222216  }
    223217  else if ( exp == 1 )
    224218  {
    225     nNew(u);
     219    n_New(u, r);
    226220    gmp_float* n = new gmp_float();
    227221    *n= *(gmp_float*)x;
     
    229223    return;
    230224  }
    231   ngfPower(x,exp-1,u);
    232 
    233   gmp_float *n=new gmp_float();
    234   *n=*(gmp_float*)x;
    235   *(gmp_float*)(*u) *= *(gmp_float*)n;
    236   delete (gmp_float*)n;
    237 }
    238 
    239 BOOLEAN ngfIsZero (number a)
     225  f = new gmp_float();
     226  f = (*(gmp_float*)x)^exp;
     227  return (number)f;
     228}
     229
     230/* kept for compatibility reasons, to be deleted */
     231void ngfPower ( number x, int exp, number * u, const coeffs r )
     232{
     233  *u = ngfPower(x, exp, r);
     234}
     235
     236BOOLEAN ngfIsZero (number a, const coeffs r)
    240237{
    241238  return ( ((gmp_float*)a)->isZero() );
     
    243240
    244241/*2
    245 * za >= 0 ?
    246 */
    247 BOOLEAN ngfGreaterZero (number a)
    248 {
    249   return ( (*(gmp_float*)a) >= (gmp_float)0.0 );
     242* za > 0 ?
     243*/
     244BOOLEAN ngfGreaterZero (number a, const coeffs r)
     245{
     246  return (((gmp_float*)a)->sign() > 0);
    250247}
    251248
     
    253250* a > b ?
    254251*/
    255 BOOLEAN ngfGreater (number a, number b)
     252BOOLEAN ngfGreater (number a, number b, const coeffs r)
    256253{
    257254  return ( (*(gmp_float*)a) > (*(gmp_float*)b) );
     
    261258* a = b ?
    262259*/
    263 BOOLEAN ngfEqual (number a, number b)
     260BOOLEAN ngfEqual (number a, number b, const coeffs r)
    264261{
    265262  return ( (*(gmp_float*)a) == (*(gmp_float*)b) );
     
    269266* a == 1 ?
    270267*/
    271 BOOLEAN ngfIsOne (number a)
     268BOOLEAN ngfIsOne (number a, const coeffs r)
    272269{
    273270  return ((gmp_float*)a)->isOne();
     
    277274* a == -1 ?
    278275*/
    279 BOOLEAN ngfIsMOne (number a)
     276BOOLEAN ngfIsMOne (number a, const coeffs r)
    280277{
    281278  return ((gmp_float*)a)->isMOne();
    282 }
    283 
    284 /*2
    285 * result =gcd(a,b)
    286 * dummy, returns 1
    287 */
    288 number ngfGcd(number a, number b)
    289 {
    290   gmp_float *result= new gmp_float( 1 );
    291   return (number)result;
    292279}
    293280
     
    318305* extracts the number a from s, returns the rest
    319306*/
    320 const char * ngfRead (const char * start, number * a)
     307const char * ngfRead (const char * start, number * a, const coeffs r)
    321308{
    322309  char *s= (char *)start;
     
    375362* write a floating point number
    376363*/
    377 void ngfWrite (number &a, const ring r)
     364void ngfWrite (number &a, const coeffs r)
    378365{
    379366  char *out;
     
    391378}
    392379
    393 #ifdef LDEBUG
    394 //BOOLEAN ngfDBTest(number a, const char *f, const int l)
    395 //{
    396 //  return TRUE;
    397 //}
    398 #endif
    399 
    400 // local Variables: ***
    401 // folded-file: t ***
    402 // compile-command: "make installg" ***
    403 // End: ***
  • coeffs/gnumpfl.h

    re3c02d2 r58aa457  
    3030void     ngfWrite(number &a, const coeffs r);
    3131
    32 #ifdef LDEBUG
    33 BOOLEAN  ngfDBTest(number a, const char *f, const int l);
    34 #endif
    3532void     ngfDelete(number *a, const coeffs r);
    3633
  • coeffs/mpr_complex.h

    re3c02d2 r58aa457  
    104104  friend gmp_float operator * ( const gmp_float & a, const gmp_float & b );
    105105  friend gmp_float operator / ( const gmp_float & a, const gmp_float & b );
     106
     107  inline gmp_float operator ^ ( const gmp_float & a, const int exp )
     108  {
     109    mpf_t b;
     110    mpf_init(b);
     111    mpf_pow( b, a.t, (unsigned long)exp );
     112    return (gmp_float)b;
     113  };
    106114
    107115  friend bool operator == ( const gmp_float & a, const gmp_float & b );
Note: See TracChangeset for help on using the changeset viewer.