DenseVector

@SerialVersionUID(1L)
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.

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
trait Serializable
trait StorageVector[V]
trait Storage[V]
trait Vector[V]
trait VectorLike[V, DenseVector[V]]
trait Tensor[Int, V]
trait TensorLike[Int, V, DenseVector[V]]
trait QuasiTensor[Int, V]
trait HasOps
class Object
trait Matchable
class Any

Value members

Constructors

def this(data: Array[V])
def this(data: Array[V], offset: Int)
def this(length: Int)(implicit man: ClassTag[V])

Concrete methods

Always returns true.

Always returns true.

def apply(i: Int): V

Creates a view of this DenseVector that is represented as a 1 by length DenseMatrix

Creates a view of this DenseVector that is represented as a 1 by length DenseMatrix

Returns a copy of this DenseVector. stride will always be 1, offset will always be 0.

Returns a copy of this DenseVector. stride will always be 1, offset will always be 0.

override def equals(p1: Any): Boolean
Definition Classes
Vector -> Any
override def foreach[@specialized(Unit) U](fn: V => U): Unit

Faster foreach

Faster foreach

Definition Classes
override def hashCode(): Int

This hashcode is consistent with over breeze.linalg.Vector hashcodes so long as the hashcode of "0" is 0.

This hashcode is consistent with over breeze.linalg.Vector hashcodes so long as the hashcode of "0" is 0.

Definition Classes
def indexAt(i: Int): Int

Gives the logical index from the physical index.

Gives the logical index from the physical index.

Returns:

i

Always returns true.

Always returns true.

Some storages (namely HashStorage) won't have active indices packed. This lets you know if the bin is actively in use.

Value parameters:
i

index into index/data arrays

def slice(start: Int, end: Int, stride: Int): DenseVector[V]

Slices the DenseVector, in the range [start,end] with a stride stride.

Slices the DenseVector, in the range [start,end] with a stride stride.

override def toArray(implicit ct: ClassTag[V]): Array[V]
Definition Classes

Creates a copy of this DenseVector that is represented as a 1 by length DenseMatrix

Creates a copy of this DenseVector that is represented as a 1 by length DenseMatrix

override def toScalaVector: Vector[V]

Returns copy of this breeze.linalg.Vector as a scala.Vector

Returns copy of this breeze.linalg.Vector as a scala.Vector

Definition Classes
override def toString: String
Definition Classes
Any
def update(i: Int, v: V): Unit
def valueAt(i: Int): V

same as apply(i). Gives the value at the underlying offset.

same as apply(i). Gives the value at the underlying offset.

Value parameters:
i

index into the data array

Returns:

apply(i)

Inherited methods

