Changeset ac5686 in git


Ignore:
Timestamp:
May 5, 2010, 5:47:52 PM (13 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
1990de843c36aeaeb40e702d7d4a1ecc8ff753ea
Parents:
3b1a8d2d42c74cbc3f3f8b25288fd7d79934d0d4
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2010-05-05 17:47:52+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:52:53+01:00
Message:
GMP-Complex numbers are done now
Location:
coeffs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • coeffs/gnumpc.cc

    r3b1a8d2 rac5686  
    4646  if ( from != NULL )
    4747  {
    48     gmp_complex *res=new gmp_complex(numberFieldToFloat(from,QTOF));
     48    gmp_complex *res=new gmp_complex(numberFieldToFloat(from,QTOF,aRing));
    4949    return (number)res;
    5050  }
     
    463463  {
    464464    char *out;
    465     out= complexToStr(*(gmp_complex*)a, gmp_output_digits);
     465    out= complexToStr(*(gmp_complex*)a, gmp_output_digits, r);
    466466    StringAppendS(out);
    467467    //    omFreeSize((void *)out, (strlen(out)+1)* sizeof(char) );
  • coeffs/mpr_complex.cc

    r3b1a8d2 rac5686  
    373373// makes a COPY of num! (Ist das gut?)
    374374//
    375 gmp_float numberToFloat( number num )
     375gmp_float numberToFloat( number num, const coeffs src)
    376376{
    377377  gmp_float r;
    378378
    379   if ( rField_is_Q() )
     379  if ( nField_is_Q(src) )
    380380  {
    381381    if ( num != NULL )
     
    389389        if ( num->s == 0 )
    390390        {
    391           nlNormalize( num );
     391          nlNormalize( num, src );
    392392        }
    393393        if (SR_HDL(num) & SR_INT)
     
    414414    }
    415415  }
    416   else if (rField_is_long_R() || rField_is_long_C())
     416  else if (nField_is_long_R(src) || nField_is_long_C(src))
    417417  {
    418418    r= *(gmp_float*)num;
    419419  }
    420   else if ( rField_is_R() )
     420  else if ( nField_is_R(src) )
    421421  {
    422422    // Add some code here :-)
     
    431431}
    432432
    433 gmp_float numberFieldToFloat( number num, int k )
     433gmp_float numberFieldToFloat( number num, int k, const coeffs src)
    434434{
    435435  gmp_float r;
     
    448448        if ( num->s == 0 )
    449449        {
    450           nlNormalize( num );
     450          nlNormalize( num, src );
    451451        }
    452452        if (SR_HDL(num) & SR_INT)
     
    702702// converts a gmp_complex to a string ( <real part> + I * <imaginary part> )
    703703//
    704 char *complexToStr( gmp_complex & c, const unsigned int oprec )
     704char *complexToStr( gmp_complex & c, const unsigned int oprec, const coeffs src )
    705705{
    706706  char *out,*in_imag,*in_real;
     
    713713    in_imag=floatToStr( abs(c.imag()), oprec );    // get imaginary part
    714714
    715     if (rField_is_long_C())
    716     {
    717       int len=(strlen(in_real)+strlen(in_imag)+7+strlen(currRing->parameter[0]))*sizeof(char);
     715    if (nField_is_long_C(src))
     716    {
     717      int len=(strlen(in_real)+strlen(in_imag)+7+strlen(src->parameter[0]))*sizeof(char);
    718718      out=(char*)omAlloc(len);
    719719      memset(out,0,len);
    720720      if (  !c.real().isZero() )  // (-23-i*5.43) or (15.1+i*5.3)
    721         sprintf(out,"(%s%s%s*%s)",in_real,c.imag().sign()>=0?"+":"-",currRing->parameter[0],in_imag);
     721        sprintf(out,"(%s%s%s*%s)",in_real,c.imag().sign()>=0?"+":"-",src->parameter[0],in_imag);
    722722      else // (-i*43) or (i*34)
    723723      {
    724724        if (c.imag().isOne())
    725           sprintf(out,"%s",currRing->parameter[0]);
     725          sprintf(out,"%s",src->parameter[0]);
    726726        else if (c.imag().isMOne())
    727           sprintf(out,"-%s",currRing->parameter[0]);
     727          sprintf(out,"-%s",src->parameter[0]);
    728728        else
    729           sprintf(out,"(%s%s*%s)",c.imag().sign()>=0?"":"-",currRing->parameter[0],in_imag);
     729          sprintf(out,"(%s%s*%s)",c.imag().sign()>=0?"":"-",src->parameter[0],in_imag);
    730730      }
    731731    }
  • coeffs/mpr_complex.h

    r3b1a8d2 rac5686  
    159159gmp_float max( const gmp_float &, const gmp_float & );
    160160
    161 gmp_float numberToFloat( number num );
    162 gmp_float numberFieldToFloat( number num, int k );
     161gmp_float numberToFloat( number num, const coeffs src );
     162gmp_float numberFieldToFloat( number num, int k, const coeffs src );
    163163//char *floatToStr( const gmp_float & r, const unsigned int oprec );
    164164//<-
     
    308308  else
    309309  {
    310     return gmp_complex( numberToFloat(num) );
    311   }
    312 }
    313 
    314 char *complexToStr( gmp_complex & c, const  unsigned int oprec );
     310    return gmp_complex( numberToFloat(num, r) );
     311  }
     312}
     313
     314char *complexToStr( gmp_complex & c, const  unsigned int oprec, const coeffs src );
    315315//<-
    316316
Note: See TracChangeset for help on using the changeset viewer.