parameters: (self,xamb)
return_statement: return xemb
docstring: Ambient space -> embedded space
docstring_summary: Ambient space -> embedded space
docstring_tokens: Ambient space - > embedded space
function: def project(self,xamb):
          """Ambient space -> embedded space"""
          if len(xamb) != len(self.b):
              raise ValueError("Invalid length of ambient space vector: %d should be %d"%(len(xamb),len(self.b)))
          import numpy as np
          #xamb = A*xemb + b
          if hasattr(self.A,'todense'):
              import scipy.sparse.linalg
              xemb = scipy.sparse.linalg.lsqr(self.A,np.asarray(xamb)-np.asarray(self.b))[0].tolist()
          elif hasattr(self.A,'dot'):
              xemb = np.linalg.lstsq(self.A,np.asarray(xamb)-np.asarray(self.b))[0].tolist()
          else:
              import scipy.sparse
              A = scipy.sparse.lil_matrix((self.A.shape[0],self.m))
              for i,row in enumerate(self.A):
                  for j,v in row.items():
                      A.rows[i].append(j)
                      A.data[i].append(v)
              xemb = scipy.sparse.linalg.lsqr(A.tocsr(),np.asarray(xamb)-np.asarray(self.b))[0].tolist()
          assert len(xemb)==self.m
          return xemb
function_tokens: def project ( self , xamb ) : if len ( xamb ) != len ( self . b ) : raise ValueError ( "Invalid length of ambient space vector: %d should be %d" % ( len ( xamb ) , len ( self . b ) ) ) import numpy as np #xamb = A*xemb + b if hasattr ( self . A , 'todense' ) : import scipy . sparse . linalg xemb = scipy . sparse . linalg . lsqr ( self . A , np . asarray ( xamb ) - np . asarray ( self . b ) ) [ 0 ] . tolist ( ) elif hasattr ( self . A , 'dot' ) : xemb = np . linalg . lstsq ( self . A , np . asarray ( xamb ) - np . asarray ( self . b ) ) [ 0 ] . tolist ( ) else : import scipy . sparse A = scipy . sparse . lil_matrix ( ( self . A . shape [ 0 ] , self . m ) ) for i , row in enumerate ( self . A ) : for j , v in row . items ( ) : A . rows [ i ] . append ( j ) A . data [ i ] . append ( v ) xemb = scipy . sparse . linalg . lsqr ( A . tocsr ( ) , np . asarray ( xamb ) - np . asarray ( self . b ) ) [ 0 ] . tolist ( ) assert len ( xemb ) == self . m return xemb