[Scipy-svn] r3172 - trunk/Lib/optimize

scipy-svn@scip... scipy-svn@scip...
Wed Jul 18 07:31:20 CDT 2007


Author: dmitrey.kroshko
Date: 2007-07-18 07:29:42 -0500 (Wed, 18 Jul 2007)
New Revision: 3172

Modified:
   trunk/Lib/optimize/optimize.py
Log:
bugfix in _cubicmin (ticket 344)



Modified: trunk/Lib/optimize/optimize.py
===================================================================
--- trunk/Lib/optimize/optimize.py	2007-07-18 11:38:43 UTC (rev 3171)
+++ trunk/Lib/optimize/optimize.py	2007-07-18 12:29:42 UTC (rev 3172)
@@ -21,7 +21,7 @@
            'line_search', 'check_grad']
 
 import numpy
-from numpy import atleast_1d, eye, mgrid, argmin, zeros, shape, \
+from numpy import atleast_1d, eye, mgrid, argmin, zeros, shape, empty, \
      squeeze, isscalar, vectorize, asarray, absolute, sqrt, Inf, asfarray, isinf
 import linesearch
 
@@ -306,7 +306,12 @@
     dc = c-a
     if (db == 0) or (dc == 0) or (b==c): return None
     denom = (db*dc)**2 * (db-dc)
-    [A,B] = numpy.dot([[dc**2, -db**2],[-dc**3, db**3]],[fb-fa-C*db,fc-fa-C*dc])
+    d1 = empty((2,2))
+    d1[0,0] = dc**2
+    d1[0,1] = -db**2
+    d1[1,0] = -dc**3
+    d1[1,1] = db**3
+    [A,B] = numpy.dot(d1,asarray([fb-fa-C*db,fc-fa-C*dc]).flatten())
     A /= denom
     B /= denom
     radical = B*B-3*A*C



More information about the Scipy-svn mailing list