ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 15 Jan 2020 10:59:29 +0100matrix base ring changes by a complex multiplicationhttps://ask.sagemath.org/question/49557/matrix-base-ring-changes-by-a-complex-multiplication/The complex multiplication of matrix changes the base ring.
A = matrix(CDF,[[1,2],[3,4]]); print(A)
B = 2*A
C = I*A
print(type(A))
print(type(B))
print(type(C))
The result is
[1.0 2.0]
[3.0 4.0]
<class 'sage.matrix.matrix_complex_double_dense.Matrix_complex_double_dense'>
<class 'sage.matrix.matrix_complex_double_dense.Matrix_complex_double_dense'>
<class 'sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense'>
So the multiplication by an imaginary number breaks the CDF property.
This is very inconvenient for numerical calculations, because the symbolic computation is very slow.cxrjddWed, 15 Jan 2020 10:59:29 +0100https://ask.sagemath.org/question/49557/Keeping zeros after matrix multiplicationhttps://ask.sagemath.org/question/48925/keeping-zeros-after-matrix-multiplication/ Hello, Sage Community!
Suppose I do the following:
var('x y z')
u = vector([0, 1, 1])
v = vector([x, y, z])
u * v
The result is obviously `y+z`. I would like to keep the zeros after the multiplication, in order to have `0x+y+z` as my result. Is it possible?
Thanks in advance for your answers!dsejasSun, 01 Dec 2019 17:46:45 +0100https://ask.sagemath.org/question/48925/Speeding up matrix multiplication?https://ask.sagemath.org/question/8438/speeding-up-matrix-multiplication/I'm currently trying write code to compute with overconvergent modular symbols. In iterating a Hecke operator, the key (i.e. most time consuming) operation that is performed tons of times is simply taking the product of a large dense matrix say $M$ with a vector $v$, both with integral entries.
More precisely, let $p$ be a (relatively small) prime (think $p=11$) and $N$ some integer (think 100). I have an $N$ by $N$ matrix and am interested in quickly computing the product $M \cdot v$ modulo $p^N$.
I am simply using the intrinsic SAGE command of multiplying a matrix by a vector, and I was surprised to see that working with matrices over ${\bf Z}/p^n{\bf Z}$ was much (i.e. 10 times) slower than working with matrices over ${\bf Z}$.
My question: is there a faster way to do this computation than using SAGE's intrinsic matrix times a vector command over ${\bf Z}$?
Robert PollackFri, 04 Nov 2011 17:46:03 +0100https://ask.sagemath.org/question/8438/Matrix Multiplicationhttps://ask.sagemath.org/question/7833/matrix-multiplication/I am trying to multiply the following:
Iz=1/2*matrix(2,2,[[1,0],[0,-1]])
a=(1,0)
Iz*a
This should work, what am I doing wrong? I would expect (1/2, 0)
Sage returns the following error:
Traceback (click to the left of this block for traceback)
...
TypeError: 'sage.matrix.matrix_rational_dense.Matrix_rational_dense'
object cannot be interpreted as an index
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_149.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("SXo9MS8yKm1hdHJpeCgyLDIsW1sxLDBdLFswLC0xXV0pO0l6CmE9KDEsMCkKSXoqYQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpJoBb2Y/___code___.py", line 5, in <module>
exec compile(u'Iz*a
File "", line 1, in <module>
File "element.pyx", line 2260, in sage.structure.element.Matrix.__mul__ (sage/structure/element.c:14881)
File "coerce.pyx", line 759, in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:6940)
TypeError: 'sage.matrix.matrix_rational_dense.Matrix_rational_dense' object cannot be interpreted as an index
Thanx
mhfreyTue, 28 Dec 2010 18:15:18 +0100https://ask.sagemath.org/question/7833/