More fun with Derivatives of Matrices

PoulsenL at capecon.com PoulsenL at capecon.com
Fri Jun 8 15:52:39 CEST 2001

I have a very complex function for which I would like to take the first
derivative.  The problem is that involves the inverse of a Matrix.
DerivVar chokes on Numpy's inverse because it is not implemented in Python.
Upon some advice from Konrad Hinsen I retrieved the matfunc.py module with
high hopes.  Unfortunately, these hopes were soon dashed due to the absence
of the __float__ attribute in the DerivVar object.

Any advice would be greatly appreciated.

C = matfunc.makeMat([[DerivVar(1.0,0),2],[3,5]])
>>> C.mmul(C.inverse())
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line
183, in inverse
return self.solve( eye(self.rows) )
File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line
143, in solve
if isinstance(b,Mat): return makeMat( map(self.solve, b.tr()) ).tr()
File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line
145, in solve
x = self._solve( b )
File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line
139, in _solve
Q, R = self.qr()
File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line
127, in qr
v, beta = R.tr()[i].house(i)
File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line
81, in house
v = Vec( Elementwise([0]*index).concat(self[index:]) ).normalize()
File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line
72, in normalize
def normalize( self ):  return self / self.norm()
File "C:\Documents and Settings\PoulsenL\Desktop\PyMCMC\matfunc.py", line
71, in norm
def norm( self ):  return math.sqrt(abs( self.dot(self.conjugate()) ))
AttributeError: DerivVar instance has no attribute '__float__'
>>>

Loren Poulsen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20010608/16d3fec0/attachment.html>