[SciPy-User] scipy.sparse.linalg.cg statistics?

Sebastian Walter sebastian.walter@gmail....
Fri Oct 1 05:44:07 CDT 2010


I don't know if that helps you, but probably you can provide any
callable object.

I.e., you can make a class like

In [1]: class Foo:
   ...:     def __call__(self,args):
   ...:         print 'Bar'
   ...:
   ...:

In [2]: f = Foo()

In [4]: f(1)
Bar

regards,
Sebastian




On Fri, Oct 1, 2010 at 12:06 PM, Nico Schlömer <nico.schloemer@gmail.com> wrote:
>> Use the 'callback' argument.
>
> That works alright I guess.
> What I do right now is creating a *global array that's filled up as
> the callback function is called, after which I go ahead and plot it.
> Using a global variable here seems somewhat ugly to me -- might there
> be a more elegant solution at all?
>
> Cheers,
> Nico
>
>
> On Tue, Sep 28, 2010 at 5:19 PM, Pauli Virtanen <pav@iki.fi> wrote:
>> Tue, 28 Sep 2010 15:34:21 +0200, Nico Schlömer wrote:
>>
>>> Hi all,
>>>
>>> I was just running some test problems with scipy.sparse.linalg.cg and
>>> thing seem work work out fine.
>>> To compare preconditioners, I'd like to get more detailed information
>>> about the convergence history, but I haven't been able to figure out how
>>> to, e.g., get the number of performed iterations or the (relative)
>>> residual for each of those steps. Compare this with
>>> http://www.mathworks.com/help/techdoc/ref/pcg.html.
>>>
>>> Any hints?
>>
>> Use the 'callback' argument.
>>
>>>>> help(scipy.sparse.linalg.cg)
>> ...
>> callback : function
>>    User-supplied function to call after each iteration.  It is called
>>    as callback(xk), where xk is the current solution vector.
>> ...
>>
>>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User@scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-User mailing list