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
|
abstract static boolean |
canEqual(Object that) |
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 boolean |
equalsVector(Vector vector) |
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.
|
abstract static int |
productArity() |
abstract static Object |
productElement(int n) |
static scala.collection.Iterator<Object> |
productIterator() |
static String |
productPrefix() |
int |
size()
Number of elements in a vector
|
static Object |
sparseVectorConverter()
BreezeVectorConverter implementation for
SparseVector |
DenseVector |
toDenseVector()
Converts the
SparseVector to a DenseVector |
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
- The number of elements in the vectorentries
- The values in the vectorSparseVector
public static SparseVector fromCOO(int size, scala.collection.Iterable<scala.Tuple2<Object,Object>> entries)
size
- The number of elements in the vectorentries
- An iterator supplying the values in the vectorSparseVector
public static SparseVector fromCOO(int size, scala.Tuple2<Object,Object> entry)
size
- The number of elements in the vectorentry
- The value in the vectorSparseVector
public static Object sparseVectorConverter()
SparseVector
This allows to convert Breeze vectors into SparseVector
public static boolean equalsVector(Vector vector)
public abstract static boolean canEqual(Object that)
public abstract static Object productElement(int n)
public abstract static int productArity()
public static scala.collection.Iterator<Object> productIterator()
public static String productPrefix()
public int size()
Vector
public int[] indices()
public double[] data()
public void update(int index, double value)
public SparseVector copy()
copy
in interface Vector
SparseVector
instancepublic 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 Vector
SparseMatrix
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()
SparseVector
to a DenseVector
public boolean equals(Object obj)
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.