'Initialize the kinematic differential equation matrices.'

def _initialize_kindiffeq_matrices(self, kdeqs):

    if kdeqs:
        if (len(self.q) != len(kdeqs)):
            raise ValueError('There    must    be    an    equal    number    of    kinematic    differential    equations    and    coordinates.')
        kdeqs = Matrix(kdeqs)
        u = self.u
        qdot = self._qdot
        u_zero = dict(((i, 0) for i in u))
        uaux_zero = dict(((i, 0) for i in self._uaux))
        qdot_zero = dict(((i, 0) for i in qdot))
        f_k = msubs(kdeqs, u_zero, qdot_zero)
        k_ku = (msubs(kdeqs, qdot_zero) - f_k).jacobian(u)
        k_kqdot = (msubs(kdeqs, u_zero) - f_k).jacobian(qdot)
        f_k = k_kqdot.LUsolve(f_k)
        k_ku = k_kqdot.LUsolve(k_ku)
        k_kqdot = eye(len(qdot))
        self._qdot_u_map = solve_linear_system_LU(Matrix([k_kqdot.T, (- ((k_ku * u) + f_k).T)]).T, qdot)
        self._f_k = msubs(f_k, uaux_zero)
        self._k_ku = msubs(k_ku, uaux_zero)
        self._k_kqdot = k_kqdot
    else:
        self._qdot_u_map = None
        self._f_k = Matrix()
        self._k_ku = Matrix()
        self._k_kqdot = Matrix()
