nodes: 0, module; 1, function_definition; 2, function_name:_qrd_solve_full; 3, parameters; 4, block; 5, identifier:a; 6, identifier:b; 7, identifier:ddiag; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, assert_statement; 15, assert_statement; 16, assert_statement; 17, comment:# The computation is straightforward.; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, return_statement; 22, identifier:dtype; 23, attribute; 24, comment:"""Solve the equation A^T x = B, D x = 0.
  
  Parameters:
  a     - an n-by-m array, m >= n
  b     - an m-vector
  ddiag - an n-vector giving the diagonal of D. (The rest of D is 0.)
  
  Returns:
  x    - n-vector solving the equation.
  s    - the n-by-n supplementary matrix s.
  pmut - n-element permutation vector defining the permutation matrix P.
  
  The equations are solved in a least-squares sense if the system is
  rank-deficient.  D is a diagonal matrix and hence only its diagonal is
  in fact supplied as an argument. The matrix s is full lower triangular
  and solves the equation
  
  P^T (A A^T + D D) P = S^T S (needs transposition?)
  
  where P is the permutation matrix defined by the vector pmut; it puts
  the rows of 'a' in order of nonincreasing rank, so that a[pmut]
  has its rows sorted that way.
  """; 25, assignment; 26, assignment; 27, assignment; 28, assignment; 29, comparison_operator:m >= n; 30, comparison_operator:b.shape == (m, ); 31, comparison_operator:ddiag.shape == (n, ); 32, assignment; 33, assignment; 34, assignment; 35, expression_list; 36, identifier:np; 37, identifier:float; 38, identifier:a; 39, call; 40, identifier:b; 41, call; 42, identifier:ddiag; 43, call; 44, pattern_list; 45, attribute; 46, identifier:m; 47, identifier:n; 48, attribute; 49, tuple; 50, attribute; 51, tuple; 52, pattern_list; 53, call; 54, identifier:bqt; 55, call; 56, pattern_list; 57, call; 58, identifier:x; 59, identifier:s; 60, identifier:pmut; 61, attribute; 62, argument_list; 63, attribute; 64, argument_list; 65, attribute; 66, argument_list; 67, identifier:n; 68, identifier:m; 69, identifier:a; 70, identifier:shape; 71, identifier:b; 72, identifier:shape; 73, identifier:m; 74, identifier:ddiag; 75, identifier:shape; 76, identifier:n; 77, identifier:q; 78, identifier:r; 79, identifier:pmut; 80, identifier:_qr_factor_full; 81, argument_list; 82, attribute; 83, argument_list; 84, identifier:x; 85, identifier:s; 86, identifier:_manual_qrd_solve; 87, argument_list; 88, identifier:np; 89, identifier:asarray; 90, identifier:a; 91, identifier:dtype; 92, identifier:np; 93, identifier:asarray; 94, identifier:b; 95, identifier:dtype; 96, identifier:np; 97, identifier:asarray; 98, identifier:ddiag; 99, identifier:dtype; 100, identifier:a; 101, identifier:np; 102, identifier:dot; 103, identifier:b; 104, attribute; 105, subscript; 106, identifier:pmut; 107, identifier:ddiag; 108, identifier:bqt; 109, keyword_argument; 110, keyword_argument; 111, identifier:q; 112, identifier:T; 113, identifier:r; 114, slice; 115, slice; 116, identifier:dtype; 117, identifier:dtype; 118, identifier:build_s; 119, True; 120, identifier:n
code: def _qrd_solve_full(a, b, ddiag, dtype=np.float):
      """Solve the equation A^T x = B, D x = 0.
  
  Parameters:
  a     - an n-by-m array, m >= n
  b     - an m-vector
  ddiag - an n-vector giving the diagonal of D. (The rest of D is 0.)
  
  Returns:
  x    - n-vector solving the equation.
  s    - the n-by-n supplementary matrix s.
  pmut - n-element permutation vector defining the permutation matrix P.
  
  The equations are solved in a least-squares sense if the system is
  rank-deficient.  D is a diagonal matrix and hence only its diagonal is
  in fact supplied as an argument. The matrix s is full lower triangular
  and solves the equation
  
  P^T (A A^T + D D) P = S^T S (needs transposition?)
  
  where P is the permutation matrix defined by the vector pmut; it puts
  the rows of 'a' in order of nonincreasing rank, so that a[pmut]
  has its rows sorted that way.
  """
  
      a = np.asarray(a, dtype)
      b = np.asarray(b, dtype)
      ddiag = np.asarray(ddiag, dtype)
  
      n, m = a.shape
      assert m >= n
      assert b.shape == (m, )
      assert ddiag.shape == (n, )
  
      # The computation is straightforward.
  
      q, r, pmut = _qr_factor_full(a)
      bqt = np.dot(b, q.T)
      x, s = _manual_qrd_solve(r[:,:n], pmut, ddiag, bqt,
                               dtype=dtype, build_s=True)
  
      return x, s, pmut