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, 30 Nov 2016 05:31:22 +0100How to record entries from a matrix (or vector)?https://ask.sagemath.org/question/35800/how-to-record-entries-from-a-matrix-or-vector/ For example, I have A*B = (a,b,c,d,e)
But I have to manually write down a = blah blah, b = blah blah, c = blah blah....
I tried the same method with list, but apparently it didn't work on a vector.
Thanks! Tue, 29 Nov 2016 23:29:35 +0100https://ask.sagemath.org/question/35800/how-to-record-entries-from-a-matrix-or-vector/Comment by fidbc for <p>For example, I have A*B = (a,b,c,d,e)
But I have to manually write down a = blah blah, b = blah blah, c = blah blah....
I tried the same method with list, but apparently it didn't work on a vector.
Thanks! </p>
https://ask.sagemath.org/question/35800/how-to-record-entries-from-a-matrix-or-vector/?comment=35801#post-id-35801It is not entirely clear what your are asking. Could you please be more specific? What does the product `A*B` have to do with the question?Tue, 29 Nov 2016 23:48:23 +0100https://ask.sagemath.org/question/35800/how-to-record-entries-from-a-matrix-or-vector/?comment=35801#post-id-35801Answer by slelievre for <p>For example, I have A*B = (a,b,c,d,e)
But I have to manually write down a = blah blah, b = blah blah, c = blah blah....
I tried the same method with list, but apparently it didn't work on a vector.
Thanks! </p>
https://ask.sagemath.org/question/35800/how-to-record-entries-from-a-matrix-or-vector/?answer=35811#post-id-35811I think you just put things in the wrong order.
I am guessing you want to achieve something like the following.
Here I'm using a random matrix and a random vector.
sage: A = random_matrix(ZZ, 5)
sage: A
[ 22 0 -128 1 -1]
[ 0 -3 -1 -1 1]
[ 1 -1 -1 1 0]
[ 3 -4 2 25 0]
[ 3 32 1 2 -1]
sage: B = random_vector(ZZ, 5)
sage: B
(1, -5, 0, 1, 14)
Here is their product.
sage: A * B
(9, 28, 7, 48, -169)
Define a, b, c, d, e to be the entries of this product.
sage: a, b, c, d, e = A * B
sage: a, b, c, d, e
(9, 28, 7, 48, -169)
sage: b
28
sage: e
-169Wed, 30 Nov 2016 05:31:22 +0100https://ask.sagemath.org/question/35800/how-to-record-entries-from-a-matrix-or-vector/?answer=35811#post-id-35811