Skip to content

Commit

Permalink
Fix integrate for several variables and add simple tests (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpsanders authored and lbenet committed Feb 21, 2018
1 parent 4a1eed0 commit c6b45d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/calculus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ function integrate(a::HomogeneousPolynomial, r::Int)
a.order == order_max && return HomogeneousPolynomial(zero(T), 0)

@inbounds posTb = pos_table[a.order+2]
@inbounds num_coeffs = size_table[a.order+2]
coeffs = zeros(T, size_table[num_coeffs])
@inbounds num_coeffs = size_table[a.order+1]

coeffs = zeros(T, size_table[a.order+2])

@inbounds for i = 1:num_coeffs
iind = coeff_table[a.order+1][i]
n = iind[r]
Expand Down
16 changes: 16 additions & 0 deletions test/manyvariables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ end
@test integrate(xT^17, 1, 2.0) == 2.0
@test_throws AssertionError integrate(xT, 1, xT)




@test derivative(2xT*yT^2,1) == 2yT^2
@test xT*xT^3 == xT^4
txy = 1.0 + xT*yT - 0.5*xT^2*yT + (1/3)*xT^3*yT + 0.5*xT^2*yT^2
Expand Down Expand Up @@ -545,3 +548,16 @@ end
TaylorSeries.rad2deg!(yT, xT, 0)
@test yT[0] == xT[0]*(180/pi)
end

@testset "Integrate for several variables" begin

t, x, y = set_variables("t x y")

@test integrate(t, 1) == 0.5*t^2
@test integrate(t, 2) == t * x
@test integrate(t, 3) == t * y
@test integrate(x, 1) == t * x
@test integrate(x, 2) == 0.5*x^2
@test integrate(y, 2) == x * y

end

0 comments on commit c6b45d2

Please sign in to comment.