mirror of
https://github.com/apachecn/ailearning.git
synced 2026-04-29 04:51:49 +08:00
2020-10-19 21:08:55
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
In [1]:
|
||||
|
||||
```
|
||||
```py
|
||||
import numpy as np
|
||||
a = np.array([[1,2,4],
|
||||
[2,5,3],
|
||||
@@ -16,7 +16,7 @@ A
|
||||
|
||||
Out[1]:
|
||||
|
||||
```
|
||||
```py
|
||||
matrix([[1, 2, 4],
|
||||
[2, 5, 3],
|
||||
[7, 8, 9]])
|
||||
@@ -26,7 +26,7 @@ matrix([[1, 2, 4],
|
||||
|
||||
In [2]:
|
||||
|
||||
```
|
||||
```py
|
||||
A = np.mat('1,2,4;2,5,3;7,8,9')
|
||||
A
|
||||
|
||||
@@ -34,7 +34,7 @@ A
|
||||
|
||||
Out[2]:
|
||||
|
||||
```
|
||||
```py
|
||||
matrix([[1, 2, 4],
|
||||
[2, 5, 3],
|
||||
[7, 8, 9]])
|
||||
@@ -44,7 +44,7 @@ matrix([[1, 2, 4],
|
||||
|
||||
In [3]:
|
||||
|
||||
```
|
||||
```py
|
||||
a = np.array([[ 1, 2],
|
||||
[ 3, 4]])
|
||||
b = np.array([[10,20],
|
||||
@@ -56,7 +56,7 @@ np.bmat('a,b;b,a')
|
||||
|
||||
Out[3]:
|
||||
|
||||
```
|
||||
```py
|
||||
matrix([[ 1, 2, 10, 20],
|
||||
[ 3, 4, 30, 40],
|
||||
[10, 20, 1, 2],
|
||||
@@ -67,7 +67,7 @@ matrix([[ 1, 2, 10, 20],
|
||||
|
||||
In [4]:
|
||||
|
||||
```
|
||||
```py
|
||||
x = np.array([[1], [2], [3]])
|
||||
x
|
||||
|
||||
@@ -75,7 +75,7 @@ x
|
||||
|
||||
Out[4]:
|
||||
|
||||
```
|
||||
```py
|
||||
array([[1],
|
||||
[2],
|
||||
[3]])
|
||||
@@ -83,14 +83,14 @@ array([[1],
|
||||
|
||||
In [5]:
|
||||
|
||||
```
|
||||
```py
|
||||
A * x
|
||||
|
||||
```
|
||||
|
||||
Out[5]:
|
||||
|
||||
```
|
||||
```py
|
||||
matrix([[17],
|
||||
[21],
|
||||
[50]])
|
||||
@@ -100,12 +100,12 @@ matrix([[17],
|
||||
|
||||
In [6]:
|
||||
|
||||
```
|
||||
```py
|
||||
print A * A.I
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
[[ 1.00000000e+00 0.00000000e+00 0.00000000e+00]
|
||||
[ 0.00000000e+00 1.00000000e+00 2.08166817e-17]
|
||||
[ 2.22044605e-16 -8.32667268e-17 1.00000000e+00]]
|
||||
@@ -116,12 +116,12 @@ print A * A.I
|
||||
|
||||
In [7]:
|
||||
|
||||
```
|
||||
```py
|
||||
print A ** 4
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
[[ 6497 9580 9836]
|
||||
[ 7138 10561 10818]
|
||||
[18434 27220 27945]]
|
||||
|
||||
Reference in New Issue
Block a user