In this case you can try:

abstract Metric

immutable Sphere{M <: Metric}
    dim::Int
end

immutable Riemannian <: Metric end
function metric(s::Sphere{Riemannian}) = ...

immutable Lorentzian <: Metric end
function metric(s::Sphere{Lorentzian}) = ...

In fact, you don't need to declare "Metric"; you can just use "Any"
instead. I like it because it adds documenation to the code.

-erik



On Mon, Jan 18, 2016 at 7:58 PM, Anonymous <[email protected]> wrote:
> The issue is that there is no cross section of metrics, one from each
> manifold, which can all be grouped under the heading of RIEMANNIAN, same
> with LORENTZIAN, etc.  Each manifold will have its own set of idiosyncratic
> metrics, and the user might require the functionality of being able to
> customize their own metric for a manifold.  That's why it makes so much
> sense to attach the metric to the manifold when you instantiate it.
> Manifolds are prototypical objects with lots of internal structure, and thus
> the code gets messy when you try to shoehorn them into the role of a
> datatype.
>
> On Monday, January 18, 2016 at 2:33:10 PM UTC-8, Simon Danisch wrote:
>>
>> Am I missing something, or why isn't there this solution:
>>
>> @enum Metric RIEMANNIAN LORENTZIAN # ...
>> immutable Sphere{Matric}
>>     dim::Int
>> end
>> function metric(s::Sphere{RIEMANNIAN})
>>
>> end
>> function metric(s::Sphere{LORENTZIAN})
>>
>> end



-- 
Erik Schnetter <[email protected]>
http://www.perimeterinstitute.ca/personal/eschnetter/

Reply via email to