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

Support complex domains (e.g., circle in the complex plane) #1

Closed
dlfivefifty opened this issue Sep 12, 2017 · 6 comments
Closed

Support complex domains (e.g., circle in the complex plane) #1

dlfivefifty opened this issue Sep 12, 2017 · 6 comments

Comments

@dlfivefifty
Copy link
Member

No description provided.

@dlfivefifty dlfivefifty mentioned this issue Sep 12, 2017
8 tasks
@daanhb
Copy link
Member

daanhb commented Sep 15, 2017

The original idea was to support this by identifying R^2 with C. This way, any 2D domain can be used as a subset of the complex plane. As a matter of fact, this is currently working, but it is not user-friendly yet and it does result in a very strange object (a unit disk with an affine map to set the radius, and an embedding map for identifying with the plane).

Of course, for popular domains such as circles and, say, Bernstein ellipses, there could be a special-purpose type as well with a straightforward implementation.

@dlfivefifty
Copy link
Member Author

I think that would be confusing, and one should only support conversion:

in(d::Domain{T}, x) where T = in(d, convert(T, x))

This would throw an error if T is SVector{2,Float64} and x isa Complex128.

I would rewrite the circle code to support non-SVector types via:

struct UnitSphere{N,T} <: Domain{T}
end

const Circle{T} = UnitSphere{2,T}
const Sphere{T} = UnitBall{3,T}
circle(::Type{T} = Float64) where {T} = Circle{SVector{2,T}}()

Then a complex-valued unit circle could be represented as Circle{Complex128}(), or a Vector{Float64} unit circle could be represented as Circle{Vector{Float64}}().

@dlfivefifty
Copy link
Member Author

Sorry, calling convert doesn't work: one wants to actually do the following:

function in(x, d::Domain) 
   T = promote_type(typeof(x), eltype(d))
   T == Any && return false
   in(convert(T, x), convert(Domain{T}, d))
end

so that we can do in(1+im , Interval()) without throwing an error.

@dlfivefifty
Copy link
Member Author

PS I'm going to just make the changes I want to make in the branch approxfun-support, and we can discuss whether they are good ideas in a pull request

@dlfivefifty
Copy link
Member Author

dlfivefifty commented Oct 17, 2018

I think this makes sense: change it to

struct UnitHyperSphere{T} <: Domain{T} end

const UnitCircle{T} = UnitHyperSphere{SVector{2,T}}
const UnitSphere{T} = UnitHyperSphere{SVector{3,T}}
const ComplexUnitCircle{T} = UnitHyperSphere{Complex{T}}

Here the definition of UnitHyperSphere{T} is x in T such that norm(x) = 1.

@daanhb
Copy link
Member

daanhb commented Mar 25, 2021

Old issue but still relevant. With the current generic definitions of balls and spheres, I'm adding:

const ComplexUnitCircle{T} = FixedUnitSphere{Complex{T}}
const ComplexUnitDisk{T,C} = FixedUnitBall{Complex{T},C}

ComplexUnitCircle() = ComplexUnitCircle{Float64}()
ComplexUnitDisk() = ComplexUnitDisk{Float64}()
ComplexUnitDisk{Float64}() = ComplexUnitDisk{Float64,:closed}()

The open complex unit disk can be made, if one is so inclined, using ComplexUnitDisk{Float64,:open}().

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