Opened 8 years ago
Closed 5 years ago
#10947 closed enhancement (fixed)
very slow matrix product
Reported by: | pang | Owned by: | tbd |
---|---|---|---|
Priority: | minor | Milestone: | sage-duplicate/invalid/wontfix |
Component: | performance | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
The following code takes a very long time in Sage 4.4 up to and including 4.6:
sage: var('t') sage: curva = vector((sin(2*t), cos(2*t), 0)) sage: M = identity_matrix(RDF,3) sage: time M*curva CPU times: user 0.02 s, sys: 0.00 s, total: 0.02 s Wall time: 0.50 s (sin(2*t), cos(2*t), 0)
The times depend on the computer, and decrease on the second call, but it is consistently, and significatively longer than the time required for:
sage: time sum(a*b for a,b in zip(curva,M.rows())) CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s Wall time: 0.00 s (sin(2*t), cos(2*t), 0)
The first call is forwarded, I think to maxima. The waiting time is probably due to waiting for the maxima process. Profile revealed that most of the time was spent on "select.select".
Change History (4)
comment:1 Changed 5 years ago by
comment:2 Changed 5 years ago by
- Milestone set to sage-duplicate/invalid/wontfix
- Status changed from new to needs_review
sage: var('t') sage: curva = vector((sin(2*t), cos(2*t), 0)) sage: M = identity_matrix(RDF,3) sage: %timeit M*curva 1000 loops, best of 3: 478 µs per loop sage: %timeit sum(a*b for a,b in zip(curva,M.rows())) 1000 loops, best of 3: 321 µs per loop
after a restart of sage:
sage: var('t') sage: curva = vector((sin(2*t), cos(2*t), 0)) sage: M = identity_matrix(RDF,3) sage: %time M*curva CPU times: user 6.67 ms, sys: 0 ns, total: 6.67 ms Wall time: 4.67 ms (sin(2*t), cos(2*t), 0) sage: %time sum(a*b for a,b in zip(curva,M.rows())) CPU times: user 3.33 ms, sys: 0 ns, total: 3.33 ms Wall time: 3.77 ms (sin(2*t), cos(2*t), 0)
So no significant difference here. Maybe because of an SSD.
comment:3 Changed 5 years ago by
- Status changed from needs_review to positive_review
Yes, this now appears to work for me as well.
comment:4 Changed 5 years ago by
- Resolution set to fixed
- Status changed from positive_review to closed
Note: See
TracTickets for help on using
tickets.
Still true in 6.1: