public static ComplexMatrix identityMatrix(int n) {
        ComplexMatrix mx = zeroMatrix(n, n);
        for (int i = 0; i < n; i++) {
            mx.setElem(i, i, Complex.fromDouble(1.0));
        }
        return mx;
    }