Non-commutative element multiplication in matrix operations (was Lexicographic ordering)
Subject: Non-commutative element multiplication in matrix operations (was Lexicographic ordering)
From: Stavros Macrakis
Date: Tue, 16 Dec 2008 12:58:18 -0500
On Tue, Dec 16, 2008 at 12:19 PM, Askunky <askunky at yahoo.fr> wrote:
> Thanks !
> Can you set the addition to be non commutative too?
>
> -F
>
See documentation:
(%i1) ?? matrix_element
0: matrix_element_add (Functions and Variables for Matrices and Linear
Algebra)
1: matrix_element_mult (Functions and Variables for Matrices and Linear
Algebra)
2: matrix_element_transpose (Functions and Variables for Matrices and
Linear Algebra)
> Stavros Macrakis a ?crit :
>
> On Tue, Dec 16, 2008 at 11:09 AM, Askunky <askunky at yahoo.fr> wrote:
>
>> Hi, thanks for your answer.
>> This *is not* the right answer... it matches the right answer when + and *
>> are both commutative. If A,B,C,D are blocks of the initial matrix, then the
>> computation should give
>> matrix([A^2+B*C,A*B+B*D],[C*A+ D*C,C*B+D^2])
>>
>
> It would have helped us give you a useful reply if you had been clear that
> A,B,C,D in your original question referred to objects with non-commutative
> multiplication (in your case, blocks). I don't understand what this has to
> do with your subject line "Lexicographic ordering".
>
> Anyway, you can select the multiplication used by matrix multiplication
> using matrix_element_mult:
>
> `matrix_element_mult' is the operation invoked in place of
> multiplication in a matrix multiplication. `matrix_element_mult'
> can be assigned any binary operator. The assigned value may be
> the name of an operator enclosed in quote marks, the name of a
> function, or a lambda expression.
>
> So set this parameter:
>
> matrix_element_mult: "."$
>
> and
>
> matrix([a,b],[c,d])^^2 =>
> matrix([b . c+a^^2,b . d+a . b],[d . c+c . a,d^^2+c . b])
>
> If some variables are scalars (with commutative multiplication) and others
> not, you may want to look at declare(...,scalar) and declare(...,nonscalar).
>
> -s
>
>
>