Ejemplo n.º 1
0
 def invertbtilde(self,nx):
   '''
   Get inverse of the transformation for btilde to get back b in the 
   original space.
   '''
   btilde = nx[:,self.split:]
   b = applyAffine(invAffine(self.gb),btilde)
   return(btilde,b)
Ejemplo n.º 2
0
 def computebtilde(self,tx):
   '''
   Computes the btilde portion after
   the transformation.
   '''
   b = tx[:,self.split:]
   btilde = applyAffine(self.gb,b)
   return(btilde)
Ejemplo n.º 3
0
 def inv(self,nx):
   '''
   Inverse map, if the map has not been defined
   via the ellipse reflection then it will be.
   '''
   btilde,b = self.invertbtilde(nx)
   atilde = nx[:,:self.split]
   ashift = self.f(btilde)
   a = applyAffine(invAffine(self.ga),atilde-ashift)
   tx = hstack([a,b])
   return(tx)    
Ejemplo n.º 4
0
 def __call__(self,tx):
   '''
   Apply the map. If this is the first time
   this has been called it will automatically
   generate the ellipse reflect transformation.
   '''
   a = tx[:,:self.split]
   btilde = self.computebtilde(tx)
   ashift = self.f(btilde)
   atilde = applyAffine(self.ga,a) + ashift
   nx = hstack([atilde,btilde])
   return(nx)
Ejemplo n.º 5
0
def plotHMapEffects(s,alpha=0.1,Nsamp=1000):
  D = s.D
  Htrans = s.Htrans
  cpairs = zip(
    (['r','b','k'][i%3] for i in count(0)),
    zip(xrange(D),[j%D for j in xrange(1,D+1)])
  )
  x = sampleSCrossSD(r0=1.0,r1=0.3,D=D-1,N=Nsamp)
  tmpx = array(x)
  for h,A in zip(Htrans.H,Htrans.A):
    f = h.f
    figure(figsize=(12,12))
    subplot(2,2,1)
    for c,(i,j) in cpairs:
      scatter(tmpx[:,i],tmpx[:,j],alpha=alpha,c=c)
    subplot(2,2,2)
    bt = h.computebtilde(tmpx)
    if bt.shape[1]==1:
      scatter(zeros(bt.shape[0]),bt[:,0],alpha=alpha)
      lnes = f.getEllipse()
      for l in lnes:
        hlines(l,-1,1)
      subplot(2,2,3)
      a = applyAffine(h.ga,tmpx[:,:h.split])
      if a.shape[1]>2:
        scatter(a[:,0],a[:,1],alpha=alpha)
      else:
        scatter(zeros_like(a[:,0]),a[:,0],alpha=alpha)
    else:
      scatter(*bt.T,alpha=alpha)
      plot(*f.getEllipse())
      subplot(2,2,3)
      a = applyAffine(h.ga,tmpx[:,:h.split])
      scatter(zeros(a.shape[0]),a[:,0],alpha=alpha)
    subplot(2,2,4)
    tmpx = h(tmpx)
    for c,(i,j) in cpairs:
      scatter(tmpx[:,i],tmpx[:,j],alpha=alpha,c=c)
    tmpx = dot(A,tmpx.T).T