Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Nov 1, 2018
1 parent 9af9f5e commit a4c6a00
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -9,7 +9,8 @@ julia:
- nightly
matrix:
allow_failures:
- julia: nightly
- julia: nightly
- os: osx
notifications:
email: false
after_script:
Expand Down
5 changes: 4 additions & 1 deletion src/Domains/Segment.jl
Expand Up @@ -38,12 +38,15 @@ convert(::Type{Segment{T}}, d::AbstractInterval) where T =convert(Segment{T}, co
Segment(d::AbstractInterval) = convert(Segment, d)



AnySegment(::Type{T}) where {T} = Segment{T}(NaN,NaN)
AnySegment() = AnySegment(Float64)
isambiguous(d::Segment) = all(isnan(leftendpoint(d))) && all(isnan(rightendpoint(d)))
isambiguous(d::IntervalOrSegmentDomain) = all(isnan(leftendpoint(d))) && all(isnan(rightendpoint(d)))
convert(::Type{Segment{T}},::AnyDomain) where {T<:Number} = AnySegment(T)
convert(::Type{Segment},::AnyDomain) = AnySegment()
convert(::Type{Interval}, d::Segment{<:Real}) = d.a < d.b ? d.a .. d.b : d.b .. d.a
convert(::Type{ClosedInterval}, ::AnyDomain) = NaN..NaN
convert(::Type{ClosedInterval{T}}, ::AnyDomain) where T = T(NaN)..T(NaN)
Interval(d::Segment) = convert(Interval, d)


Expand Down
25 changes: 24 additions & 1 deletion test/ODETest.jl
@@ -1,4 +1,4 @@
using ApproxFun, SpecialFunctions, Test
using ApproxFun, SpecialFunctions, LazyArrays, Test
import ApproxFun: Multiplication, testraggedbelowoperator, testbandedoperator, interlace, ∞

@testset "ODE" begin
Expand Down Expand Up @@ -209,4 +209,27 @@ using ApproxFun, SpecialFunctions, Test

@test abs(u'(1.3) + u(1.3-1) )  10eps()
end

@testset "Tenth order" begin
x = Fun()
D = Derivative()


L=D^10 + cosh(x)*D^8 + x^3*D^6 + x^4*D^4 + cos(x)*D^2 + x^2
d = ChebyshevInterval()
B = [Dirichlet(d) ;
Neumann(d) ;
[Evaluation(d,leftendpoint,k) for k=2:4]... ;
[Evaluation(d,rightendpoint,k) for k=2:4]...]

rs = rangespace(B)
@test ApproxFun.blocklengths(rs) == [10]

A = [B; L]
rs = rangespace(A)
@test ApproxFun.blocklengths(rs) isa Vcat

u = [B; L] \ [ [0.,0.], [1.,1.], zeros(6)..., exp(x)]
@test u(0.5) -0.4024723414410859 # Empirical
end
end
18 changes: 14 additions & 4 deletions test/SpeedODETest.jl
Expand Up @@ -3,15 +3,27 @@ using ApproxFun, SpecialFunctions, Test

## ODEs

d = Interval(-20000.,20000.)
d = -20000..20000.0
x = Fun(identity,d)
u = [Dirichlet(d);Derivative(d)^2+I]\[[1,0],0]
u = [Dirichlet(d);Derivative(d)^2+I]\[[1,0],0]
@time u = [Dirichlet(d);Derivative(d)^2+I]\[[1,0],0]

@profile u = [Dirichlet(d);Derivative(d)^2+I]\[[1,0],0]

using Profile
Profile.print()
using BandedMatrices
A = brand(5000,5000,1,1)
B = similar(A)

@time BLAS.axpy!(2.0, A, B)
@time B .= 2.0 .* A .+ B


println("Cos/Sin: should be ~0.016920 seconds (3.19 k allocations: 12.593 MiB)")

d=Interval(-1000.,5.)
d = -1000..5.0
x=Fun(identity,d)
u=[Dirichlet(d);Derivative(d)^2-x]\[[1,0],0]
u=[Dirichlet(d);Derivative(d)^2-x]\[[1,0],0]
Expand All @@ -22,8 +34,6 @@ M=cache([Dirichlet(d);Derivative(d)^2-x];padding=true)
@time ApproxFun.resizedata!(M,12500,:)
println("Airy construct op: 0.003200 seconds (131 allocations: 3.723 MiB)")



S=Chebyshev()
x=Fun(identity,S)
D=Derivative(S)
Expand Down
9 changes: 9 additions & 0 deletions test/VectorTest.jl
Expand Up @@ -3,6 +3,9 @@ using ApproxFun, LazyArrays, FillArrays, LinearAlgebra, SpecialFunctions, Test
ArraySpace, testblockbandedoperator, blocklengths, ∞,
testraggedbelowoperator, Vec




@testset "Vector" begin
@testset "Construction" begin
f = Fun(x->[1.,0.])
Expand Down Expand Up @@ -376,4 +379,10 @@ using ApproxFun, LazyArrays, FillArrays, LinearAlgebra, SpecialFunctions, Test
-0.836059 0.265569 -0.170879 -0.148885;
-0.612945 -0.836059 0.732284 -0.170879] atol=1E-3
end

@testset "diagonal" begin
x = Fun(0.0..1)
@test isambiguous(domain(zero(typeof(x))))
@test diagm(0 => [x,x]) * [1,2] == [x,2x]
end
end

0 comments on commit a4c6a00

Please sign in to comment.