code: def B2q(B, tol=None):
      """Estimate q vector from input B matrix `B`
  
      We require that the input `B` is symmetric positive definite.
  
      Because the solution is a square root, the sign of the returned
      vector is arbitrary.  We set the vector to have a positive x
      component by convention.
  
      Parameters
      ----------
      B : (3,3) array-like
         B matrix - symmetric. We do not check the symmetry.
      tol : None or float
         absolute tolerance below which to consider eigenvalues of the B
         matrix to be small enough not to worry about them being negative,
         in check for positive semi-definite-ness.  None (default) results
         in a fairly tight numerical threshold proportional to the maximum
         eigenvalue
  
      Returns
      -------
      q : (3,) vector
         Estimated q vector from B matrix `B`
      """
      B = np.asarray(B)
      if not np.allclose(B - B.T, 0):
          raise ValueError("B matrix is not symmetric enough")
      w, v = npl.eigh(B)
      if tol is None:
          tol = np.abs(w.max()) * B.shape[0] * np.finfo(w.dtype).eps
      non_trivial = np.abs(w) > tol
      if np.any(w[non_trivial] < 0):
          raise ValueError("B not positive semi-definite")
      inds = np.argsort(w)[::-1]
      max_ind = inds[0]
      vector = v[:, max_ind]
      # because the factor is a sqrt, the sign of the vector is arbitrary.
      # We arbitrarily set it to have a positive x value.
      if vector[0] < 0:
          vector *= -1
      return vector * w[max_ind]
  
imports: import numpy
  import numpy.linalg
label_desc: Use image node_id 1 for calling a global function with example usage: B2q(B, tol) and returns: unknown