private void solveUsingTriangle(double real, int index, DMatrixRMaj r)
        {
            for (int i = 0; i < index; i++)
            {
                _implicit.A.add(i, i, -real);
            }

            SpecializedOps_DDRM.subvector(_implicit.A, 0, index, index, false, 0, r);
            CommonOps_DDRM.changeSign(r);

            TriangularSolver_DDRM.solveU(_implicit.A.data, r.data, _implicit.A.numRows, 0, index);

            for (int i = 0; i < index; i++)
            {
                _implicit.A.add(i, i, real);
            }
        }
        private void solveWithLU(double real, int index, DMatrixRMaj r)
        {
            DMatrixRMaj A = new DMatrixRMaj(index, index);

            CommonOps_DDRM.extract(_implicit.A, 0, index, 0, index, A, 0, 0);

            for (int i = 0; i < index; i++)
            {
                A.add(i, i, -real);
            }

            r.reshape(index, 1, false);

            SpecializedOps_DDRM.subvector(_implicit.A, 0, index, index, false, 0, r);
            CommonOps_DDRM.changeSign(r);

            // TODO this must be very inefficient
            if (!solver.setA(A))
            {
                throw new InvalidOperationException("Solve failed");
            }
            solver.solve(r, r);
        }
Exemple #3
0
 public void changeSign(Matrix a)
 {
     CommonOps_DDRM.changeSign((DMatrixRMaj)a);
 }