Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f0654dc

Browse filesBrowse files
committed
compare timing of inv, pinv and solve
1 parent d9212bb commit f0654dc
Copy full SHA for f0654dc

File tree

Expand file treeCollapse file tree

1 file changed

+12
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-0
lines changed

‎spatialmath/timing.py

Copy file name to clipboardExpand all lines: spatialmath/timing.py
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,21 @@ def result(op, t):
221221
a = np.r_[1.0, 2.0, 3.0]
222222
b = np.r_[-5.0, 4.0, 3.0]
223223
224+
A = np.random.randn(6,6)
225+
As = (A + A.T) / 2
226+
bb = np.random.randn(6)
224227
'''
225228
table.rule()
226229

230+
t = timeit.timeit(stmt='c = np.linalg.inv(As)', setup=misc_setup, number=N)
231+
result("np.inv(As)", t)
232+
233+
t = timeit.timeit(stmt='c = np.linalg.pinv(As)', setup=misc_setup, number=N)
234+
result("np.pinv(As)", t)
235+
236+
t = timeit.timeit(stmt='c = np.linalg.solve(As, bb)', setup=misc_setup, number=N)
237+
result("np.solve(As, b)", t)
238+
227239
t = timeit.timeit(stmt='c = np.cross(a,b)', setup=misc_setup, number=N)
228240
result("np.cross()", t)
229241

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.