breeze.linalg

This package contains everything relating to Vectors, Matrices, Tensors, etc.

If you're doing basic work, you probably want breeze.linalg.DenseVector and breeze.linalg.DenseMatrix, which support most operations. We also have breeze.linalg.SparseVectors and (basic!) support for a sparse matrix (breeze.linalg.CSCMatrix).

This package object contains Matlab-esque functions for interacting with tensors and matrices.

Type members

Classlikes

object * extends Broadcaster
sealed trait Axis

This trait is commonly used for breeze.linalg.sum and its kin for summing along a particular axis of a Matrix.

This trait is commonly used for breeze.linalg.sum and its kin for summing along a particular axis of a Matrix.

Companion:
object
object Axis
Companion:
class
class BitVector(val data: BitSet, val length: Int, val enforceLength: Boolean) extends Vector[Boolean] with VectorLike[Boolean, BitVector]

A BitVector is a Vector of Booleans backed by a java.util.Bitset. Much better memory usage and sometimes faster.

A BitVector is a Vector of Booleans backed by a java.util.Bitset. Much better memory usage and sometimes faster.

Value parameters:
enforceLength

if false, then the BitVector won't throw exceptions if it's used in operations with vectors longer than it.

Companion:
object
object BitVector
Companion:
class
trait Broadcasted[+T, B] extends NumericOps[Broadcasted[T, B]]

A Broadcasted is a type that represents "broadcasting" (a la numpy).

A Broadcasted is a type that represents "broadcasting" (a la numpy).

Unlike Numpy, broadcasting in Breeze is explicit: matrix(*, ::) lifts UFuncs and operators so that they apply over each row matrix(::, *) is the same, but for columns

case class BroadcastedColumns[T, ColType](underlying: T) extends BroadcastedLike[T, ColType, BroadcastedColumns[T, ColType]]

Class for classes that are broadcasting their columns. That is denseMatrix(::, *) /= denseVector

Class for classes that are broadcasting their columns. That is denseMatrix(::, *) /= denseVector

Type parameters:
T

the type of the tensor

Value parameters:
underlying

the tensor (or equivalent) being broadcasted

Companion:
object
Companion:
class
trait BroadcastedLike[T, B, Self <: Broadcasted[T, B]] extends Broadcasted[T, B] with NumericOps[Self]
case class BroadcastedRows[T, RowType](underlying: T) extends BroadcastedLike[T, RowType, BroadcastedRows[T, RowType]]

Class for classes that are broadcasting their rows. That is denseMatrix(*, ::) /= denseVector

Class for classes that are broadcasting their rows. That is denseMatrix(*, ::) /= denseVector

Type parameters:
T

the type of the tensor

Value parameters:
underlying

the tensor (or equivalent) being broadcasted

Companion:
object
Companion:
class
Companion:
object
Companion:
class
class CSCMatrix[@specialized(Double, Int, Float, Long) V](var _data: Array[V], val rows: Int, val cols: Int, val colPtrs: Array[Int], var used: Int, var _rowIndices: Array[Int])(implicit evidence$1: Zero[V]) extends Matrix[V] with MatrixLike[V, CSCMatrix[V]] with Serializable

A compressed sparse column matrix, as used in Matlab and CSparse, etc.

A compressed sparse column matrix, as used in Matlab and CSparse, etc.

In general, you should probably NOT use the class's constructors unless you know what you are doing. We don't validate the input data for performance reasons. So make sure you understand the https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29 correctly. Otherwise, please use the factory methods under CSCMatrix and CSCMatrix#Builder to construct CSC matrices.

Value parameters:
_data

active values

_rowIndices

row indices of the elements in data Most implementations based on "Direct Methods for Sparse Linear Systems" by Timothy A. Davis

colPtrs

the locations in data that start a column

cols

number of columns

rows

number of rows

