public class BasicVector extends DenseVector
BasicVector stores the underlying data in a standard array.| Constructor and Description |
|---|
BasicVector() |
BasicVector(double[] array) |
BasicVector(int length) |
| Modifier and Type | Method and Description |
|---|---|
Vector |
blankOfLength(int length)
Creates a blank (an empty vector) copy of this vector with the given
length. |
static BasicVector |
constant(int length,
double value)
|
Vector |
copyOfLength(int length)
Copies this vector into the new vector with specified
length. |
static BasicVector |
fromArray(double[] array)
Creates a new
BasicVector from the given array w/o
copying the underlying array. |
static BasicVector |
fromBinary(byte[] array)
Decodes
BasicVector from the given byte array. |
static BasicVector |
fromCollection(Collection<? extends Number> list)
Creates new
BasicVector from |
static BasicVector |
fromCSV(String csv)
Parses
BasicVector from the given CSV string. |
static BasicVector |
fromMap(Map<Integer,? extends Number> map,
int length)
Creates new
BasicVector from index-value map |
static BasicVector |
fromMatrixMarket(String mm)
Parses
BasicVector from the given Matrix Market string. |
double |
get(int i)
Gets the specified element of this vector.
|
static BasicVector |
random(int length,
Random random)
|
void |
set(int i,
double value)
Sets the specified element of this matrix to given
value. |
void |
swapElements(int i,
int j)
Swaps the specified elements of this vector.
|
<T extends Vector> |
to(VectorFactory<T> factory)
Converts this vector using the given
factory. |
double[] |
toArray()
Converts this dense vector to a double array.
|
byte[] |
toBinary()
Encodes this vector into a byte array.
|
static BasicVector |
unit(int length)
Creates an unit
BasicVector of the given length. |
static BasicVector |
zero(int length)
Creates a zero
BasicVector of the given length. |
apply, apply, apply, toColumnMatrix, toDiagonalMatrix, toMatrixMarket, toRowMatrixadd, add, blank, copy, divide, each, ensureLengthIsCorrect, equals, equals, euclideanNorm, fail, fold, hadamardProduct, hashCode, infinityNorm, innerProduct, is, iterator, length, manhattanNorm, max, min, mkString, mkString, multiply, multiply, non, norm, outerProduct, product, select, setAll, shuffle, slice, sliceLeft, sliceRight, subtract, subtract, sum, toCSV, toCSV, toDenseVector, toMatrixMarket, toSparseVector, toString, transform, update, updateAtpublic BasicVector()
public BasicVector(int length)
public BasicVector(double[] array)
public static BasicVector zero(int length)
BasicVector of the given length.public static BasicVector constant(int length, double value)
public static BasicVector unit(int length)
BasicVector of the given length.public static BasicVector random(int length, Random random)
public static BasicVector fromArray(double[] array)
BasicVector from the given array w/o
copying the underlying array.public static BasicVector fromBinary(byte[] array)
BasicVector from the given byte array.array - the byte array representing a vectorpublic static BasicVector fromCSV(String csv)
BasicVector from the given CSV string.csv - the CSV string representing a vectorpublic static BasicVector fromMatrixMarket(String mm)
BasicVector from the given Matrix Market string.mm - the string in Matrix Market formatpublic static BasicVector fromCollection(Collection<? extends Number> list)
BasicVector fromlist - list containing doublespublic static BasicVector fromMap(Map<Integer,? extends Number> map, int length)
BasicVector from index-value mapmap - index-value maplength - vector lengthpublic double get(int i)
Vectorpublic void set(int i,
double value)
Vectorvalue.public void swapElements(int i,
int j)
VectorswapElements in class Vectori - element's indexj - element's indexpublic Vector copyOfLength(int length)
Vectorlength.copyOfLength in class Vectorlength - the length of new vectorpublic double[] toArray()
DenseVectortoArray in class DenseVectorpublic <T extends Vector> T to(VectorFactory<T> factory)
Vectorfactory.public Vector blankOfLength(int length)
Vectorlength.blankOfLength in class Vectorlength - the length of the blank vectorCopyright © 2015. All rights reserved.