# JuliaDiffEq with custom types

**URL:** https://discourse.julialang.org/t/juliadiffeq-with-custom-types/16294
**Category:** Numerics
**Tags:** diffeq
**Created:** [October 13, 2018, 9:57pm UTC](https://discourse.julialang.org/t/juliadiffeq-with-custom-types/16294 "2018-10-13T21:57:52Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [February 11, 2019, 10:10am UTC](https://discourse.julialang.org/t/juliadiffeq-with-custom-types/16294/12 "2019-02-11T10:10:34Z")

</div>

This recovers the fastness of Static arrays, using Setfield.jl

```julia
function Base.copy(bc::Broadcasted{<:MtypeStyle{N,T}}) where {N,T}
    # traverse Broadcasted tree to find Mtype instances
    name, p = get_name_p(bc)
    # This trick works:
    # https://discourse.julialang.org/t/constructing-svector-with-a-loop/15372/7
    s = SVector{N,T}(1:N)
    for (i,v) in enumerate(bc)
        @set s[i] = v
    end
    Mtype{N,T}(s, name, p)
end

```

x-ref [Constructing SVector with a loop - #7 by tkf](https://discourse.julialang.org/t/constructing-svector-with-a-loop/15372/7)

---

_[View the full topic](https://discourse.julialang.org/t/juliadiffeq-with-custom-types/16294)._
