exploit fusing broadcasts in Julia 0.5+ #356
Comments
You can also implement |
I guess the idea is to get all functions without having to override them? This will work for smooth functions. I guess the existing overrides that take into account singularities can remain, without the . Notation. Sent from my iPad
|
Yes. Also, you avoid having to construct the Chebyshev coefficients multiple times in nested calls. |
You may also want to override |
I guess that makes sense if a domain is identified by the identity function on the domain, which is consistent with the Fun(Domain([-1,1])) notation. Though I'm thinking of changing [-1,1] to -1..1 to mean the unit interval. |
Is there a natural way to do singularity detection a la automatic differentiation? We can determine the range of a function automatically, so can represent it as an Interval, so for example if the range of f is 0..1 and then sqrt.(f) is called, perhaps the sqrt decay can be detected automatically |
Can't you detect the presence (if not the location) of singularities by noticing that the coefficients are not decaying exponentially? |
Note that |
I don't think looking at the coefficients will be robust enough. Sent from my iPhone
|
A basic version of this is now implemented in the development branch. |
@stevengj If there is a vector-valued f = Fun(x ->[exp(x),sin(x)])
norm.(f) == Fun(x ->norm([exp(x),sin(x)])) # broadcast over x
norm.(f) == Fun(x ->[norm(exp(x)),norm(sin(x))]) # broadcast over vector index |
I would expect |
I agree, and that is what has been implemented in "development": f = Fun(x ->[exp(x),sin(x)])
F = [Fun(exp),Fun(sin)]
norm.(f) == Fun(x ->norm([exp(x),sin(x)]))
norm.(F) == [norm(Fun(exp)),norm(Fun(sin))] # isa Vector{Float64} When you simultaneously broadcast with both norm.(f,[1,2]) == norm.(F,[1,2]) == [norm(f[1],1),norm(f[2],2)] # isa Vector{Float64} Converting the norm.(f,Fun([1,2])) == Fun(x->[norm(f[1](x),1),norm(f[2](x),2)]) # isa Fun EDIT: Ignore the last one. |
If you implement
broadcast(op, f::Fun) = Fun(x -> f(x), domain(f))
then you will be able to do e.g.sin.(erf.(f))
wherex::Fun
and it will automatically turn into a single fusedFun(x -> sin(erf(f(x))), domain(f))
constructor call.Furthermore, you will probably want
broadcast{T<:Union{Number,Fun}}(op, f::T...) = ...
so that you can do operations combining multipleFun
objects and numbers, e.g.atan2.(f,g)
orbesselj.(3, f)
.(In 0.6, this will automatically give you fusing
Fun
constructors for binary operators like.+
and.^
, too.)See JuliaLang/julia#16285
The text was updated successfully, but these errors were encountered: