Re: [eigen] solve API |

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [eigen] solve API*From*: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>*Date*: Mon, 28 Jun 2010 14:30:10 -0400*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=89FL5UGInJz6LJYXnhqIEVOWA2GMiJ15mgHahMtlYRQ=; b=UOkaQ+3+m+ff6wNQ8JRjzrBEVliApew501Jj6OF9xWmQIuTYngEe8D2gGyY3tS26uu MswQjjzbkTYHHrU4Bfqo/ZnE/7eNjxgN3pp7vVkQtxwY3PTyhr+j8BJEgo4aSkgVVBwv 8QB7HZ4+iHj8f1VcwNsqt1+rNlX94GBOthXjk=*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=lAmyUvb6TN2Ax5o42i49w22oUOPL0weYvHAkq7cxXiA04L/gKHK99UZb4DiNT54Uez q66pqaPvROP+Pf+sJY/5Nf5A0DkgSB1ttTYgAtmUqXTkK+yskV4h4lkE6ywz3wDOOLV0 oTWJIn3lO9As6j0kbaBR6jnrhU7QESMp5MaO8=

2010/6/28 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>: > On Mon, Jun 28, 2010 at 5:15 PM, FMDSPAM <fmdspam@xxxxxxxxx> wrote: >> Just my 2 cent: >> >> I know, that expression do not have to be evaluated but nevertheless >> I would try to avoid the word "inverse()", because of lession #1: "Never use >> matrix inversion". > > This rule exists only because of the poor implementation/API of the > other libs ;) > > I'm kidding, I see your point, but I don't see it as a strong argument > against inverse. > > In books you never use "solve" in your mathematical formula, but > always write, e.g., A^1 B. Wouldn't it be convenient to be able to > write code which closely follow what you found in a textbook, or to > write code as you write formulas on your paper sheets without worrying > about performance? In math, one indeed says A^-1 B when A is invertible. Or at least when A is injective (so it makes sense as the unique element of A^-1({B}) ). But I've never seen A^-1 B used when A isn't injective. In that case, one says in plain text "let X be a solution of AX=B". There is no way to write that as a formula. So I see your point in the invertible case, but I feel that there is a problem in the non-invertible case. Since invertibility is a numerical issue, I agree not to let it impact the API. But at least, non-square matrices should be banned. How about this proposal: - call it solver() in the general case - add inverse() as another method that checks that the matrix is square, and returns solver(). Of course, in all decompositions that are restricted to square matrices, no need for solver(), so this amounts to just your proposal: inverse(). Benoit > Actually, I'm pretty sure that many newcomers to > linear algebra do not know about these details, and simply write what > they read in their favorite book: A.inverse() * B (I've seen that > several times). So if A.inverse() would return a A.lu().inverse() > proxy, then no more worry. > >> >> What about >> >> x = b * A.adjoint().lu().invertor() (like benoit's solver()) >> > > As I said to Manoj, this is not equivalent to have the adjoint applied > on the inverse proxy (lu.inverse().adjoint()) because I want to be > able to use the LU dec to solve both adjoint and non adjoint problems. > > So it should be: > > LU<> lu(A); > > x = lu.invertor() * b; > y = lu.invertor().adjoint() * b; > > but "invertor().adjoint()" is a bit weird. Nonetheless, I prefer > invertor() to solve() or solver(). > > >> >> But cleaner for me to read is, what Manoj suggesting: >>> >>> x = solve(A,b); // left >>> x = solve(b,A); // right >>> x = solve(b, A.triangularView<Lower>()); // Gael's example >> >> It's OK to read and understand w/o scarring about "inverse()" too. > > it is really ambiguous because > > x = solve(b,A); > > can mean x = b^-1 A, and anyway this proposal works at a different > level that the one we are considering. > > cheers, > gael > >> >> --Frank >> >> >> > > >

**Follow-Ups**:**Re: [eigen] solve API***From:*Gael Guennebaud

**References**:**[eigen] solve API***From:*Gael Guennebaud

**Re: [eigen] solve API***From:*Manoj Rajagopalan

**Re: [eigen] solve API***From:*FMDSPAM

**Re: [eigen] solve API***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] solve API** - Next by Date:
**Re: [eigen] solve API** - Previous by thread:
**Re: [eigen] solve API** - Next by thread:
**Re: [eigen] solve API**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |