neanderthal icon indicating copy to clipboard operation
neanderthal copied to clipboard

Display of RealBlockVector with large values is off (printing only)

Open maersdal opened this issue 3 years ago • 1 comments

I don't know if this is just my setup, or an actual bug in the printing of these vectors. It is a visual/printing issue only I think.

Experienced issue:

(ns sauce
  (:require [uncomplicate.neanderthal 
             [core :refer [scal]] 
             [native :refer [dv]]]))
(println  (scal 2000 (dv -1 2 5.2 0)))

outputs

#RealBlockVector[double, n:4, offset: 0, stride:1]
[-2.00E+34.00E+3 1.04E+4 .00     ]

nil

Whats wrong:

  • The spaces are at the end (?) so 2000 followed by 4000 it looks like -2x10^34 ...
  • The leading zero of the last element is gone, expected 0.00, or 0, not .00

expected output

#RealBlockVector[double, n:4, offset: 0, stride:1]
[-2.00E+3 4.00E+3 1.04E+4 0.00]

nil

My system:

  • OS: WSL2 with ubuntu 20.04,
  • clj with deps.edn

editor:

  • VS code with Calva using nrepl and cider middleware (standard jack-in)

Now It could probably be solved with a print-method, but I'm a beginner and don't know how to do that yet.

maersdal avatar Jan 12 '21 17:01 maersdal

To change how things print you should take a look in here: https://github.com/uncomplicate/neanderthal/blob/5c76fb83eb43b7aa3307e6e90d5025e41750a00f/src/clojure/uncomplicate/neanderthal/internal/printing.clj

I've definitely done this before.. if I find my code I'll update this comment later

kxygk avatar Apr 13 '22 12:04 kxygk