comparison pyCSalgos/BP/l1eq_pd.py @ 65:3d53309236c4

Added cvxopt_lp.py. Some bugfixes in gap.py and l1eq_pd.py
author Nic Cleju <nikcleju@gmail.com>
date Fri, 16 Mar 2012 13:35:47 +0200
parents 2fc28e2ae0a2
children
comparison
equal deleted inserted replaced
64:a115c982a0fd 65:3d53309236c4
219 #end 219 #end
220 220
221 # End of original Matab code 221 # End of original Matab code
222 #---------------------------- 222 #----------------------------
223 223
224 # Nic: check if b is 0; if so, return 0
225 # Otherwise it will break later
226 if numpy.linalg.norm(b) < 1e-16:
227 return numpy.zeros_like(x0)
228
224 #largescale = isa(A,'function_handle'); 229 #largescale = isa(A,'function_handle');
225 if hasattr(A, '__call__'): 230 if hasattr(A, '__call__'):
226 largescale = True 231 largescale = True
227 else: 232 else:
228 largescale = False 233 largescale = False
255 # return; 260 # return;
256 #end 261 #end
257 #x0 = A'*w; 262 #x0 = A'*w;
258 try: 263 try:
259 w = scipy.linalg.solve(numpy.dot(A,A.T), b, sym_pos=True) 264 w = scipy.linalg.solve(numpy.dot(A,A.T), b, sym_pos=True)
260 hcond = 1.0/numpy.linalg.cond(np.dot(A,A.T)) 265 hcond = 1.0/numpy.linalg.cond(numpy.dot(A,A.T))
261 except scipy.linalg.LinAlgError: 266 except scipy.linalg.LinAlgError:
262 if verbose: 267 if verbose:
263 print 'A*At is ill-conditioned: cannot find starting point' 268 print 'A*At is ill-conditioned: cannot find starting point'
264 xp = x0.copy() 269 xp = x0.copy()
265 return xp 270 return xp