|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectSciLib.Math.vector
public class vector
This class defines a dynamic vector of type double.
| Constructor Summary | |
|---|---|
vector()
Allocates an empty vector. |
|
vector(double[] vec)
Allocates a vector from the array vec. |
|
vector(int n)
Allocates a vector of size n with initialized values 0. |
|
vector(int[] vec)
Allocates a vector from the array vec. |
|
vector(vector x)
Make a copy of the vector x. |
|
| Method Summary | |
|---|---|
void |
abs()
change the vector to its absolute values. |
static vector |
abs(vector v)
change the vector to its absolute values. |
void |
add(double x)
Add an element of value x to the vector. |
void |
append(vector x)
Append a vector x to this vector |
int |
argmax()
Compute the index of the maximum element in the vector. |
int |
argmin()
Compute the index of the minimum element in the vector. |
void |
concat(vector x)
Append a vector x to this vector |
double |
distance(vector x)
compute the distance between this point vector to a vector x |
static double |
distance(vector x,
vector y)
compute the distance between to point vector |
static double |
dot(integerVector i1,
vector x,
integerVector i2,
vector y)
compute the dot product of the two sparse vectors x, y |
static double |
dot(vector x,
vector y)
compute the dot product of the two vectors x, y |
double |
elementAt(int i)
return the value of vector at index i. |
static vector |
generate(double from,
double to,
double inc)
Make a uniform vector that has elements from a double "from" to a double "to", the values are increased by a value "inc" . |
static vector |
generate(int from,
int to)
create a uniform vector that has elements from an integer "from" to an integer "to". |
double[] |
getData()
Make an array of type double that contains all data of the vector. |
static vector |
linspace(double from,
double to)
Make a uniform vector of the default size 100 whose elements have values from a double "from" to a double "to". |
static vector |
linspace(double from,
double to,
int n)
Make a uniform vector of the size n whose elements have values from a double "from" to a double "to". |
void |
load(java.lang.String fileName)
Load data from a file to a vector. |
double |
max()
return the maximum value of the vector. |
double |
min()
return the minimum value of the vector. |
void |
minus(vector x)
minus this vector with the vector x and store the result in this vector. |
static vector |
minus(vector x,
vector y)
minus two vector x, y. |
double |
mult(vector x)
Compute the scalar product of this vector with the vector x. |
static double |
mult(vector x,
vector y)
Compute the scalar product of two vectors with x, y. |
double |
norm()
Compute the norm of the vector. |
void |
normalize()
normalize the vector so that its norm is equal to 1. |
static vector |
ones(int n)
Make a vector of length n whose elements have value 1. |
void |
plus(vector x)
plus this vector with the vector x and store the result in this vector |
static vector |
plus(vector x,
vector y)
plus two vector x, y. |
void |
pointByPointMult(vector x)
Time each element of this vector with each element of x and store the result in this in this vector. |
void |
print()
Print all elements of the vector using System.out. |
void |
print(int n)
print all elements of the vector with n decimal digits using System.out. |
void |
random()
Fill this vector with random values between 0 and 1. |
void |
random(double a,
double b)
Fill this vector with random values between a and b. |
void |
read(java.lang.String fileName)
Read data from a file to a vector. |
void |
resize(int n)
Change the size of the vector to n. |
void |
roundUp(int n)
Round up all elements of the vector to n decimal digits. |
static vector |
roundUp(vector x,
int n)
Round up all elements of the vector to n decimal digits. |
void |
scale(double s)
Scaling all elements of vector with a factor s. |
void |
setElementAt(double x,
int i)
change the value of element at index i with the double x. |
int |
size()
Return the length of the vector. |
double |
squareDistance(vector x)
compute the square distance between this point vector to a vector x |
static double |
squareDistance(vector x,
vector y)
compute the square distance between to point vector |
double |
squareNorm()
return the square of the norm of the vector. |
vector |
subvector(int from)
make a vector whose elements are equal to elements of this vector with the indexes from an integer "from" to the end of this vector. |
vector |
subvector(int from,
int to)
Make a vector whose elements are equal to elements of this vector with the indexes from an integer "from" to an intger "to". |
java.lang.String |
toString()
create a String that contains the elements of the vector. |
java.lang.String |
toString(int n)
create a String that contains the elements of the vector with n decimal digits format. |
void |
translate(double s)
plus all elements of the vector with factor s. |
void |
trimToSize()
Remove all the unused elements of the vector. |
void |
write(java.lang.String fileName)
Write all elements of the vector to a file. |
void |
write(java.lang.String fileName,
int n)
Write all elements of the vector to a file with the n deimal digits format. |
static vector |
zeros(int n)
Make a vector of length n whose elements have value 0. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public vector()
public vector(int n)
n - The length of the vectorpublic vector(double[] vec)
vec - An array of type doublepublic vector(int[] vec)
vec - An array of type doublepublic vector(vector x)
x - A vector| Method Detail |
|---|
public final void abs()
public static final vector abs(vector v)
public void add(double x)
x - A double valuepublic void append(vector x)
x - A vectorpublic final int argmax()
public final int argmin()
public void concat(vector x)
x - A vectorpublic double squareDistance(vector x)
x - A vector
public static double squareDistance(vector x,
vector y)
x - A vectory - A vector
public double distance(vector x)
x - A vector
public static double dot(vector x,
vector y)
x - A vectory - A vector
public static double dot(integerVector i1,
vector x,
integerVector i2,
vector y)
i1 - stores indexes of nozero elements of x, An integerVectorx - A vectori2 - stores indexes of nozero elements of y, An integerVectory - A vector
public static double distance(vector x,
vector y)
x - A vectory - A vector
public double elementAt(int i)
throws java.lang.ArrayIndexOutOfBoundsException
i - An integer
java.lang.ArrayIndexOutOfBoundsException
public static vector generate(int from,
int to)
from - An integerto - An integer
public static vector generate(double from,
double to,
double inc)
from - A doubleto - A double
public double[] getData()
public static vector linspace(double from,
double to)
from - A doubleto - A double
public static vector linspace(double from,
double to,
int n)
from - A doubleto - A doublen - The number of elements
public void load(java.lang.String fileName)
fileName - A Stringpublic final double max()
public final double min()
public void minus(vector x)
throws SizeException
x - A vector
SizeException
public static vector minus(vector x,
vector y)
throws SizeException
x - A vectory - A vector
SizeException
public double mult(vector x)
throws SizeException
x - A vector
SizeException
public static double mult(vector x,
vector y)
throws SizeException
x - A vectory - A vector
SizeExceptionpublic final double norm()
public final void normalize()
public static vector ones(int n)
public void plus(vector x)
throws SizeException
x - A vector
SizeException
public static vector plus(vector x,
vector y)
throws SizeException
x - A vectory - A vector
SizeException
public void pointByPointMult(vector x)
throws SizeException
SizeExceptionpublic void print()
public void print(int n)
n - The number of decimal digitspublic void random()
public void random(double a,
double b)
a - A double valueb - A double valuepublic void read(java.lang.String fileName)
fileName - a Stringpublic void resize(int n)
n - The new length of the vectorpublic void roundUp(int n)
n - The number of decimal digits
public static vector roundUp(vector x,
int n)
n - The number of decimal digits
public void scale(double s)
s - A double value that is the sacling factor
public void setElementAt(double x,
int i)
throws java.lang.ArrayIndexOutOfBoundsException
x - A double valuei - An integer
java.lang.ArrayIndexOutOfBoundsExceptionpublic final int size()
public final double squareNorm()
public vector subvector(int from,
int to)
from - start indexto - end index
public vector subvector(int from)
from - start index
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(int n)
n - The number of decimal digits
public void translate(double s)
s - A double valuepublic void trimToSize()
public void write(java.lang.String fileName)
fileName - A String
public void write(java.lang.String fileName,
int n)
fileName - A Stringpublic static vector zeros(int n)
n - An integer
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||