def pascal(n, kind='symmetric', exact=True):
 from scipy.special import comb
 if (kind not in ['symmetric', 'lower', 'upper']):
  raise ValueError("kind must be 'symmetric', 'lower', or 'upper'")
 if exact:
  if (n >= 35):
   L_n = np.empty((n, n), dtype=object)
   L_n.fill(0)
  else:
   L_n = np.zeros((n, n), dtype=np.uint64)
  for i in range(n):
   for j in range((i + 1)):
    L_n[(i, j)] = comb(i, j, exact=True)
 else:
  L_n = comb(*np.ogrid[:n, :n])
 if (kind is 'lower'):
  p = L_n
 elif (kind is 'upper'):
  p = L_n.T
 else:
  p = np.dot(L_n, L_n.T)
 return p

def pascal ( n , kind = 'symmetric' , exact = True ) : from scipy . special import comb if ( kind not in [ 'symmetric' , 'lower' , 'upper' ] ) : raise ValueError ( "kind must be 'symmetric', 'lower', or 'upper'" ) if exact : if ( n >= 35 ) : L_n = np . empty ( ( n , n ) , dtype = object ) L_n . fill ( 0 ) else : L_n = np . zeros ( ( n , n ) , dtype = np . uint64 ) for i in range ( n ) : for j in range ( ( i + 1 ) ) : L_n [ ( i , j ) ] = comb ( i , j , exact = True ) else : L_n = comb ( * np . ogrid [ : n , : n ] ) if ( kind is 'lower' ) : p = L_n elif ( kind is 'upper' ) : p = L_n . T else : p = np . dot ( L_n , L_n . T ) return p
returns the n x n pascal matrix .