I've been thinking more about your suggestion with Array{Any, D}. The type
of the entries (Vector{Float64} in my case) are not inferred. Is there a
way to inform Julia that 'Any' is actually Vector{Float64} for all entries.
I.e., something like Array{Vector{Float64}, D} ?
On Thursday, June 2,
That's a nice solution -- thanks!
On Thursday, June 2, 2016 at 1:54:23 PM UTC+2, Erik Schnetter wrote:
>
> In these cases I do the following:
>
> (1) Add additional type parameters, as in
>
> ```Julia
> type FooImp{D,D1}
> baz::Array{D}
> bar::Array{D1}
> end
> ```
>
> (2) Add a function
The annoyance is when you have to store these things in a type because for type
stability you need to parameterize the type on everything the sotred fields
parameterize on, including the "redundant" ones.
For example, I have a tensor type which is wrapping a tuple and instead of
storing
In these cases I do the following:
(1) Add additional type parameters, as in
```Julia
type FooImp{D,D1}
baz::Array{D}
bar::Array{D1}
end
```
(2) Add a function that calculates the type:
```Julia
Foo(D) = FooImpl{D,D+1}
```
In many cases I can then have to write `Foo(D)` instead of
The problem with not specifying D is type inference. I actually have more
entries in Foo and would like
type Foo{D}
baz::Array{D}
bar::Array{D+1}
end
I want to use Foo in calculations and for D = 1 I am doing something like
baz + bar[:,1]
baz + bar[:,2]
For D = 2:
baz + bar[:,:,1]
baz +
I really doubt that it can be expressed this way, because Julia will do
pattern matching/unification on the type of `bar`, and it would have to
know that -1 is the inverse of +1 to unify D+1 with the type of the input
array. Can you give more context about what you're trying to do? Why can't