Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numeric.LinearAlgebra.Static: incorrect representation of compact diagonal matrices #291

Open
mistransky opened this issue Apr 1, 2019 · 1 comment

Comments

@mistransky
Copy link

Compact diagonal matrices are probably incorrectly represented. The following code demonstrates it by creating a 2x2 identity matrix, and tries to calculate its determinant, which should be 1.0. The code throws an exception that the input matrix is (1x3), non-square.

{-# Language DataKinds #-}

import Numeric.LinearAlgebra.Static

main :: IO ()
main = do
  let m = diag $ vec2 1 1
  print $ det m

produces output:

det of nonsquare (1x3) matrix CallStack (from HasCallStack): error, called at src/Internal/Algorithms.hs:664:21 in hmatrix-0.19.0.0-948a7582e6e481b024f5d19f7e12faf0d1021543381941caf40c72920d1a8233:Internal.Algorithms

GHC: 8.6.3, 8.6.4
hmatrix: 0.19.0.0
tried on Linux x86_64: Debian 9, Fedora 29

@mistransky
Copy link
Author

Looking through the source code, I take back that type-level sized compact diagonal matrices are incorrectly represented. It looks like that functions like det are simply not yet implemented for such representation:

detL :: KnownNat n => Sq n -> 
detL = LA.det . unwrap

What gets unwrapped is unfortunately a row vector with fill element in the first position, and the non-sized version of det is applied leading to an exception. There are probably more unimplemented functions like det for this representation. I take it, that the Static module is still very experimental..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant