uncomplicate / neanderthal

Fast Clojure Matrix Library
http://neanderthal.uncomplicate.org
Eclipse Public License 1.0
1.06k stars 56 forks source link

weird issue, creating a dge interacts with existing vector? #86

Closed ftravers closed 4 years ago

ftravers commented 4 years ago

uncomplicate/neanderthal {:mvn/version "0.26.0"}

(with-release [x (dv 0.3 0.9)
               w1 (dge 4 2 [0.3 0.6
                            0.1 2.0
                            0.9 3.7
                            0.0 1.0]
                       {:layout :row})
               h1 (mv! w1 x (dv 4))
               w2 (dge 1 4 [0.75 0.15 0.22 0.33] {:layout :row})]
  h1)
;; #RealBlockVector[double, n:4, offset: 0, stride:1]
;; [2.12E-314 2.12E-314 3.6 .90]

  (with-release [x (dv 0.3 0.9)
                 w1 (dge 4 2 [0.3 0.6
                              0.1 2.0
                              0.9 3.7
                              0.0 1.0]
                         {:layout :row})
                 h1 (dv 4)]
    (mv! w1 x h1)
    h1)
;; #RealBlockVector[double, n:4, offset: 0, stride:1]
;; [   0.00    0.00    3.60    0.90 ]

Somehow this line

w2 (dge 1 4 [0.75 0.15 0.22 0.33] {:layout :row})

kills the h1 vector?

And its even the wrong answer I think? Should be like the following, I think:

  (with-release [w1 (dge 4 2 [0.3 0.6
                              0.1 2.0
                              0.9 3.7
                              0.0 1.0]
                         {:layout :row})
                 x (dv 0.3 0.9)]
    (mv w1 x))
;; #RealBlockVector[double, n:4, offset: 0, stride:1]
;; [   0.63    1.83    3.60    0.90 ]
blueberry commented 4 years ago

The REPL is printing the objects that have already being cleaned up (by with-release) by the time the printing occurs. Either use let, or print the objects inside the with-release scope.