<i id='8JLJM'><tr id='8JLJM'><dt id='8JLJM'><q id='8JLJM'><span id='8JLJM'><b id='8JLJM'><form id='8JLJM'><ins id='8JLJM'></ins><ul id='8JLJM'></ul><sub id='8JLJM'></sub></form><legend id='8JLJM'></legend><bdo id='8JLJM'><pre id='8JLJM'><center id='8JLJM'></center></pre></bdo></b><th id='8JLJM'></th></span></q></dt></tr></i><div id='8JLJM'><tfoot id='8JLJM'></tfoot><dl id='8JLJM'><fieldset id='8JLJM'></fieldset></dl></div>
      • <bdo id='8JLJM'></bdo><ul id='8JLJM'></ul>
      <tfoot id='8JLJM'></tfoot>
      <legend id='8JLJM'><style id='8JLJM'><dir id='8JLJM'><q id='8JLJM'></q></dir></style></legend>

      <small id='8JLJM'></small><noframes id='8JLJM'>

    1. 是否有与 NumPy 的省略号切片语法 (...) 等效的 Julia?

      Is there a Julia equivalent to NumPy#39;s ellipsis slicing syntax (...)?(是否有与 NumPy 的省略号切片语法 (...) 等效的 Julia?)

            <tbody id='ZfwSI'></tbody>
          <i id='ZfwSI'><tr id='ZfwSI'><dt id='ZfwSI'><q id='ZfwSI'><span id='ZfwSI'><b id='ZfwSI'><form id='ZfwSI'><ins id='ZfwSI'></ins><ul id='ZfwSI'></ul><sub id='ZfwSI'></sub></form><legend id='ZfwSI'></legend><bdo id='ZfwSI'><pre id='ZfwSI'><center id='ZfwSI'></center></pre></bdo></b><th id='ZfwSI'></th></span></q></dt></tr></i><div id='ZfwSI'><tfoot id='ZfwSI'></tfoot><dl id='ZfwSI'><fieldset id='ZfwSI'></fieldset></dl></div>
            <bdo id='ZfwSI'></bdo><ul id='ZfwSI'></ul>
          • <tfoot id='ZfwSI'></tfoot>
            • <legend id='ZfwSI'><style id='ZfwSI'><dir id='ZfwSI'><q id='ZfwSI'></q></dir></style></legend>

                <small id='ZfwSI'></small><noframes id='ZfwSI'>

                本文介绍了是否有与 NumPy 的省略号切片语法 (...) 等效的 Julia?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 NumPy 中,省略号语法 用于

                In NumPy, the ellipsis syntax is for

                填写多个:,直到切片说明符的个数与数组的维度相匹配.

                filling in a number of : until the number of slicing specifiers matches the dimension of the array.

                (转述这个答案).

                我如何在 Julia 中做到这一点?

                How can I do that in Julia?

                推荐答案

                还没有,但如果你愿意,你可以自己动手.

                Not yet, but you can help yourself if you want.

                    import Base.getindex, Base.setindex!
                    const .. = Val{:...}
                
                    setindex!{T}(A::AbstractArray{T,1}, x, ::Type{Val{:...}}, n) = A[n] = x
                    setindex!{T}(A::AbstractArray{T,2}, x, ::Type{Val{:...}}, n) = A[ :, n] = x
                    setindex!{T}(A::AbstractArray{T,3}, x, ::Type{Val{:...}}, n) = A[ :, :, n] =x
                
                    getindex{T}(A::AbstractArray{T,1}, ::Type{Val{:...}}, n) = A[n]
                    getindex{T}(A::AbstractArray{T,2}, ::Type{Val{:...}}, n) = A[ :, n]
                    getindex{T}(A::AbstractArray{T,3}, ::Type{Val{:...}}, n) = A[ :, :, n]
                

                那你就可以写了

                    > rand(3,3,3)[.., 1]
                    3x3 Array{Float64,2}:
                     0.0750793  0.490528  0.273044
                     0.470398   0.461376  0.01372 
                     0.311559   0.879684  0.531157
                

                如果您想要更精细的切片,您需要生成/扩展定义或使用分段函数.

                If you want more elaborate slicing, you need to generate/expand the definition or use staged functions.

                如今,请参阅 https://github.com/ChrisRackauckas/EllipsisNotation.jl

                这篇关于是否有与 NumPy 的省略号切片语法 (...) 等效的 Julia?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How to run python3.7 based flask web api on azure(如何在 azure 上运行基于 python3.7 的烧瓶 web api)
                Azure Python Web App Internal Server Error(Azure Python Web 应用程序内部服务器错误)
                Run python dlib library on azure app service(在 azure app 服务上运行 python dlib 库)
                Why is the azure app service django deploy keep failing?(为什么 azure app service django deploy 总是失败?)
                How to Add rows using subqueries in sqlalchemy?(如何在 sqlalchemy 中使用子查询添加行?)
                How do I write a Django query with a subquery as part of the WHERE clause?(如何编写带有子查询的 Django 查询作为 WHERE 子句的一部分?)
                <i id='uxjSq'><tr id='uxjSq'><dt id='uxjSq'><q id='uxjSq'><span id='uxjSq'><b id='uxjSq'><form id='uxjSq'><ins id='uxjSq'></ins><ul id='uxjSq'></ul><sub id='uxjSq'></sub></form><legend id='uxjSq'></legend><bdo id='uxjSq'><pre id='uxjSq'><center id='uxjSq'></center></pre></bdo></b><th id='uxjSq'></th></span></q></dt></tr></i><div id='uxjSq'><tfoot id='uxjSq'></tfoot><dl id='uxjSq'><fieldset id='uxjSq'></fieldset></dl></div>

                      <tbody id='uxjSq'></tbody>

                    <small id='uxjSq'></small><noframes id='uxjSq'>

                      <legend id='uxjSq'><style id='uxjSq'><dir id='uxjSq'><q id='uxjSq'></q></dir></style></legend>

                        <bdo id='uxjSq'></bdo><ul id='uxjSq'></ul>

                        <tfoot id='uxjSq'></tfoot>