Questions tagged [scala-breeze]

Breeze is a linear algebra library for Scala.

Breeze is a linear algebra library for Scala.

From the project's GitHub page:

Breeze is a library for numerical processing, machine learning, and natural language processing. Its primary focus is on being generic, clean, and powerful without sacrificing (much) efficiency. Breeze is the merger of the ScalaNLP and Scalala projects, because one of the original maintainers is unable to continue development.

197 questions
3
votes
1 answer

Creating a Breeze DenseMatrix using an existing List of Lists in Scala

I've a List[List[Int]] = List(List(1, 2, 3, 0, 0, 0, 0, 0, 0), List(0, 0, 0, 1, 2, 3, 0, 0, 0), List(0, 0, 0, 0, 0, 0, 1, 2, 3)) and I want to create a Matrix/DenseMatrix with 3 rows and 9 columns so that I can perform some Linear Algebra…
Soumya Simanta
  • 11,523
  • 24
  • 106
  • 161
3
votes
1 answer

How can I read an hdf5 matrix using scala/breeze?

I am using the Breeze library in Scala. Is there a simple way to read an HDF5 dataset into a matrix (presumably using the Java HDF5 interface)?
Jim Garrison
  • 4,199
  • 4
  • 25
  • 39
3
votes
2 answers

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…
kos
  • 51
  • 3
3
votes
2 answers

Using Scala Breeze to do numPy style broadcasting

Is there a generic way using Breeze to achieve what you can do using broadcasting in NumPy? Specifically, if I have an operator I'd like to apply to two 3x4 matrices, I can apply that operation element-wise. However, what I have is a 3x4 matrix and…
Dave DeCaprio
  • 2,051
  • 17
  • 31
2
votes
1 answer

Using -= with incompatible types (Double and DenseVector) causes strange scala compiler error

I am rather new to scala and having encountered an initially completely uninformative NullPointerException by the scala compiler I was now able to narrow down the issue and remove it's cause, but I still don't fully understand the compiler's…
Beztix
  • 21
  • 3
2
votes
1 answer

Cant Access Matrix Rows Inside DiffFunction

I am trying to run this simple program: object Test { def foo(args: (Double, Double, Double)*) = { val x = DenseMatrix(args.toList :_*) val r = DenseVector(5.0, 5.0, 0.0) println(sum(x(*, ::) - r)) // works val func = new…
Michael
  • 427
  • 1
  • 3
  • 13
2
votes
0 answers

Breeze - Apply a functions to a DenseVector to get a DenseMatrix

Given some vector of numbers, I want to apply a different function to the vector and get a matrix of the results. Is there an idiomatic way of doing this in breeze? import breeze.linalg._ val dv = DenseMatrix(0.0, 5.0, 6.0, 3.0, 7.0) val someOpDef =…
Simon
  • 323
  • 2
  • 15
2
votes
0 answers

Import not found outside of class scope

I'm running the Scala code below in a Zeppelin notebook, on an Azure HDInsight instance. %livy2.spark import breeze.linalg.DenseVector var foo: DenseVector[Double] = DenseVector.zeros[Double](1) class ClassBar() { var baz: DenseVector[Double]…
2
votes
1 answer

scala breeze, remove column or row from matrix

Is it possible to remove one or more columns or rows from a matrix in breeze? It's possible in matlab by setting it to an empty matrix but in breeze u get a dimension error.
user25470
  • 585
  • 4
  • 17
2
votes
1 answer

How to Elementwise Sum a Sequence of DenseVectors in Breeze

I have a sequence of DenseVector[Double] and I would like to sum them elementwise to get a single DenseVector[Double]. Is there an easy built-in way of doing this in the Breeze Scala library?
user1893354
  • 5,778
  • 12
  • 46
  • 83
2
votes
1 answer

Why does Breeze use Array to represent a matrix?

The class DenseMatrix has a parameter data of type Array[V]. Why not using some other mutable collection that can grow dynamically, such as Vector?
Hari Bage
  • 31
  • 3
2
votes
1 answer

How to specify java runtime option in build.sbt or intellij-idea

I am trying to learn scala and this is my first language on the JVM, so apologies for asking what is probably a basic question. I am trying to use a specific BLAS/LAPACK library for netlib-java. This can be achieved by adding the sbt flag: sbt…
Lindon
  • 1,292
  • 1
  • 10
  • 21
2
votes
1 answer

Fitting linear model in Scalanlp/Breeze

I try to fit a linear model (and get the R^2) to the following test-data 0.0 0.0 1.0 1.0 2.0 2.0 3.0 3.1 I wrote the following code using scalanlp/breeze 0.12 : import breeze.linalg.{DenseMatrix, DenseVector} import…
Raphael Roth
  • 26,751
  • 15
  • 88
  • 145
2
votes
1 answer

Workaround for chained indexing Scala compiler error?

Chained indexing in ND4S and Breeze produces a Scala compiler error: var m = Nd4j.create(2, 3) var a = m(0, ->) var b = a(0) var c = m(0, ->)(0) The first two work but the third produces: not enough arguments for method apply: (implicit ev:…
Sam
  • 385
  • 1
  • 10
2
votes
0 answers

scala.MatchError while unpickling json string of DenseVector

I tried pickling and unpickling an object of Breeze's (https://github.com/scalanlp/breeze) DenseVector class (http://www.scalanlp.org/api/breeze/#breeze.linalg.DenseVector). Didn't need to add any custom picklers. While pickling succeeded,…
devendraj
  • 21
  • 3
1 2
3
13 14