final def %[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Alias for :%(b) when b is a scalar.

Alias for :%(b) when b is a scalar.

Inherited from:
ImmutableNumericOps
final def %:%[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise modulo of this and b.

Element-wise modulo of this and b.

Inherited from:
ImmutableNumericOps
final def %=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Alias for :%=(b) when b is a scalar.

Alias for :%=(b) when b is a scalar.

Inherited from:
NumericOps
final def &[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Alias for &:&(b) for all b.

Alias for &:&(b) for all b.

Inherited from:
ImmutableNumericOps
final def &:&[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise logical "and" operator -- returns true if corresponding elements are non-zero.

Element-wise logical "and" operator -- returns true if corresponding elements are non-zero.

Inherited from:
ImmutableNumericOps
final def &=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise and of this and b.

Mutates this by element-wise and of this and b.

Inherited from:
NumericOps
final def *[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Matrix multiplication

Matrix multiplication

Inherited from:
ImmutableNumericOps
final def *:*[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise product of this and b.

Element-wise product of this and b.

Inherited from:
ImmutableNumericOps
final def *=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Alias for :*=(b) when b is a scalar.

Alias for :*=(b) when b is a scalar.

Inherited from:
NumericOps
final def +[B, C, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Alias for :+(b) for all b.

Alias for :+(b) for all b.

Inherited from:
NumericOps
final def +:+[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise sum of this and b.

Element-wise sum of this and b.

Inherited from:
ImmutableNumericOps
final def +=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Alias for :+=(b) for all b.

Alias for :+=(b) for all b.

Inherited from:
NumericOps
final def -[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Alias for -:-(b) for all b.

Alias for -:-(b) for all b.

Inherited from:
ImmutableNumericOps
final def -:-[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise difference of this and b.

Element-wise difference of this and b.

Inherited from:
ImmutableNumericOps
final def -=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Alias for :-=(b) for all b.

Alias for :-=(b) for all b.

Inherited from:
NumericOps
final def /[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Alias for :/(b) when b is a scalar.

Alias for :/(b) when b is a scalar.

Inherited from:
ImmutableNumericOps
final def /:/[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise quotient of this and b.

Element-wise quotient of this and b.

Inherited from:
ImmutableNumericOps
final def /=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Alias for :/=(b) when b is a scalar.

Alias for :/=(b) when b is a scalar.

Inherited from:
NumericOps
final def :!=[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise inequality comparator of this and b.

Element-wise inequality comparator of this and b.

Inherited from:
ImmutableNumericOps
final def :%=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise modulo of b into this.

Mutates this by element-wise modulo of b into this.

Inherited from:
NumericOps
final def :&=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise and of this and b.

Mutates this by element-wise and of this and b.

Inherited from:
NumericOps
final def :*=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise multiplication of b into this.

Mutates this by element-wise multiplication of b into this.

Inherited from:
NumericOps
final def :+=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise addition of b into this.

Mutates this by element-wise addition of b into this.

Inherited from:
NumericOps
final def :-=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise subtraction of b from this

Mutates this by element-wise subtraction of b from this

Inherited from:
NumericOps
final def :/=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise division of b into this

Mutates this by element-wise division of b into this

Inherited from:
NumericOps
final def :=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise assignment of b into this.

Mutates this by element-wise assignment of b into this.

Inherited from:
NumericOps
final def :==[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise equality comparator of this and b.

Element-wise equality comparator of this and b.

Inherited from:
ImmutableNumericOps
final def :^=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise exponentiation of this by b.

Mutates this by element-wise exponentiation of this by b.

Inherited from:
NumericOps
final def :^^=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise xor of this and b.

Mutates this by element-wise xor of this and b.

Inherited from:
NumericOps
final def :|=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise or of this and b.

Mutates this by element-wise or of this and b.

Inherited from:
NumericOps
final def <:<[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise less=than comparator of this and b.

Element-wise less=than comparator of this and b.

Inherited from:
NumericOps
final def <:=[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise less-than-or-equal-to comparator of this and b.

Element-wise less-than-or-equal-to comparator of this and b.

Inherited from:
NumericOps
final def >:=[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise greater-than-or-equal-to comparator of this and b.

Element-wise greater-than-or-equal-to comparator of this and b.

Inherited from:
NumericOps
final def >:>[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise greater-than comparator of this and b.

Element-wise greater-than comparator of this and b.

Inherited from:
NumericOps
def \[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Shaped solve of this by b.

Shaped solve of this by b.

Inherited from:
ImmutableNumericOps
final def ^:^[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise exponentiation of this and b.

Element-wise exponentiation of this and b.

Inherited from:
ImmutableNumericOps
final def ^^[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Alias for :^^(b) for all b.

Alias for :^^(b) for all b.

Inherited from:
ImmutableNumericOps
final def ^^:^^[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise logical "xor" operator -- returns true if only one of the corresponding elements is non-zero.

Element-wise logical "xor" operator -- returns true if only one of the corresponding elements is non-zero.

Inherited from:
ImmutableNumericOps
final def ^^=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise xor of this and b.

Mutates this by element-wise xor of this and b.

Inherited from:
NumericOps
Inherited from:
TensorLike
def apply[Slice1, Slice2, Result](slice1: Slice1, slice2: Slice2)(implicit canSlice: CanSlice2[DenseVector[V], Slice1, Slice2, Result]): Result

Method for slicing that is tuned for Matrices.

Method for slicing that is tuned for Matrices.

Inherited from:
TensorLike
def apply[Result](a: Int, b: Int, c: Int, slice: Int*)(implicit canSlice: CanSlice[DenseVector[V], Seq[Int], Result]): Result

Slice a sequence of elements. Must be at least 2.

Slice a sequence of elements. Must be at least 2.

Inherited from:
TensorLike
def apply[Slice, Result](slice: Slice)(implicit canSlice: CanSlice[DenseVector[V], Slice, Result]): Result

method for slicing a tensor. For instance, DenseVectors support efficient slicing by a Range object.

method for slicing a tensor. For instance, DenseVectors support efficient slicing by a Range object.

Inherited from:
TensorLike
final def dot[B, BB >: B, That](b: B)(implicit op: Impl2[DenseVector[V], BB, That]): That

Inner product of this and b.

Inner product of this and b.

Inherited from:
ImmutableNumericOps
def exists(f: V => Boolean): Boolean
Inherited from:
Vector
def findAll(f: V => Boolean): IndexedSeq[Int]

Returns all indices k whose value satisfies a predicate.

Returns all indices k whose value satisfies a predicate.

Inherited from:
QuasiTensor
def fold[E1 >: V](z: E1)(op: (E1, E1) => E1): E1

See scala.collection.mutable.ArrayOps.fold.

See scala.collection.mutable.ArrayOps.fold.

Inherited from:
Vector
def foldLeft[B](z: B)(op: (B, V) => B): B

See scala.collection.mutable.ArrayOps.foldLeft.

See scala.collection.mutable.ArrayOps.foldLeft.

Inherited from:
Vector
def foldRight[B](z: B)(op: (V, B) => B): B

See scala.collection.mutable.ArrayOps.foldRight.

See scala.collection.mutable.ArrayOps.foldRight.

Inherited from:
Vector
override def forall(f: V => Boolean): Boolean
Definition Classes
Inherited from:
Vector
def forall(fn: (Int, V) => Boolean): Boolean

Returns true if and only if the given predicate is true for all elements.

Returns true if and only if the given predicate is true for all elements.

Inherited from:
TensorLike
def foreachKey[U](fn: Int => U): Unit

Applies the given function to each key in the tensor.

Applies the given function to each key in the tensor.

Inherited from:
TensorLike
def foreachPair[U](fn: (Int, V) => U): Unit

Applies the given function to each key and its corresponding value.

Applies the given function to each key and its corresponding value.

Inherited from:
TensorLike
def foreachValue[U](fn: V => U): Unit

Applies the given function to each value in the map (one for each element of the domain, including zeros).

Applies the given function to each value in the map (one for each element of the domain, including zeros).

Inherited from:
TensorLike

How many elements must be iterated over using valueAt/indexAt. In HashVectors, activeSize is the number of non-zero elements, while iterableSize is the number of buckets currently allocated. (activeSize <= iterableSize in general, activeSize == iterableSize for everything except hashing implementations.)

How many elements must be iterated over using valueAt/indexAt. In HashVectors, activeSize is the number of non-zero elements, while iterableSize is the number of buckets currently allocated. (activeSize <= iterableSize in general, activeSize == iterableSize for everything except hashing implementations.)

Inherited from:
Storage
def iterator: Iterator[(Int, V)]
Inherited from:
Vector
def keySet: Set[Int]
Returns:

the set of keys in this vector (0 until length)

Inherited from:
Vector
Inherited from:
TensorLike
Inherited from:
Vector
def map[V2, That](fn: V => V2)(implicit canMapValues: CanMapValues[DenseVector[V], V, V2, That]): That
Inherited from:
VectorLike
def mapActivePairs[O, That](f: (Int, V) => O)(implicit bf: CanMapKeyValuePairs[DenseVector[V], Int, V, O, That]): That

Maps all active key-value pairs values.

Maps all active key-value pairs values.

Inherited from:
TensorLike
def mapActiveValues[O, That](f: V => O)(implicit bf: CanMapValues[DenseVector[V], V, O, That]): That

Maps all non-zero values.

Maps all non-zero values.

Inherited from:
TensorLike
def mapPairs[O, That](f: (Int, V) => O)(implicit bf: CanMapKeyValuePairs[DenseVector[V], Int, V, O, That]): That

Creates a new map containing a transformed copy of this map.

Creates a new map containing a transformed copy of this map.

Inherited from:
TensorLike
def mapValues[O, That](f: V => O)(implicit bf: CanMapValues[DenseVector[V], V, O, That]): That

Creates a new map containing a transformed copy of this map.

Creates a new map containing a transformed copy of this map.

Inherited from:
TensorLike
def padTo(len: Int, elem: V)(implicit cm: ClassTag[V]): Vector[V]

See scala.collection.mutable.ArrayOps.padTo.

See scala.collection.mutable.ArrayOps.padTo.

Inherited from:
Vector
Inherited from:
TensorLike
def reduce[E1 >: V](op: (E1, E1) => E1): E1

See scala.collection.mutable.ArrayOps.reduce.

See scala.collection.mutable.ArrayOps.reduce.

Inherited from:
Vector
def reduceLeft[B >: V](op: (B, V) => B): B

See scala.collection.mutable.ArrayOps.reduceLeft.

See scala.collection.mutable.ArrayOps.reduceLeft.

Inherited from:
Vector
def reduceRight[B >: V](op: (V, B) => B): B

See scala.collection.mutable.ArrayOps.reduceRight.

See scala.collection.mutable.ArrayOps.reduceRight.

Inherited from:
Vector
def scan[E1 >: V](z: E1)(op: (E1, E1) => E1)(implicit cm: ClassTag[V], cm1: ClassTag[E1]): Vector[E1]

See scala.collection.mutable.ArrayOps.scan.

See scala.collection.mutable.ArrayOps.scan.

Inherited from:
Vector
def scanLeft[B](z: B)(op: (B, V) => B)(implicit cm1: ClassTag[B]): Vector[B]

See scala.collection.mutable.ArrayOps.scanLeft.

See scala.collection.mutable.ArrayOps.scanLeft.

Inherited from:
Vector
def scanRight[B](z: B)(op: (V, B) => B)(implicit cm1: ClassTag[B]): Vector[B]

See scala.collection.mutable.ArrayOps.scanRight.

See scala.collection.mutable.ArrayOps.scanRight.

Inherited from:
Vector
override def size: Int
Definition Classes
Inherited from:
Vector
final def t[That, Slice1, Result](a: Slice1)(implicit op: CanTranspose[DenseVector[V], That], canSlice: CanSlice[That, Slice1, Result]): Result

A transposed view of this object, followed by a slice. Sadly frequently necessary.

A transposed view of this object, followed by a slice. Sadly frequently necessary.

Inherited from:
ImmutableNumericOps
final def t[That, Slice1, Slice2, Result](a: Slice1, b: Slice2)(implicit op: CanTranspose[DenseVector[V], That], canSlice: CanSlice2[That, Slice1, Slice2, Result]): Result

A transposed view of this object, followed by a slice. Sadly frequently necessary.

A transposed view of this object, followed by a slice. Sadly frequently necessary.

Inherited from:
ImmutableNumericOps
final def t[That](implicit op: CanTranspose[DenseVector[V], That]): That

A transposed view of this object.

A transposed view of this object.

Inherited from:
ImmutableNumericOps
def toDenseVector(implicit cm: ClassTag[V]): DenseVector[V]
Inherited from:
Vector
def toVector(implicit cm: ClassTag[V]): Vector[V]

Returns copy of this breeze.linalg.Vector as a scala.Vector

Returns copy of this breeze.linalg.Vector as a scala.Vector

Inherited from:
Vector
final def unary_![That](implicit op: Impl[DenseVector[V], That]): That
Inherited from:
ImmutableNumericOps
final def unary_-[That](implicit op: Impl[DenseVector[V], That]): That
Inherited from:
ImmutableNumericOps
Inherited from:
TensorLike
Inherited from:
Vector
final def |[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Alias for :||(b) for all b.

Alias for :||(b) for all b.

Inherited from:
ImmutableNumericOps
final def |:|[B, That](b: B)(implicit op: Impl2[DenseVector[V], B, That]): That

Element-wise logical "or" operator -- returns true if either element is non-zero.

Element-wise logical "or" operator -- returns true if either element is non-zero.

Inherited from:
ImmutableNumericOps
final def |=[B](b: B)(implicit op: InPlaceImpl2[DenseVector[V], B]): DenseVector[V]

Mutates this by element-wise or of this and b.

Mutates this by element-wise or of this and b.

Inherited from:
NumericOps

Concrete fields

val data: Array[V]
val length: Int
val offset: Int
val stride: Int