Efficient way to chain element-wise operations for code generation?
显示 更早的评论
Hi, I have functions that chain elementwise array operations eg:
function y = Foo(X)
y = 20*log10(abs(X));
end
I want to use Matlab Coder to make C code out of this.
I inspect the C code generated.
It performs all the sub-expressions as their own separate loops like:
//Pseudocode:
for (loop over array){
Y = abs(X)
}
for (loop over array){
Y = log10(Y)
}
for (loop over array){
Y = 20.0f * Y
}
is there any way to fuse all these into 1 loop (as shown below) without manually editting the generated code:
for (loop over array){
Y = 20.0f * log10(abs(X))
}
I'm hoping for something like an elementwise functor mapped across an array like arrayfun, but I haven't been able to get anything working.
回答(1 个)
Gershom Agim
2019-2-6
编辑:Gershom Agim
2019-2-6
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB Coder 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!