Changeset da434c in git for kernel/mpr_complex.h


Ignore:
Timestamp:
Apr 28, 2004, 3:31:36 PM (20 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
d7797c7213f5578d33b30fdba9df4d4db6e82de9
Parents:
e53f119e2af350f2008d95156ceb0fccb57642e7
Message:
*hannes: gcc 3


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

Legend:

Unmodified
Added
Removed
  • kernel/mpr_complex.h

    re53f11 rda434c  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: mpr_complex.h,v 1.1.1.1 2003-10-06 12:15:58 Singular Exp $ */
     6/* $Id: mpr_complex.h,v 1.2 2004-04-28 13:31:36 Singular Exp $ */
    77
    88/*
     
    6565  }
    6666
     67  inline gmp_float & operator = ( const gmp_float & a )
     68  {
     69    mpf_set( t, a.t );
     70    return *this;
     71  };
     72  inline gmp_float & operator = ( const mpz_t & a )
     73  {
     74    mpf_set_z( t, a );
     75    return *this;
     76  };
     77  inline gmp_float & operator = ( const mprfloat a )
     78  {
     79    mpf_set_d( t, (double) a );
     80    return *this;
     81  };
     82  inline gmp_float & operator = ( const long a )
     83  {
     84    mpf_set_d( t, (double) a );
     85    return *this;
     86  };
     87
     88  gmp_float & operator += ( const gmp_float & a );
     89  gmp_float & operator -= ( const gmp_float & a );
     90  inline gmp_float & operator *= ( const gmp_float & a )
     91  {
     92    mpf_mul( t, t, a.t );
     93    return *this;
     94  };
     95
     96  inline gmp_float & operator /= ( const gmp_float & a )
     97  {
     98    mpf_div( t, t, a.t );
     99    return *this;
     100  };
     101
    67102  friend gmp_float operator + ( const gmp_float & a, const gmp_float & b );
    68103  friend gmp_float operator - ( const gmp_float & a, const gmp_float & b );
    69104  friend gmp_float operator * ( const gmp_float & a, const gmp_float & b );
    70105  friend gmp_float operator / ( const gmp_float & a, const gmp_float & b );
    71 
    72   gmp_float & operator += ( const gmp_float & a );
    73   gmp_float & operator -= ( const gmp_float & a );
    74   inline gmp_float & operator *= ( const gmp_float & a );
    75   inline gmp_float & operator /= ( const gmp_float & a );
    76106
    77107  friend bool operator == ( const gmp_float & a, const gmp_float & b );
     
    83113  friend gmp_float operator - ( const gmp_float & a );
    84114
    85   gmp_float & operator = ( const gmp_float & a );
    86   gmp_float & operator = ( const mpz_t & a );
    87   gmp_float & operator = ( const mprfloat a );
    88   gmp_float & operator = ( const long a );
    89 
    90   inline int sign();    // t>0:+1, t==0:0, t<0:-1
     115  inline int sign()    // t>0:+1, t==0:0, t<0:-1
     116  { return mpf_sgn( t ); };
     117 
    91118  bool isZero();  // t == 0 ?
    92119  bool isOne();   // t == 1 ?
     
    96123
    97124  // access
    98   inline const mpf_t *mpfp() const;
    99   inline mpf_t *_mpfp();
     125  inline const mpf_t *mpfp() const { return &t; };
     126  inline mpf_t *_mpfp() { return &t; };
    100127 
    101   inline operator double();
    102   inline operator double() const;
    103 
    104   inline operator int();
    105   inline operator int() const;
     128  inline operator double() { return mpf_get_d( t ); };
     129  inline operator double() const { return mpf_get_d( t ); };
     130
     131  inline operator int() { return (int)mpf_get_d( t ); };
     132  inline operator int() const { return (int)mpf_get_d( t ); };
    106133
    107134private:
     
    109136};
    110137
    111 // <gmp_float> operator <gmp_float>
    112 inline gmp_float & gmp_float::operator *= ( const gmp_float & a )
    113 {
    114   mpf_mul( t, t, a.t );
    115   return *this;
    116 }
    117 inline gmp_float & gmp_float::operator /= ( const gmp_float & a )
    118 {
    119   mpf_div( t, t, a.t );
    120   return *this;
    121 }
    122 
    123 // <gmp_float> = <*>
    124 inline gmp_float & gmp_float::operator = ( const gmp_float & a )
    125 {
    126   mpf_set( t, a.t );
    127   return *this;
    128 }
    129 inline gmp_float & gmp_float::operator = ( const mpz_t & a )
    130 {
    131   mpf_set_z( t, a );
    132   return *this;
    133 }
    134 inline gmp_float & gmp_float::operator = ( const mprfloat a )
    135 {
    136   mpf_set_d( t, (double) a );
    137   return *this;
    138 }
    139 inline gmp_float & gmp_float::operator = ( const long a )
    140 {
    141   mpf_set_d( t, (double) a );
    142   return *this;
    143 }
    144 
    145 // cast to double
    146 inline gmp_float::operator double()
    147 {
    148   return mpf_get_d( t );
    149 }
    150 inline gmp_float::operator double() const
    151 {
    152   return mpf_get_d( t );
    153 }
    154 
    155 // cast to int
    156 inline gmp_float::operator int()
    157 {
    158   return (int)mpf_get_d( t );
    159 }
    160 inline gmp_float::operator int() const
    161 {
    162   return (int)mpf_get_d( t );
    163 }
    164 
    165 // get sign of real number ( -1: t < 0; 0: t==0; 1: t > 0 )
    166 inline int gmp_float::sign()
    167 {
    168   return mpf_sgn( t );
    169 }
    170 
    171 // access pointer
    172 inline const mpf_t *gmp_float::mpfp() const
    173 {
    174   return &t;
    175 }
    176 
    177 inline mpf_t *gmp_float::_mpfp()
    178 {
    179   return &t;
    180 }
    181138
    182139// built-in functions of GMP
Note: See TracChangeset for help on using the changeset viewer.