New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Very inefficient scalar multiplication on FreeModule_ambient with somewhat large rank #13304
Comments
comment:1
Attachment: trac_13304_gen_speedup.patch.gz The patch overrides |
comment:3
The change looks fine to me and passes all tests. Maybe you should
|
comment:4
It's possible that calling What's more, previously, asking for one basis element triggered basis computation and caching. After that, getting basis elements should be fast. With your patch this caching doesn't get triggered by asking for one basis vector any more. Code that previously benefited m might see a decrease in speed (which can be solved by first explicitly asking for the whole basis to trigger caching). It might still be a good idea to not cache, but you might document the possible pitfall. |
comment:5
The question is, in which situations do we actually ask for the basis of the ambient space? I found out that there is a similar problem when constructing subspaces, see Surprisingly, there is a difference between the fields |
comment:7
(from the previous comments, it looks like the patch in its current state is not waiting for a review) |
comment:9
See also #10262. Replying to @nbruin:
If I understand correctly, the basis we are talking about is essentially the identity matrix. In fact, I am not convinced caching it (strongly at least) is such a good idea even in general—either recomputing it or computing whatever information one really needs instead sounds better in all cases I can think of. But in any case I think it is insane to call a function that may keep in cache a basis of, say, ℤ10000, unless one absolutely needs the whole basis! |
Author: Daniel Smertnig, Marc Mezzarobba |
Commit: |
comment:11
I opened a separate ticket (#15953) for the more general issue of whether and when to cache the basis. |
Changed branch from u/mmezzarobba/13304-free_module_ambient+coerce to public/ticket/13304 |
comment:16
Frédéric, did you review the commits prior to yours? |
Reviewer: Vincent Delecroix |
comment:17
Hello, You got it right for integer vectors but the generic constructor of
In particular the following also takes life time for the very same reason
|
comment:18
Replying to @videlec:
Does it make the solution in this ticket inadequate? Or is it just a similar problem that can be handled separately? |
comment:19
Replying to @mezzarobba:
Second option. It is just a one line change (that I can even do myself). Do you prefer this one line change to be on another ticket? |
comment:20
Replying to @videlec:
No, please feel free to do it here if you like. (I can't do it myself at the moment.) |
comment:22
Replying to @videlec:
The problem mentioned in comment:17 and the follow-ups needs #17585. In the meantime I am running the test for this branch on sage-6.6.beta0 and will set a positive review accordinlgy. Vincent |
comment:24
I think that #17585 provides a better and more fundamental fix to the problem: the line
is just removed completely. |
Work Issues: add doctest |
comment:26
Replying to @jdemeyer:
The first one should go in #17585, no? |
Changed work issues from add doctest to none |
comment:27
Sorry, there was a misunderstanding. I thought that this ticket fixed both issues. |
Changed branch from public/ticket/13304 to |
As reported in a thread in sage-support trivial scalar multiplication in
FreeModule_ambient
can be extremely slow or lead to out of memory errors:The problem is that, during coercion,
_an_element_impl()
and in turngen(0)
ofFreeModule_ambient
gets called. The default implementation ofgen
callsbasis()
, computing the entire standard basis, and then returns the first basis vector.CC: @jdemeyer
Component: linear algebra
Author: Daniel Smertnig, Marc Mezzarobba
Branch/Commit:
8f09d51
Reviewer: Vincent Delecroix
Issue created by migration from https://trac.sagemath.org/ticket/13304
The text was updated successfully, but these errors were encountered: