-
Notifications
You must be signed in to change notification settings - Fork 689
UserGuide
This guide aims to be a little more in-depth than the QuickStart, which is more of a tour of the high level features of Breeze. There is also the Breeze Linear Algebra guide, which functions as a cheat sheet, especially for Matlab and Numpy users. Much of this guide is patterned after the NumPy User Guide. API documentation is available at http://www.scalanlp.org/api.
- Introduction
-
Breeze Basics
-
Vectors and Matrices
- Creating Vectors and Matrices
- DenseVector
- DenseMatrix The goal of Breeze is to be the scientific computing platform for Scala. It is patterned after NumPy, Matlab, and R, to varying degrees, but tries to make sure everything is "Scalaic". At the moment, Breeze provides dense linear algebra, numerical routines, optimization, random number generation, and more.
-
Vectors and Matrices
At the core of Breeze is the Tensor hierarchy, which includes DenseVector, DenseMatrix, SparseVector, HashVector, CSCMatrix, Counter, and Counter2. These data structures are designed to be efficient, using existing native libraries for operations where possible (based on the jblas library), and code generated loops where not.
Breeze currently has supports for Vectors and for Matrices, with higher-arity tensors possible in the future. XXX
All math-y types (mostly Tensors at this point) in Breeze derive from NumericOps, which provide handy operator methods for basic operations. Operators in Breeze are supported by the type class pattern, which basically means that implicit parameters do all the heavy lifting. For example, here is the definition of the + operation in NumericOps:
trait NumericOps[+This] {
final def + [TT>:This,B,That](b : B)(implicit op : BinaryOp[TT,B,OpAdd,That]) = {
op(repr, b)
}
}
BinaryOp is like a Function2 that also has a type parameter for the kind of operation it is supporting. The implementations of BinaryOps are usually found in a (super-trait of) the companion object for either the lefthand side or righthand side operand for an operator. For instance, the operator that adds two DenseVector[Int]
s together is BinaryOp[DenseVector[Int], DenseVector[Int], OpAdd, DenseVector[Int]]
, which is defined in the trait DenseVectorOps_Int
.
In general, you should just try operations, and see if it works. Breeze is still pretty early in development, so some things that seem like they should work don't yet. If that happens, file a bug! See the section Defining Your Own Operators (XXX) for information about how to define operators yourself.
XXX
Breeze is a numerical processing library for Scala. http://www.scalanlp.org