# Different behaviors between SVector and SMatrix parametric types

**URL:** <https://discourse.julialang.org/t/different-behaviors-between-svector-and-smatrix-parametric-types/65837>\
**Category:** New to Julia\
**Tags:** parametric-types\
**Created:** [August 4, 2021, 7:38pm UTC](https://discourse.julialang.org/t/different-behaviors-between-svector-and-smatrix-parametric-types/65837 "2021-08-04T19:38:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jinml](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jinml](https://discourse.julialang.org/u/jinml)\
**Post date:** [August 4, 2021, 7:38pm UTC](https://discourse.julialang.org/t/different-behaviors-between-svector-and-smatrix-parametric-types/65837/1 "2021-08-04T19:38:12Z")

</div>

Hi, I’m confused about the different parametric type behaviors between `SVector` and `SMatrix`, both are `SArray` types. When sufficient size info is supplied, `SVector` has all parameters evaluated, but `SMatrix` still has one parameter left free, which seems unnecessary, as shown in the screenshot below:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/2/f2167048a391ac6e211c87d6fa5d8dbcbd582120.png)  
why can’t `SMatrix` figure out the total size of the array is 4 in this case?

---

<div class="post-metadata">

**Author:** ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)\
**Post date:** [August 4, 2021, 7:52pm UTC](https://discourse.julialang.org/t/different-behaviors-between-svector-and-smatrix-parametric-types/65837/2 "2021-08-04T19:52:20Z")

</div>

It gets figured out on construction. Until then you can make all sorts of random types, which cannot ever be types of objects – in fact `Tuple{2,2}` is already such a thing.

```julia
julia> Matrix{-99}
Matrix{-99} (alias for Array{-99, 2})

julia> SMatrix{2,2,Int}(1,2,3,4)
2×2 SMatrix{2, 2, Int64, 4} with indices SOneTo(2)×SOneTo(2):
 1 3
 2 4

julia> Tuple{2}(2)
ERROR: MethodError: First argument to `convert` must be a Type, got 2

```

---

<div class="post-metadata">

**Author:** ![jinml](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jinml](https://discourse.julialang.org/u/jinml)\
**Post date:** [August 4, 2021, 7:57pm UTC](https://discourse.julialang.org/t/different-behaviors-between-svector-and-smatrix-parametric-types/65837/3 "2021-08-04T19:57:06Z")

</div>

Thanks, but I think the main confusion is that why `SVector` **can** figure out that total size?

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [August 4, 2021, 7:59pm UTC](https://discourse.julialang.org/t/different-behaviors-between-svector-and-smatrix-parametric-types/65837/4 "2021-08-04T19:59:46Z")

</div>

Because that’s how [`SVector` is defined](https://github.com/JuliaArrays/StaticArrays.jl/blob/e30448b7a85bd6c1bf0f9174c289aec3d3454905/src/SVector.jl#L16)

> `const SVector{S,T} = SArray{Tuple{S}, T, 1, S}`

Whereas `SMatrix` [requires all 4 type parameters](https://github.com/JuliaArrays/StaticArrays.jl/blob/e30448b7a85bd6c1bf0f9174c289aec3d3454905/src/SMatrix.jl#L17):

> `const SMatrix{S1, S2, T, L} = SArray{Tuple{S1, S2}, T, 2, L}`

The crucial difference is that `L == S1 * S2` is not something the compiler can infer/calculate in type parameter space.
