Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala Breeze (a library for numerical processing); How to convert a DenseMatrix of Int's to a DenseMatrix of Doubles?

Using the Scala Breeze library :

How can I convert an instance of a breeze.linalg.DenseMatrix of Int values to a DenseMatrix of Doubles (both matrices have the same dimensions)?

(I am trying to get a image/picture in a matrix for image processing using Breeze)

like image 557
kos Avatar asked Dec 28 '25 15:12

kos


1 Answers

fotNelton's answer works. Another option is:

dm.mapValues(_.toInt)

or

dm.values.map(_.toInt)

As of Breeze 0.6, you can also say:

convert(dm, Int)
like image 91
dlwh Avatar answered Dec 31 '25 18:12

dlwh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!