public class SparseVector extends Object implements Vector, scala.Serializable, scala.Product
Constructor and Description |
---|
SparseVector(int size,
int[] indices,
double[] data) |
Modifier and Type | Method and Description |
---|---|
double |
apply(int index)
Element wise access function
|
SparseVector |
copy()
Copies the vector instance
|
double[] |
data() |
double |
dot(Vector other)
Returns the dot product of the recipient and the argument
|
boolean |
equals(Object obj) |
static SparseVector |
fromCOO(int size,
scala.collection.Iterable<scala.Tuple2<Object,Object>> entries)
Constructs a sparse vector from a coordinate list (COO) representation where each entry
is stored as a tuple of (index, value).
|
static SparseVector |
fromCOO(int size,
scala.collection.Seq<scala.Tuple2<Object,Object>> entries)
Constructs a sparse vector from a coordinate list (COO) representation where each entry
is stored as a tuple of (index, value).
|
static SparseVector |
fromCOO(int size,
scala.Tuple2<Object,Object> entry)
Convenience method to be able to instantiate a SparseVector with a single element.
|
int |
hashCode() |
int[] |
indices() |
double |
magnitude()
Magnitude of a vector
|
SparseMatrix |
outer(Vector other)
Returns the outer product (a.k.a.
|
int |
size()
Number of elements in a vector
|
static Object |
sparseVectorConverter()
BreezeVectorConverter implementation for
SparseVector |
DenseVector |
toDenseVector() |
String |
toString() |
void |
update(int index,
double value)
Updates the element at the given index with the provided value
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
equalsVector
public static SparseVector fromCOO(int size, scala.collection.Seq<scala.Tuple2<Object,Object>> entries)
size
- entries
- public static SparseVector fromCOO(int size, scala.collection.Iterable<scala.Tuple2<Object,Object>> entries)
size
- entries
- public static SparseVector fromCOO(int size, scala.Tuple2<Object,Object> entry)
size
- entry
- public static Object sparseVectorConverter()
SparseVector
This allows to convert Breeze vectors into SparseVector
public int size()
Vector
public int[] indices()
public double[] data()
public void update(int index, double value)
public SparseVector copy()
public double dot(Vector other)
public SparseMatrix outer(Vector other)
this
with other
. The result is given in SparseMatrix
representation.
outer
in interface Vector
other
- a VectorSparseMatrix
which equals the outer product of this
with other.
public double magnitude()
public double apply(int index)
* @param index index of the accessed element
public DenseVector toDenseVector()
public boolean equals(Object obj)
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.