haskell-numerics / hmatrix

Linear algebra and numerical computation
381 stars 104 forks source link

Triangular matrices #221

Closed idontgetoutmuch closed 7 years ago

idontgetoutmuch commented 7 years ago

I have a triangular matrix so it seems one ought to be able to use dtrtrs rather than dgetrs but it's not clear how to add this.

I can see

foreign import ccall unsafe "luS_l_R" dgetrs :: R ::> R :> R ::> Ok

in LAPACK.hs so I look for a C function lus_l_R.

I can see

int luS_l_R(KODMAT(a), KDVEC(ipiv), ODMAT(b)) {

in lapack-aux.c which ultimately calls

int dgetrs_(char *trans, integer *n, integer *nrhs,
    doublereal *a, integer *lda, integer *ipiv, doublereal *b, integer *
    ldb, integer *info);

which I believe is in LAPACK itself (but why the underscore at the end?).

So do I need to create a function similar to lus_l_R? And if so what should I call it?

Any other help or tips would be gratefully received.

Actually I think I can copy the code for symmetric positive definite real linear systems. I will continue and cry for help when I get stuck.

albertoruiz commented 7 years ago

The underscore is the suffix of the fortran function names when they are used from C.

In principle I have no plans to add full support for triangular matrices but any specific function will be welcome. I hope the needed code will be similar to the existing one. I don't have much time at the moment for low level lapack programming but let me know if you get stuck.

idontgetoutmuch commented 7 years ago

Thanks - I have it working on my machine and have created a PR.