16
16
cosh, sinh, tanh, sech, csch, coth, acosh, asinh, atanh, lerpi,
17
17
cbrt, typemax, typemin, unsafe_trunc, floatmin, floatmax, rounding,
18
18
setrounding, maxintfloat, widen, significand, frexp, tryparse, iszero,
19
- isone, big, _string_n, decompose, minmax
19
+ isone, big, _string_n, decompose, minmax,
20
+ sinpi, cospi, sind, cosd, tand, asind, acosd, atand
20
21
21
22
import .. Rounding: rounding_raw, setrounding_raw
22
23
@@ -780,7 +781,7 @@ function sum(arr::AbstractArray{BigFloat})
780
781
end
781
782
782
783
# Functions for which NaN results are converted to DomainError, following Base
783
- for f in (:sin , :cos , :tan , :sec , :csc , :acos , :asin , :atan , :acosh , :asinh , :atanh )
784
+ for f in (:sin , :cos , :tan , :sec , :csc , :acos , :asin , :atan , :acosh , :asinh , :atanh , :sinpi , :cospi )
784
785
@eval begin
785
786
function ($ f)(x:: BigFloat )
786
787
isnan (x) && return x
@@ -798,6 +799,32 @@ function atan(y::BigFloat, x::BigFloat)
798
799
return z
799
800
end
800
801
802
+ # degree functions
803
+ for f in (:sin , :cos , :tan )
804
+ @eval begin
805
+ function ($ (Symbol (f,:d )))(x:: BigFloat )
806
+ isnan (x) && return x
807
+ z = BigFloat ()
808
+ ccall (($ (string (:mpfr_ ,f,:u )), :libmpfr ), Int32, (Ref{BigFloat}, Ref{BigFloat}, Culong, MPFRRoundingMode), z, x, 360 , ROUNDING_MODE[])
809
+ isnan (z) && throw (DomainError (x, " NaN result for non-NaN input." ))
810
+ return z
811
+ end
812
+ function ($ (Symbol (:a ,f,:d )))(x:: BigFloat )
813
+ isnan (x) && return x
814
+ z = BigFloat ()
815
+ ccall (($ (string (:mpfr_a ,f,:u )), :libmpfr ), Int32, (Ref{BigFloat}, Ref{BigFloat}, Culong, MPFRRoundingMode), z, x, 360 , ROUNDING_MODE[])
816
+ isnan (z) && throw (DomainError (x, " NaN result for non-NaN input." ))
817
+ return z
818
+ end
819
+ end
820
+ end
821
+ function atand (y:: BigFloat , x:: BigFloat )
822
+ z = BigFloat ()
823
+ ccall ((:mpfr_atan2u , :libmpfr ), Int32, (Ref{BigFloat}, Ref{BigFloat}, Ref{BigFloat}, Culong, MPFRRoundingMode), z, y, x, 360 , ROUNDING_MODE[])
824
+ return z
825
+ end
826
+
827
+
801
828
# Utility functions
802
829
== (x:: BigFloat , y:: BigFloat ) = ccall ((:mpfr_equal_p , :libmpfr ), Int32, (Ref{BigFloat}, Ref{BigFloat}), x, y) != 0
803
830
<= (x:: BigFloat , y:: BigFloat ) = ccall ((:mpfr_lessequal_p , :libmpfr ), Int32, (Ref{BigFloat}, Ref{BigFloat}), x, y) != 0
0 commit comments