forked from numpy/numpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
56 lines (47 loc) · 1.11 KB
/
test.py
File metadata and controls
56 lines (47 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import numpy as np
def test_dgelsd():
A = np.array([[0,1],[1,1],[2,1],[3,1]],np.double)
B = np.array([-1,0.2,0.9,2.1],np.double)
work = np.zeros(802,np.double);
answer = np.linalg.lapack_lite.dgelsd(
4,2,1,A,4,B,4,np.zeros(2),-1,0,work,802,np.zeros(20,np.int32),0)
print(answer)
print(B)
def test_lstsq_1():
A = np.array([[0,1],[1,1],[2,1],[3,1]],np.double)
B = np.array([-1,0.2,0.9,2.1],np.double)
answer = np.linalg.lstsq(A,B);
print(answer);
def test_lstsq_2():
A = np.array([
[-3,1],[-0.9,1],[-1.8,1],
[3.2,1],[1,1],[3.3,1]
],np.double)
B = np.array([3.9,2.3,2,-1.4,-1,-0.1],np.double)
answer = np.linalg.lstsq(A,B);
print(answer);
def test_svd_4x3():
A = np.array([
[-3,6,-1],
[11,-3,0],
[0,-1,3],
[4,4,4]
]);
answer = np.linalg.svd(A,full_matrices=True,compute_uv=True);
print(answer)
def test_eig_3x3():
A = np.array([
[3,6,2],
[1,7,6],
[9,3,2]
])
answer = np.linalg.eig(A);
print(answer);
def test_eig_2x2():
A = np.array([
[3,1],
[0,2]
]);
answer = np.linalg.eig(A);
print(answer);
test_eig_3x3()