Re: Determinant of Matrix

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed May 07 2014 - 11:44:22 MDT

To my knowledge, there is no NCL function that explicitly or
implicitly (ie, an attribute) returns the determinant.

===

Some NCL functions do calculate a determinant internally
(eg, 'solve_linsys') however these are not returned as part of solution.

https://www.ncl.ucar.edu/Document/Functions/Built-in/solve_linsys.shtml

===
An untested double precision f77 subroutine is attached. You could
alter to handle float if you wish.
+++
NOTE:

LAPACK, which is used by NCL functions, does not have an explicit
subroutine to calculate the determinant. If there was, NCL would
provide a function.

That said, a double precision LAPACK library is (silently)
distributed with NCL. You could use LAPACK's DGETRF
to compute an LU factorization of a real general M-by-N matrix.
Documentation is appended. The following URL shows how to use
the complex form of DGETRF (ZGETRF) to calculate a determinant.
I'm sure you could modify to handle double.

http://dualm.wordpress.com/2012/01/06/computing-determinant-in-fortran/

***

       SUBROUTINE DGETRF( M, N, A, LDA, IPIV, INFO )
*
* -- LAPACK routine (version 3.2) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2006
*
* .. Scalar Arguments ..
       INTEGER INFO, LDA, M, N
* ..
* .. Array Arguments ..
       INTEGER IPIV( * )
       DOUBLE PRECISION A( LDA, * )
* ..
*
* Purpose
* =======
*
* DGETRF computes an LU factorization of a general M-by-N matrix A
* using partial pivoting with row interchanges.
*
* The factorization has the form
* A = P * L * U
* where P is a permutation matrix, L is lower triangular with unit
* diagonal elements (lower trapezoidal if m > n), and U is upper
* triangular (upper trapezoidal if m < n).
*
* This is the right-looking Level 3 BLAS version of the algorithm.
*
* Arguments
* =========
*
* M (input) INTEGER
* The number of rows of the matrix A. M >= 0.
*
* N (input) INTEGER
* The number of columns of the matrix A. N >= 0.
*
* A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
* On entry, the M-by-N matrix to be factored.
* On exit, the factors L and U from the factorization
* A = P*L*U; the unit diagonal elements of L are not stored.
*
* LDA (input) INTEGER
* The leading dimension of the array A. LDA >= max(1,M).
*
* IPIV (output) INTEGER array, dimension (min(M,N))
* The pivot indices; for 1 <= i <= min(M,N), row i of the
* matrix was interchanged with row IPIV(i).
*
* INFO (output) INTEGER
* = 0: successful exit
* < 0: if INFO = -i, the i-th argument had an illegal value
* > 0: if INFO = i, U(i,i) is exactly zero. The factorization
* has been completed, but the factor U is exactly
* singular, and division by zero will occur if it is used
* to solve a system of equations.
*
* =====================================================================
*

On 5/7/14, 8:53 AM, Capehart, William J wrote:
> Hi All:
>
> Is there a Determinant of a Matrix deeply hidden in side of of the "return attributes" of an existing function or do I have to "WRAPIT" one myself.
>
> Just wonderin'
>
> Bill
>
>
>
> ================================================================
> Bill Capehart <William.Capehart@sdsmt.edu<mailto:William.Capehart@sdsmt.edu>> Associate Professor
> Department of Atmospheric & Envir. Sciences AES PhD Coordinator
> 213 Mineral Industries Building Skype/EVO: wcapehart
> South Dakota School of Mines and Technology Ph: +1-605-394-1994
> 501 East Saint Joseph Street Fax: +1-605-394-6061
> Rapid City, SD 57701-3995 Mobile: +1-605-484-5692
> =================== http://capehart.sdsmt.edu ==================
>
>
>
>
> _______________________________________________
> 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 Wed May 7 11:44:30 2014

This archive was generated by hypermail 2.1.8 : Fri May 09 2014 - 15:23:18 MDT