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

SMatrix constructors do not all produce concrete types #1242

Open
just-walk opened this issue Feb 1, 2024 · 2 comments
Open

SMatrix constructors do not all produce concrete types #1242

just-walk opened this issue Feb 1, 2024 · 2 comments

Comments

@just-walk
Copy link

The constructor docstring for SMatrix indicates that not all parameters are needed if they are inferrable from the input. In particular, L is inferrable from S1 and S2.

help?> SMatrix
search: SMatrix @SMatrix DenseMatrix SizedMatrix StaticMatrix AbstractMatrix StridedMatrix

  SMatrix{S1, S2, T, L}(x::NTuple{L, T})
  SMatrix{S1, S2, T, L}(x1, x2, x3, ...)

  Construct a statically-sized matrix SMatrix. Since this type is immutable, the data must be provided upon construction
  and cannot be mutated later. The L parameter is the length of the array and is always equal to S1 * S2. Constructors
  may drop the L, T and even S2 parameters if they are inferrable from the input (e.g. L is always inferrable from S1 and
  S2).

However, dropping the L parameter produces an abstract type.

julia> typeof(SMatrix{3, 3, Float64})
UnionAll

julia> typeof(SMatrix{3, 3, Float64, 9})
DataType

julia> isconcretetype(SMatrix{3, 3, Float64})
false

julia> isconcretetype(SMatrix{3, 3, Float64, 9})
true

Is this a desired behavior? I've run into type-stability issues because of it.

@hyrodium
Copy link
Collaborator

hyrodium commented Feb 2, 2024

Is this a desired behavior?

Not desired, but expected.

There is a LengthFreeStaticMatrices.jl package for this issue.

@jishnub
Copy link
Member

jishnub commented Feb 2, 2024

The idea is that such a type isn't concrete by itself, but instances constructed using it would have a concrete type.

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

3 participants