public class ConstantVector extends Vec
setLength(int)
and
setConstant(double)
values respectively. The Constant Vector
representation uses only constant space.
Constructor and Description |
---|
ConstantVector(double constant,
int length)
Creates a new vector where all values have a single implicit value
|
Modifier and Type | Method and Description |
---|---|
ConstantVector |
clone() |
double |
get(int index)
Gets the value stored at a specific index in the vector
|
boolean |
isSparse()
Indicates whether or not this vector is optimized for sparce computation,
meaning that most values in the vector are zero - and considered
implicit.
|
int |
length()
Returns the length of this vector
|
double |
mean()
Computes the mean value of all values stored in this vector
|
double |
median()
Returns the median value in this vector
|
Vec |
normalized()
Returns a new vector that is the result of normalizing this vector by the
L2 norm
|
double |
pNorm(double p)
Returns the p-norm of this vector.
|
void |
set(int index,
double val)
Sets the value stored at a specified index in the vector
|
void |
setConstant(double constant)
Sets the constant value that will be used as the value stored in every
index of this vector.
|
void |
setLength(int length)
Sets the length of this vector.
|
double |
standardDeviation()
Computes the standard deviation of the values in this vector
|
double |
sum()
Computes the sum of the values in this vector
|
double |
variance()
Computes the variance of the values in this vector, which is
Vec.standardDeviation() 2 |
add, add, applyFunction, applyIndexFunction, arrayCopy, canBeMutated, copyTo, copyToCol, copyToRow, countNaNs, divide, dot, equals, equals, getNonZeroIterator, getNonZeroIterator, hashCode, increment, iterator, kurtosis, max, min, multiply, multiply, multiply, multiply, mutableAdd, mutableAdd, mutableAdd, mutableDivide, mutableMultiply, mutablePairwiseDivide, mutablePairwiseMultiply, mutableSubtract, mutableSubtract, mutableSubtract, nnz, normalize, pairwiseDivide, pairwiseMultiply, pNormDist, random, random, skewness, sortedCopy, subtract, subtract, toString, zeroOut, zeros
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public ConstantVector(double constant, int length)
constant
- the constant to use as the single value for all indiceslength
- the length of this vectorpublic void setConstant(double constant)
constant
- the constant value to represent as a vectorpublic void setLength(int length)
length
- the new length for this vectorpublic int length()
Vec
public double get(int index)
Vec
public double sum()
Vec
public double mean()
Vec
public double variance()
Vec
Vec.standardDeviation()
2public double standardDeviation()
Vec
standardDeviation
in class Vec
public Vec normalized()
Vec
normalized
in class Vec
public double pNorm(double p)
Vec
public double median()
Vec
public void set(int index, double val)
Vec
public boolean isSparse()
Vec
public ConstantVector clone()
Copyright © 2017. All rights reserved.