Companion:
object
Companion:
class
trait CanPadLeft[Input, Dimensions, Output]
Companion:
object
object CanPadLeft
Companion:
class
trait CanPadRight[Input, Dimensions, Output]
Companion:
object
Companion:
class
trait Counter[K, V] extends Tensor[K, V] with CounterLike[K, V, Map[K, V], Counter[K, V]]
Companion:
object
object Counter extends CounterOps
Companion:
class
trait Counter2[K1, K2, V] extends Tensor[(K1, K2), V] with Counter2Like[K1, K2, V, Counter[K2, V], Counter2[K1, K2, V]]
Companion:
object
Companion:
class
trait Counter2Like[K1, K2, V, T <: Counter[K2, V], +This <: Counter2[K1, K2, V]] extends TensorLike[(K1, K2), V, This]

A map-like tensor that acts like a collection of key-value pairs where the set of values may grow arbitrarily.

A map-like tensor that acts like a collection of key-value pairs where the set of values may grow arbitrarily.

trait CounterLike[K, V, +M <: Map[K, V], +This <: Counter[K, V]] extends TensorLike[K, V, This] with Serializable

A map-like tensor that acts like a collection of key-value pairs where the set of values may grow arbitrarily.

A map-like tensor that acts like a collection of key-value pairs where the set of values may grow arbitrarily.

final class DenseMatrix[@specialized(Double, Int, Float, Long) V](val rows: Int, val cols: Int, val data: Array[V], val offset: Int, val majorStride: Int, val isTranspose: Boolean) extends Matrix[V] with MatrixLike[V, DenseMatrix[V]] with Serializable

A DenseMatrix is a matrix with all elements found in an array. It is column major unless isTranspose is true, It is designed to be fast: Double- (and potentially Float-)valued DenseMatrices can be used with blas, and support operations to that effect.

A DenseMatrix is a matrix with all elements found in an array. It is column major unless isTranspose is true, It is designed to be fast: Double- (and potentially Float-)valued DenseMatrices can be used with blas, and support operations to that effect.

Value parameters:
cols

number of cols

data

The underlying data. Column-major unless isTranpose is true. Mutate at your own risk. Note that this matrix may be a view of the data. Use linearIndex(r,c) to calculate indices.

isTranspose

if true, then the matrix is considered to be "transposed" (that is, row major)

majorStride

distance separating columns (or rows, for isTranspose). should have absolute value >= rows (or cols, for isTranspose)

offset

starting point into array

rows

number of rows

Companion:
object
class DenseVector[@specialized(Double, Int, Float, Long) V](val data: Array[V], val offset: Int, val stride: Int, val length: Int) extends StorageVector[V] with VectorLike[V, DenseVector[V]] with Serializable

A DenseVector is the "obvious" implementation of a Vector, with one twist. The underlying data may have more data than the Vector, represented using an offset into the array (for the 0th element), and a stride that is how far elements are apart from one another.

A DenseVector is the "obvious" implementation of a Vector, with one twist. The underlying data may have more data than the Vector, represented using an offset into the array (for the 0th element), and a stride that is how far elements are apart from one another.

The i'th element is at offset + i * stride

Value parameters:
data

data array

length

number of elements

offset

index of the 0'th element

stride

separation between elements

Companion:
object
class HashVector[@specialized(Double, Int, Float, Long) E](val array: OpenAddressHashArray[E]) extends Vector[E] with VectorLike[E, HashVector[E]] with Serializable

A HashVector is a sparse vector backed by an OpenAddressHashArray

A HashVector is a sparse vector backed by an OpenAddressHashArray

Companion:
object
object HashVector
Companion:
class
trait ImmutableNumericOps[+This] extends HasOps
final implicit class InjectNumericOps[T](val repr: T) extends AnyVal with ImmutableNumericOps[T]
object LSMR extends SerializableLogging

Nearly direct port of http://www.mathworks.com/matlabcentral/fileexchange/27183-lsmr--an-iterative-algorithm-for-least-squares-problems (BSD licensed code)

Nearly direct port of http://www.mathworks.com/matlabcentral/fileexchange/27183-lsmr--an-iterative-algorithm-for-least-squares-problems (BSD licensed code)

http://web.stanford.edu/group/SOL/software/lsmr/

The only difference is that they square the regularization factor.

object LU extends UFunc

Computes the LU factorization of the given real M-by-N matrix X such that X = P * L * U where P is a permutation matrix (row exchanges).

Computes the LU factorization of the given real M-by-N matrix X such that X = P * L * U where P is a permutation matrix (row exchanges).

class LapackException(msg: String) extends RuntimeException with LinearAlgebraException

Marker trait for exceptions thrown from the breeze.linalg package.

Marker trait for exceptions thrown from the breeze.linalg package.

trait Matrix[@specialized(Double, Int, Float, Long) V] extends MatrixLike[V, Matrix[V]]
Companion:
object
trait MatrixConstructors[Mat <: (Matrix)]
class MatrixEmptyException extends IllegalArgumentException with LinearAlgebraException
trait MatrixLike[@specialized(Double, Int, Float, Long) V, +Self <: Matrix[V]] extends Tensor[(Int, Int), V] with TensorLike[(Int, Int), V, Self]
class MatrixNotSquareException extends IllegalArgumentException with LinearAlgebraException
class MatrixNotSymmetricException extends IllegalArgumentException with LinearAlgebraException
class MatrixSingularException(msg: String) extends RuntimeException with LinearAlgebraException

Thrown when trying to solve using a singular matrix.

Thrown when trying to solve using a singular matrix.

trait NormBasedDistance extends UFunc

TODO

TODO

class NotConvergedException(val reason: Reason, msg: String) extends RuntimeException with LinearAlgebraException

Exception thrown if a routine has not converged.

Exception thrown if a routine has not converged.

Companion:
object
trait NumericOps[+This] extends ImmutableNumericOps[This]

In some sense, this is the real root of the linalg hierarchy. It provides methods for doing operations on a Tensor-like thing. All methods farm out to some implicit or another. We use this when we don't care about the index into the Tensor, or if we don't really have an index.

In some sense, this is the real root of the linalg hierarchy. It provides methods for doing operations on a Tensor-like thing. All methods farm out to some implicit or another. We use this when we don't care about the index into the Tensor, or if we don't really have an index.

Companion:
object
object NumericOps
Companion:
class
object Options
class PCA(val x: DenseMatrix[Double], val covmat: DenseMatrix[Double])

