>>> K = SymmetricPSD(5)
>>> A = matrix([[5,4,3,2,1],
- ... [4,5,4,3,2],
- ... [3,4,5,4,3],
- ... [2,3,4,5,4],
- ... [1,2,3,4,5]])
+ ... [4,5,4,3,2],
+ ... [3,4,5,4,3],
+ ... [2,3,4,5,4],
+ ... [1,2,3,4,5]])
>>> A in K
True
However, this matrix has a negative eigenvalue:
>>> K = SymmetricPSD(2)
- >>> A = matrix([[1,-2],
- ... [-2,1]])
+ >>> A = matrix([[ 1, -2],
+ ... [-2, 1]])
+ >>> A in K
+ False
+
+ An asymmetric cone with positive eigenvalues is not in the cone:
+
+ >>> K = SymmetricPSD(2)
+ >>> A = matrix([[10, 2],
+ ... [4, 8]])
>>> A in K
False
raise TypeError('the given point has the wrong dimensions')
if not point.typecode == 'd':
point = matrix(point, (self.dimension(), self.dimension()), 'd')
+ if not norm(point - point.trans()) < options.ABS_TOL:
+ # It's not symmetric.
+ return False
return all([e > -options.ABS_TOL for e in eigenvalues(point)])