Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #30179: ModulesWithBasis.linear_combination should be a method o…
…f Modules This method does not need a basis. Moving it to `Modules` will make it available in `FiniteRankFreeModule`. {{{ def linear_combination(self, iter_of_elements_coeff, factor_on_left=True): r""" Return the linear combination `\lambda_1 v_1 + \cdots + \lambda_k v_k` (resp. the linear combination `v_1 \lambda_1 + \cdots + v_k \lambda_k`) where ``iter_of_elements_coeff`` iterates through the sequence `((\lambda_1, v_1), ..., (\lambda_k, v_k))`. INPUT: - ``iter_of_elements_coeff`` -- iterator of pairs ``(element, coeff)`` with ``element`` in ``self`` and ``coeff`` in ``self.base_ring()`` - ``factor_on_left`` -- (optional) if ``True``, the coefficients are multiplied from the left; if ``False``, the coefficients are multiplied from the right EXAMPLES:: sage: m = matrix([[0,1],[1,1]]) sage: J.<a,b,c> = JordanAlgebra(m) sage: J.linear_combination(((a+b, 1), (-2*b + c, -1))) 1 + (3, -1) """ if factor_on_left: return self.sum(coeff * element for element, coeff in iter_of_elements_coeff) else: return self.sum(element * coeff for element, coeff in iter_of_elements_coeff) }}} URL: https://trac.sagemath.org/30179 Reported by: mkoeppe Ticket author(s): Matthias Koeppe Reviewer(s): Travis Scrimshaw
- Loading branch information