VectorBuilder

@SerialVersionUID(1L) 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, <B> indices are not unique in the index array</b>. 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
trait Serializable
trait HasOps
class Object
trait Matchable
class Any

Value members

Constructors

def this(length: Int, initialNonZero: Int)(implicit ring: Semiring[E], man: ClassTag[E])
def this(implicit ring: Semiring[E], man: ClassTag[E], zero: Zero[E])

Concrete methods

def activeIterator: Iterator[(Int, E)]
def activeKeysIterator: Iterator[Int]
def activeSize: Int
def activeValuesIterator: Iterator[E]
def add(i: Int, v: E): Unit

Only gives true if isActive would return true for all i. (May be false anyway)

Only gives true if isActive would return true for all i. (May be false anyway)

def apply(i: Int): E
def clear(): Unit
def compact(): Unit
def contains(i: Int): Boolean
def data: Array[E]
def default: E

This is always assumed to be equal to 0, for now.

This is always assumed to be equal to 0, for now.

override def equals(p1: Any): Boolean
Definition Classes
Any
def index: Array[Int]
def indexAt(i: Int): Int

Gives the logical index from the physical index.

Gives the logical index from the physical index.

def isActive(rawIndex: Int): Boolean
def reserve(nnz: Int): Unit
def size: Int
def toSparseVector(alreadySorted: Boolean, keysAlreadyUnique: Boolean): SparseVector[E]
override def toString: String
Definition Classes
Any
def toVector: Vector[E]
def update(i: Int, v: E): Unit
def use(index: Array[Int], data: Array[E], activeSize: Int): Unit

Sets the underlying sparse array to use this data

Sets the underlying sparse array to use this data

Value Params
activeSize

number of active elements. The first activeSize will be used.

data

values corresponding to the index

index

must be a sorted list of indices

def valueAt(i: Int): E

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

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

Value Params
i

index into the data array

Inherited methods

final def %[B, That](b: B)(implicit op: Impl2[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], B, That]): That

Matrix multiplication

Matrix multiplication

Inherited from
ImmutableNumericOps
final def *:*[B, That](b: B)(implicit op: Impl2[VectorBuilder[E], 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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], B]): VectorBuilder[E]

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

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

Inherited from
NumericOps
final def -[B, That](b: B)(implicit op: Impl2[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], B]): VectorBuilder[E]

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

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

Inherited from
NumericOps
final def /[B, That](b: B)(implicit op: Impl2[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], 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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], 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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], B]): VectorBuilder[E]

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[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], B]): VectorBuilder[E]

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 dot[B, BB >: B, That](b: B)(implicit op: Impl2[VectorBuilder[E], BB, That]): That

Inner product of this and b.

Inner product of this and b.

Inherited from
ImmutableNumericOps
final def t[That, Slice1, Result](a: Slice1)(implicit op: CanTranspose[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], That]): That

A transposed view of this object.

A transposed view of this object.

Inherited from
ImmutableNumericOps
final def unary_![That](implicit op: Impl[VectorBuilder[E], That]): That
Inherited from
ImmutableNumericOps
final def unary_-[That](implicit op: Impl[VectorBuilder[E], That]): That
Inherited from
ImmutableNumericOps
final def |[B, That](b: B)(implicit op: Impl2[VectorBuilder[E], 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[VectorBuilder[E], 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[VectorBuilder[E], B]): VectorBuilder[E]

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

var length: Int