Clear all

Entry of a symmetric matrix

Posts: 9
Topic starter
Eminent Member
Joined: 1 year ago

Is there a way to set up an edit table of a 2-D matrix so that it won't allow you to enter a non-symmetric matrix?  I have a covariance matrix, which should be symmetric. 

The ideal would be to disallow a non-symmetric entry -- for example, if you change a cell, it would immediately change is transposed cell. Or maybe would only let you enter a triangular matrix (although would be better if you can see the full symmetric matrix while entering it). Failing that, I'd like immediate feedback that there is a problem when you press the green checkmark (and not just an error later when you evaluate, which I am able to do). 

1 Reply
Posts: 22
Joined: 12 years ago

Here is an example that does what you want:

The edit table look like this:

The gray cells are read-only, so you can only change the white cells in the lower triangle. As soon as you change a cell, the symmetric value in the gray area changes too. 

I did this by using two variables -- one for an underlying store (which just holds the lower triangle) and one for the symmetric matrix itself. I then defined the Symmetric_matrix to be

SubTable( If J>=I then Matrix_storage else Transpose(Matrix_storage,I,J) )

It says: If you are the lower triangle (editable part), reflect the cells of Matrix_storage in the edit table (SubTable displays cells from other sources in a new edit table). The else part uses a computed value, and is hence read-only.  

This is all it takes to enforce the symmetry and to cause the read-only cells to display with a gray background.

The final embellishment is that, from the Typescript window, I entered this command:

ProactivelyEvaluate Symmetric_matrix:16

You can see on the doc page for ProactivelyEvaluate that 16 means the edit table should accept entry immediately when you enter a value into the cell, instead of waiting for you to press the Green checkbox. That way it updates the symmetrical cell immediately.



Scroll to Top