## Auxiliary matrix operations/initialization not working.

General discussions about how to formulate a script for FlexPDE.

### Auxiliary matrix operations/initialization not working.

Hello,

I have had troubles getting matrix multiplication to always work. It seems to rely on the way one initializes matrices as well as the size of the matrices involved (square or rectangular).

The script below works when I use
M1 = matrix((1,2,3),(4,5,6),(7,8,9))
But fails with the complaint "Operator cannot be expanded by the element" when I use
M1 = matrix[3,3]
repeat i = 1 to 3 repeat j = 1 to 3 M1[i,j] = (i-1)*3+j endrepeat endrepeat

In addition, I have had trouble initializing vector matrices. I have begun to use vector matrices because flexpde doesn't seem to like me adding a matrix and an array despite the fact that they are the same size. However it seems I cannot initialize such vector matrices in the way I want to.

The script below works when I use
M4 = matrix((1),(2),(3))
But fails with the error "Empty list" when I use
M4 = matrix for i (1 by 1 to 3) for j (1 by 1 to 1): i

While I can use "for j (1)", this is inconvenient as it makes it difficult for me to switch back and forth between 1 and more than 1 objects since the columns of the matrix correspond to different objects.

The full working script is below with the variations that cause the error commented out:

DEFINITIONS { parameter definitions }
! M1 = matrix[3,3]
! repeat i = 1 to 3 repeat j = 1 to 3 M1[i,j] = (i-1)*3+j endrepeat endrepeat
M1 = matrix((1,2,3),(4,5,6),(7,8,9))
M2 = matrix((1,2),(3,4),(5,6))
M3 = M1**M2
M4 = matrix((1),(2),(3))
! M4 = matrix for i (1 by 1 to 3) for j (1 by 1 to 1): i
M5 = M1**M4

BOUNDARIES
REGION START(0,0) LINE TO (1,0) TO (1,1) TO (0,1) TO CLOSE

PLOTS

summary
repeat i = 1 to 3 repeat j = 1 to 3 report(M1[i,j]) endrepeat endrepeat
repeat i = 1 to 3 repeat j = 1 to 2 report(M2[i,j]) endrepeat endrepeat
repeat i = 1 to 3 repeat j = 1 to 2 report(M3[i,j]) endrepeat endrepeat
repeat i = 1 to 3 repeat j = 1 to 1 report(M4[i,j]) endrepeat endrepeat
repeat i = 1 to 3 repeat j = 1 to 1 report(M5[i,j]) endrepeat endrepeat

END

Hopefully there can be some way to get around these issues other than explicitly writing out every component of relatively large matrices. If anyone has any ideas or if there are fixes available, it would be nice to know about. Thanks,

Jared Barber
Jared Barber

Posts: 47
Joined: Thu Jan 24, 2013 10:37 am