numpy 矩阵计算例子
生活随笔
收集整理的這篇文章主要介紹了
numpy 矩阵计算例子
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
#-*- coding: UTF-8 -*-import numpy as npa = np.matrix([[1,2,3],[5,5,6],[7,9,9]])
s=a*a**-1
print s'''矩陣轉置'''b= np.array([1, 2, 3])
b.reshape((-1,1))
print b
b.reshape((1,-1))
print b'''矩陣乘法'''a = np.arange(12).reshape(2,3,2)
b = np.arange(12,24).reshape(2,2,3)
c = np.dot(a,b)
print c.shape'''矩陣內積'''
a = np.arange(12).reshape(2,3,2)
b = np.arange(12,24).reshape(2,3,2)
c = np.inner(a,b)
print c.shape'''矩陣外積'''
print np.outer([1,2,3],[4,5,6,7])
總結
以上是生活随笔為你收集整理的numpy 矩阵计算例子的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Eigen: C++开源矩阵计算工具——
- 下一篇: C语言中不安全的函数