mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-11-24 15:07:37 +03:00
adopt backend implementations of pow
(#2334)
This commit is contained in:
parent
f317555967
commit
f436388a6b
@ -794,7 +794,7 @@ log x = prim__doubleLog x
|
||||
|
||||
public export
|
||||
pow : Double -> Double -> Double
|
||||
pow x y = exp (y * log x) -- prim__doublePow x y
|
||||
pow x y = prim__doublePow x y
|
||||
|
||||
public export
|
||||
sin : Double -> Double
|
||||
|
@ -170,7 +170,7 @@ schOp StrSubstr [x, y, z] = pure $ op "string-substr" [x, y, z]
|
||||
-- `e` is Euler's number, which approximates to: 2.718281828459045
|
||||
schOp DoubleExp [x] = pure $ op "flexp" [x] -- Base is `e`. Same as: `pow(e, x)`
|
||||
schOp DoubleLog [x] = pure $ op "fllog" [x] -- Base is `e`.
|
||||
schOp DoublePow [x, y] = pure $ op "expt" [x, y]
|
||||
schOp DoublePow [x, y] = pure $ op "flexpt" [x, y]
|
||||
schOp DoubleSin [x] = pure $ op "flsin" [x]
|
||||
schOp DoubleCos [x] = pure $ op "flcos" [x]
|
||||
schOp DoubleTan [x] = pure $ op "fltan" [x]
|
||||
|
90
tests/prelude/double001/Types.idr
Normal file
90
tests/prelude/double001/Types.idr
Normal file
@ -0,0 +1,90 @@
|
||||
nan, inf : Double
|
||||
nan = 0.0 / 0.0
|
||||
inf = 1.0 / 0.0
|
||||
|
||||
powDoubleCases : List Double
|
||||
powDoubleCases = [
|
||||
pow (-inf) (-inf),
|
||||
pow (-inf) (-2),
|
||||
pow (-inf) (-0.5),
|
||||
pow (-inf) 0,
|
||||
pow (-inf) 0.5,
|
||||
pow (-inf) 2,
|
||||
pow (-inf) inf,
|
||||
pow (-inf) nan,
|
||||
|
||||
pow (-2) (-inf),
|
||||
pow (-2) (-2),
|
||||
pow (-2) (-0.5),
|
||||
pow (-2) 0,
|
||||
pow (-2) 0.5,
|
||||
pow (-2) 2,
|
||||
pow (-2) inf,
|
||||
pow (-2) nan,
|
||||
|
||||
pow (-0.5) (-inf),
|
||||
pow (-0.5) (-2),
|
||||
pow (-0.5) (-0.5),
|
||||
pow (-0.5) 0,
|
||||
pow (-0.5) 0.5,
|
||||
pow (-0.5) 2,
|
||||
pow (-0.5) inf,
|
||||
pow (-0.5) nan,
|
||||
|
||||
pow 0 (-inf),
|
||||
pow 0 (-2),
|
||||
pow 0 (-0.5),
|
||||
pow 0 0,
|
||||
pow 0 0.5,
|
||||
pow 0 2,
|
||||
pow 0 inf,
|
||||
pow 0 nan,
|
||||
|
||||
pow 0.5 (-inf),
|
||||
pow 0.5 (-2),
|
||||
pow 0.5 (-0.5),
|
||||
pow 0.5 0,
|
||||
pow 0.5 0.5,
|
||||
pow 0.5 2,
|
||||
pow 0.5 inf,
|
||||
pow 0.5 nan,
|
||||
|
||||
pow 1 (-inf),
|
||||
pow 1 (-2),
|
||||
pow 1 (-0.5),
|
||||
pow 1 0,
|
||||
pow 1 0.5,
|
||||
pow 1 2,
|
||||
pow 1 inf,
|
||||
pow 1 nan,
|
||||
|
||||
pow 2 (-inf),
|
||||
pow 2 (-2),
|
||||
pow 2 (-0.5),
|
||||
pow 2 0,
|
||||
pow 2 0.5,
|
||||
pow 2 2,
|
||||
pow 2 inf,
|
||||
pow 2 nan,
|
||||
|
||||
pow inf (-inf),
|
||||
pow inf (-2),
|
||||
pow inf (-0.5),
|
||||
pow inf 0,
|
||||
pow inf 0.5,
|
||||
pow inf 2,
|
||||
pow inf inf,
|
||||
pow inf nan,
|
||||
|
||||
pow nan (-inf),
|
||||
pow nan (-2),
|
||||
pow nan (-0.5),
|
||||
pow nan 0,
|
||||
pow nan 0.5,
|
||||
pow nan 2,
|
||||
pow nan inf,
|
||||
pow nan nan
|
||||
]
|
||||
|
||||
main : IO ()
|
||||
main = traverse_ printLn powDoubleCases
|
74
tests/prelude/double001/expected
Normal file
74
tests/prelude/double001/expected
Normal file
@ -0,0 +1,74 @@
|
||||
1/1: Building Types (Types.idr)
|
||||
Main> 0.0
|
||||
0.0
|
||||
0.0
|
||||
1.0
|
||||
+inf.0
|
||||
+inf.0
|
||||
+inf.0
|
||||
+nan.0
|
||||
0.0
|
||||
0.25
|
||||
+nan.0
|
||||
1.0
|
||||
+nan.0
|
||||
4.0
|
||||
+inf.0
|
||||
+nan.0
|
||||
+inf.0
|
||||
4.0
|
||||
+nan.0
|
||||
1.0
|
||||
+nan.0
|
||||
0.25
|
||||
0.0
|
||||
+nan.0
|
||||
+inf.0
|
||||
+inf.0
|
||||
+inf.0
|
||||
1.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
+nan.0
|
||||
+inf.0
|
||||
4.0
|
||||
1.4142135623730951
|
||||
1.0
|
||||
0.7071067811865476
|
||||
0.25
|
||||
0.0
|
||||
+nan.0
|
||||
1.0
|
||||
1.0
|
||||
1.0
|
||||
1.0
|
||||
1.0
|
||||
1.0
|
||||
1.0
|
||||
1.0
|
||||
0.0
|
||||
0.25
|
||||
0.7071067811865476
|
||||
1.0
|
||||
1.4142135623730951
|
||||
4.0
|
||||
+inf.0
|
||||
+nan.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
1.0
|
||||
+inf.0
|
||||
+inf.0
|
||||
+inf.0
|
||||
+nan.0
|
||||
+nan.0
|
||||
+nan.0
|
||||
+nan.0
|
||||
1.0
|
||||
+nan.0
|
||||
+nan.0
|
||||
+nan.0
|
||||
+nan.0
|
||||
Main> Bye for now!
|
2
tests/prelude/double001/input
Normal file
2
tests/prelude/double001/input
Normal file
@ -0,0 +1,2 @@
|
||||
:exec main
|
||||
:q
|
3
tests/prelude/double001/run
Executable file
3
tests/prelude/double001/run
Executable file
@ -0,0 +1,3 @@
|
||||
rm -rf build
|
||||
|
||||
$1 --no-banner --no-color --console-width 0 Types.idr < input
|
Loading…
Reference in New Issue
Block a user