# Multiplying matrices with different parents

I am trying to multiple a symbolic 1x1 matrix with one element in it, by a square matrix over a finite field. for example

[-9*x0^2 - 11*x0*x1 - 5*x1^2 - 11*x0*x2 - 4*x1*x2 + 7*x2^2 + 13*x1*x3 + 8*x2*x3 + 4*x3^2 - 6*x0*x4 - 4*x1*x4 - 15*x2*x4 + 9*x0*x5 - 8*x1*x5 - 5*x2*x5 - 3*x3*x5]


to be multiplied with them matrix

[18 23 14  1  6 21]
[24  3  3  0  2  0]
[17 25  2 16 23  8]
[ 8 21 16  5  1  9]
[14 28  8 17 12 12]
[ 6 24 18 19  3  1]


however when i try this i get the following error:

TypeError: unsupported operand parent(s) for *: 'Full MatrixSpace of 1 by 1 dense matrices over Multivariate Polynomial Ring in x0, x1, x2, x3, x4, x5 over Finite Field of size 31' and 'Full MatrixSpace of 6 by 6 dense matrices over Finite Field of size 31'

Is there a way to do this?

edit retag close merge delete

What should be the result? The $1\times 1$-matrix should be considered as a scalar? Please also paste some minimal code that reproduces the problem (for instance only one or two variables and a $2\times 2$-matrix), which can be easily copy+pasted. Potential helpers have the same situation in a few seconds in the interpreter...

( 2018-03-19 18:41:45 -0600 )edit

Sort by » oldest newest most voted

How do you want to multiply a 1x1 matrix with a 6x6 matrix? Do you want to take the scalar multiple of the 6x6 matrix by the sole entry of the 1x1 matrix? That is something you can do. If your first matrix is A and your second one is B then sage will quite happily compute

A[0,0]*B


Based on the comments below, perhaps you're looking for something like this instead:

sage: R.<x,y>=GF(31)[]
sage: B=matrix(GF(31),2,2,[1,2,3,4])
sage: L=[x^2,x*y,y^2]
sage: [f*B for f in L]
[
[  x^2 2*x^2]  [  x*y 2*x*y]  [  y^2 2*y^2]
[3*x^2 4*x^2], [3*x*y 4*x*y], [3*y^2 4*y^2]
]

more

Yes that's basically what i want to do, except what i need is not quite as simple as that. I basically have a column vector in which each of it's components is a multivariate equation for example the one i have given above, i need to multiply each of these multivariate equations in the column vector by the 6x6 matrix, so i am trying to treat each multivariate equation as a 1x1 matrix to do so, but i get the error i noted in my question. I don't know if i have made much sense here :/

( 2018-03-19 13:46:11 -0600 )edit

??? What do you expect your end result to be? A column vector whose entries are 6x6 matrices? I'm not sure sage will be happy with that. Are you sure it's not just a list of multivariate equations and that you want a list of 6x6 matrices as a result? Putting things in a vector or a matrix imbues the data with an algebraic structure that may not fit your needs. Sometimes a list is better.

( 2018-03-19 16:47:37 -0600 )edit

I think you may be correct with that list interpretation that makes a lot more sense to me, a list of 6x6 matrices as a result is what i require, how would i go about doing this using lists then?? I haven't actually used lists in sage yet :/

( 2018-03-19 17:11:56 -0600 )edit