On Fri, 2014-10-24 at 10:38 +0200, Juan Jose Garcia Ripoll wrote:
> * Added a conjugate gradient solver of linear equations, linalg::cgs. It
> works much like linalg::solve() but, being iterative, it demands an
> optional initial state and some iteration and tolerance limits. Tests
> for cgs and solve have been added as well.
Along this line, the library starts to implement some generic versions
of their functions so that they work with closures. The first experiment
takes place with cgs(), which now admits closing over functions using
our own kludgy syntax, but this should include eigs() and eigs_sym() in
the near future.
One example of the current syntax would be
const RTensor mymap(const RTensor &x, const RTensor &A)
{
return mmult(A, x);
}
...
RTensor B = random_unitary(12);
RTensor y = RTensor::random(igen << 12);
cgs(with_args(mymap,B), y);
But hopefully this will also work with closures as in
RTensor B = random_unitary(12);
RTensor y = RTensor::random(igen << 12);
cgs([=](const RTensor &x) { return mmult(B, x); }, y);