Open
Description
We have two ways of instantiating PMSymmetricMatrix
:
- by using the
rows:
method, inherited fromPMMatrix
m := PMSymmetricMatrix rows: #(
(1 2)
(2 3)).
- by converting a
PMMatrix
toPMSymmetricMatrix
usingasSymmetricMatrix
.
m := PMMatrix rows: #(
(1 2)
(2 3)).
m := m asSymmetricMatrix.
Neither of these methods checks whether a given matrix is really symmetric. This results in a better performance, especially in case of large matrices, when doing such test every time we create (or convert) a matrix could be expensive.
However, PMMatrix
implements a method isSymmetric
isSymmetric
^ self = self transpose
which is overridden by PMSymmetricMatrix
to always return true
isSymmetric
"Answers true because the receiver is a symmetric matrix"
^true
Which gives some confusing results
m := PMSymmetricMatrix rows: #(
(1 0)
(2 3)).
m isSymmetric. "true"
m := PMMatrix rows: #(
(1 0)
(2 3)).
m := m asSymmetricMatrix.
m isSymmetric. "true"
I think that either we should not allow initializingPMSymmetricMatrix
with non-symmetric matrix (which is confusing already), or if we do (for the sake of performance), we should at least leave the method isSymmetric
for testing if a symmetric matrix is actually symmetric.