Package parsimony :: Package algorithms :: Module deflation
[hide private]
[frames] | no frames]

Source Code for Module parsimony.algorithms.deflation

 1  # -*- coding: utf-8 -*- 
 2  """ 
 3  The :mod:`parsimony.algorithms.deflation` module contains deflation procedures. 
 4  functions. 
 5   
 6  Created on Fri Mar 21 15:18:56 2014 
 7   
 8  Copyright (c) 2013-2014, CEA/DSV/I2BM/Neurospin. All rights reserved. 
 9   
10  @author:  Tommy Löfstedt 
11  @email:   lofstedt.tommy@gmail.com 
12  @license: BSD 3-clause. 
13  """ 
14  import abc 
15   
16  import numpy as np 
17   
18  __all__ = ["ProjectionDeflation", 
19             "RowProjectionDeflation", "ColumnProjectionDeflation", 
20             "RankOneDeflation"] 
21 22 23 -class Deflation(object):
24 __metaclass__ = abc.ABCMeta 25 26 @abc.abstractmethod
27 - def deflate(self, X, w):
28 raise NotImplementedError('Abstract method "deflate" must be ' \ 29 'specialised!')
30
31 32 -class RowProjectionDeflation(Deflation):
33
34 - def deflate(self, X, w):
35 return X - np.dot(np.dot(X, w), w.T) / np.dot(w.T, w)
36 37 38 ProjectionDeflation = RowProjectionDeflation
39 40 41 -class ColumnProjectionDeflation(Deflation):
42
43 - def deflate(self, X, t):
44 return X - np.dot(t / np.dot(t.T, t), np.dot(t.T, X))
45
46 47 -class RankOneDeflation(Deflation):
48
49 - def deflate(self, X, t, p):
50 return X - np.dot(t, p.T)
51