#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 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...)
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`. Actually I don't understand the point of the distinction
between `Vector` and `FreeModuleElement` at all.
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)):
diff --git a/src/sage/modules/vector_double_dense.pyx
b/src/sage/modules/vector_double_dense.pyx
index 9efe536..279ce58 100644
--- a/src/sage/modules/vector_double_dense.pyx
+++ b/src/sage/modules/vector_double_dense.pyx
@@ -389,8 +389,6 @@ cdef class
Vector_double_dense(free_module_element.FreeModuleElement):
sage: w*v
1.0
"""
- if not right.parent() == self.parent():
- right = self.parent().ambient_module()(right)
if self._degree == 0:
from copy import copy
return copy(self)
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/17583#comment:9>
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.