Changeset c12222 in git


Ignore:
Timestamp:
May 20, 2010, 12:18:26 PM (14 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
e1fdcd8ea460f8c28c868c05c0d259c7c4ccb596
Parents:
2f8028c574b7c94d009a6d3ad022799721ce8341
Message:
long R simplified

git-svn-id: file:///usr/local/Singular/svn/trunk@12800 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/gnumpfl.cc

    r2f8028 rc12222  
    2525static number ngfMapP(number from)
    2626{
    27   if ( from != NULL)
    28     return ngfInit(npInt(from,ngfMapRing), currRing);
    29   else
    30     return NULL;
     27  return ngfInit(npInt(from,ngfMapRing), currRing);
    3128}
    3229number ngfMapQ(number from)
    3330{
    34   if ( from != NULL )
    35   {
    36     gmp_float *res=new gmp_float(numberFieldToFloat(from,QTOF));
    37     return (number)res;
    38   }
    39   else
    40     return NULL;
     31  gmp_float *res=new gmp_float(numberFieldToFloat(from,QTOF));
     32  return (number)res;
    4133}
    4234union nf
     
    5143static number ngfMapR(number from)
    5244{
    53   if ( from != NULL )
    54   {
    55     gmp_float *res=new gmp_float((double)nf(from).F());
    56     return (number)res;
    57   }
    58   else
    59     return NULL;
     45  gmp_float *res=new gmp_float((double)nf(from).F());
     46  return (number)res;
    6047}
    6148static number ngfMapC(number from)
    6249{
    63   if ( (from != NULL) || ((gmp_complex*)from)->real().isZero() )
    64   {
    65     gmp_float *res=new gmp_float(((gmp_complex*)from)->real());
    66     return (number)res;
    67   }
    68   else
    69     return NULL;
     50  gmp_float *res=new gmp_float(((gmp_complex*)from)->real());
     51  return (number)res;
    7052}
    7153
     
    10183number ngfInit (int i, const ring r)
    10284{
    103   gmp_float* n= NULL;
    104   if ( i != 0 )
    105   {
    106     n= new gmp_float( (double)i );
    107   }
     85  gmp_float* n= new gmp_float( (double)i );
    10886  return (number)n;
    10987}
     
    11492int ngfInt(number &i, const ring r)
    11593{
    116   if ( i == NULL ) return 0;
    11794  double d=(double)*(gmp_float*)i;
    11895  if (d<0.0)
     
    139116number ngfCopy(number a)
    140117{
    141   gmp_float* b= NULL;
    142   if ( a !=  NULL )
    143   {
    144     b= new gmp_float( *(gmp_float*)a );
    145   }
     118  gmp_float* b= new gmp_float( *(gmp_float*)a );
    146119  return (number)b;
    147120}
     
    149122number ngf_Copy(number a, ring r)
    150123{
    151   gmp_float* b= NULL;
    152   if ( a !=  NULL )
    153   {
    154     b= new gmp_float( *(gmp_float*)a );
    155   }
     124  gmp_float* b= new gmp_float( *(gmp_float*)a );
    156125  return (number)b;
    157126}
     
    162131number ngfNeg (number a)
    163132{
    164   if ( a == NULL ) return NULL;
    165133  *(gmp_float*)a= -(*(gmp_float*)a);
    166134  return (number)a;
     
    173141{
    174142  gmp_float* r= NULL;
    175   if ( (a==NULL) || ((gmp_float*)a)->isZero() )
     143  if (((gmp_float*)a)->isZero() )
    176144  {
    177145    WerrorS(nDivBy0);
     
    189157number ngfAdd (number a, number b)
    190158{
    191   gmp_float* r= NULL;
    192   if ( a==NULL && b==NULL )
    193   {
    194     return NULL;
    195   }
    196   else if ( a == NULL )
    197   {
    198     r= new gmp_float( *(gmp_float*)b );
    199   }
    200   else if ( b == NULL )
    201   {
    202     r= new gmp_float( *(gmp_float*)a );
    203   }
    204   else
    205   {
    206     r= new gmp_float( (*(gmp_float*)a) + (*(gmp_float*)b) );
    207   }
     159  gmp_float* r= new gmp_float( (*(gmp_float*)a) + (*(gmp_float*)b) );
    208160  return (number)r;
    209161}
     
    214166number ngfSub (number a, number b)
    215167{
    216   gmp_float* r= NULL;
    217   if ( a==NULL && b==NULL )
    218   {
    219     return NULL;
    220   }
    221   else if ( a == NULL )
    222   {
    223     r= new gmp_float( -(*(gmp_float*)b) );
    224   }
    225   else if ( b == NULL )
    226   {
    227     r= new gmp_float( *(gmp_float*)a );
    228   }
    229   else
    230   {
    231     r= new gmp_float( (*(gmp_float*)a) - (*(gmp_float*)b) );
    232   }
     168  gmp_float* r= new gmp_float( (*(gmp_float*)a) - (*(gmp_float*)b) );
    233169  return (number)r;
    234170}
     
    239175number ngfMult (number a, number b)
    240176{
    241   gmp_float* r= NULL;
    242   if ( a==NULL || b==NULL )
    243   {
    244     return NULL;
    245   }
    246   else
    247   {
    248     r= new gmp_float( (*(gmp_float*)a) * (*(gmp_float*)b) );
    249   }
     177  gmp_float* r= new gmp_float( (*(gmp_float*)a) * (*(gmp_float*)b) );
    250178  return (number)r;
    251179}
     
    256184number ngfDiv (number a, number b)
    257185{
    258   if ( a==NULL )
    259   {
    260     // 0/b = 0
    261     return NULL;
    262   }
    263   else if ( b==NULL || ((gmp_float*)b)->isZero() )
     186  if ( ((gmp_float*)b)->isZero() )
    264187  {
    265188    // a/0 = error
     
    284207  else if ( ngfIsZero(x) ) // 0^e, e>0
    285208  {
    286     gmp_float* n = NULL;
     209    *u=ngfInit(0, currRing);
     210    return;
     211  }
     212  else if ( exp == 1 )
     213  {
     214    nNew(u);
     215    gmp_float* n = new gmp_float();
     216    *n= *(gmp_float*)x;
    287217    *u=(number)n;
    288     return;
    289   }
    290   else if ( exp == 1 )
    291   {
    292     nNew(u);
    293     if ( x == NULL )
    294     {
    295       gmp_float* n = new gmp_float();
    296       *u=(number)n;
    297     }
    298     else
    299     {
    300       gmp_float* n = new gmp_float();
    301       *n= *(gmp_float*)x;
    302       *u=(number)n;
    303     }
    304218    return;
    305219  }
     
    314228BOOLEAN ngfIsZero (number a)
    315229{
    316   if ( a == NULL ) return TRUE;
    317230  return ( ((gmp_float*)a)->isZero() );
    318231}
     
    323236BOOLEAN ngfGreaterZero (number a)
    324237{
    325   if ( a == NULL ) return TRUE;
    326238  return ( (*(gmp_float*)a) >= (gmp_float)0.0 );
    327239}
     
    332244BOOLEAN ngfGreater (number a, number b)
    333245{
    334   if ( a==NULL )
    335   {
    336     return (((gmp_float*)b)->sign() < 0);
    337   }
    338   if ( b==NULL )
    339   {
    340     return (((gmp_float*)a)->sign() > 0);
    341   }
    342246  return ( (*(gmp_float*)a) > (*(gmp_float*)b) );
    343247}
     
    348252BOOLEAN ngfEqual (number a, number b)
    349253{
    350   if ( a == NULL && b == NULL )
    351   {
    352     return TRUE;
    353   }
    354   else if ( a == NULL || b == NULL )
    355   {
    356     return FALSE;
    357   }
    358254  return ( (*(gmp_float*)a) == (*(gmp_float*)b) );
    359255}
     
    364260BOOLEAN ngfIsOne (number a)
    365261{
    366   if ( a == NULL ) return FALSE;
    367262  return ((gmp_float*)a)->isOne();
    368263}
     
    373268BOOLEAN ngfIsMOne (number a)
    374269{
    375   if ( a == NULL ) return FALSE;
    376270  return ((gmp_float*)a)->isMOne();
    377271}
Note: See TracChangeset for help on using the changeset viewer.