• <bdo id='7qROP'></bdo><ul id='7qROP'></ul>
      1. <tfoot id='7qROP'></tfoot>
      2. <i id='7qROP'><tr id='7qROP'><dt id='7qROP'><q id='7qROP'><span id='7qROP'><b id='7qROP'><form id='7qROP'><ins id='7qROP'></ins><ul id='7qROP'></ul><sub id='7qROP'></sub></form><legend id='7qROP'></legend><bdo id='7qROP'><pre id='7qROP'><center id='7qROP'></center></pre></bdo></b><th id='7qROP'></th></span></q></dt></tr></i><div id='7qROP'><tfoot id='7qROP'></tfoot><dl id='7qROP'><fieldset id='7qROP'></fieldset></dl></div>

        <legend id='7qROP'><style id='7qROP'><dir id='7qROP'><q id='7qROP'></q></dir></style></legend>
      3. <small id='7qROP'></small><noframes id='7qROP'>

        Fortran 相当于 numpy.where() 函数?

        时间:2023-09-12
          <bdo id='v0nhx'></bdo><ul id='v0nhx'></ul>
          <legend id='v0nhx'><style id='v0nhx'><dir id='v0nhx'><q id='v0nhx'></q></dir></style></legend>
            <tbody id='v0nhx'></tbody>
        • <i id='v0nhx'><tr id='v0nhx'><dt id='v0nhx'><q id='v0nhx'><span id='v0nhx'><b id='v0nhx'><form id='v0nhx'><ins id='v0nhx'></ins><ul id='v0nhx'></ul><sub id='v0nhx'></sub></form><legend id='v0nhx'></legend><bdo id='v0nhx'><pre id='v0nhx'><center id='v0nhx'></center></pre></bdo></b><th id='v0nhx'></th></span></q></dt></tr></i><div id='v0nhx'><tfoot id='v0nhx'></tfoot><dl id='v0nhx'><fieldset id='v0nhx'></fieldset></dl></div>

        • <small id='v0nhx'></small><noframes id='v0nhx'>

        • <tfoot id='v0nhx'></tfoot>

                  本文介绍了Fortran 相当于 numpy.where() 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想在 Fortran 中做这样的事情:

                  I would like to do something like this in Fortran:

                  program where
                  
                  real :: a(6) = (/ 4, 5, 6, 7, 8, 9 /)
                  
                  print *, a(a>7)
                  
                  end program
                  

                  在 Python 我通常会使用 NumPy 像这样:

                  In Python I would typically do this with NumPy like this:

                  import numpy
                  
                  a = numpy.array([ 4, 5, 6, 7, 8, 9])
                  
                  print a[numpy.where(a>7)]
                  
                  #or 
                  
                  print a[a>7]
                  

                  我玩过,但到目前为止没有任何效果,但我猜它相当简单.

                  I've played around, but nothing has worked thus far, but I'm guessing it is fairly simple.

                  推荐答案

                  我将稍微扩展@VladimirF 的答案,因为我怀疑您不想将自己限制在确切的打印示例中.

                  I'll extend slightly the answer by @VladimirF as I suspect you don't want to limit yourself to the exact print example.

                  a>7 返回一个与 a 对应的 logical 数组,其中 .true. 位于条件的索引处满足,.false. 否则.pack 内部函数采用这样的掩码并返回一个数组,其中包含掩码中带有 .true. 的那些元素.

                  a>7 returns a logical array corresponding to a with .true. at index where the condition is met, .false. otherwise. The pack intrinsic takes such a mask and returns an array with those elements with .true. in the mask.

                  但是,您可以使用可能适合您 numpy.where 愿望的掩码做其他事情.例如,有 where 构造(和 where 语句)和 merge 内在函数.此外,您可以再次使用 pack 和掩码来获取索引并进行更多相关操作.

                  However, you can do other things with the mask which may fit under your numpy.where desire. For example, there is the where construct (and where statement) and the merge intrinsic. Further you can use pack again with the mask to get the indices and do more involved manipulations.

                  这篇关于Fortran 相当于 numpy.where() 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:numpy.f2py 从 fortran 的子程序返回时发生错误 下一篇:用python读取fortran无格式文件

                  相关文章

                  最新文章

                    1. <i id='FyGi0'><tr id='FyGi0'><dt id='FyGi0'><q id='FyGi0'><span id='FyGi0'><b id='FyGi0'><form id='FyGi0'><ins id='FyGi0'></ins><ul id='FyGi0'></ul><sub id='FyGi0'></sub></form><legend id='FyGi0'></legend><bdo id='FyGi0'><pre id='FyGi0'><center id='FyGi0'></center></pre></bdo></b><th id='FyGi0'></th></span></q></dt></tr></i><div id='FyGi0'><tfoot id='FyGi0'></tfoot><dl id='FyGi0'><fieldset id='FyGi0'></fieldset></dl></div>

                        <bdo id='FyGi0'></bdo><ul id='FyGi0'></ul>
                      <tfoot id='FyGi0'></tfoot>
                      <legend id='FyGi0'><style id='FyGi0'><dir id='FyGi0'><q id='FyGi0'></q></dir></style></legend>

                    2. <small id='FyGi0'></small><noframes id='FyGi0'>