Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot add Piecewise functions if intervals are not the same #45

Closed
goretkin opened this issue Nov 24, 2014 · 2 comments
Closed

cannot add Piecewise functions if intervals are not the same #45

goretkin opened this issue Nov 24, 2014 · 2 comments

Comments

@goretkin
Copy link
Contributor

julia> s = Fun(sin, [0., 7.]);

julia> c = Fun(cos, [0., 7.]);

julia> as = abs(s);

julia> ac = abs(c);

julia> ac+as;
ERROR: assertion failed: domainscompatible(a,b)
 in conversion_rule at /Users/goretkin/.julia/v0.3/ApproxFun/src/Spaces/Ultraspherical/UltrasphericalOperators.jl:273
 in maxspace at /Users/goretkin/.julia/v0.3/ApproxFun/src/Fun/FunctionSpace.jl:109
 in maxspace at /Users/goretkin/.julia/v0.3/ApproxFun/src/Spaces/Modifier/VectorSpace.jl:149
 in + at /Users/goretkin/.julia/v0.3/ApproxFun/src/Fun/Fun.jl:119

I spent a couple of hours trying to figure out how I should implement this but I don't know enough about ApproxFun. I put what I started in a gist https://gist.github.com/goretkin/5d4fb776b9ef09f4bd1f

I think the point here is to add ac + as without recomputing the coefficients, though one stopgap could be to override the addition method on Fun{PiecewiseSpace} directly and compute Fun( (x)-> ac[x] + as[x], unique(merge_sorted(breaks(ac.space), breaks(as.space))))

@dlfivefifty
Copy link
Member

Ah good point, since the intervals are different.  I think I just need to override maxspace to say we can convert to piecewise with all pieces…

PiecewiseSpace is far from well-developed

On 24 Nov 2014, at 3:28 pm, Gustavo Goretkin notifications@github.com wrote:

julia> s = Fun(sin, [0., 7.]);

julia> c = Fun(cos, [0., 7.]);

julia> as = abs(s);

julia> ac = abs(c);

julia> ac+as;
ERROR: assertion failed: domainscompatible(a,b)
in conversion_rule at /Users/goretkin/.julia/v0.3/ApproxFun/src/Spaces/Ultraspherical/UltrasphericalOperators.jl:273
in maxspace at /Users/goretkin/.julia/v0.3/ApproxFun/src/Fun/FunctionSpace.jl:109
in maxspace at /Users/goretkin/.julia/v0.3/ApproxFun/src/Spaces/Modifier/VectorSpace.jl:149
in + at /Users/goretkin/.julia/v0.3/ApproxFun/src/Fun/Fun.jl:119
I spent a couple of hours trying to figure out how I should implement this but I don't know enough about ApproxFun. I put what I started in a gist https://gist.github.com/goretkin/5d4fb776b9ef09f4bd1f https://gist.github.com/goretkin/5d4fb776b9ef09f4bd1f
I think the point here is to add ac + as without recomputing the coefficients, though one stopgap could be to override the addition method on Fun{PiecewiseSpace} directly and compute Fun( (x)-> ac[x] + as[x], unique(merge_sorted(breaks(ac.space), breaks(as.space))))


Reply to this email directly or view it on GitHub #45.

@dlfivefifty
Copy link
Member

OK, this should work now for PiecewiseSpace{ChebyshevSpace}. I override union to determine a space that contains two other spaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants