Auxiliary matrix division not working.

General discussions about how to formulate a script for FlexPDE.

Auxiliary matrix division not working.

Postby Jared Barber on Fri Jan 06, 2017 8:16 am

Hello,

While this is similar to the topic "Auxiliary matrix operations etc." I have decided to post this separately as this seems to be a very blatant bug while the original problem script commands in the original topic may or not be bug-related.

In the help we see the following:

New ARRAYS or MATRICES can be created by performing element-by-element arithmetic operations on existing ARRAYS and MATRICES:

P = 1/M { each element of matrix P is the reciprocal of the corresponding element of M }
Q = P+M

Unfortunately the following script, taken directly from the help, breaks because flexpde says "The divide operation is undefined for the pair (scalar,matrix)":

DEFINITIONS

M = MATRIX((1,2,3),(4,5,6),(7,8,9))
P = 1/M

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

END

In addition, I have been trying to perform component-wise matrix division on two matrices. Trying P = M1/M2 won't work I'm guessing for similar reasons that 1/M won't work above (error = "The divide operation is undefined for the pair (*matrix*,matrix)"). In addition, the script below shows another route that does not work:

DEFINITIONS

M1 = MATRIX((1),(2),(3))
M2 = MATRIX((4),(5),(6))
P = matrix for i (1 by 1 to 3) for j (1) : M1[i,j]/M2[i,j]

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

PLOTS
SUMMARY
repeat i = 1 to 3 report(M1[i,1]/M2[i,1]) endrepeat
repeat i = 1 to 3 report(P[i,1]) endrepeat

END

For some reason, flexpde is not performing and/or storing M1[i,j]/M2[i,j] correctly as can be seen by the reports.

The current work around (for anyone who is looking for it) is to use an intermediate matrix:

M1 = MATRIX((1),(2),(3))
M2 = MATRIX((4),(5),(6))
M2inv = matrix for i (1 by 1 to 3) for j(1) : 1/M2[i,j]
P = M1*M2inv

Note that one cannot use M2inv = 1/M2 to define the intermediate matrix as this matrix division notation seems to be broken as noted above.

Hopefully this can be fixed and, if not, at least there is the workaround given above. Of course, if others know of even better workarounds or why my above code doesn't seem to be working, it would be great to hear about. Also, of course, if it does get fixed, that would be nice as well.

Thanks,

Jared
Jared Barber
 
Posts: 37
Joined: Thu Jan 24, 2013 10:37 am

Return to FlexPDE Discussion

Who is online

Users browsing this forum: No registered users and 5 guests