Changeset da434c in git for kernel/mpr_complex.h
- Timestamp:
- Apr 28, 2004, 3:31:36 PM (20 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- d7797c7213f5578d33b30fdba9df4d4db6e82de9
- Parents:
- e53f119e2af350f2008d95156ceb0fccb57642e7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/mpr_complex.h
re53f11 rda434c 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: mpr_complex.h,v 1. 1.1.1 2003-10-06 12:15:58Singular Exp $ */6 /* $Id: mpr_complex.h,v 1.2 2004-04-28 13:31:36 Singular Exp $ */ 7 7 8 8 /* … … 65 65 } 66 66 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 67 102 friend gmp_float operator + ( const gmp_float & a, const gmp_float & b ); 68 103 friend gmp_float operator - ( const gmp_float & a, const gmp_float & b ); 69 104 friend gmp_float operator * ( const gmp_float & a, const gmp_float & b ); 70 105 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 );76 106 77 107 friend bool operator == ( const gmp_float & a, const gmp_float & b ); … … 83 113 friend gmp_float operator - ( const gmp_float & a ); 84 114 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 91 118 bool isZero(); // t == 0 ? 92 119 bool isOne(); // t == 1 ? … … 96 123 97 124 // 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; }; 100 127 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 ); }; 106 133 107 134 private: … … 109 136 }; 110 137 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 double146 inline gmp_float::operator double()147 {148 return mpf_get_d( t );149 }150 inline gmp_float::operator double() const151 {152 return mpf_get_d( t );153 }154 155 // cast to int156 inline gmp_float::operator int()157 {158 return (int)mpf_get_d( t );159 }160 inline gmp_float::operator int() const161 {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 pointer172 inline const mpf_t *gmp_float::mpfp() const173 {174 return &t;175 }176 177 inline mpf_t *gmp_float::_mpfp()178 {179 return &t;180 }181 138 182 139 // built-in functions of GMP
Note: See TracChangeset
for help on using the changeset viewer.