📜  numpy.ravel_multi_index()函数| Python

📅  最后修改于: 2022-05-13 01:54:55.687000             🧑  作者: Mango

numpy.ravel_multi_index()函数| Python

numpy.ravel_multi_index()函数将索引数组的元组转换为平面索引数组,将边界模式应用于多索引。

代码#1:

# Python program explaining
# numpy.ravel_multi_index() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.array([[3, 6, 6], [4, 5, 1]])
  
gfg = geek.ravel_multi_index(arr, (7, 6))
  
print(gfg) 

输出 :

[22 41 37]


代码#2:

# Python program explaining
# numpy.ravel_multi_index() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.array([[3, 6, 6], [4, 5, 1]])
  
gfg = geek.ravel_multi_index(arr, (7, 6), order = 'F')
  
print(gfg) 

输出 :

[31 41 13]


代码#3:

# Python program explaining
# numpy.ravel_multi_index() function
  
# importing numpy as geek 
import numpy as geek
  
arr = geek.array([[3, 6, 6], [4, 5, 1]])
  
gfg = geek.ravel_multi_index(arr, (7, 6), mode = 'clip')
  
print(gfg) 

输出 :

[22 41 37]