Stream: helpdesk (published)

Topic: Broadcasting over custom array type


view this post on Zulip Brenhin Keller (Jun 05 2022 at 03:44):

Is there a method you can implement if you want a broadcast over a custom array type to return an array of that is also of your custom array type instead of a Base.Array?
i.e.

A::MyArray
B = A .+ 5 # Want this to return a `MyArray`  too

view this post on Zulip Brenhin Keller (Jun 05 2022 at 03:44):

I thought similar might do it but seems like not

view this post on Zulip Sukera (Jun 05 2022 at 06:01):

You need to overload Base.Broadcast.broadcasted

view this post on Zulip Sukera (Jun 05 2022 at 06:04):

See also https://youtu.be/jS9eouMJf_Y?t=1445

view this post on Zulip Sukera (Jun 05 2022 at 06:04):

it's a little dated by now (especially in regards to "put @inbounds there"), but the talk is still the best summary of custom arrays & broadcasting that I know of


Last updated: Oct 02 2023 at 04:34 UTC