-
Notifications
You must be signed in to change notification settings - Fork 20
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
Adding different FixedVectors results in stack overflow #101
Comments
OK I figured out how to do my use case: function translate{N}(x::FixedVector{N}, dx::FixedVector{N})
(x_promoted, dx_promoted) = promote(x, dx) # Force same data type
x_promoted + (typeof(x_promoted))(dx_promoted) # Force same base type
end This returns the appropriate container using Do we care about the stack overflow? |
The stack overflow definitely seems bad - should probably be either a no method error, or be promoted to
TBH, the discussion of what |
Seems to me like we need a system of abstractions: FixedSizeVector <: FixedSizeAffine <: FixedSizeStorage The storage knows how to index, concatenated, etc. The Affine space defines affine combinations. The vector space does all of the things in The problem is, base Julia needs exactly the same thing! Would people welcome such levels of abstraction? I can see the utility in geometric settings, and having lighter-weight storage containers makes sense to me also. But, everything is wrapped up in |
The difficult design issue is that extra abstraction always comes with a mental cost to understand each abstraction. On the other hand, you can stick a bunch of related abstractions together into a single type, but this can get conceptually messy if you go too far. To me, FixedArray should have exactly the same semantics as Array where possible, as Base users already have a good mental model of what to expect. For better or worse Array is a bit of a bag of all tricks - depending on dimensionality it can be a vector, a linear operator, a multidimensional rectangular container, an efficient extensible list/stack (in 1D), etc. |
Fixed via #105 |
Note that the type is currently taken from the left hand side for |
If you try add two
FixedSizeArray
s of different base types, then you may get stack overflows with common operations.For example:
The problem comes back to this in ops.jl:
which ends up calling itself, unless the base types are the same. There are two problems:
promote
and generated functions/function generatorsconstructor_expr
, etc? I will dig around.The text was updated successfully, but these errors were encountered: