public void invertMultiply
        (double[][] AinvB,
         double[][] B)
        {
        // Verify preconditions.
        if (AinvB.length != N)
            {
            throw new IllegalArgumentException
                ("LinearSolve.invertMultiply(): AinvB is not a " +
                 N + "-by-" + N + " matrix");
            }
        if (B.length != N)
            {
            throw new IllegalArgumentException
                ("LinearSolve.invertMultiply(): B is not a " +
                 N + "-by-" + N + " matrix");
            }
        for (int i = 0; i < N; ++ i)
            {
            if (AinvB[i].length != N)
                {
                throw new IllegalArgumentException
                    ("LinearSolve.invertMultiply(): AinvB is not a " +
                     N + "-by-" + N + " matrix");
                }
            if (B[i].length != N)
                {
                throw new IllegalArgumentException
                    ("LinearSolve.invertMultiply(): B is not a " +
                     N + "-by-" + N + " matrix");
                }
            }

        // Allocate temporary storage.
        double[] x = new double [N];

        // Compute and store the columns of the inverse product.
        for (int i = 0; i < N; ++ i)
            {
            // Apply the permutation to column i of B.
            for (int j = 0; j < N; ++ j)
                {
                x[j] = B[p[j]][i];
                }
            luSolve (LU, p, x, N);
            for (int j = 0; j < N; ++ j)
                {
                AinvB[j][i] = x[j];
                }
            }
        }