class_docstr: This object holds the general model form for a dynamic system. This
  model is used for computing the linearized form of the system, while
  properly dealing with constraints leading to  dependent coordinates and
  speeds. The notation and method is described in [1]_.
  
  Attributes
  ==========
  
  f_0, f_1, f_2, f_3, f_4, f_c, f_v, f_a : Matrix
      Matrices holding the general system form.
  q, u, r : Matrix
      Matrices holding the generalized coordinates, speeds, and
      input vectors.
  q_i, u_i : Matrix
      Matrices of the independent generalized coordinates and speeds.
  q_d, u_d : Matrix
      Matrices of the dependent generalized coordinates and speeds.
  perm_mat : Matrix
      Permutation matrix such that [q_ind, u_ind]^T = perm_mat*[q, u]^T
  
  References
  ==========
  
  .. [1] D. L. Peterson, G. Gede, and M. Hubbard, "Symbolic linearization of
         equations of motion of constrained multibody systems," Multibody
         Syst Dyn, vol. 33, no. 2, pp. 143-161, Feb. 2015, doi:
         10.1007/s11044-014-9436-5.
class_docstr_tok: ["This","object","holds","the","general","model","form","for","a","dynamic","system",".","This","model","is","used","for","computing","the","linearized","form","of","the","system",",","while","properly","dealing","with","constraints","leading","to","dependent","coordinates","and","speeds",".","The","notation","and","method","is","described","in","[","1","]","_",".","Attributes","==========","f_0",",","f_1",",","f_2",",","f_3",",","f_4",",","f_c",",","f_v",",","f_a",":","Matrix","Matrices","holding","the","general","system","form",".","q",",","u",",","r",":","Matrix","Matrices","holding","the","generalized","coordinates",",","speeds",",","and","input","vectors",".","q_i",",","u_i",":","Matrix","Matrices","of","the","independent","generalized","coordinates","and","speeds",".","q_d",",","u_d",":","Matrix","Matrices","of","the","dependent","generalized","coordinates","and","speeds",".","perm_mat",":","Matrix","Permutation","matrix","such","that","[","q_ind",",","u_ind","]","^T","=","perm_mat","*","[","q",",","u","]","^T","References","==========","..","[","1","]","D.","L.","Peterson",",","G.","Gede",",","and","M.","Hubbard",",","``","Symbolic","linearization","of","equations","of","motion","of","constrained","multibody","systems",",","''","Multibody","Syst","Dyn",",","vol",".","33",",","no",".","2",",","pp",".","143-161",",","Feb.","2015",",","doi",":","10.1007\/s11044-014-9436-5","."]
docstr: Parameters
  ==========
  
  f_0, f_1, f_2, f_3, f_4, f_c, f_v, f_a : array_like
      System of equations holding the general system form.
      Supply empty array or Matrix if the parameter
      does not exist.
  q : array_like
      The generalized coordinates.
  u : array_like
      The generalized speeds
  q_i, u_i : array_like, optional
      The independent generalized coordinates and speeds.
  q_d, u_d : array_like, optional
      The dependent generalized coordinates and speeds.
  r : array_like, optional
      The input variables.
  lams : array_like, optional
      The lagrange multipliers
  linear_solver : str, callable
      Method used to solve the several symbolic linear systems of the
      form ``A*x=b`` in the linearization process. If a string is
      supplied, it should be a valid method that can be used with the
      :meth:`sympy.matrices.matrixbase.MatrixBase.solve`. If a callable is
      supplied, it should have the format ``x = f(A, b)``, where it
      solves the equations and returns the solution. The default is
      ``'LU'`` which corresponds to SymPy's ``A.LUsolve(b)``.
      ``LUsolve()`` is fast to compute but will often result in
      divide-by-zero and thus ``nan`` results.
