def apply_constraints(self, b, constraints):
        """Apply constraints to matrix and rhs vector `b`

        Parameters
        ----------
        b : array
        constraints : tuple of 2-tuples
            The 2-tuples represent (row, val)
            The constraint indents the matrix row and sets b[row] = val
        """
        if len(constraints) > 0:
            if self._lu is None:
                A = self.mats2D[0]
                A = A.tolil()
                for (row, val) in constraints:
                    _, zerorow = A[row].nonzero()
                    A[(row, zerorow)] = 0
                    A[row, row] = 1
                    b[row] = val
                self.mats2D[0] = A.tocsc()
            else:
                for (row, val) in constraints:
                    b[row] = val
        return b