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

Make Map into a type #133

Closed
dlfivefifty opened this issue Feb 26, 2015 · 3 comments
Closed

Make Map into a type #133

dlfivefifty opened this issue Feb 26, 2015 · 3 comments

Comments

@dlfivefifty
Copy link
Member

dlfivefifty commented Feb 26, 2015

Should domains be more systematic, with canonical domains and maps? I'm thinking something like this

abstract Domain
abstract Map

abstract CanonicalDomain <: Domain

immutable UnitInterval <: CanonicalDomain end
immutable UnitCircle <: CanonicalDomain end

immutable Affine <: Map 
   a
   b
end
call(A::Affine,x)=A.a + A.b*x
inv(A::Affine,x)=(x-A.a)/A.b
# Also Mobius, Tan, etc.

immutable MappedDomain{M,D} <: Domain
   map::M
   domain::D
end

tocanonical(M::MappedDomain,x)=inv(M.map,x)
fromcanonical(M::MappedDomain,x)=M.map(x)

typealias Interval MappedDomain{Affine,UnitInterval}
typealias Circle MappedDomain{Affine,UnitCircle}
@dlfivefifty
Copy link
Member Author

dlfivefifty commented May 24, 2015

I think maps should work like this:

m=Map(Interval(),Line())
m(x)           # replaces fromcanonical(Line(),x)
m'(x)          # replaces fromcanonicalD(Line(),x)
inv(m)(x)    # replaces tocanonical(Line(),x)
inv(m)'(x)    # replaces tocanonicalD(Line(),x)

@dlfivefifty dlfivefifty added this to the Upgrade to v0.4 milestone May 24, 2015
@dlfivefifty dlfivefifty changed the title Split Domains to Map, CanonicalDomain and MappedDomain? Make Map into a type May 24, 2015
@dlfivefifty
Copy link
Member Author

I think Map should be an abstract type.

# represent map from type T to type V
abstract type Map{T, V} <: Callable end

# x -> c
struct ConstantMap{T} <: Map{T,T}
   c::T
end

(f::ConstantMap)(x) = f.c

# A*x + b
struct AffineMap{T, V} <: Map{T, V}
   A::T
   b::V
end

(f::AffineMap)(x) = f.A*x + f.b
inv(f::AffineMap) = AffineMap(inv(f.A), f.A \ f.b)
ctranspose(f::AffineMap) = ConstantMap(f.A) # derivative

# represent (az + b)/(cz + d)
struct MobiusMap{T} <: Map{T,T}
  a::T
  b::T
  c::T
  d::T
end

(m::MobiusMap, a::AffineMap) = MobiusMap(m.a*a.A , m.b + m.a*a.b, m.c*a.A, m.d + m.c*a.b)

# default maps
Map(d1::Segment, d2::Segment) = AffineMap((d2.b - d2.a)/(d1.b - d1.a) , (d1.b*d2.a - d2.b*d1.a)/(d1.b - d1.a))
Map(d1::Circle, d2::Circle) = AffineMap( ... )
function Map(d1::PeriodicInterval, d2::Line) 
  if d1 == Circle()
      MobiusMap(-im, im, 1, 1)
  else 
     m1 = Map(d1, Interval())
     Map(Interval(), Circle())  m1
   end
end

@dlfivefifty
Copy link
Member Author

@marcusdavidwebb @daanhb this is related to our conversation at OPSFA

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

No branches or pull requests

1 participant