|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.strbio.math.IVector
public class IVector
a class to encapsulate a 1-D matrix of integers. Can do a bunch of math functions, and save/load from a file.
Version 1.03, 7/7/99 - added equals Version 1.02, 7/6/99 - added reverse Version 1.01, 6/28/99 - added print, changed some PrintfStream to Printf Version 1.0, 3/30/98 - original version.
DVector
,
IMatrix
Field Summary | |
---|---|
int[] |
data
data contains the actual array itself; it's public so that it can be manipulated directly (for speed, such as that is in java) and so that you can do something like 'iv.data[0] = tmp' as well as 'tmp = iv.data[0]' without needing 2 different functions. |
Constructor Summary | |
---|---|
IVector()
makes a blank vector of dimension 0; you can assign a int[] to the data directly, or load data in from a file |
|
IVector(int dim)
makes an emptry IVector object with a specified dimension All data should be zeroed out... this is not done explicitly, but relies on Java's default values. |
|
IVector(int[] x)
makes a new IVector object out of a int[] array. |
|
IVector(IVector x)
copies another IVector. |
Method Summary | |
---|---|
void |
add(IVector x)
Adds another IVector to this one. |
static IVector |
add(IVector a,
IVector b)
Adds two IVector's and returns a new IVector containing the sum. |
IVector |
cross(IVector x)
Returns the cross product of multiplying this with another vector. |
static IVector |
cross(IVector x,
IVector y)
Returns the cross product of multiplying two vectors. |
int |
dimension()
returns the dimension the encapsulated array. |
int |
dot(IVector x)
Returns the dot product of multiplying this with another vector. |
static int |
dot(IVector x,
IVector y)
Returns the dot product of multiplying two vectors. |
IVector |
eliminate(int pos)
Return a copy of the vector with one position removed. |
boolean |
equals(java.lang.Object x)
mathematical objects are equal if their contents are. |
int |
length()
returns the dimension the encapsulated array. |
void |
load(java.io.BufferedReader infile)
Load from an open BufferedReader. |
void |
load(java.lang.String filename)
Loads from a text file. |
int |
max()
What's the maximum value in the array? |
int |
min()
What's the minimum value in the array? |
void |
multiply(int x)
Multiplies all values in this IVector by a specified int. |
static IVector |
multiply(int b,
IVector a)
Multiplies a IVector by an int and returns a new IVector containing the result. |
static IVector |
multiply(IVector a,
int b)
Multiplies a IVector by an int and returns a new IVector containing the result. |
void |
print(Printf outfile)
prints in ascii to an open Printf, with a nicer format than 'save'. |
void |
reverse()
reverses the order of data in the vector. |
static IVector |
reverse(IVector x)
returns a vector which is the reverse of this one. |
void |
save(Printf outfile)
Save to an open PrintfStream. |
void |
save(java.lang.String filename)
Saves to a new text file. |
void |
setValue(int x)
Sets every value in the matrix to a specified int. |
void |
setValueAt(int x,
int d)
Sets the data at a given index. |
IVector |
sort()
returns a vector of indices to sort an IVector (small -> large). |
void |
subtract(IVector x)
Subtracts another IVector from this one. |
static IVector |
subtract(IVector a,
IVector b)
Subtracts one IVector's from another returns a new IVector containing the difference. |
int |
valueAt(int x)
Returns the data at a given index. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int[] data
Constructor Detail |
---|
public IVector(int dim)
dim
- dimensionpublic IVector()
public IVector(int[] x)
public IVector(IVector x)
Method Detail |
---|
public IVector eliminate(int pos)
public boolean equals(java.lang.Object x)
equals
in class java.lang.Object
public final int length()
public final int dimension()
public final int valueAt(int x)
x
- indexpublic final void setValueAt(int x, int d)
x
- indexd
- value to set the data topublic final void setValue(int x)
public final void reverse()
public static final IVector reverse(IVector x)
public final void add(IVector x)
public static final IVector add(IVector a, IVector b)
public final void subtract(IVector x)
public static final IVector subtract(IVector a, IVector b)
public final void multiply(int x)
public static final IVector multiply(IVector a, int b)
public static final IVector multiply(int b, IVector a)
public final int dot(IVector x)
public static final int dot(IVector x, IVector y)
public final IVector cross(IVector x)
public static final IVector cross(IVector x, IVector y)
public final int max()
public final int min()
public IVector sort()
public void print(Printf outfile) throws java.io.IOException
java.io.IOException
save(org.strbio.io.Printf)
public final void save(Printf outfile) throws java.io.IOException
java.io.IOException
PrintfStream
public final void load(java.io.BufferedReader infile) throws java.io.IOException
java.io.IOException
BufferedReader
public final void save(java.lang.String filename) throws java.io.IOException
filename
- the file name.
java.io.IOException
public final void load(java.lang.String filename) throws java.io.IOException
filename
- the file name.
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |