當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Python numpy.asmatrix()用法及代碼示例


numpy.asmatrix(data,dtype = None)通過將輸入解釋為矩陣來返回矩陣。
參數:

data  : array-like input data 
dtype : Data type of returned array

返回值:

Interprets the input as a matrix
# Python Programming illustrating 
# numpy.asmatrix 
  
import numpy as geek 
  
# array-like input 
b = geek.matrix([[5, 6, 7], [4, 6]]) 
print("Via array-like input : \n", b, "\n") 
  
c = geek.asmatrix(b) 
b[0, 1] = 10
print("c matrix : \n", c)

輸出:


Via array-like input : 
 [[[5, 6, 7] [4, 6]]] 

c matrix : 
 [[[5, 6, 7] 10]]


相關用法


注:本文由純淨天空篩選整理自 numpy.asmatrix() in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。