Given a quadratic form $q: E \to \mathbb{R}$ (where $E$ is some vector space), it's always possible to find a decomposition of the form $$q(v) = \sum_{i=1}^n \alpha_i l_i(v)^2,$$ where the $\alpha_i \in \mathbb{R}$ are scalars and $l_i : E \to \mathbb{R}$ are independent linear forms. In French it's called the Gaussian decomposition ("décomposition de Gauss") of $q$; I don't know if this has a standard name in English.
Is there a way to find these decompositions easily in Mathematica? One way would be, given a symmetric square matrix $M$, to find an invertible matrix $P$ such that $P^T M P$ is diagonal; the matrix $P$ would represent the predual basis of $(l_i)$). As far as I can tell, Mathematica only has Orthogonalize, which only works for positive definite quadratic forms.
To give an example of what I'm asking. Say that $q : \mathbb{R}^3 \to \mathbb{R}$ is defined as
$$q(x,y,z) = 2 x^2 + 12 x y + 17 y^2 + 4 x z + 16 y z - z^2.$$
Then, completing the squares, one gets
$$q(x,y,z) = 2 (x + 3 y + z)^2 - (y - 2 z)^2 + z^2,$$
so I would either want an output of the form {{2,-1,1}, {{1,3,1}, {0,1,-2}, {0,0,1}}} (for the dual basis) or {{2,-1,1}, {{1, -3, -7}, {0, 1, 2}, {0, 0, 1}}} (for the predual basis).
Note that Orthogonalize fails, as q is not positive definite:
q[{x_, y_, z_}] = 2 (x + 3 y + z)^2 - (y - 2 z)^2 + z^2
b[u_, v_] := (q[u + v] - q[u] - q[v])/2
Orthogonalize[IdentityMatrix[3], b]
(* Orthogonalize::ornfa: The second argument b is not an inner product function, which always should return a number or symbol. If its two numeric arguments are the same, it should return a non-negative real number. *)