努比。Python中的bmat()

努比。bmat(obj,l_dict=无,g_dict=无): 从嵌套对象返回特殊的二维矩阵,这些嵌套对象可以是字符串或数组。 参数:

null
  
object : array-like or string 
l_dict  : (dict, optional) replaces local operands,
A dictionary that replaces local operands in current frame
g_dict  : (dict, optional) replaces global operands, 
A dictionary that replaces global operands in current frame. 
 

返回:

2-D matrix from nested objects

# Python Program illustrating
# numpy.bmat
import numpy as geek
A = geek.mat( '4 1; 22 1' )
B = geek.mat( '5 2; 5 2' )
C = geek.mat( '8 4; 6 6' )
# array like igeekut
a = geek.bmat([[A, B], [C, A]])
print ( "Via bmat array like input : " , a, "" )
# string like igeekut
s = geek.bmat( 'A, B; A, A' )
print ( "Via bmat string like input : " , s)


输出:

Via bmat array like input : 
 [[ 4  1  5  2]
 [22  1  5  2]
 [ 8  4  4  1]
 [ 6  6 22  1]] 


Via bmat string like input : 
 [[ 4  1  5  2]
 [22  1  5  2]
 [ 4  1  4  1]
 [22  1 22  1]]

注: 这些代码不会在联机IDE上运行。请在您的系统上运行它们以探索工作环境 . 本文由 莫希特·古普塔(Mohit Gupta_OMG) .如果你喜欢GeekSforgek,并想贡献自己的力量,你也可以使用 写极客。组织 或者把你的文章寄去评论-team@geeksforgeeks.org.看到你的文章出现在Geeksforgeks主页上,并帮助其他极客。

如果您发现任何不正确的地方,或者您想分享有关上述主题的更多信息,请写下评论。

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享