#17583: Clean up free module elements
-------------------------------------+-------------------------------------
Reporter: jdemeyer | Owner:
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-6.5
Component: linear algebra | Resolution:
Keywords: | Merged in:
Authors: Jeroen Demeyer | Reviewers: Marc Mezzarobba
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/jdemeyer/ticket/17583 | a6d357a8b2874aaec970aa0d2afc3fa14d60969e
Dependencies: #17561 | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by jdemeyer):
Replying to [comment:9 mmezzarobba]:
> Replying to [comment:6 jdemeyer]:
> > Yes, to apply the following optimization: instead of starting with
zero and `a[i]*b[i]`, we start with `a[0] * b[0]` and add `a[i]*b[i]` for
`i >= 1`.
>
> Fine. (I was not sure that it would be faster...)
It's always going to be somewhat faster and it avoids extra work in case
the parents are not equal.
> Regarding your last commit, I agree with the changes, but I don't
understand why `dot_product` is defined in `FreeModuleElement` rather than
in `Vector`.
I could easily move it...
> Actually I don't understand the point of the distinction between
`Vector` and `FreeModuleElement` at all.
Currently in Sage, the only `Vector`s are also `FreeModuleElement`s. But
one could envision a parent which is not a ''free'' module...
> Also, I think we can do two additional simplifications related to
`dot_product`:
> {{{
> diff --git a/src/sage/matrix/matrix_generic_sparse.pyx
b/src/sage/matrix/matrix_generic_sparse.pyx
> index b2ff48a..a4cf07c 100644
> --- a/src/sage/matrix/matrix_generic_sparse.pyx
> +++ b/src/sage/matrix/matrix_generic_sparse.pyx
> @@ -495,17 +495,6 @@ def Matrix_sparse_from_rows(X):
> return M(entries, coerce=False, copy=False)
>
>
> -## def _sparse_dot_product(v, w):
> -## """
> -## INPUT:
> -## v and w are dictionaries with integer keys.
> -## """
> -## x = set(v.keys()).intersection(set(w.keys()))
> -## a = 0
> -## for k in x:
> -## a = a + v[k]*w[k]
> -## return a
> -
> cdef _convert_sparse_entries_to_dict(entries):
> e = {}
> for i in xrange(len(entries)):
> }}}
Absolutely not on this ticket, but see #17663.
--
Ticket URL: <http://trac.sagemath.org/ticket/17583#comment:10>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.