double orthogonality = 0;
// Compute pairwise inner products
DoubleMatrix2D cosines = A.zMult(A, null, 1, 0, true, false);
for (int r = 0; r < cosines.rows(); r++)
{
for (int c = r + 1; c < cosines.columns(); c++)
{
orthogonality += cosines.getQuick(r, c);
}