| 52 | |
| 53 | |
| 54 | bool isPSD (const SymMatrix &M) |
| 55 | /* Check a Matrix is both Symetric and Positive Semi Definite |
| 56 | * Creates a temporary copy |
| 57 | * |
| 58 | * Numerics of Algorithm: |
| 59 | * Use UdUfactor and checks reciprocal condition number >=0 |
| 60 | * Algorithms using UdUfactor will will therefore succeed if isPSD(M) is true |
| 61 | * Do NOT assume because isPSD is true that M will appear to be PSD to other numerical algorithms |
| 62 | * Return: |
| 63 | * true iff M isSymetric and is PSD by the above algorithm |
| 64 | */ |
| 65 | { |
| 66 | RowMatrix UD(M.size1(),M.size1()); |
| 67 | |
| 68 | RowMatrix::value_type rcond = UdUfactor(UD, M); |
| 69 | return rcond >= 0.; |
| 70 | } |
| 71 | |
| 72 | |
| 73 | bool isSymmetric (const Matrix &M) |