# 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!

edit retag close merge delete

It 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?

( 2016-11-29 23:48:23 +0200 )edit

Sort by » oldest newest most voted

I 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
-169

more