Language Reference


SQRSYM Function

SQRSYM (matrix);

The SQRSYM function takes a packed-symmetric matrix (such as generated by the SYMSQR function ) and transforms it back into a dense square matrix.

The argument to the SQRSYM function is a symmetric matrix. The elements of the argument are unpacked (in row-major order) into the lower triangle of the result and reflected across the diagonal into the upper triangle. If you want the lower-triangular elements to be stacked in column-major order, use the VECH function .

For example, the following statements return a symmetric matrix:

v = T(1:6);
sqr = sqrsym(v);
print sqr;

Figure 24.389: Symmetric Matrix

sqr
1 2 4
2 3 5
4 5 6



The SQRSYM function and the SYMSQR function are inverse operations on the set of symmetric matrices. See also the SQRVECH function , which unpacks elements in column-major order.