Minor changes

15 views
Skip to first unread message

Juan Jose Garcia Ripoll

unread,
Oct 24, 2014, 4:36:16 AM10/24/14
to libt...@googlegroups.com
Two major changes:

* Tensor now reexports std::real, std::imag, std::abs, std::conj This
demands the existence of these functions, which are there since C++98,
so there should be no problem.

* 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.

Juanjo

P.S.: For your information, cgs() is an algorithm that works on
Hermitian matrices, ideally those that have a gap in the spectrum. Help
is welcome to implement other algorithms such as the biconjugate
gradient (bicgs) that are also present in Matlab.

Juan Jose Garcia Ripoll

unread,
Oct 24, 2014, 9:06:31 AM10/24/14
to libt...@googlegroups.com
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);



Reply all
Reply to author
Forward
0 new messages