public class DenseVector extends java.lang.Object implements Vector
double based vector representation.| Constructor and Description |
|---|
DenseVector(DenseVector vector)
Copy constructor.
|
DenseVector(double... data)
Construct a vector, initialized by a
double[]. |
DenseVector(int length)
Construct a vector.
|
DenseVector(int[] data)
Construct a vector, initialized by a
int[]. |
DenseVector(int length,
double value)
Construct a vector, initialized by repeating a value.
|
DenseVector(Matrix A)
Construct a vector from a column or row matrix.
|
DenseVector(Vector v)
Cast any vector to a
DenseVector. |
| Modifier and Type | Method and Description |
|---|---|
DenseVector |
add(double scalar)
Add a constant to all entries in this vector.
|
Vector |
add(Vector that)
\(this + that\)
|
double |
angle(Vector that)
Measure the angle, \(\theta\), between
this and that. |
DenseVector |
deepCopy()
The implementation returns an instance created from
this by the copy
constructor of the class, or just this if the instance itself is
immutable. |
Vector |
divide(Vector that)
Divide
this by that, entry-by-entry. |
boolean |
equals(java.lang.Object obj) |
double |
get(int i)
Get the value at position i.
|
int |
hashCode() |
double |
innerProduct(Vector that)
Inner product in the Euclidean space is the dot product.
|
DenseVector |
minus(double scalar)
Subtract a constant from all entries in this vector.
|
Vector |
minus(Vector that)
\(this - that\)
|
Vector |
multiply(Vector that)
Multiply
this by that, entry-by-entry. |
double |
norm()
Compute the length or magnitude or Euclidean norm of a vector, namely, \(\|v\|\).
|
double |
norm(int p)
Get the norm of a vector.
|
Vector |
opposite()
Get the opposite of this vector.
|
DenseVector |
pow(double scalar)
Take the exponentiation of all entries in this vector, entry-by-entry.
|
DenseVector |
scaled(double c)
Scale this vector by a constant, entry-by-entry.
|
Vector |
scaled(Real c)
Scale this vector by a constant, entry-by-entry.
|
void |
set(int from,
DenseVector replacement)
Replace a sub-vector
v[from : replacement.length] by a replacement starting at position from. |
void |
set(int i,
double value)
Change the value of an entry in this vector.
|
int |
size()
Get the length of this vector.
|
double[] |
toArray()
Cast this vector into a 1D
double[]. |
java.lang.String |
toString() |
DenseVector |
ZERO()
Get a 0-vector that has the same length as this vector.
|
public DenseVector(int length)
length - the length of this vectorpublic DenseVector(int length,
double value)
length - the length of this vectorvalue - the initial valuepublic DenseVector(double... data)
double[].data - an 1D arraypublic DenseVector(int[] data)
int[].data - an 1D arraypublic DenseVector(Matrix A)
A - a column or row matrixpublic DenseVector(Vector v)
DenseVector.v - a vectorpublic DenseVector(DenseVector vector)
vector - a vectorpublic int size()
Vectorpublic void set(int i,
double value)
Vectorpublic void set(int from,
DenseVector replacement)
v[from : replacement.length] by a replacement starting at position from.from - the starting position of the replacementreplacement - a vector for substitutionjava.lang.IllegalArgumentException - if the replacement length exceeds the end of this vectorpublic double get(int i)
Vectorpublic Vector add(Vector that)
Vectoradd in interface AbelianGroup<Vector>add in interface Vectorthat - a vectorpublic Vector minus(Vector that)
Vectorminus in interface AbelianGroup<Vector>minus in interface Vectorthat - a vectorpublic DenseVector scaled(double c)
Vector
vector.scaled(1. / vector.norm())
public Vector scaled(Real c)
Vector
vector.scaled(1. / vector.norm())
scaled in interface VectorSpace<Vector,Real>scaled in interface Vectorc - a constantpublic Vector opposite()
Vectoropposite in interface AbelianGroup<Vector>opposite in interface Vectorpublic Vector multiply(Vector that)
Vectorthis by that, entry-by-entry.public Vector divide(Vector that)
Vectorthis by that, entry-by-entry.public DenseVector add(double scalar)
Vectorpublic DenseVector minus(double scalar)
Vectorpublic DenseVector pow(double scalar)
Vectorpublic double norm(int p)
Vectorpublic double norm()
Vectornorm in interface BanachSpace<Vector,Real>norm in interface Vectorpublic double angle(Vector that)
Vectorthis and that.
That is,
\[
this \cdot that = \|this\| \times \|that\| \times \cos \theta
\]public double innerProduct(Vector that)
VectorinnerProduct in interface HilbertSpace<Vector,Real>innerProduct in interface Vectorthat - a vectorpublic DenseVector ZERO()
VectorZERO in interface AbelianGroup<Vector>ZERO in interface Vectorpublic double[] toArray()
Vectordouble[].public DenseVector deepCopy()
DeepCopyablethis by the copy
constructor of the class, or just this if the instance itself is
immutable.deepCopy in interface DeepCopyabledeepCopy in interface Vectorpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object