Clone this wiki locally
Scalala is the numerical linear algebra library for Scala, supporting rich Matlab-like operators on vectors and matrices, and a library of numerical and plotting routines. Scalala takes it inspiration from numerical programming environments such as Matlab and R, that can easily express linear algebra as simple expressions involving matrices, vectors and scalars. However, general purpose programming with richer data structures in these environments ranges from slow to painful. Scalala is designed to marry the syntax of interactive numeric environments, the performance of dedicated linear algebra libraries, and the flexibility of general purpose programming in Scala.
Scalala's type system extends the designed of the Scala 2.8 collections with rich data types supporting numerically valued collections, such as vectors (with an
Int key and any numerical value) and matrices (with an
(Int,Int) key). Scalala defines operators on these collections that allow them to be manipulated in a statically type-safe way with simple syntax like
x.t * x for an inner product of two vectors, where
x.t transposes the column vector
x to a row vector:
val x = DenseVector(1,2,3); x.t * x == 14 x * x.t == DenseMatrix((1,2,3),(2,4,6),(3,6,9))
The library also enriches Scala's built-in collection types with similar operators and numerical routines. You can do math on arbitrarily nested numerically valued collections and tuples:
import scalala.operators.Implicits._ Map("a" -> 1, "b" -> 2) * 2 == Map("a" -> 2, "b" -> 4) (1,2) + (5,1) == (6,3) Array(2,3,4) :/ 2.0 == Array(1.0,1.5,2.0) (List(1,2), Map("a"->1.0, "b"->2.0)) + 1 == (List(2,3), Map("a"->2.0, "b"->3.0))
Scala's implicit resolution rules allow highly optimized code-paths to be plugged into the library in a type-safe way, meaning that Scalala defers to LAPACK and BLAS wherever possible.
The library also supports matlab-like plotting routines. When combined with the Scala interpreter, Scalala is an able Scala-hosted interactive data analysis platform.