# roundPSDmatrix -- rational rounding of a PSD matrix

## Synopsis

• Usage:
(Qp,ispsd) = roundPSDmatrix(Q,A,b,d)
• Inputs:
• Q, , a symmetric matrix (real)
• A, , (rational)
• b, , (rational)
• d, an integer, the rounding precision
• Outputs:
• Qp, , the rounded matrix (rational)
• ispsd, , true if Qp is positive semidefinite

## Description

Let $S^n$ be the space of symmetric $n\times n$ matrices, and let $L \subset S^n$ be a rational affine subspace. By vectorization we may describe this subspace in the form $A q = b$ for some matrix $A$ with $n(n+1)/2$ columns. Given a real matrix $Q\in S^n$, this method finds a nearby rational matrix $Q_p$ on $L$.