haskell-numerics / hmatrix

Linear algebra and numerical computation
381 stars 104 forks source link

Fixed vector show instance and related haddock entries. #270

Closed pdobsan closed 6 years ago

pdobsan commented 6 years ago

The show instance was changed in vector 0.11. The merged modifications adjust hmatrix/base to that change. That fixes issues #227 and #177.

idontgetoutmuch commented 6 years ago

Does anyone know why CI didn't run for this PR? @nh2?

pdobsan commented 6 years ago

Regarding CI: That could have been my fault, at first attempt I referred to a wrong (non existent) issue number in the comment. I fixed this by editing the comment.

About test: Actually I kind of used one, but that is being a game of inspecting the result visually I do not know how to incorporate this process into a proper test. Here is the Lib module of that small app:

{-# LANGUAGE DataKinds #-}

module Lib
    ( vecShowTest
    ) where

import Numeric.LinearAlgebra.Static
import qualified Numeric.LinearAlgebra as LA
import qualified Numeric.GSL.Minimization as Min

u = vec4 10 20 30 40
v = vec2 5 0 & 0 & 3 & 7

b = matrix
    [ 2, 0,-1
    , 1, 1, 7
    , 5, 3, 1
    , 2, 8, 0 ] :: L 4 3

w = vector [1..10] :: R 10

f [x,y] = 10*(x-1)^2 + 20*(y-2)^2 + 30

vecShowTest :: IO ()
vecShowTest = do
    print u
    print v
    print b
    print w
    print $ diag u
    print (eye + 2 :: Sq 4)
    print $ LA.diag (LA.fromList [1,2,3 :: Double])
    --
    let (s,p) = Min.minimize Min.NMSimplex2 1E-2 30 [1,1] f [5,7]
    print s
    print p

And that's the output:

(vector [10.0,20.0,30.0,40.0] :: R 4)
(vector [5.0,0.0,0.0,3.0,7.0] :: R 5)
(matrix
 [ 2.0, 0.0, -1.0
 , 1.0, 1.0,  7.0
 , 5.0, 3.0,  1.0
 , 2.0, 8.0,  0.0 ] :: L 4 3)
(vector [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0] :: R 10)
(diag 0.0 [10.0,20.0,30.0,40.0] :: L 4 4)
(diag 2.0 [3.0,3.0,3.0,3.0] :: L 4 4)
(3><3)
 [ 1.0, 0.0, 0.0
 , 0.0, 2.0, 0.0
 , 0.0, 0.0, 3.0 ]
[0.992043084930623,1.9969168063252665]
(24><5)
 [  1.0,              512.5,     1.130388330520878,                     6.5,                5.0
 ,  2.0, 290.62499999999943,    1.4092945437739812,                    5.25,  3.999999999999993
 ,  3.0, 290.62499999999943,    1.4092945437739812,                    5.25,  3.999999999999993
 ,  4.0,  252.5000000000007,    1.4092945437739812,                     5.5, 0.9999999999999822
 ,  5.0, 101.40624999999866,    1.8474832731162802,                   2.625,  3.499999999999978
 ,  6.0, 101.40624999999866,    1.8474832731162802,                   2.625,  3.499999999999978
 ,  7.0, 59.999999999998366,    1.8474832731162802, -1.7763568394002505e-15, 2.9999999999999583
 ,  8.0, 42.275390625000156,    1.3213162892022134,       2.093749999999999, 1.8749999999999656
 ,  9.0,  35.68420410156273,     1.068946182854996,     0.25781249999999667, 1.9062499999999516
 , 10.0,  35.66440582275317,    0.8409024133398828,      0.5878906249999976, 2.4453124999999574
 , 11.0, 30.680086612701363,   0.47615303278349647,      1.2583007812499978,  2.025390624999959
 , 12.0, 30.680086612701363,   0.36729204659991477,      1.2583007812499978,  2.025390624999959
 , 13.0, 30.538867646828564,    0.2995597112537205,      1.0926208496093706, 1.8494873046874536
 , 14.0, 30.137329032295384,   0.17243254444062853,        0.88295745849609, 2.0041198730468297
 , 15.0, 30.137329032295384,    0.1261625605790985,        0.88295745849609, 2.0041198730468297
 , 16.0, 30.090488905627698,   0.10621986093517005,      0.9581913948059037,  2.060419082641554
 , 17.0, 30.005106627602476,  6.264489592911397e-2,      1.0218096971511799, 2.0041832923888694
 , 18.0, 30.005106627602476,  4.338565210772595e-2,      1.0218096971511799, 2.0041832923888694
 , 19.0, 30.005106627602476,  4.338565210772581e-2,      1.0218096971511799, 2.0041832923888694
 , 20.0, 30.005106627602476, 2.7426309223472823e-2,      1.0218096971511799, 2.0041832923888694
 , 21.0, 30.005106627602476, 2.1880086558587433e-2,      1.0218096971511799, 2.0041832923888694
 , 22.0,  30.00082324663893,  1.567028446199071e-2,       0.992043084930623, 1.9969168063252665
 , 23.0,  30.00082324663893, 1.3369595417230918e-2,       0.992043084930623, 1.9969168063252665
 , 24.0,  30.00082324663893,  7.958657037734847e-3,       0.992043084930623, 1.9969168063252665 ]

Apart from this script, I used ghci as I was going through the docs and copied back the pieces.

idontgetoutmuch commented 6 years ago

The CI doesn't kick in for this PR because the administrator (@albertoruiz in this case) has to enable CI for all PRs not just for collaborators (I am a collaborator). @albertoruiz I think it would be easier for you to transfer the project to the organisation I mentioned in my recent email. That way I can make the necessary changes.

idontgetoutmuch commented 6 years ago

I will create a test with what you have provided and create a PR which will trigger CI. Hopefully then I can do the merge.

idontgetoutmuch commented 6 years ago

I believe CI will now kick in if you make a change. Perhaps you can e.g. squash your commits or make some minor change and push. Hopefully CI will then run.

pdobsan commented 6 years ago

On Thu, May 03, 2018 at 12:52:45AM -0700, idontgetoutmuch wrote:

I believe CI will now kick in if you make a change. Perhaps you can e.g. squash your commits or make some minor change and push.

I've made a minor change and pushed it. It seems to be working, current status: Pending CircleCI is running your tests.

idontgetoutmuch commented 6 years ago

@pdobsan I promise to look at this tomorrow