Ask Your Question
0

Matrix of vectors

asked 2013-04-10 08:04:16 +0100

DG44 gravatar image

updated 2013-04-10 08:35:11 +0100

Hi.

Suppose that I have a collection of vectors $v_1, \ldots, v_n \in \mathbb{R}^3$ and I wish to compute all cross products $v_i \times v_j \in \mathbb{R}^3$ where $1 \leq i < j \leq n$. Is it possible to store the output in a matrix, i.e. can I form a matrix M in Sage where $M(i,j) = v_i \times v_j$?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-04-10 13:35:40 +0100

ppurka gravatar image

What kind of operations would you do on a 3-dimensional matrix? As far as I know this is not possible in Sage because the matrix needs to be defined over some ring. If you are not doing any fancy operations, then you might as well just store the vectors in a list of lists.

sage: v = vector(ZZ, [1,2,3])
sage: w = vector(ZZ, [2,3,4])
sage: V = [v, w]
sage: L = [[a.cross_product(b) for b in V] for a in V]
sage: L
[[(0, 0, 0), (-1, 2, -1)], [(1, -2, 1), (0, 0, 0)]]
edit flag offensive delete link more
0

answered 2013-04-10 08:33:13 +0100

DG44 gravatar image

What I would like is to create a matrix M where M(i,j) is a vector, not just a real number!

The code you gave produces a 2x2 matrix just of real numbers I believe. I want vectors to specify the entries M(i,j) of M, not the rows/columns.

edit flag offensive delete link more

Comments

You should have written this as a comment to calc314's answer, not as an answer to your question. On the other hand, ppurka's answer is appropriate and you should accept it (click the "accept" button) so that you question is displayed as solved and the correct answer is highlighted.

slelievre gravatar imageslelievre ( 2013-04-15 17:14:24 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-04-10 08:04:16 +0100

Seen: 497 times

Last updated: Apr 10 '13