小编els*_*can的帖子

Numpy 哪里有 Julia 代码的功能?

我读了答案 “什么是 Julia 相当于 numpy 的 where 函数?”。,但还没有看到答案 (ifelse) 如何为用户提供 numpy.where 的所有功能。我在下面发布了示例代码:

    A = [0.0 0.9 0.0 0.99 0.0]

    a = 1:长度(A)

    #-v- 按预期产生 [0 1.0 0 1.0 0],但如何获取索引值?
    b = ifelse.(A .- 1.0 .> -1.0, 1.0, 0 )
    #-^- 如何得到数组[0.9 0.99]?如何从数组中删除所有零?

除了使用 for 循环之外的任何解决方法将不胜感激。

python numpy where-clause julia array-broadcasting

2
推荐指数
2
解决办法
300
查看次数

标签 统计

array-broadcasting ×1

julia ×1

numpy ×1

python ×1

where-clause ×1