docstr_tok: ["Parameters","==========","f_0",",","f_1",",","f_2",",","f_3",",","f_4",",","f_c",",","f_v",",","f_a",":","array_like","System","of","equations","holding","the","general","system","form",".","Supply","empty","array","or","Matrix","if","the","parameter","does","not","exist",".","q",":","array_like","The","generalized","coordinates",".","u",":","array_like","The","generalized","speeds","q_i",",","u_i",":","array_like",",","optional","The","independent","generalized","coordinates","and","speeds",".","q_d",",","u_d",":","array_like",",","optional","The","dependent","generalized","coordinates","and","speeds",".","r",":","array_like",",","optional","The","input","variables",".","lams",":","array_like",",","optional","The","lagrange","multipliers","linear_solver",":","str",",","callable","Method","used","to","solve","the","several","symbolic","linear","systems","of","the","form","``","A","*","x=b","``","in","the","linearization","process",".","If","a","string","is","supplied",",","it","should","be","a","valid","method","that","can","be","used","with","the",":","meth",":","`","sympy.matrices.matrixbase.MatrixBase.solve","`",".","If","a","callable","is","supplied",",","it","should","have","the","format","``","x","=","f","(","A",",","b",")","``",",","where","it","solves","the","equations","and","returns","the","solution",".","The","default","is","``","'LU","'","``","which","corresponds","to","SymPy","'s","``","A.LUsolve","(","b",")","``",".","``","LUsolve","(",")","``","is","fast","to","compute","but","will","often","result","in","divide-by-zero","and","thus","``","nan","``","results","."]
code: def __init__(
      self,
      f_0,
      f_1,
      f_2,
      f_3,
      f_4,
      f_c,
      f_v,
      f_a,
      q,
      u,
      q_i=None,
      q_d=None,
      u_i=None,
      u_d=None,
      r=None,
      lams=None,
      linear_solver="LU",
  ):
      """
      Parameters
      ==========
  
      f_0, f_1, f_2, f_3, f_4, f_c, f_v, f_a : array_like
          System of equations holding the general system form.
          Supply empty array or Matrix if the parameter
          does not exist.
      q : array_like
          The generalized coordinates.
      u : array_like
          The generalized speeds
      q_i, u_i : array_like, optional
          The independent generalized coordinates and speeds.
      q_d, u_d : array_like, optional
          The dependent generalized coordinates and speeds.
      r : array_like, optional
          The input variables.
      lams : array_like, optional
          The lagrange multipliers
      linear_solver : str, callable
          Method used to solve the several symbolic linear systems of the
          form ``A*x=b`` in the linearization process. If a string is
          supplied, it should be a valid method that can be used with the
          :meth:`sympy.matrices.matrixbase.MatrixBase.solve`. If a callable is
          supplied, it should have the format ``x = f(A, b)``, where it
          solves the equations and returns the solution. The default is
          ``'LU'`` which corresponds to SymPy's ``A.LUsolve(b)``.
          ``LUsolve()`` is fast to compute but will often result in
          divide-by-zero and thus ``nan`` results.
  
      """
      self.linear_solver = _parse_linear_solver(linear_solver)
  
      # Generalized equation form
      self.f_0 = Matrix(f_0)
      self.f_1 = Matrix(f_1)
      self.f_2 = Matrix(f_2)
      self.f_3 = Matrix(f_3)
      self.f_4 = Matrix(f_4)
      self.f_c = Matrix(f_c)
      self.f_v = Matrix(f_v)
      self.f_a = Matrix(f_a)
  
      # Generalized equation variables
      self.q = Matrix(q)
      self.u = Matrix(u)
      none_handler = lambda x: Matrix(x) if x else Matrix()
      self.q_i = none_handler(q_i)
      self.q_d = none_handler(q_d)
      self.u_i = none_handler(u_i)
      self.u_d = none_handler(u_d)
      self.r = none_handler(r)
      self.lams = none_handler(lams)
  
      # Derivatives of generalized equation variables
      self._qd = self.q.diff(dynamicsymbols._t)
      self._ud = self.u.diff(dynamicsymbols._t)
      # If the user doesn't actually use generalized variables, and the
      # qd and u vectors have any intersecting variables, this can cause
      # problems. We'll fix this with some hackery, and Dummy variables
      dup_vars = set(self._qd).intersection(self.u)
      self._qd_dup = Matrix(
          [var if var not in dup_vars else Dummy() for var in self._qd]
      )
  
      # Derive dimesion terms
      l = len(self.f_c)
      m = len(self.f_v)
      n = len(self.q)
      o = len(self.u)
      s = len(self.r)
      k = len(self.lams)
      dims = namedtuple("dims", ["l", "m", "n", "o", "s", "k"])
      self._dims = dims(l, m, n, o, s, k)
  
      self._Pq = None
      self._Pqi = None
      self._Pqd = None
      self._Pu = None
      self._Pui = None
      self._Pud = None
      self._C_0 = None
      self._C_1 = None
      self._C_2 = None
      self.perm_mat = None
  
      self._setup_done = False
  
file_path: sympy/sympy/physics/mechanics/linearize.py
imports: from sympy import Matrix, eye, zeros
  from sympy.core.symbol import Dummy
  from sympy.utilities.iterables import flatten
  from sympy.physics.vector import dynamicsymbols
  from sympy.physics.mechanics.functions import msubs, _parse_linear_solver
  from collections import namedtuple
  from collections.abc import Iterable
label_desc: Use image node_id 1 to create a new Linearizer object  with example: obj = Linearizer(f_0, f_1, f_2, f_3, f_4, f_c, f_v, f_a, q, u, q_i, q_d, u_i, u_d, r, lams, linear_solver)