help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inverse Matrix Function appears a bit wonky


From: David Bateman
Subject: Re: Inverse Matrix Function appears a bit wonky
Date: Fri, 5 Nov 2004 14:40:35 +0100
User-agent: Mutt/1.4.1i

According to John W. Eaton <address@hidden> (on 11/05/04):
> On  5-Nov-2004, David Bateman <address@hidden> wrote:
> 
> | There is indeed a significant speed difference, which is why I submitted
> | a patch to add the calc_cond option to the inverse functions. I noticed
> | a significant speed penalty on this point in the sciview benchmarks.
> | 
> | What is always calculated by LAPACK is rcond, which is an estimate of
> | the reciprocal of the condition number. If you request the condition
> | number then "{z,d}gecon" is called that calculates not just an
> | estimate, but the real thing.
> 
> I'm not sure what has happened, but the code in inv.cc never calls
> Matrix::inverse with four arguments, so the calc_cond argument
> always has the default value of 1 (which says to compute the condition
> number).

If Matrix::inverse(void) ot Matrix::inverse(int&) are called then call
translates to

Matrix
Matrix::inverse (int& info) const
{
  double rcond;
  return inverse (info, rcond, 0, 0);
}

So calc_cond is zero in this case, though info flags returned by dgetri
will be positive indicating that the matrix is singular, and you convert
all non zero info flags to -1. Therefore Finv will know that the matrix
is singular.

The problem as you say that in Finv, it doesn't check for the number of 
nargout and call the right version of Matrix::inverse. It looks like part
of this patch went AWOL.

> If the condition number is not calculated, there seems to be no way to
> detect at least some numerically singular matrices.  It seems that
> DGETRF can return INFO == 0 even for exactly singular matrices like
> [1,2,3;4,5,6;7,8,9].  For example, try the following program:
<snip>
> So if we don't compute the condition number, we have no way of warning
> the user that the matrix that they just inverted is numerically
> singular.  That seems bad to me (and is why this whole thread started
> in the first place).

Err, yes well you're right its bad.. So we forget the speed benifit of
not calculating the condition (which is minor, about 10% if I remember
correctly) and always flag properly a singular matrix...

Cheers
David

-- 
David Bateman                                address@hidden
Motorola CRM                                 +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax) 
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]