@@ -2,6 +2,9 @@ using Formatting
2
2
using Compat
3
3
using Base. Test
4
4
5
+ _erfinv (z) = sqrt (π) * Base. Math. @horner (z, 0 , 1 , 0 , π/ 12 , 0 , 7 π^ 2 / 480 , 0 , 127 π^ 3 / 40320 , 0 ,
6
+ 4369 π^ 4 / 5806080 , 0 , 34807 π^ 5 / 182476800 ) / 2
7
+
5
8
function test_equality ()
6
9
println ( " test cformat equality..." )
7
10
srand (10 )
@@ -11,7 +14,7 @@ function test_equality()
11
14
l. args[2 ]. args[2 ] = @compat Expr (:macrocall , Symbol (" @sprintf" ), fmt, :x )
12
15
mfmtr = eval ( l )
13
16
for i in 1 : 10000
14
- n = erfinv ( rand () * 1.99 - 1.99 / 2.0 )
17
+ n = _erfinv ( rand () * 1.99 - 1.99 / 2.0 )
15
18
expect = mfmtr ( n )
16
19
actual = sprintf1 ( fmt, n )
17
20
@test expect == actual
@@ -24,7 +27,7 @@ function test_equality()
24
27
l. args[2 ]. args[2 ] = @compat Expr (:macrocall , Symbol (" @sprintf" ), fmt, :x )
25
28
mfmtr = eval ( l )
26
29
for i in 1 : 10000
27
- j = round (Int, erfinv ( rand () * 1.99 - 1.99 / 2.0 ) * 100000 )
30
+ j = round (Int, _erfinv ( rand () * 1.99 - 1.99 / 2.0 ) * 100000 )
28
31
expect = mfmtr ( j )
29
32
actual = sprintf1 ( fmt, j )
30
33
@test expect == actual
@@ -64,20 +67,20 @@ println( "integer sprintf speed, bypass repeated lookup")
64
67
function native_float ()
65
68
srand ( 10 )
66
69
for i in 1 : 200000
67
- @sprintf ( " %10.4f" , erfinv ( rand () ) )
70
+ @sprintf ( " %10.4f" , _erfinv ( rand () ) )
68
71
end
69
72
end
70
73
function runtime_float ()
71
74
srand ( 10 )
72
75
for i in 1 : 200000
73
- sprintf1 ( " %10.4f" , erfinv ( rand () ) )
76
+ sprintf1 ( " %10.4f" , _erfinv ( rand () ) )
74
77
end
75
78
end
76
79
function runtime_float_bypass ()
77
80
f = generate_formatter ( " %10.4f" )
78
81
srand ( 10 )
79
82
for i in 1 : 200000
80
- f ( erfinv ( rand () ) )
83
+ f ( _erfinv ( rand () ) )
81
84
end
82
85
end
83
86
0 commit comments