def GramSchmidt(vlist, orthonormal=False):
 out = []
 m = len(vlist)
 for i in range(m):
  tmp = vlist[i]
  for j in range(i):
   tmp -= vlist[i].project(out[j])
  if (not tmp.values()):
   raise ValueError('GramSchmidt: vector set not linearly independent')
  out.append(tmp)
 if orthonormal:
  for i in range(len(out)):
   out[i] = out[i].normalized()
 return out

def GramSchmidt ( vlist , orthonormal = False ) : out = [ ] m = len ( vlist ) for i in range ( m ) : tmp = vlist [ i ] for j in range ( i ) : tmp -= vlist [ i ] . project ( out [ j ] ) if ( not tmp . values ( ) ) : raise ValueError ( 'GramSchmidt: vector set not linearly independent' ) out . append ( tmp ) if orthonormal : for i in range ( len ( out ) ) : out [ i ] = out [ i ] . normalized ( ) return out
apply the gram-schmidt process to a set of vectors .