Efficient Algorithm for Computer Simulation of Constrained Mechanical Systems with Redundant Constraint and/or Singular Configuration