original_docstring: 
      (phi, dphi_dn) = SphericalBasisOutAll(k, Bnm, x, nUV)
     	
      Returns phi and dPhi/dn for a summation of outgoing Spherical Basis functions with
     	coefficients Bnm. The algorithm is equivalent to that implemented in SphericalBasisOut,
     	but this version avoids repeated call to lpmv, since that is very time consuming.
     	
     	Arguments:
     	k     wavenumber - positive real scalar
     	Bnm   directivity coefficients - vector with a square number of elements
     	x     evaluation positions - real-valued array with 3 columns
     	nUV   unit vector defining direction in which to compute dPhi/dn - 1x3
     	
      Returned quantities are vectors with the same number of elements as x has rows.
      
docstring: (phi, dphi_dn) = SphericalBasisOutAll(k, Bnm, x, nUV)
  Returns phi and dPhi/dn for a summation of outgoing Spherical Basis functions with
  coefficients Bnm. The algorithm is equivalent to that implemented in SphericalBasisOut,
  but this version avoids repeated call to lpmv, since that is very time consuming.
  
  
  
  Returned quantities are vectors with the same number of elements as x has rows.
docstring_tokens: ( phi dphi_dn ) = SphericalBasisOutAll ( k Bnm x nUV ) Returns phi and dPhi / dn for a summation of outgoing Spherical Basis functions with coefficients Bnm . The algorithm is equivalent to that implemented in SphericalBasisOut but this version avoids repeated call to lpmv since that is very time consuming . Returned quantities are vectors with the same number of elements as x has rows .
code: def spherical_basis_out_all(k, Bnm, pos, nUV):
      '''
      (phi, dphi_dn) = SphericalBasisOutAll(k, Bnm, x, nUV)
     	
      Returns phi and dPhi/dn for a summation of outgoing Spherical Basis functions with
     	coefficients Bnm. The algorithm is equivalent to that implemented in SphericalBasisOut,
     	but this version avoids repeated call to lpmv, since that is very time consuming.
     	
     	Arguments:
     	k     wavenumber - positive real scalar
     	Bnm   directivity coefficients - vector with a square number of elements
     	x     evaluation positions - real-valued array with 3 columns
     	nUV   unit vector defining direction in which to compute dPhi/dn - 1x3
     	
      Returned quantities are vectors with the same number of elements as x has rows.
      '''
      
      # Convert cartesison coordinates x to spherical coordinates:
      x = pos[0].reshape((1,1))
      y = pos[1].reshape((1,1))
      z = pos[2].reshape((1,1))
      (r, alpha, sinbeta, cosbeta) = cart2sph(x,y,z)
  
      # dot products of nUV with unit vectors of spherical coordinate system (at x):
      nUVrUV, nUValphaUV, nUVbetaUV = cart2sphUV(x,y,z,nUV)
  	
      # Evaluate spherical harmonic functions and their derivatives:
      #if (Bnm.ndim != 1):
      #    raise IndexError('Bnm must be 1-dimensional')
      
      Order = int(np.sqrt(Bnm.size)) - 1
      y, dy_dbeta, dy_dalpha = spherical_harmonic_all(Order, alpha, sinbeta, cosbeta)
  
      # Loop over m and n and evalute phi and dPhi/dn:
      phi = np.zeros((r.size,1), np.complex64)
      dphi_dn = np.zeros((r.size,1), np.complex64)
      for n in range(Order + 1):
          R, dR_dkr = spherical_hankel_out(n, k*r)
          for m in range(-n, n + 1):
              i = sub2indSH(m,n)
              phi += Bnm[i,0] * R * y[0,i]
              dphi_dn += Bnm[i,0] * (nUVrUV * k * dR_dkr * y[0,i] + (R / r) * (nUVbetaUV * dy_dbeta[0,i] + nUValphaUV * dy_dalpha[0,i] / sinbeta))
  
      return (phi, dphi_dn)
code_tokens: def spherical_basis_out_all ( k , Bnm , pos , nUV ) : x = pos [ 0 ] . reshape ( ( 1 , 1 ) ) y = pos [ 1 ] . reshape ( ( 1 , 1 ) ) z = pos [ 2 ] . reshape ( ( 1 , 1 ) ) ( r , alpha , sinbeta , cosbeta ) = cart2sph ( x , y , z ) nUVrUV , nUValphaUV , nUVbetaUV = cart2sphUV ( x , y , z , nUV ) Order = int ( np . sqrt ( Bnm . size ) ) - 1 y , dy_dbeta , dy_dalpha = spherical_harmonic_all ( Order , alpha , sinbeta , cosbeta ) phi = np . zeros ( ( r . size , 1 ) , np . complex64 ) dphi_dn = np . zeros ( ( r . size , 1 ) , np . complex64 ) for n in range ( Order + 1 ) : R , dR_dkr = spherical_hankel_out ( n , k * r ) for m in range ( - n , n + 1 ) : i = sub2indSH ( m , n ) phi += Bnm [ i , 0 ] * R * y [ 0 , i ] dphi_dn += Bnm [ i , 0 ] * ( nUVrUV * k * dR_dkr * y [ 0 , i ] + ( R / r ) * ( nUVbetaUV * dy_dbeta [ 0 , i ] + nUValphaUV * dy_dalpha [ 0 , i ] / sinbeta ) ) return ( phi , dphi_dn )
short_docstring: (phi, dphi_dn) = SphericalBasisOutAll(k, Bnm, x, nUV)
  Returns phi and dPhi/dn for a summation of outgoing Spherical Basis functions with
  coefficients Bnm.
short_docstring_tokens: ( phi dphi_dn ) = SphericalBasisOutAll ( k Bnm x nUV ) Returns phi and dPhi / dn for a summation of outgoing Spherical Basis functions with coefficients Bnm .
comment: '''
      (phi, dphi_dn) = SphericalBasisOutAll(k, Bnm, x, nUV)
     	
      Returns phi and dPhi/dn for a summation of outgoing Spherical Basis functions with
     	coefficients Bnm. The algorithm is equivalent to that implemented in SphericalBasisOut,
     	but this version avoids repeated call to lpmv, since that is very time consuming.
     	
     	Arguments:
     	k     wavenumber - positive real scalar
     	Bnm   directivity coefficients - vector with a square number of elements
     	x     evaluation positions - real-valued array with 3 columns
     	nUV   unit vector defining direction in which to compute dPhi/dn - 1x3
     	
      Returned quantities are vectors with the same number of elements as x has rows.
      '''$SEP$# Convert cartesison coordinates x to spherical coordinates:$SEP$# dot products of nUV with unit vectors of spherical coordinate system (at x):$SEP$# Evaluate spherical harmonic functions and their derivatives:$SEP$#if (Bnm.ndim != 1):$SEP$#    raise IndexError('Bnm must be 1-dimensional')$SEP$# Loop over m and n and evalute phi and dPhi/dn: