|Re: [eigen] TriangularView::solve() interface|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] TriangularView::solve() interface
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 25 Aug 2009 19:27:28 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=y7ynfJLOn7rdiXQmWxX2dNHM8jSZYapLZomCJTjMvJE=; b=g6fosj3inGhrh0y+NybFmfK70Z76G1Tbo4s06oYQ3A07TSjGuJ+XBR1JcKveKwfauC TkZdNKrjGI1dXUONuu2fGX5gutQwLn13CAY8Jf/lFOsh2EeKObDXhyQCbtp3vIpG7zOL TaA3iocfyhqUbQBhvS+XN8m1M9BlkuO6ClJac=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=tb5+xwQLrvrSwbP6lCeEY4PwXpd1DeM3mIydd+NComppKJjp/vsdjUR6jeuQym1QXW YAdDP4kaxwglQRC2ubjhtPH+FAbvO5RLsyB4wh+sLkvnVl4xjPBsY99JyiNXvSnMR0Js LEdZRF9IscUZYCxHTSx1wSA+1+yn1TnLztwxY=
As I'm going to explain ASAP in a mail to this list, I believe that we
can drop altogether the "bool success" in all solve() methods.
There remains the choice of an API between
API 1: a.solve(b,&result)
API 2: result = a.solve(b)
The main argument in favor of API 1 is the one Keir mentions.
But what about the wonderful little ReturnByValue class that Gael
wrote? I suggest we investigate that, at the moment I don't see why it
wouldn't work here! It would allow to have API 2 with the guarantee of
it unfolding to the same as API 1.
Maybe Gael can comment.
Meanwhile, is there consensus that, if it works, then we want it?
Again, this is assuming that the bool return value are removed, i'm
going to write to the list to advocate that.
2009/8/25 Keir Mierle <mierle@xxxxxxxxx>:
> I had some thoughts about this, so before I forget:
> On Mon, Aug 24, 2009 at 7:36 AM, Jitse Niesen <jitse@xxxxxxxxxxxxxxxxx>
>> While rewriting part of the tutorial, I noticed that the new
>> TriangularView::solve() function returns the solution vector, while the
>> other solve functions pass the solution via one of the parameters. Compare
>> x = A.triangularView<UpperTriangular>().solve(b);
> With this interface, are we guaranteed that NVRO will work? In other words,
> are we sure this won't force memory copies and reallocations? With the
> pointer interface, I am confident that eigen will do the right thing if my
> matrix is the right size. With the return value, I have less control. In
> particular, I believe you are only guaranteed that the following:
> Matrix<...> x = A.lu().solve(b)
> will directly construct x instead of via a temporary. Consider:
> Matrix<double, HUGE, HUGE> x = A.lu().solve(b); // Ok, NVRO works here
> // ...
> // ...
> // form new b
> x = A.lu().solve(b) // Oops! x is already constructed, so here we must
> create a temporary and copy.
> Many numerical problems involve solving systems with the same dimensions
> repeatedly; it would be a shame if there was no ability to avoid the price
> of large temporaries.
>> A.partialLu().solve(b, &x);
> An alternative, which I am not necessarily advocating because of the reasons
> above, is the following:
> bool success;
> x = A.partialLU().solve(b, &success);
> This has the benefit that success can be an optional parameter, and the API
> becomes uniform.
> Yet another thought:
> If we make the solver interfaces like the following:
> bool maybe_success = A.lu().solve(b, &x);
> and changed the meaning of the return value to the following:
> If the return value is true, then the solve *may* have succeeded. If the
> return value is false, then the system *definitely* did not solve. This way
> we can use the same API everywhere, and ignore the return value in cases
> where it's known that the algorithm always returns true. Each solve()
> implementation will declare what behaviour it has regarding success, with
> the default behaviour to always return true.
>> Was this done on purpose?
>> The docs on the eigen website  were magically updated, but some of the
>> latex was not parsed correctly. Am I doing anything wrong? Everything works
>> fine on my own computer.
>> Something to perhaps add to the to-do list: a routine to estimate the
>> condition number of a matrix based on the LU decomposition.