# Question:easy way (w/o programming) to calculate a special matrix

## Question:easy way (w/o programming) to calculate a special matrix

Maple

Hi,

I'm searching for an easier way to execute the following computation using only matrix calculations
(meaning no programming, no loops):

> restart:with(linalg):
> S:=matrix(3,3,[s11,s12,s13,s21,s22,s23,s31,s32,s33]):
> X:=matrix(3,1,[x1,x2,x3]):
> A:=array(1..3,1..3):
> for j from 1 to 3 do
>   for i from 1 to 3 do
>     A[i,j]:=S[i,j]/X[j,1]
>   od;
> od;
> op(A);

So far, I've got the following ideas:

A)
> S:=matrix(3,3,[s11,s12,s13,s21,s22,s23,s31,s32,s33]):
> X:=matrix(3,1,[x1,x2,x3]):
> h:=matrix(1,3,[1,1,1]):
> Xm:=evalm(transpose(h)&*transpose(X)):
## memberwise division: S / Xm

How can I do a memberwise division?

B)
>S:=matrix(3,3,[s11,s12,s13,s21,s22,s23,s31,s32,s33]):
>X:=matrix(3,1,[x1,x2,x3]):
## make X the diagonal of a square matrix
> Xd:=matrix(3,3,[x1,0,0,0,x2,0,0,0,x3]):
> A:=evalm(S&*inverse(Xd));

How can I make a vector X the diagonal of a square matrix (without retyping the values)?