Skip to content

Commit

Permalink
Int64 -> Int (#189)
Browse files Browse the repository at this point in the history
This follows from a suggestion by @mforets TaylorModels.jl#16
  • Loading branch information
lbenet authored Jan 21, 2019
1 parent 0495404 commit 506facd
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ AbstractSeries
## Functions and methods

```@docs
Taylor1(::Type{T}, ::Int64=1) where {T<:Number}
Taylor1(::Type{T}, ::Int=1) where {T<:Number}
HomogeneousPolynomial(::Type{T}, ::Int) where {T<:Number}
TaylorN(::Type{T}, ::Int; ::Int=get_order()) where {T<:Number}
set_variables
Expand Down
4 changes: 2 additions & 2 deletions docs/src/userguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ t
```

The definition of `shift_taylor(a)` uses the method
[`Taylor1([::Type{Float64}], [order::Int64=1])`](@ref), which is a
[`Taylor1([::Type{Float64}], [order::Int=1])`](@ref), which is a
shortcut to define the independent variable of a Taylor expansion,
of given type and order (defaults are `Float64` and `order=1`).
This is one of the easiest ways to work with the package.
Expand Down Expand Up @@ -117,7 +117,7 @@ log(1-t)
sqrt(1 + t)
imag(exp(tI)')
real(exp(Taylor1([0.0,1im],17))) - cos(Taylor1([0.0,1.0],17)) == 0.0
convert(Taylor1{Rational{Int64}}, exp(t))
convert(Taylor1{Rational{Int}}, exp(t))
```

Again, errors are thrown whenever it is necessary.
Expand Down
10 changes: 5 additions & 5 deletions examples/1-KeplerProblem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -660,19 +660,19 @@
" lz0 = lz1(x0, y0, vx0, vy0)\n",
" \n",
" # Change, measured in the local `eps` of the change of energy and angular momentum\n",
" eps_ene = eps(ene0); dEne = zero(Int64)\n",
" eps_lz = eps(lz0); dLz = zero(Int64)\n",
" eps_ene = eps(ene0); dEne = zero(Int)\n",
" eps_lz = eps(lz0); dLz = zero(Int)\n",
" \n",
" # Vectors to plot the orbit with PyPlot\n",
" tV, xV, yV, vxV, vyV = Float64[], Float64[], Float64[], Float64[], Float64[]\n",
" DeneV, DlzV = Int64[], Int64[]\n",
" DeneV, DlzV = Int[], Int[]\n",
" push!(tV, t0)\n",
" push!(xV, x0)\n",
" push!(yV, y0)\n",
" push!(vxV, vx0)\n",
" push!(vyV, vy0)\n",
" push!(DeneV, zero(Int64))\n",
" push!(DlzV, zero(Int64))\n",
" push!(DeneV, zero(Int))\n",
" push!(DlzV, zero(Int))\n",
" \n",
" # This is the main loop; we include a minimum step size for security\n",
" dt = 1.0\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/User guide.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
"Note that the information about the maximum order considered is displayed\n",
"using a big-O notation.\n",
"\n",
"The definition of `affine(a)` uses the method `Taylor1{T<:Number}(::Type{T},order::Int64)`, which is a\n",
"The definition of `affine(a)` uses the method `Taylor1{T<:Number}(::Type{T},order::Int)`, which is a\n",
"shortcut to define the independent variable of a Taylor expansion,\n",
"with a given type and given order. As we show below, this is one of the\n",
"easiest ways to work with the package.\n",
Expand Down Expand Up @@ -580,7 +580,7 @@
}
],
"source": [
"convert(Taylor1{Rational{Int64}}, exp(t))"
"convert(Taylor1{Rational{Int}}, exp(t))"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DataType for polynomial expansions in one independent variable.
- `coeffs :: Array{T,1}` Expansion coefficients; the ``i``-th
component is the coefficient of degree ``i-1`` of the expansion.
- `order :: Int64` Maximum order (degree) of the polynomial.
- `order :: Int` Maximum order (degree) of the polynomial.
Note that `Taylor1` variables are callable. For more information, see
[`evaluate`](@ref).
Expand Down Expand Up @@ -69,7 +69,7 @@ julia> Taylor1(Rational{Int}, 4)
1//1 t + 𝒪(t⁵)
```
"""
Taylor1(::Type{T}, order::Int64=1) where {T<:Number} = Taylor1( [zero(T), one(T)], order)
Taylor1(::Type{T}, order::Int=1) where {T<:Number} = Taylor1( [zero(T), one(T)], order)
Taylor1(order::Int=1) = Taylor1(Float64, order)


Expand Down
8 changes: 4 additions & 4 deletions src/hash_tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ and `pos_table`. Internally, these are treated as `const`.
# Hash tables
coeff_table :: Array{Array{Array{Int64,1},1},1}
coeff_table :: Array{Array{Array{Int,1},1},1}
The ``i+1``-th component contains a vector with the vectors of all the possible
combinations of monomials of a `HomogeneousPolynomial` of order ``i``.
index_table :: Array{Array{Int64,1},1}
index_table :: Array{Array{Int,1},1}
The ``i+1``-th component contains a vector of (hashed) indices that represent
the distinct monomials of a `HomogeneousPolynomial` of order (degree) ``i``.
size_table :: Array{Int64,1}
size_table :: Array{Int,1}
The ``i+1``-th component contains the number of distinct monomials of the
`HomogeneousPolynomial` of order ``i``, equivalent to `length(coeff_table[i])`.
pos_table :: Array{Dict{Int64,Int64},1}
pos_table :: Array{Dict{Int,Int},1}
The ``i+1``-th component maps the hash index to the (lexicographic) position
of the corresponding monomial in `coeffs_table`.
Expand Down
8 changes: 4 additions & 4 deletions src/other_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,19 @@ a `TaylorN` expansion will be computed. If the dimension of x0 (`length(x0)`)
is different from the variables set for `TaylorN` (`get_numvars()`), an
`AssertionError` will be thrown.
"""
function taylor_expand(f::Function; order::Int64=15)
function taylor_expand(f::Function; order::Int=15)
a = Taylor1(order)
return f(a)
end

function taylor_expand(f::Function, x0::T; order::Int64=15) where {T<:Number}
function taylor_expand(f::Function, x0::T; order::Int=15) where {T<:Number}
a = Taylor1([x0, one(T)], order)
return f(a)
end

#taylor_expand function for TaylorN
function taylor_expand(f::Function, x0::Vector{T};
order::Int64=get_order()) where {T<:Number}
order::Int=get_order()) where {T<:Number}

ll = length(x0)
@assert ll == get_numvars() && order <= get_order()
Expand All @@ -235,7 +235,7 @@ function taylor_expand(f::Function, x0::Vector{T};
return f( X )
end

function taylor_expand(f::Function, x0...; order::Int64=get_order())
function taylor_expand(f::Function, x0...; order::Int=get_order())
x0 = promote(x0...)
T = eltype(x0[1])
ll = length(x0)
Expand Down
2 changes: 1 addition & 1 deletion src/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ subscripts for the different variables.
```julia
julia> set_variables(Int, "x y z", order=4)
3-element Array{TaylorSeries.TaylorN{Int64},1}:
3-element Array{TaylorSeries.TaylorN{Int},1}:
1 x + 𝒪(‖x‖⁵)
1 y + 𝒪(‖x‖⁵)
1 z + 𝒪(‖x‖⁵)
Expand Down
16 changes: 8 additions & 8 deletions test/manyvariables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ eeuler = Base.MathConstants.e
yH = HomogeneousPolynomial([0,1],1)
@test HomogeneousPolynomial(0,0) == 0
xT = TaylorN(xH, 17)
yT = TaylorN(Int64, 2, order=17)
yT = TaylorN(Int, 2, order=17)
zeroT = zero( TaylorN([xH],1) )
@test zeroT.coeffs == zeros(HomogeneousPolynomial{Int}, 1)
@test length(zeros(HomogeneousPolynomial{Int}, 1)) == 2
Expand All @@ -107,7 +107,7 @@ eeuler = Base.MathConstants.e
HomogeneousPolynomial{Complex{Int}}
@test convert(HomogeneousPolynomial,1im) ==
HomogeneousPolynomial([complex(0,1)], 0)
@test convert(HomogeneousPolynomial{Int64},[1,1]) == xH+yH
@test convert(HomogeneousPolynomial{Int},[1,1]) == xH+yH
@test convert(HomogeneousPolynomial{Float64},[2,-1]) == 2.0xH-yH
@test typeof(convert(TaylorN,1im)) == TaylorN{Complex{Int}}
@test convert(TaylorN, 1im) ==
Expand All @@ -118,7 +118,7 @@ eeuler = Base.MathConstants.e
@test promote(xH, [1,1])[2] == xH+yH
@test promote(xH, yT)[1] == xT
@test promote(xT, [xH,yH])[2] == xT+yT
@test typeof(promote(im*xT,[xH,yH])[2]) == TaylorN{Complex{Int64}}
@test typeof(promote(im*xT,[xH,yH])[2]) == TaylorN{Complex{Int}}
# @test TaylorSeries.fixorder(TaylorN(1, order=1),17) == xT
@test iszero(zeroT.coeffs)
@test iszero(zero(xH))
Expand Down Expand Up @@ -470,7 +470,7 @@ eeuler = Base.MathConstants.e
@test TaylorSeries.gradient(f1) == [ 3*xT^2-4*xT*yT-TaylorN(7,0), 6*yT-2*xT^2 ]
@test (f2) == [2*xT - 4*xT^3, TaylorN(1,0)]
@test TaylorSeries.jacobian([f1,f2], [2,1]) == TaylorSeries.jacobian( [g1(xT+2,yT+1), g2(xT+2,yT+1)] )
jac = Array{Int64}(undef, 2, 2)
jac = Array{Int}(undef, 2, 2)
TaylorSeries.jacobian!(jac, [g1(xT+2,yT+1), g2(xT+2,yT+1)])
@test jac == TaylorSeries.jacobian( [g1(xT+2,yT+1), g2(xT+2,yT+1)] )
TaylorSeries.jacobian!(jac, [f1,f2], [2,1])
Expand All @@ -485,15 +485,15 @@ eeuler = Base.MathConstants.e
@test TaylorSeries.hessian(f1^2)/2 == [ [49,0] [0,12] ]
@test TaylorSeries.hessian(f1-f2-2*f1*f2) == (TaylorSeries.hessian(f1-f2-2*f1*f2))'
@test TaylorSeries.hessian(f1-f2,[1,-1]) == TaylorSeries.hessian(g1(xT+1,yT-1)-g2(xT+1,yT-1))
hes = Array{Int64}(undef, 2, 2)
hes = Array{Int}(undef, 2, 2)
TaylorSeries.hessian!(hes, f1*f2)
@test hes == TaylorSeries.hessian(f1*f2)
@test [xT yT]*hes*[xT, yT] == [ 2*TaylorN((f1*f2)[2]) ]
TaylorSeries.hessian!(hes, f1^2)
@test hes/2 == [ [49,0] [0,12] ]
TaylorSeries.hessian!(hes, f1-f2-2*f1*f2)
@test hes == hes'
hes1 = Array{Int64}(undef, 2, 2)
hes1 = Array{Int}(undef, 2, 2)
TaylorSeries.hessian!(hes1, f1-f2,[1,-1])
TaylorSeries.hessian!(hes, g1(xT+1,yT-1)-g2(xT+1,yT-1))
@test hes1 == hes
Expand Down Expand Up @@ -550,7 +550,7 @@ eeuler = Base.MathConstants.e
@test norm(a, Inf) == 8.0
@test norm((3.0 + 4im)*x) == abs(3.0 + 4im)

@test TaylorSeries.rtoldefault(TaylorN{Int64}) == 0
@test TaylorSeries.rtoldefault(TaylorN{Int}) == 0
@test TaylorSeries.rtoldefault(TaylorN{Float64}) == sqrt(eps(Float64))
@test TaylorSeries.rtoldefault(TaylorN{BigFloat}) == sqrt(eps(BigFloat))
@test TaylorSeries.real(TaylorN{Float64}) == TaylorN{Float64}
Expand Down Expand Up @@ -637,7 +637,7 @@ eeuler = Base.MathConstants.e
for i in [0,1,3,5]
@test q[i] == p[i]*(180/pi)
end
xT = 5+TaylorN(Int64, 1, order=10)
xT = 5+TaylorN(Int, 1, order=10)
yT = TaylorN(2, order=10)
TaylorSeries.deg2rad!(yT, xT, 0)
@test yT[0] == xT[0]*(pi/180)
Expand Down
6 changes: 3 additions & 3 deletions test/mixtures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ using LinearAlgebra, SparseArrays
ctN1 = convert(TaylorN{Taylor1{Float64}}, t1N)
@test eltype(xHt) == Taylor1{Float64}
@test eltype(tN1) == Taylor1{Float64}
@test eltype(Taylor1([xH])) == HomogeneousPolynomial{Int64}
@test eltype(Taylor1([xH])) == HomogeneousPolynomial{Int}
@test eltype(tN1) == Taylor1{Float64}
@test get_order(HomogeneousPolynomial([Taylor1(1), 1.0+Taylor1(2)])) == 1
@test 3*tN1 == TaylorN([HomogeneousPolynomial([3t]),3xHt,3yHt^2])
Expand Down Expand Up @@ -221,8 +221,8 @@ using LinearAlgebra, SparseArrays
@test norm(-10X+4Y,Inf) == 10.


@test TaylorSeries.rtoldefault(TaylorN{Taylor1{Int64}}) == 0
@test TaylorSeries.rtoldefault(Taylor1{TaylorN{Int64}}) == 0
@test TaylorSeries.rtoldefault(TaylorN{Taylor1{Int}}) == 0
@test TaylorSeries.rtoldefault(Taylor1{TaylorN{Int}}) == 0
for T in (Float64, BigFloat)
@test TaylorSeries.rtoldefault(TaylorN{Taylor1{T}}) == sqrt(eps(T))
@test TaylorSeries.rtoldefault(Taylor1{TaylorN{T}}) == sqrt(eps(T))
Expand Down
4 changes: 2 additions & 2 deletions test/onevariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ eeuler = Base.MathConstants.e
@test p(vr) == evaluate.(p,vr)
@test p(Mr) == p.(Mr)
@test p(Mr) == evaluate.(p,Mr)
taylor_a = Taylor1(Int64,10)
taylor_a = Taylor1(Int,10)
taylor_x = exp(Taylor1(Float64,13))
@test taylor_x(taylor_a) == evaluate(taylor_x, taylor_a)
A_T1 = [t 2t 3t; 4t 5t 6t ]
Expand Down Expand Up @@ -427,7 +427,7 @@ eeuler = Base.MathConstants.e
@test norm(t_a,Inf) == 12
@test norm(t_C) == norm(complex(3.0,4.0)*a)

@test TaylorSeries.rtoldefault(Taylor1{Int64}) == 0
@test TaylorSeries.rtoldefault(Taylor1{Int}) == 0
@test TaylorSeries.rtoldefault(Taylor1{Float64}) == sqrt(eps(Float64))
@test TaylorSeries.rtoldefault(Taylor1{BigFloat}) == sqrt(eps(BigFloat))
@test TaylorSeries.real(Taylor1{Float64}) == Taylor1{Float64}
Expand Down

0 comments on commit 506facd

Please sign in to comment.