JuliaLinearAlgebra / MatrixDepot.jl

An Extensible Test Matrix Collection for Julia
http://matrixdepotjl.readthedocs.org/
Other
75 stars 22 forks source link

Pascal triangle generated only till upto small size #18

Closed ranjanan closed 9 years ago

ranjanan commented 9 years ago

matrixdepot("pascal", 50) will generate an OverFlowError()

One possible fix is to change the convert function at the end of the binomial function in intfuncs.jl in Base. Instead of converting to an Int to should convert to Float

weijianzhg commented 9 years ago

I agree. Thanks for the suggestion. I will fix it soon.

weijianzhg commented 9 years ago

@ranjanan I just had a check of the Base code. I think intfuncs.jl is meant for Integer functions. So instead of converting the data to Float, I convert my code it BigInt first. See here. This solves the problem.

julia> matrixdepot("pascal", 50)
50x50 Array{Float64,2}:
 1.0   1.0     1.0      1.0       1.0  …       1.0              1.0       
 1.0   2.0     3.0      4.0       5.0         49.0             50.0       
 1.0   3.0     6.0     10.0      15.0       1225.0           1275.0       
 1.0   4.0    10.0     20.0      35.0      20825.0          22100.0       
 1.0   5.0    15.0     35.0      70.0     270725.0         292825.0       
 1.0   6.0    21.0     56.0     126.0  …       2.86969e6        3.16251e6 
 1.0   7.0    28.0     84.0     210.0          2.58272e7        2.89897e7 
 1.0   8.0    36.0    120.0     330.0          2.02928e8        2.31917e8 
 1.0   9.0    45.0    165.0     495.0          1.42049e9        1.65241e9 
 1.0  10.0    55.0    220.0     715.0          8.99646e9        1.06489e10
 ⋮                                     ⋱                                  
 1.0  42.0   903.0  13244.0  148995.0          3.97517e25       7.30133e25
 1.0  43.0   946.0  14190.0  163185.0          8.51822e25       1.58195e26
 1.0  44.0   990.0  15180.0  178365.0          1.80269e26       3.38465e26
 1.0  45.0  1035.0  16215.0  194580.0          3.76927e26       7.15391e26
 1.0  46.0  1081.0  17296.0  211876.0  …       7.78982e26       1.49437e27
 1.0  47.0  1128.0  18424.0  230300.0          1.59183e27       3.08621e27
 1.0  48.0  1176.0  19600.0  249900.0          3.21753e27       6.30374e27
 1.0  49.0  1225.0  20825.0  270725.0          6.43507e27       1.27388e28
 1.0  50.0  1275.0  22100.0  292825.0          1.27388e28       2.54776e28