Perform Principal Components Analysis on input data. Handles scaling of the when computing the covariance matrix. Lazily produces the scores (the translation of the data to their new coordinates on the PC axes.

Perform Principal Components Analysis on input data. Handles scaling of the when computing the covariance matrix. Lazily produces the scores (the translation of the data to their new coordinates on the PC axes.

Input is a matrix that has data points as rows. Variable naming and documentation inspired and used directy from the 'princomp' function in R.

We occasionally need a Tensor that doesn't extend NumericOps directly. This is that tensor.

We occasionally need a Tensor that doesn't extend NumericOps directly. This is that tensor.

trait RandomGeneratorUFunc[T] extends UFunc
class SliceMatrix[@specialized(Int) K1, @specialized(Int) K2, @specialized(Double, Int, Float, Long) V](val tensor: Tensor[(K1, K2), V], val slice1: IndexedSeq[K1], val slice2: IndexedSeq[K2])(implicit evidence$1: Semiring[V], evidence$2: ClassTag[V]) extends Matrix[V] with MatrixLike[V, SliceMatrix[K1, K2, V]]
Companion:
object
class SliceVector[@specialized(Int) K, @specialized(Double, Int, Float, Long) V](val tensor: Tensor[K, V], val slices: IndexedSeq[K])(implicit evidence$1: ClassTag[V]) extends Vector[V] with VectorLike[V, SliceVector[K, V]]

A SliceVector is a vector that is a view of another underlying tensor. For instance:

A SliceVector is a vector that is a view of another underlying tensor. For instance:

val m = DenseMatrix(...)
m( (1,2), (3,4), (4,5))

will give a SliceVector such that apply/update at index 0 will map to m(1,2), index 1 to m(3,4), etc.

Companion:
object
Companion:
class
class SparseVector[@specialized(Double, Int, Float, Long) V](val array: SparseArray[V])(implicit zero: Zero[V]) extends StorageVector[V] with VectorLike[V, SparseVector[V]] with Serializable

A vector backed by binary search (with breeze.collection.mutable.SparseArray). There is a parallel array of ints (in 0 until length) and values, sorted by index value. To quickly access all stored values use the following loop:

A vector backed by binary search (with breeze.collection.mutable.SparseArray). There is a parallel array of ints (in 0 until length) and values, sorted by index value. To quickly access all stored values use the following loop:

var offset = 0
while( offset < v.activeSize) {
  val index: Int = v.indexAt(offset)
  val value: E = v.valueAt(offset)

  offset += 1
}
Companion:
object
Companion:
class
trait StorageVector[V] extends Vector[V] with Storage[V]
implicit class String2File(s: String)

Add methods to the string class in order to make file reading easier

Add methods to the string class in order to make file reading easier

trait Tensor[@specialized(Int) K, @specialized(Double, Int, Float, Long) V] extends TensorLike[K, V, Tensor[K, V]]

A Tensor defines a map from an index set to a set of values.

A Tensor defines a map from an index set to a set of values.

Companion:
object
object Tensor
Companion:
class
trait TensorLike[@specialized(Int) K, @specialized(Double, Int, Float, Long) V, +This <: Tensor[K, V]] extends QuasiTensor[K, V] with NumericOps[This]
final case class Transpose[+T](inner: T) extends NumericOps[Transpose[T]]

Represents the Transpose of an instance of a type. The most common use is for Transpose[DenseVector[T]] to represent row vectors

Represents the Transpose of an instance of a type. The most common use is for Transpose[DenseVector[T]] to represent row vectors

trait Vector[@specialized(Int, Double, Float) V] extends VectorLike[V, Vector[V]]

A Vector represents the mathematical concept of a vector in math.

A Vector represents the mathematical concept of a vector in math.

Companion:
object
Companion:
class
class VectorBuilder[@specialized(Double, Int, Float, Long) E](var _index: Array[Int], var _data: Array[E], var used: Int, var length: Int)(implicit ring: Semiring[E]) extends NumericOps[VectorBuilder[E]] with Serializable

A VectorBuilder is basically an unsorted Sparse Vector. Two parallel arrays are maintained, one of indices, and another of values. The indices are not sorted. Moreover, indices are not unique in the index array. Furthermore, apply(i) and update(i, v) are linear in the number of active values in the array.

A VectorBuilder is basically an unsorted Sparse Vector. Two parallel arrays are maintained, one of indices, and another of values. The indices are not sorted. Moreover, indices are not unique in the index array. Furthermore, apply(i) and update(i, v) are linear in the number of active values in the array.

  • and - are linear operations: they just append to the end. Component wise multiply, divide, and dot product are also linear, but require creating a HashVector copy. (TODO: maybe a SparseVector?)

In general, these should never be used, except for building, or for doing feature vector type things where you just need a sparse vector with a fast dot product with a "real" vector.

Companion:
object
Companion:
class
trait VectorConstructors[Vec <: (Vector)]

Trait that can mixed to companion objects to enable utility methods for creating vectors.

Trait that can mixed to companion objects to enable utility methods for creating vectors.

trait VectorLike[@specialized V, +Self <: Vector[V]] extends Tensor[Int, V] with TensorLike[Int, V, Self]

Trait for operators and such used in vectors.

Trait for operators and such used in vectors.

sealed trait View

Trait used for methods that can return a view or a copy.

Trait used for methods that can return a view or a copy.

Companion:
object
object View
Companion:
class

Usually used as the return type from zipValues

Usually used as the return type from zipValues

object accumulate extends UFunc

Returns a cumulative sum of the vector (ie cumsum).

Returns a cumulative sum of the vector (ie cumsum).

object all extends UFunc

all(t) true if all elements of t are non-zero all(f, t) returns true if all elements of t satisfy f

all(t) true if all elements of t are non-zero all(f, t) returns true if all elements of t satisfy f

object any extends UFunc

any(t) true if any element of t is non-zero any(f, t) returns true if any element of t satisfies f

any(t) true if any element of t is non-zero any(f, t) returns true if any element of t satisfies f

object argmax extends UFunc
object argmin extends UFunc
object argsort extends UFunc
object argtopk extends UFunc

A Chebyshev distance metric implementation between two points

A Chebyshev distance metric implementation between two points

object cholesky extends UFunc

Computes the cholesky decomposition A of the given real symmetric positive definite matrix X such that X = A A.t.

Computes the cholesky decomposition A of the given real symmetric positive definite matrix X such that X = A A.t.

TODO: For higher dimensionalities, the return value really should be a sparse matrix due to its inherent lower triangular nature.

object clip extends ElementwiseUFunc
object cond extends UFunc

Computes the condition number of the given real matrix.

Computes the condition number of the given real matrix.

object convert extends MappingUFunc
object cosineDistance extends UFunc

The cosine distance between two points: cosineDistance(a,b) = 1 - (a dot b)/(norm(a) * norm(b))

The cosine distance between two points: cosineDistance(a,b) = 1 - (a dot b)/(norm(a) * norm(b))

object det extends UFunc

Computes the determinant of the given real matrix.

Computes the determinant of the given real matrix.

object diag extends UFunc with diagLowPrio2

returns a vector along the diagonal of v. Requires a square matrix?

returns a vector along the diagonal of v. Requires a square matrix?

Value parameters:
m

the matrix

trait diagLowPrio extends UFunc
trait diagLowPrio2 extends UFunc with diagLowPrio
object diff extends UFunc with diffLowPrio
sealed trait diffLowPrio
object dim extends UFunc

breeze 7/15/14

breeze 7/15/14

object eig extends UFunc

Eigenvalue decomposition (right eigenvectors)

Eigenvalue decomposition (right eigenvectors)

This function returns the real and imaginary parts of the eigenvalues, and the corresponding eigenvectors. For most (?) interesting matrices, the imaginary part of all eigenvalues will be zero (and the corresponding eigenvectors will be real). Any complex eigenvalues will appear in complex-conjugate pairs, and the real and imaginary components of the eigenvector for each pair will be in the corresponding columns of the eigenvector matrix. Take the complex conjugate to find the second eigenvector.

Based on EVD.java from MTJ 0.9.12

object eigSym extends UFunc

Computes all eigenvalues (and optionally right eigenvectors) of the given real symmetric matrix X.

Computes all eigenvalues (and optionally right eigenvectors) of the given real symmetric matrix X.

A Euclidean distance metric implementation between two points

A Euclidean distance metric implementation between two points

object evdr extends UFunc

Approximate truncated randomized EVD

Approximate truncated randomized EVD

object fliplr extends UFunc

mirrors the columns (left<->right).

mirrors the columns (left<->right).

object flipud extends UFunc

mirrors the rows (up down)

mirrors the rows (up down)

object hsplit extends UFunc
object inv extends UFunc

Computes the inverse of a given real matrix. In general, you should avoid using this metho in combination with *. Instead, wherever you might want to write inv(A) * B, you should write A \ B.

Computes the inverse of a given real matrix. In general, you should avoid using this metho in combination with *. Instead, wherever you might want to write inv(A) * B, you should write A \ B.

object isClose extends UFunc
object kron extends UFunc

Returns the Kronecker product of two matrices a and b, usually denoted a ⊗ b.

Returns the Kronecker product of two matrices a and b, usually denoted a ⊗ b.

object logAndNormalize extends UFunc
object logDiff extends MappingUFunc
object logNormalize extends UFunc
object logdet extends UFunc

Computes the log of the determinant of the given real matrix. The value returned is (sign of determinant, log of determinant). This method can be more accurate than just using breeze.linalg.det, if det is very small.

Computes the log of the determinant of the given real matrix. The value returned is (sign of determinant, log of determinant). This method can be more accurate than just using breeze.linalg.det, if det is very small.

A Manhattan distance measure implementation between two points

A Manhattan distance measure implementation between two points

object max extends UFunc with maxLowPrio with VectorizedReduceUFunc
sealed trait maxLowPrio
object min extends UFunc with minLowPrio with VectorizedReduceUFunc
sealed trait minLowPrio
object minMax extends UFunc

A Minkowski distance metric implementation between two points

A Minkowski distance metric implementation between two points

object mpow extends UFunc

Raises m to the exp'th power. Relies on eigenvalue decomposition when m's eigenvalues are real, if not it relies on exponentiation by squaring.

Raises m to the exp'th power. Relies on eigenvalue decomposition when m's eigenvalues are real, if not it relies on exponentiation by squaring.

object norm extends UFunc
object normalize extends UFunc with normalizeLowPrio

Normalizes the argument such that its norm is 1.0 (with respect to the argument n). Returns value if value's norm is 0.

Normalizes the argument such that its norm is 1.0 (with respect to the argument n). Returns value if value's norm is 0.

sealed trait normalizeLowPrio
object pinv extends UFunc with pinvLowPrio
object product extends UFunc
object ptp extends UFunc
object qr extends UFunc

QR Factorization

QR Factorization

Previous versions of Breeze had qr(m, skipQ), where we could skip the computation in making Q if we didn't want it. That is now supplanted by qr.justR(m)

Supports complete and reduced mode of factorization of matrix A with dimensions (m, n). If mode is complete matrices Q and R have dimensions (m, m), (m, n). If mode is reduced matrices Q and R have dimensions (m, k), (k, n) with k = min(m, n).

Complete QR factorization can be called by qr(A).

Reduced QR factorization can be called by qr.reduced(A). If computation of Q is unnecessary, it can be skipped by qr.reduced.justR(A)

Returns:

(Q, R) Q - A matrix with orthonormal columns R - The upper-triangular matrix

object qrp extends UFunc

QR Factorization with pivoting

QR Factorization with pivoting

input: A m x n matrix output: (Q,R,P,pvt) where AP = QR Q: m x m R: m x n P: n x n : permutation matrix (P(pvt(i),i) = 1) pvt : pivot indices

Gives Gaussian-distributed random Double(s)

Gives Gaussian-distributed random Double(s)

  • randn()... returns a Gaussian random variable with mean 0, variance 1
  • randn( n: Int )... returns a DenseVector with n randn's
  • randn( (n1: Int, n2: Int) )... returns an n1 x n2 DenseMatrix with randn's

Gives a random Double.

Gives a random Double.

  • randomDouble()... returns a random double, in [0, 1]
  • randomDouble( n: Int )... returns a DenseVector with n random doubles, in [0, 1]
  • randomDouble( n: Int, (r1: Double, r2: Double) )... returns a DenseVector with n random doubles, in [r1, r2]
  • randomDouble( (n1: Int, n2: Int) )... returns an n1 x n2 DenseMatrix with n random doubles, in [0, 1]
  • randomDouble( (n1: Int, n2: Int), (r1: Double, r2: Double) )... returns an n1 x n2 DenseMatrix with n random doubles, in [r1, r2]

Gives a random Int.

Gives a random Int.

  • randomInt()... returns a random Int, in [0, 1]
  • randomInt( n: Int )... returns a DenseVector with n random Ints, in [0, 1]
  • randomInt( n: Int, (r1: Int, r2: Int) )... returns a DenseVector with n random Ints, in [r1, r2)
  • randomInt( (n1: Int, n2: Int) )... returns an n1 x n2 DenseMatrix with n random Ints, in [0, 1]
  • randomInt( (n1: Int, n2: Int), (r1: Int, r2: Int) )... returns an n1 x n2 DenseMatrix with n random Ints, in [r1, r2)
object rank extends UFunc

Computes the rank of a matrix.

Computes the rank of a matrix.

The rank of the matrix is computed using the SVD method. The singular values of the SVD which are greater than a specified tolerance are counted.

Value parameters:
m

matrix for which to compute the rank

tol

optional tolerance for singular values. If not supplied, the default tolerance is: max(m.cols, m.rows) * eps * sigma_max, where eps is the machine epsilon and sigma_max is the largest singular value of m.

Returns:

the rank of the matrix (number of singular values)

object reshape extends UFunc

breeze 7/4/14

breeze 7/4/14

object reverse extends UFunc

Returns a reversed copy of the DenseVector.

Returns a reversed copy of the DenseVector.

object roll extends UFunc

roll the array

roll the array

object rot90 extends UFunc

Rotates a matrix by 90 * k degrees counter clockwise. if k is not specified, it defaults to 1.

Rotates a matrix by 90 * k degrees counter clockwise. if k is not specified, it defaults to 1.

object scaleAdd extends UFunc
object shuffle extends UFunc

Return the given DenseVector, Array, or DenseMatrix as a shuffled copy by using Fisher-Yates shuffle. Additionally, can return the given Array as a shuffled copy with the corresponding shuffle index information, or return the given Array as a shuffled copy using the inverse of the given shuffle index information, reversing the shuffle.

Return the given DenseVector, Array, or DenseMatrix as a shuffled copy by using Fisher-Yates shuffle. Additionally, can return the given Array as a shuffled copy with the corresponding shuffle index information, or return the given Array as a shuffled copy using the inverse of the given shuffle index information, reversing the shuffle.

object softmax extends UFunc

Computes the softmax (a.k.a. logSum) of an object. Softmax is defined as \log \sum_i \exp(x(i)), but implemented in a more numerically stable way. Softmax is so-called because it is a differentiable function that tends to look quite a lot like max. Consider log(exp(30) + exp(10)). That's basically 30. We use softmax a lot in machine learning.

Computes the softmax (a.k.a. logSum) of an object. Softmax is defined as \log \sum_i \exp(x(i)), but implemented in a more numerically stable way. Softmax is so-called because it is a differentiable function that tends to look quite a lot like max. Consider log(exp(30) + exp(10)). That's basically 30. We use softmax a lot in machine learning.

object split extends UFunc

split the array

split the array

Computes the squared distance between two vectors.

Computes the squared distance between two vectors.

sealed trait squaredDistanceLowPrio extends UFunc
sealed trait sumLowPrio
object svd extends UFunc

Computes the SVD of a M-by-N matrix Returns an M-by-M matrix U, a vector of singular values, and a N-by-N matrix V'

Computes the SVD of a M-by-N matrix Returns an M-by-M matrix U, a vector of singular values, and a N-by-N matrix V'

object svdr extends UFunc

Approximate truncated randomized SVD

Approximate truncated randomized SVD

object tanimotoDistance extends UFunc
object tile extends UFunc
object trace extends UFunc

Computes the determinant of the given real matrix.

Computes the determinant of the given real matrix.

object unique extends UFunc

deduplicates the array

deduplicates the array

object vsplit extends UFunc
object where extends UFunc

where(a) returns those indices that are non-zero

where(a) returns those indices that are non-zero

where(cond, a, b) returns the value from a if cond is non-zero, and the value from b otherwise

object zipValues extends UFunc

Value members

Concrete methods

def axpy[A, X, Y](a: A, x: X, y: Y)(implicit axpy: InPlaceImpl3[Y, A, X]): Unit

Computes y += x * a, possibly doing less work than actually doing that operation

Computes y += x * a, possibly doing less work than actually doing that operation

def copy[T](t: T)(implicit canCopy: CanCopy[T]): T

Copy a T. Most tensor objects have a CanCopy implicit, which is what this farms out to.

Copy a T. Most tensor objects have a CanCopy implicit, which is what this farms out to.

Compute the covariance matrix from the given data, centering if necessary. Very simple, just does the basic thing.

Compute the covariance matrix from the given data, centering if necessary. Very simple, just does the basic thing.

def cross[V1](a: DenseVector[V1], b: DenseVector[V1])(implicit ring: Ring[V1], man: ClassTag[V1]): DenseVector[V1]

Vector cross product of 3D vectors a and b.

Vector cross product of 3D vectors a and b.

def csvread(file: File, separator: Char, quote: Char, escape: Char, skipLines: Int): DenseMatrix[Double]

Reads in a DenseMatrix from a CSV File

Reads in a DenseMatrix from a CSV File

def csvwrite(file: File, mat: Matrix[Double], separator: Char, quote: Char, escape: Char, skipLines: Int): Unit
def linspace(a: Double, b: Double, length: Int): DenseVector[Double]

Generates a vector of linearly spaced values between a and b (inclusive). The returned vector will have length elements, defaulting to 100.

Generates a vector of linearly spaced values between a and b (inclusive). The returned vector will have length elements, defaulting to 100.

The lower triangular portion of the given real quadratic matrix X. Note that no check will be performed regarding the symmetry of X.

The lower triangular portion of the given real quadratic matrix X. Note that no check will be performed regarding the symmetry of X.

def mmwrite[T : Numeric](file: File, mat: Matrix[T]): Unit
def padLeft[T](v: DenseVector[T], dimensions: Dimensions1)(implicit canPad: CanPadLeft[DenseVector[T], Dimensions1, DenseVector[T]]): DenseVector[T]
def padLeft[T](v: DenseVector[T], dimensions: Dimensions1, mode: OptPadMode)(implicit canPad: CanPadLeft[DenseVector[T], Dimensions1, DenseVector[T]]): DenseVector[T]
def padLeft[T](v: DenseMatrix[T], dimensions: Dimensions1)(implicit canPad: CanPadLeft[DenseMatrix[T], Dimensions1, DenseMatrix[T]]): DenseMatrix[T]
def padLeft[T](v: DenseMatrix[T], dimensions: Dimensions2, mode: OptPadMode)(implicit canPad: CanPadLeft[DenseMatrix[T], Dimensions2, DenseMatrix[T]]): DenseMatrix[T]
def padRight[T](v: DenseVector[T], dimensions: Dimensions1)(implicit canPad: CanPadRight[DenseVector[T], Dimensions1, DenseVector[T]]): DenseVector[T]
def padRight[T](v: DenseVector[T], dimensions: Dimensions1, mode: OptPadMode)(implicit canPad: CanPadRight[DenseVector[T], Dimensions1, DenseVector[T]]): DenseVector[T]
def padRight[T](v: DenseMatrix[T], dimensions: Dimensions1)(implicit canPad: CanPadRight[DenseMatrix[T], Dimensions1, DenseMatrix[T]]): DenseMatrix[T]
def padRight[T](v: DenseMatrix[T], dimensions: Dimensions2, mode: OptPadMode)(implicit canPad: CanPadRight[DenseMatrix[T], Dimensions2, DenseMatrix[T]]): DenseMatrix[T]

Performs a principal components analysis on the given numeric data matrix and returns the results as an object of class PCA.

Performs a principal components analysis on the given numeric data matrix and returns the results as an object of class PCA.

If the no covariance matrix is supplied, one obtained from the given data is used.

def ranks[V : Ordering](x: Vector[V]): Array[Double]

Returns the rank of each element in the given vector, adjusting for ties.

Returns the rank of each element in the given vector, adjusting for ties.

A generic function (based on the R function of the same name) whose default method centers and/or scales the columns of a numeric matrix.

A generic function (based on the R function of the same name) whose default method centers and/or scales the columns of a numeric matrix.

If ‘scale’ is ‘TRUE’ then scaling is done by dividing the (centered) columns of ‘x’ by their standard deviations if ‘center’ is ‘TRUE’, and the root mean square otherwise. If ‘scale’ is ‘FALSE’, no scaling is done.

The lower triangular portion of the given real quadratic matrix X with the diagnal elements is zero!

The lower triangular portion of the given real quadratic matrix X with the diagnal elements is zero!

The upper triangular portion of the given real quadratic matrix X with the diagnal elements is zero!

The upper triangular portion of the given real quadratic matrix X with the diagnal elements is zero!

The upper triangular portion of the given real quadratic matrix X. Note that no check will be performed regarding the symmetry of X.

The upper triangular portion of the given real quadratic matrix X. Note that no check will be performed regarding the symmetry of X.

Concrete fields

val rand: randomDouble.type

Alias for randomDouble

Alias for randomDouble

val to determine if breeze is using natives or f2jblas

val to determine if breeze is using natives or f2jblas

Implicits

Implicits

final implicit def InjectNumericOps[T](repr: T): InjectNumericOps[T]
final implicit def String2File(s: String): String2File

Add methods to the string class in order to make file reading easier

Add methods to the string class in order to make file reading easier