Code: Select all
Type mpfr
Declare Constructor ( )
Declare Constructor ( Byval rhs As Long )
Declare Constructor ( Byval rhs As LongInt )
Declare Constructor ( Byval rhs As Integer )
Declare Constructor ( Byval rhs As Double )
Declare Constructor ( Byval rhs As Single )
Declare Constructor ( Byref rhs As String )
Declare Constructor ( Byref rhs As mpfr )
Declare Destructor ( )
Declare Operator Let ( Byref rhs As mpfr )
Declare Operator Let ( Byval rhs As Long )
Declare Operator Let ( Byval rhs As LongInt )
Declare Operator Let ( Byval rhs As Integer )
Declare Operator Let ( Byval rhs As Double )
Declare Operator Let ( Byval rhs As Single )
Declare Operator Let ( Byref rhs As String )
Declare Operator Cast ( ) As String
Declare Operator Cast ( ) As Long
Declare Operator Cast ( ) As Double
Declare Operator Cast ( ) As Single
'----------------------------------------------
Declare Operator += (Byref rhs as mpfr)
Declare Operator += (Byval rhs as long)
Declare Operator += (byval rhs as double)
Declare Operator += (byval rhs as single)
Declare Operator += (byval rhs as longint)
Declare Operator += (byval rhs as integer)
Declare Operator += (byref rhs as String)
Declare Operator -= (Byref rhs as mpfr)
Declare Operator -= (byval rhs as double)
Declare Operator -= (byval rhs as single)
Declare Operator -= (byval rhs as longint)
Declare Operator -= (byval rhs as integer)
Declare Operator -= (byval rhs as long)
Declare Operator -= (byref rhs as String)
Declare Operator *= (Byref rhs as mpfr)
Declare Operator *= (byval rhs as double)
Declare Operator *= (byval rhs as single)
Declare Operator *= (byval rhs as longint)
Declare Operator *= (byval rhs as integer)
Declare Operator *= (byval rhs as long)
Declare Operator *= (byref rhs as String)
Declare Operator /= (Byref rhs as mpfr)
Declare Operator /= (byval rhs as double)
Declare Operator /= (byval rhs as single)
Declare Operator /= (byval rhs as longint)
Declare Operator /= (byval rhs as integer)
Declare Operator /= (byval rhs as long)
Declare Operator /= (byref rhs as String)
Declare Operator ^= (Byref rhs as mpfr)
Declare Operator ^= (byval rhs as double)
Declare Operator ^= (byval rhs as single)
Declare Operator ^= (byval rhs as longint)
Declare Operator ^= (byval rhs as integer)
Declare Operator ^= (byval rhs as long)
Declare Operator ^= (byref rhs as String)
' For Next Implicit step = +1
Declare Operator For ( )
Declare Operator Step( )
Declare Operator Next( Byref end_cond As mpfr ) As Integer
' For Next Exlicit step
Declare Operator For ( Byref stp As mpfr )
Declare Operator Step( Byref stp As mpfr )
Declare Operator Next( Byref end_cond As mpfr, Byref step_var As mpfr ) As Integer
'----------------------------------------------
declare function toString( byval frmt as string = "%32.28g") as string
declare Function toLong ( ) As Long
declare Function toDouble ( ) As Double
declare Function toSingle ( ) As Single
num As mpfr_t
End Type
Declare Operator + ( Byref lhs As mpfr, Byref rhs As mpfr ) As mpfr
Declare Operator - ( Byref lhs As mpfr, Byref rhs As mpfr ) As mpfr
Declare Operator * ( Byref lhs As mpfr, Byref rhs As mpfr ) As mpfr
Declare Operator \ ( Byref lhs As mpfr, Byref rhs As mpfr ) As mpfr
Declare Operator / ( Byref lhs As mpfr, Byref rhs As mpfr ) As mpfr
Declare Operator ^ ( Byref lhs As mpfr, Byval rhs As mpfr ) As mpfr
Declare Operator - ( Byref rhs As mpfr ) As mpfr
Declare Operator = ( Byref lhs As mpfr, Byref rhs As mpfr ) As Integer
Declare Operator < ( Byref lhs As mpfr, Byref rhs As mpfr ) As Integer
Declare Operator > ( Byref lhs As mpfr, Byref rhs As mpfr ) As Integer
Declare Operator <= ( Byref lhs As mpfr, Byref rhs As mpfr ) As Integer
Declare Operator >= ( Byref lhs As mpfr, Byref rhs As mpfr ) As Integer
Declare Operator <> ( Byref lhs As mpfr, Byref rhs As mpfr ) As Integer
function mpfr.toString( byval frmt as string = "%32.28g") as string
dim as string sp =" "
frmt = left(frmt,len(frmt)-1)+"R*"+right(frmt,1)
if instr(frmt , "%")=0 then frmt = "%"+frmt
dim as long length
length = mpfr_snprintf(0, 0, frmt, mpfr_rounding_mode, @num)
dim as zstring ptr rstring=allocate(length+20)
mpfr_sprintf(rstring, frmt, mpfr_rounding_mode, @num)
if mpfr_sgn(@num)<0 then sp = ""
function = sp + ltrim(*rstring)
deallocate(rstring)
end function
Function mpfr.toLong ( ) As Long
Function = mpfr_get_si(@num, mpfr_rounding_mode)
End Function
Function mpfr.toDouble ( ) As Double
Function = mpfr_get_d(@num, mpfr_rounding_mode)
End Function
Function mpfr.toSingle ( ) As Single
Function = mpfr_get_flt(@num, mpfr_rounding_mode)
End Function
Constructor mpfr ( )
mpfr_init2(@num, mpfr_digits_precision * 3.33)
mpfr_set_si(@num, 0, mpfr_rounding_mode)
End Constructor
Constructor mpfr ( Byval rhs As Long )
mpfr_init2(@num, mpfr_digits_precision * 3.33)
mpfr_set_si(@num, rhs, mpfr_rounding_mode)
End Constructor
Constructor mpfr ( Byref rhs As String )
mpfr_init2(@num, mpfr_digits_precision * 3.33)
mpfr_set_str(@num, rhs, 10, mpfr_rounding_mode)
End Constructor
Constructor mpfr ( Byref rhs As mpfr )
mpfr_init2(@num, mpfr_digits_precision * 3.33)
mpfr_set(@num, @rhs.num, mpfr_rounding_mode)
End Constructor
Constructor mpfr ( Byval rhs As LongInt )
Dim As String s=str(rhs)
mpfr_init2(@num, mpfr_digits_precision * 3.33)
mpfr_set_str(@num, s, 10, mpfr_rounding_mode)
End Constructor
Constructor mpfr ( Byval rhs As Integer )
Dim As String s=str(rhs)
mpfr_init2(@num, mpfr_digits_precision * 3.33)
mpfr_set_str(@num, s, 10, mpfr_rounding_mode)
End Constructor
Constructor mpfr ( Byval rhs As Double )
mpfr_init2(@num, mpfr_digits_precision * 3.33)
mpfr_set_d(@num, rhs, mpfr_rounding_mode)
End Constructor
Constructor mpfr ( Byval rhs As Single )
mpfr_init2(@num, mpfr_digits_precision * 3.33)
mpfr_set_flt(@num, rhs, mpfr_rounding_mode)
End Constructor
Destructor mpfr ( )
mpfr_clear(@num)
End Destructor
Operator mpfr.let ( Byref rhs As mpfr )
mpfr_set(@num, @rhs.num, mpfr_rounding_mode)
End Operator
Operator mpfr.let ( Byval rhs As Long )
mpfr_set_si(@num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.let ( Byref rhs As String )
mpfr_set_str(@num, rhs, 10, mpfr_rounding_mode)
End Operator
Operator mpfr.Let ( Byval rhs As LongInt )
Dim As String s=str(rhs)
mpfr_set_str(@num, s, 10, mpfr_rounding_mode)
End Operator
Operator mpfr.Let ( Byval rhs As Integer )
Dim As String s=str(rhs)
mpfr_set_str(@num, s, 10, mpfr_rounding_mode)
End Operator
Operator mpfr.Let ( Byval rhs As Double )
mpfr_set_d(@num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.Let ( Byval rhs As Single )
mpfr_set_flt(@num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.cast ( ) As String
dim as long length = mpfr_digits_precision
dim as string sp =" ", s = "%"+str(length+4)+"."+str(length-1)+"R*g"
length = mpfr_snprintf(0, 0, s, mpfr_rounding_mode, @num)
dim as zstring ptr rstring=allocate(length+20)
mpfr_sprintf(rstring, s, mpfr_rounding_mode, @num)
if mpfr_sgn(@num)<0 then sp = ""
Operator = sp + ltrim(*rstring)
deallocate(rstring)
End Operator
Operator mpfr.cast ( ) As Long
Operator = mpfr_get_si(@num, mpfr_rounding_mode)
End Operator
Operator mpfr.cast ( ) As Double
Operator = mpfr_get_d(@num, mpfr_rounding_mode)
End Operator
Operator mpfr.cast ( ) As Single
Operator = mpfr_get_flt(@num, mpfr_rounding_mode)
End Operator
'============================================================================
'' For Next for mpfr type
''
'' implicit step versions
''
'' In this example, we interpret implicit step
'' to mean 1
Operator mpfr.for ( )
End Operator
Operator mpfr.step ( )
this += 1 'this = this+1 '
End Operator
Operator mpfr.next ( Byref end_cond As mpfr ) As Integer
Return this <= end_cond
End Operator
'' explicit step versions
''
Operator mpfr.for ( Byref step_var As mpfr )
End Operator
Operator mpfr.step ( Byref step_var As mpfr )
this += step_var 'this = this + step_var '
End Operator
Operator mpfr.next ( Byref end_cond As mpfr, Byref step_var As mpfr ) As Integer
If step_var < 0 Then
Return this >= end_cond
Else
Return this <= end_cond
End If
End Operator
'============================================================================
Operator + ( Byref lhs As mpfr, Byref rhs As mpfr ) As mpfr
Dim As mpfr result
mpfr_add(@result.num, @lhs.num, @rhs.num, mpfr_rounding_mode)
Operator = result
End Operator
Operator - ( Byref rhs As mpfr ) As mpfr
Dim As mpfr result
mpfr_neg(@result.num, @rhs.num, mpfr_rounding_mode)
Operator = result
End Operator
Operator - ( Byref lhs As mpfr, Byref rhs As mpfr ) As mpfr
Dim As mpfr result
mpfr_sub(@result.num, @lhs.num, @rhs.num, mpfr_rounding_mode)
Operator = result
End Operator
Operator * ( Byref lhs As mpfr, Byref rhs As mpfr ) As mpfr
Dim As mpfr result
mpfr_mul(@result.num, @lhs.num, @rhs.num, mpfr_rounding_mode)
Operator = result
End Operator
Operator / ( Byref lhs As mpfr, Byref rhs As mpfr ) As mpfr
Dim As mpfr result
mpfr_div(@result.num, @lhs.num, @rhs.num, mpfr_rounding_mode)
Operator = result
End Operator
Operator ^ ( Byref lhs As mpfr, Byval rhs As mpfr ) As mpfr
Dim As mpfr result
mpfr_pow(@result.num, @lhs.num, @rhs.num, mpfr_rounding_mode)
Operator = result
End Operator
'=================
Operator mpfr.+= (byref rhs as mpfr)
mpfr_add(@this.num, @this.num, @rhs.num, mpfr_rounding_mode)
End Operator
Operator mpfr.+= (Byval rhs as long)
mpfr_add_si(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.+= (byval rhs as double)
mpfr_add_d(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.+= (byval rhs as single)
mpfr_add_d(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.+= (byval rhs as longint)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_add(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.+= (byval rhs as integer)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_add(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.+= (byref rhs as String)
Dim As mpfr tmp
tmp=rhs
mpfr_add(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.-= (byref rhs as mpfr)
mpfr_sub(@this.num, @this.num, @rhs.num, mpfr_rounding_mode)
End Operator
Operator mpfr.-= (Byval rhs as long)
mpfr_sub_si(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.-= (byval rhs as double)
mpfr_sub_d(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.-= (byval rhs as single)
mpfr_sub_d(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.-= (byval rhs as longint)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_sub(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.-= (byval rhs as integer)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_sub(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.-= (byref rhs as String)
Dim As mpfr tmp
tmp=rhs
mpfr_sub(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.*= (byref rhs as mpfr)
mpfr_mul(@this.num, @this.num, @rhs.num, mpfr_rounding_mode)
End Operator
Operator mpfr.*= (Byval rhs as long)
mpfr_mul_si(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.*= (byval rhs as double)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_mul_d(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.*= (byval rhs as single)
mpfr_mul_d(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.*= (byval rhs as longint)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_mul(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.*= (byval rhs as integer)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_mul(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.*= (byref rhs as String)
Dim As mpfr tmp
tmp=rhs
mpfr_mul(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr./= (byref rhs as mpfr)
mpfr_div(@this.num, @this.num, @rhs.num, mpfr_rounding_mode)
End Operator
Operator mpfr./= (Byval rhs as long)
mpfr_div_si(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr./= (byval rhs as double)
mpfr_div_d(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr./= (byval rhs as single)
mpfr_div_d(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr./= (byval rhs as longint)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_div(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr./= (byval rhs as integer)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_div(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr./= (byref rhs as String)
Dim As mpfr tmp
tmp=rhs
mpfr_div(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.^= (byref rhs as mpfr)
mpfr_pow(@this.num, @this.num, @rhs.num, mpfr_rounding_mode)
End Operator
Operator mpfr.^= (Byval rhs as long)
mpfr_pow_si(@this.num, @this.num, rhs, mpfr_rounding_mode)
End Operator
Operator mpfr.^= (byval rhs as double)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_pow(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.^= (byval rhs as single)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_pow(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.^= (byval rhs as longint)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_pow(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.^= (byval rhs as integer)
Dim As mpfr tmp
tmp=str(rhs)
mpfr_pow(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator mpfr.^= (byref rhs as String)
Dim As mpfr tmp
tmp=rhs
mpfr_pow(@this.num, @this.num, @tmp.num, mpfr_rounding_mode)
End Operator
Operator = ( Byref lhs As mpfr, Byref rhs As mpfr ) As Integer
Operator = (mpfr_cmp(@lhs.num, @rhs.num) = 0)
End Operator
Operator < ( Byref lhs As mpfr, Byref rhs As mpfr ) As Integer
Operator = (mpfr_cmp(@lhs.num, @rhs.num) < 0)
End Operator
Operator > ( Byref lhs As mpfr, Byref rhs As mpfr ) As Integer
Operator = (mpfr_cmp(@lhs.num, @rhs.num) > 0)
End Operator
Operator <= ( Byref lhs As mpfr, Byref rhs As mpfr ) As Integer
Operator = (mpfr_cmp(@lhs.num, @rhs.num) <= 0)
End Operator
Operator >= ( Byref lhs As mpfr, Byref rhs As mpfr ) As Integer
Operator = (mpfr_cmp(@lhs.num, @rhs.num) >= 0)
End Operator
Operator <> ( Byref lhs As mpfr, Byref rhs As mpfr ) As Integer
Operator = (mpfr_cmp(@lhs.num, @rhs.num) <> 0)
End Operator
operator Abs(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_abs(@result.num, @rhs.num, mpfr_rounding_mode)
operator = result
end operator
operator Acos(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_acos(@result.num, @rhs.num, mpfr_rounding_mode)
operator = result
end operator
function Acosh overload(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_acosh(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
function Ai(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_ai(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
operator Asin(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_asin(@result.num, @rhs.num, mpfr_rounding_mode)
operator = result
end operator
function Asinh overload(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_asinh(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
function Atan(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_atan(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
operator Atn(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_atan(@result.num, @rhs.num, mpfr_rounding_mode)
operator = result
end operator
Function Atan2_ ( ByVal y As Double, ByVal x As Double ) As Double
Function = Atan2 ( y, x )
End Function
#undef Atan2
Declare Function Atan2 Overload ( ByVal y As Double, ByVal x As Double ) As Double
Function Atan2 ( ByVal y As Double, ByVal x As Double ) As Double
Function = Atan2_ ( y, x )
End Function
function Atan2(byref lhs as mpfr, byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_atan2 (@result.num, @lhs.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
function Atanh overload(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_atanh(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
function cbrt(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_cbrt(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function ceil(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_ceil(@result.num, @x.num)
function = result
end function
function floor(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_floor(@result.num, @x.num)
return result
end function
operator int(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_floor(@result.num, @x.num)
operator = result
end operator
operator frac(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_frac(@result.num, @x.num, mpfr_rounding_mode)
operator = result
end operator
function catalan_const() as mpfr
Dim As mpfr result
mpfr_const_catalan(@result.num, mpfr_rounding_mode)
return result
end function
function euler_const() as mpfr
Dim As mpfr result
mpfr_const_euler(@result.num, mpfr_rounding_mode)
return result
end function
function log2_const() as mpfr
Dim As mpfr result
mpfr_const_log2(@result.num, mpfr_rounding_mode)
return result
end function
function pi_const() as mpfr
Dim As mpfr result
mpfr_const_pi(@result.num, mpfr_rounding_mode)
return result
end function
operator Cos(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_cos(@result.num, @rhs.num, mpfr_rounding_mode)
operator = result
end operator
function Cosh overload(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_cosh(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
function Cot(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_cot(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
function Coth(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_coth(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
function Csc(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_csc(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
function Csch(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_csch(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
function Digamma(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_digamma(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
function Eint(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_eint(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
function Erf(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_erf(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
function Erfc(byref rhs as mpfr) as mpfr
Dim As mpfr result
mpfr_erfc(@result.num, @rhs.num, mpfr_rounding_mode)
Return result
end function
operator Exp(byref x as mpfr) as mpfr
dim as mpfr result
mpfr_exp(@result.num, @x.num, mpfr_rounding_mode)
operator = result
end operator
function Exp10 overload(byref x as mpfr) as mpfr
dim as mpfr result
mpfr_exp10(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function Exp2(byref x as mpfr) as mpfr
dim as mpfr result
mpfr_exp2(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function Expm1(byref x as mpfr) as mpfr
dim as mpfr result
mpfr_expm1(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function facui(byval x as culong) as mpfr
Dim As mpfr result
mpfr_fac_ui(@result.num, x, mpfr_rounding_mode)
return result
end function
function fma(byref a as mpfr, byref b as mpfr, byref c as mpfr) as mpfr
Dim As mpfr result
mpfr_fma(@result.num, @a.num, @b.num, @c.num, mpfr_rounding_mode)
return result
end function
function fms(byref a as mpfr, byref b as mpfr, byref c as mpfr) as mpfr
Dim As mpfr result
mpfr_fms(@result.num, @a.num, @b.num, @c.num, mpfr_rounding_mode)
return result
end function
function gamma(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_gamma(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function hypot(byref x as mpfr, byref y as mpfr) as mpfr
Dim As mpfr result
mpfr_hypot(@result.num, @x.num, @y.num, mpfr_rounding_mode)
return result
end function
function j0(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_j0(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function j1(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_j1(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function jn(byref x as mpfr, byval n as clong) as mpfr
Dim As mpfr result
mpfr_jn(@result.num, n, @x.num, mpfr_rounding_mode)
return result
end function
function y0(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_y0(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function y1(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_y1(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function yn(byref x as mpfr, byval n as clong) as mpfr
Dim As mpfr result
mpfr_yn(@result.num, n, @x.num, mpfr_rounding_mode)
return result
end function
function Zeta(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_zeta(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function ZetaUi(byval n as clong) as mpfr
Dim As mpfr result
mpfr_zeta_ui(@result.num, n, mpfr_rounding_mode)
return result
end function
function lgamma(byval signp as long ptr, byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_lgamma(@result.num, signp, @x.num, mpfr_rounding_mode)
return result
end function
function Li2(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_li2(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function lngamma(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_lngamma(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
operator Log(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_log(@result.num, @x.num, mpfr_rounding_mode)
operator = result
end operator
function Log10 overload(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_log10(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function Log1p(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_log1p(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function Log2(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_log2(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function Sec(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_sec(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function Sech(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_sech(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
operator Sin(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_sin(@result.num, @x.num, mpfr_rounding_mode)
operator = result
end operator
function Sinh overload(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_sinh(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
Function Sqr_ ( ByVal number As Double ) As Double
Function = Sqr( number )
End Function
#undef Sqr
Declare Function Sqr Overload ( ByVal number As Double ) As Double
Function Sqr ( ByVal number As Double ) As Double
Function = Sqr_( number )
End Function
function Sqr(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_sqrt(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function Square(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_sqr(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
operator Tan(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_tan(@result.num, @x.num, mpfr_rounding_mode)
operator = result
end operator
function Tanh overload(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_tanh(@result.num, @x.num, mpfr_rounding_mode)
return result
end function
function Trunc(byref x as mpfr) as mpfr
Dim As mpfr result
mpfr_trunc(@result.num, @x.num)
return result
end function
/'
function str_(byval x as double) as string
return str(x)
end function
#undef str
declare function str overload (byval x as double) as string
function str(byval x as double) as string
return str_(x)
end function
function str (byref x as mpfr ) As String
dim as long length = mpfr_digits_precision
dim as string sp =" ", s = "%"+str(length+4)+"."+str(length-1)+"R*g"
length = mpfr_snprintf(0, 0, s, mpfr_rounding_mode, @x.num)
dim as zstring ptr rstring=allocate(length+20)
mpfr_sprintf(rstring, s, mpfr_rounding_mode, @x.num)
if mpfr_sgn(@x.num)<0 then sp = ""
return sp + ltrim(*rstring)
deallocate(rstring)
End function
'/