# MMatrix in struct

**URL:** <https://discourse.julialang.org/t/mmatrix-in-struct/86341>\
**Category:** New to Julia\
**Created:** [August 25, 2022, 4:21pm UTC](https://discourse.julialang.org/t/mmatrix-in-struct/86341 "2022-08-25T16:21:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![james3](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@james3](https://discourse.julialang.org/u/james3)\
**Post date:** [August 25, 2022, 4:21pm UTC](https://discourse.julialang.org/t/mmatrix-in-struct/86341/1 "2022-08-25T16:21:38Z")

</div>

I wish to define a struct, containing a square `MMatrix`. The number of rows / columns is `N`. I tried to do this as

```julia
mutable struct my_struct{N, T <: AbstractFloat}
    a::MVector{N, T}
    b::MMatrix{N, N, T, N * N}
end

```

but this does not work as `N * N` is not defined in general. How can I specify that `N` is a integer _value_? Thanks.

---

<div class="post-metadata">

**Author:** ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Post date:** [August 25, 2022, 4:46pm UTC](https://discourse.julialang.org/t/mmatrix-in-struct/86341/2 "2022-08-25T16:46:38Z")

</div>

One approach could be to add another parameter.

```julia
mutable struct my_struct{N, T <: AbstractFloat, L}
    a::MVector{N, T}
    b::MMatrix{N, N, T, L}
end

my_struct(@MVector([1.0,2]), @MMatrix( [1.0 2; 2 3]))

```

This works since the parameter `L` can be determined at construction: [API · StaticArrays.jl](https://juliaarrays.github.io/StaticArrays.jl/stable/pages/api/#StaticArraysCore.MMatrix)
