From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>

Date: Fri Apr 26 2013 - 07:32:19 MDT

Date: Fri Apr 26 2013 - 07:32:19 MDT

Hi Will

Both NCL functions are merely interfaces to LAPACK codes.

Both use the LAPACK DGETRF to perform the LU factorization.

The description for 'inverse_matrix' contains

" However, if efficiency is a concern, this is not the preferred method

(see solve_linsys)."

Hence, 'solve_linsys' looks like the way to go.

-----

solve_linsys: DGESV (DGETRF, DGETRS)

driver: http://www.netlib.org/lapack/double/dgesv.f

lu-fact: http://www.netlib.org/lapack/double/dgetrf.f

solver: http://www.netlib.org/lapack/double/dgetrs.f

-----

inverse_matrix: DGETRF, DGETRI

lu-fact: http://www.netlib.org/lapack/double/dgetrf.f

inverse: http://www.netlib.org/lapack/double/dgetri.f

D

On 4/25/13 6:56 PM, Will Hobbs wrote:

*> Hi all
*

*>
*

*> The documentation for the inverse_matrix() function states that it uses LU factorisation to invert, but also states that for most solutions the function solve_linsys() is more efficient, but it also uses LU factorisation.
*

*>
*

*> Theoretically, that means that for an invertible matrix A,
*

*>
*

*>> Ainv = inverse_matrix(A)
*

*>
*

*> is the same as
*

*>
*

*>> I = conform(A, 0, -1) ;create identity matrix 'I'
*

*>> do i = 0, nrow-1
*

*>> I(i,i) = 1
*

*>> end do
*

*>> Ainv = solve_linsys(A, I)
*

*>
*

*> Mathematically they're the same, but is there any way in which the functions are coded that would make one more efficient than the other? Or is the 'inverse_matrix()' function just doing what I did in the second case?
*

*>
*

*> I'm dealing with large covariance matrices for a lot of model control runs, so even a modest difference in efficiency would be interesting to know.
*

*>
*

*> Many thanks
*

*>
*

*> Will
*

*>
*

*>
*

*>
*

*>
*

*> _______________________________________________
*

*> ncl-talk mailing list
*

*> List instructions, subscriber options, unsubscribe:
*

*> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
*

*>
*

_______________________________________________

ncl-talk mailing list

List instructions, subscriber options, unsubscribe:

http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Fri Apr 26 07:32:23 2013

*
This archive was generated by hypermail 2.1.8
: Fri Apr 26 2013 - 17:10:25 MDT
*