Closed sid-kap closed 6 years ago
The Show instance of the diagonal matrix shows the internal, compact representation, including the default value and the diagonal elements. We can show the expanded matrix using disp
(the argument is the number of desired decimal places, but if all elements look like integers the decimals are not shown).
λ> eye :: L 0 0
(matrix
[] :: L 0 0)
λ> eye :: L 1 1
(1.0 :: L 1 1)
λ> disp 3 (eye :: L 1 1)
L 1 1
1
λ> eye :: L 2 2
(diag 0.0 [1.0,1.0] :: L 2 2)
λ> disp 3 (eye :: L 2 2)
L 2 2
1 0
0 1
λ> eye :: L 3 3
(diag 0.0 [1.0,1.0,1.0] :: L 3 3)
λ> disp 3 (eye :: L 3 3)
L 3 3
1 0 0
0 1 0
0 0 1
λ> eye :: Sq 7
(diag 0.0 [1.0,1.0,1.0,1.0,1.0,1.0,1.0] :: L 7 7)
λ> disp 3 (eye :: Sq 7)
L 7 7
1 0 0 0 0 0 0
0 1 0 0 0 0 0
0 0 1 0 0 0 0
0 0 0 1 0 0 0
0 0 0 0 1 0 0
0 0 0 0 0 1 0
0 0 0 0 0 0 1
But it seems that some elements and square brackets are missing in your results. Are you using iHaskell or something similar?
I'm using ghci, by the command stack ghci
, using Stackage lts-5.2 on GHC 7.10.3. This error also happens to me in compiled programs that I build with stack (also using lts-5.2 and GHC 7.10.3).
Potentially related.
*Radoye.Megamind.Interpret.Forward> y
(vector0,5.0,11.0,19.0] :: R 5)
*Radoye.Megamind.Interpret.Forward> LAS.disp 3 y
R 5
-1 1 5 11 19
*Radoye.Megamind.Interpret.Forward>
In my stack.yaml I have:
resolver: lts-7.13
packages:
- '.'
extra-deps:
- hmatrix-0.18.0.0
Seems like Show instances have some magic numbers hard coded. Did the underlying printer change?
I think there might be an error with the
Show
instance for diagonal matrices, at least for Static matrices. Here is an example in ghci:Note that the 1x1 instance displays correctly, but the 2x2 and 5x5 instances do not.
Can anyone else reproduce this?