[ncl-talk] Need a solution for calculate Determinant of a (rather) large matrix

Dennis Shea shea at ucar.edu
Tue Jul 10 07:59:50 MDT 2018


Normally, NCL would use an LAPACK code to compute a mathematical quantity.
However, LAPACK contains no such subroutine due to issues with accuracy and
stability:


http://www.netlib.org/lapack/faq.html#_are_there_routines_in_lapack_to_compute_determinants

Really, 'they' (applied mathematicians) do not want people calculating the
determinant.
===

NCL uses a computer program from:

    An Introduction to  Computational Physics, Tao Pang (Cambridge
University Press,1997).
===

The use of integer or float values as input should have no effect. All
non-double input is promoted to double prior to input to the fortran code
used to perform the calculations.

I have no idea why you are encountering extremely long execution times. My
6.3.0 [MAC] returns a result more or less immediately. What version of gcc
do you have installed? Please send the output from the following:

%> uname -a

%> gcc --version

====
That said:  I have tried to calculate the determinant with N=41

   N = 41
   x = random_uniform(0,5,(/N,N/))
   d = determinant(x)                          ; VERY fast; instantaneous
return value
   print(d)

Variable: d
Type: float
Total Size: 4 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:   [1]
Coordinates:
(0)

*1.767279e+31       <====  ????  I have no idea what the correct answer is*
Ummm, rather large number!!!

====
I will open a JIRA trouble ticket and ask the core NCL developers if
everything looks good.

====
Again, echoing LAPACK, calculating a determinant has issues.

Regards

On Tue, Jul 10, 2018 at 6:34 AM, Lam Hoang <lamhpvn at gmail.com> wrote:

> Dear all,
> I want to calculate determinant of a 41x41 real (float) matrix. I used
> determinant() function
> https://www.ncl.ucar.edu/Document/Functions/Built-in/determinant.shtml
>
> However it is very slow.
>
> I try to run the sample in the above page, it's quick. Even if I replace
> integer values by float values (i.e replace 1 by 1.0, 0 by 0.0 and so on)
> I try to create a 4x4 real matrix, give all members a value of 1.0
> It seems that the determinant() function runs forever and does not return
> any value
>
> In the following illustration, a is sample matrix after replacing integer
> by float values. It takes NCL few seconds to return the value d = 30
>
> x is new 4x4 matrix created by my new() function, it never gives me any
> result.
>
> *Variable: a*
>
> *Type: float*
>
> *Total Size: 64 bytes*
>
> *            16 values*
>
> *Number of Dimensions: 2*
>
> *Dimensions and sizes: [4] x [4]*
>
> *Coordinates: *
>
> *(0) d = 30*
>
>
> *Variable: x*
>
> *Type: float*
>
> *Total Size: 64 bytes*
>
> *            16 values*
>
> *Number of Dimensions: 2*
>
> *Dimensions and sizes: [4] x [4]*
>
> *Coordinates: *
>
>
>
> Any suggestion or solution for this?
>
> Regards,
>
>
> p/s: I am using NCL v6.3.0
>
> --
> Lam Hoang, PhD
> Chief of Climate Prediction Division,
> Viet Nam National Center of Hydro-Meteorology Forecasting
> National Hydro-Meteorological Services of Vietnam
> 8 Phao Dai Lang street, Lang Thuong, Dong Da, Ha Noi, Vietnam
> Mob: +84 9 682 34 682
>
> Associate Researcher,
> School of Earth, Atmosphere and Environment
> Monash University, VIC 3800
> Email: lam.hoang at monash.edu
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180710/ec6e609e/attachment.html>


More information about the ncl-talk mailing list