|
14 | 14 | def test_nothing(): |
15 | 15 | pass |
16 | 16 |
|
17 | | -# |
18 | | -###def rand_sparse(n,density): |
19 | | -### n_features = n |
20 | | -### n_samples = n |
21 | | -### rng1 = np.random.RandomState(42) |
22 | | -### rng2 = np.random.RandomState(43) |
23 | | -### |
24 | | -### nnz = int(n_samples*n_features*density) |
25 | | -### |
26 | | -### row = rng1.randint(n_samples, size=nnz) |
27 | | -### cols = rng2.randint(n_features, size=nnz) |
28 | | -### data = rng1.rand(nnz) |
29 | | -### |
30 | | -### S = scipy.sparse.coo_matrix((data, (row, cols)), shape=(n_samples, n_features)) |
31 | | -### return S.tocsc() |
32 | | -### |
33 | | -###def time_noop(): |
34 | | -### def helper(N,I,SN,SI): |
35 | | -### igl.noop(SN=SN) |
36 | | -### # start timer |
37 | | -### runs = 100 |
38 | | -### start = time.time() |
39 | | -### for i in range(runs): |
40 | | -### igl.noop(SN=SN) |
41 | | -### # end timer |
42 | | -### end = time.time() |
43 | | -### return (end - start)/runs |
44 | | -### n = 10000 |
45 | | -### m = 10 |
46 | | -### N64_f = np.asfortranarray(np.random.randn(n,m).astype(np.float64)) |
47 | | -### I64_f = np.asfortranarray(np.random.randn(n,m).astype(np.int64)) |
48 | | -### # random sparse matrix |
49 | | -### SN64 = rand_sparse(n,1.0/(n)) |
50 | | -### # print number of nonzeros |
51 | | -### SI64 = (rand_sparse(n,1.0/(n))*1000).astype(np.int64) |
52 | | -### print(f"noop<{n},{m}>: {helper(N64_f,I64_f,SN64,SI64)} secs") |
53 | | -### |
54 | | -###time_noop() |
| 17 | + |
| 18 | +##def rand_sparse(n,density): |
| 19 | +## n_features = n |
| 20 | +## n_samples = n |
| 21 | +## rng1 = np.random.RandomState(42) |
| 22 | +## rng2 = np.random.RandomState(43) |
55 | 23 | ## |
56 | | -### print(igl.matlab_format(V,"V")) |
57 | | -### print(igl.matlab_format_index(F,"F")) |
58 | | -### print(igl.matlab_format(dV,"dV")) |
59 | | -### print(igl.matlab_format_index(dF,"dF")) |
60 | | -# |
61 | | -# |
62 | | -## seed numpy's random number generator |
| 24 | +## nnz = int(n_samples*n_features*density) |
63 | 25 | ## |
64 | | -#def triangulated_square(): |
65 | | -# V = np.array([[0,0,0],[1,0,0],[1,1,0],[0,1,0]],dtype=np.float64) |
66 | | -# F = np.array([[0,1,2],[0,2,3]],dtype=np.int64) |
67 | | -# return V,F |
| 26 | +## row = rng1.randint(n_samples, size=nnz) |
| 27 | +## cols = rng2.randint(n_features, size=nnz) |
| 28 | +## data = rng1.rand(nnz) |
| 29 | +## |
| 30 | +## S = scipy.sparse.coo_matrix((data, (row, cols)), shape=(n_samples, n_features)) |
| 31 | +## return S.tocsc() |
| 32 | +## |
| 33 | +##def time_noop(): |
| 34 | +## def helper(N,I,SN,SI): |
| 35 | +## igl.noop(SN=SN) |
| 36 | +## # start timer |
| 37 | +## runs = 100 |
| 38 | +## start = time.time() |
| 39 | +## for i in range(runs): |
| 40 | +## igl.noop(SN=SN) |
| 41 | +## # end timer |
| 42 | +## end = time.time() |
| 43 | +## return (end - start)/runs |
| 44 | +## n = 10000 |
| 45 | +## m = 10 |
| 46 | +## N64_f = np.asfortranarray(np.random.randn(n,m).astype(np.float64)) |
| 47 | +## I64_f = np.asfortranarray(np.random.randn(n,m).astype(np.int64)) |
| 48 | +## # random sparse matrix |
| 49 | +## SN64 = rand_sparse(n,1.0/(n)) |
| 50 | +## # print number of nonzeros |
| 51 | +## SI64 = (rand_sparse(n,1.0/(n))*1000).astype(np.int64) |
| 52 | +## print(f"noop<{n},{m}>: {helper(N64_f,I64_f,SN64,SI64)} secs") |
| 53 | +## |
| 54 | +##time_noop() |
68 | 55 | # |
69 | | -#def single_tet(): |
70 | | -# V = np.array([[0,0,0],[1,0,0],[0,1,0],[0,0,1]],dtype=np.float64) |
71 | | -# F = np.array([[2,1,0],[1,3,0],[3,2,0],[2,3,1]],dtype=np.int64) |
72 | | -# T = np.array([[0,1,2,3]],dtype=np.int64) |
73 | | -# return V,F,T |
| 56 | +## print(igl.matlab_format(V,"V")) |
| 57 | +## print(igl.matlab_format_index(F,"F")) |
| 58 | +## print(igl.matlab_format(dV,"dV")) |
| 59 | +## print(igl.matlab_format_index(dF,"dF")) |
| 60 | + |
| 61 | + |
| 62 | +# seed numpy's random number generator |
74 | 63 | # |
| 64 | +def triangulated_square(): |
| 65 | + V = np.array([[0,0,0],[1,0,0],[1,1,0],[0,1,0]],dtype=np.float64) |
| 66 | + F = np.array([[0,1,2],[0,2,3]],dtype=np.int64) |
| 67 | + return V,F |
| 68 | + |
| 69 | +def single_tet(): |
| 70 | + V = np.array([[0,0,0],[1,0,0],[0,1,0],[0,0,1]],dtype=np.float64) |
| 71 | + F = np.array([[2,1,0],[1,3,0],[3,2,0],[2,3,1]],dtype=np.int64) |
| 72 | + T = np.array([[0,1,2,3]],dtype=np.int64) |
| 73 | + return V,F,T |
| 74 | + |
75 | 75 | #def test_edges(): |
76 | 76 | # F = np.array([[0,1,2],[0,2,3]],dtype=np.int64) |
77 | 77 | # E,oE = igl.orient_halfedges(F) |
@@ -168,11 +168,12 @@ def test_nothing(): |
168 | 168 | # V,T,F = igl.readMESH("out.mesh") |
169 | 169 | # igl.writeMSH("out.msh",V,F,T) |
170 | 170 | # V,F,T,_,_,_,_,_,_,_ = igl.readMSH("out.msh") |
171 | | -# |
172 | | -#def test_bvh(): |
173 | | -# V,F,T = single_tet() |
174 | | -# tree = igl.AABB() |
175 | | -# tree.init(V,T) |
| 171 | + |
| 172 | +def test_bvh(): |
| 173 | + V,F,T = single_tet() |
| 174 | + tree = igl.AABB() |
| 175 | + tree.init(V,T) |
| 176 | + |
176 | 177 | # P = np.array([[0.5,0.5,0.0],[0.5,0.5,0.5]],dtype=np.float64) |
177 | 178 | # # first row of P |
178 | 179 | # q = P[0,:] |
|
0 commit comments