相关疑难解决方法(0)

朱莉娅的Refs和Broadcasting之间有什么联系

对于两个对象A,B我们以前可以[A*A, A*B]使用代码获取向量A .* [A, B].根据Julia 0.7中的弃用警告,似乎新方法是使用第一个A的引用.所以它变成了Ref(A) .* [A,B].

似乎参考和广播业务之间没有强大的联系.这里有什么链接以及为什么使用参考首选(至少通过弃用警告)?

最小工作示例

import Base.*
struct example
    num::Int
end
function *(lhs::example, rhs::example)
    return example(lhs.num * rhs.num)
end
A = example(2)
B = example(4)
# Previously this could be done as follows.
A .* [A, B]
# Now we need to use Refs
Ref(A) .* [A, B]
Run Code Online (Sandbox Code Playgroud)

julia

4
推荐指数
1
解决办法
167
查看次数

标签 统计

julia ×1