Gridap.jl
Gridap.jl copied to clipboard
Specialize `mapreduce` for `VectorValue` etc?
Thanks for the nice package. I was playing around with it a bit and wanted to try out a toy problem (in different spatial dimensions) with analytical solution
u(x) = prod(sinpi, x)
However, this does not work right now since x::VectorValue
and VectorValue <: Number
. Thus, prod
hits mapreduce
with special case
https://github.com/JuliaLang/julia/blob/7dc132cf5a44717dbb619812dc05fd127c9d805a/base/reduce.jl#L438
which tries to handle x
as a single number instead of an iterable.
Do you think it would make sense to specialize mapreduce
for cases like this? Right now, I need to use a workaround such as
u(x) = prod(i -> sinpi(x[i]), eachindex(x))
Not a solution, but an other alternative fix for this is
u(x) = prod(sinpi, x.data)
like you mentioned it might be best and general to specialize TensorValue
family for mapreduce
.