|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.strbio.math.IMatrix
public class IMatrix
a class to encapsulate a 2-D matrix of integers Can do a bunch of math functions, and save/load from a file.
Version 1.13, 7/7/99 - added equals Version 1.12, 3/1/99 - added print() Version 1.11, 1/29/99 - changed some PrintfStream to Printf. Version 1,1, 5/18/98 - added saveBinary, autodetecting load. Version 1.01, 4/28/98 - fixed a couple of saving bugs Version 1.0, 3/30/98 - original version
DMatrix
,
IVector
Field Summary | |
---|---|
int[][] |
data
data contains the actual matrix 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 'im.data[0][0] = tmp' as well as 'tmp = im.data[0][0]' without needing 2 different functions. |
Constructor Summary | |
---|---|
IMatrix()
makes a blank 0x0 matrix; you can assign a int[][] to the data directly, or load data in from a file |
|
IMatrix(IMatrix x)
copies another IMatrix. |
|
IMatrix(int[][] x)
makes a new IMatrix object out of a int[][] array. |
|
IMatrix(int c,
int r)
makes an emptry IMatrix object with a specified number of columns and rows. |
Method Summary | |
---|---|
void |
add(IMatrix x)
Adds another IMatrix to this one. |
static IMatrix |
add(IMatrix a,
IMatrix b)
Adds two IMatrix's and returns a new IMatrix containing the sum. |
int |
cols()
returns the number of columns in the encapsulated array. |
boolean |
equals(java.lang.Object x)
mathematical objects are equal if their contents are. |
boolean |
isEmpty()
Does the matrix contain all zeroes? |
void |
load(java.io.BufferedReader infile)
Load text matrix from an open BufferedReader. |
void |
load(java.io.DataInputStream infile)
Load binary matrix from an open DataInputStream. |
void |
load(java.lang.String filename)
Loads matrix from a file; file type (text/binary) is autodetected. |
int |
max()
What's the maximum value in the matrix? |
int |
min()
What's the minimum value in the matrix? |
static IMatrix |
multiply(IMatrix a,
int b)
Multiplies a IMatrix by an int and returns a new IMatrix containing the result. |
void |
multiply(int x)
Multiplies all values in this IMatrix by a specified int. |
static IMatrix |
multiply(int b,
IMatrix a)
Multiplies a IMatrix by an int and returns a new IMatrix containing the result. |
void |
print(Printf outfile)
prints in ascii to an open Printf, with a nicer format than 'save'. |
int |
rows()
returns the number of rows in the encapsulated array. |
void |
save(Printf outfile)
Save to an open Printf. |
void |
save(java.lang.String filename)
Saves to a new text file. |
void |
saveBinary(java.io.DataOutputStream outfile)
Save in binary format to an open DataOutputStream |
void |
saveBinary(java.lang.String filename)
Saves to a new binary file. |
void |
setValue(int x)
Sets every value in the matrix to a specified int. |
void |
setValueAt(int c,
int r,
int d)
Sets the data at a given column/row. |
void |
subtract(IMatrix x)
Subtracts another IMatrix from this one. |
static IMatrix |
subtract(IMatrix a,
IMatrix b)
Subtracts one IMatrix's from another returns a new IMatrix containing the difference. |
int |
valueAt(int c,
int r)
Returns the data at a given column/row. |
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 IMatrix(int c, int r)
c
- columnsr
- rowspublic IMatrix()
public IMatrix(int[][] x)
public IMatrix(IMatrix x)
Method Detail |
---|
public boolean equals(java.lang.Object x)
equals
in class java.lang.Object
public final int cols()
public final int rows()
public final int valueAt(int c, int r)
c
- columnr
- rowpublic final void setValueAt(int c, int r, int d)
c
- columnr
- rowd
- value to set the data topublic final void setValue(int x)
public final void add(IMatrix x)
public static final IMatrix add(IMatrix a, IMatrix b)
public final void subtract(IMatrix x)
public static final IMatrix subtract(IMatrix a, IMatrix b)
public final void multiply(int x)
public static final IMatrix multiply(IMatrix a, int b)
public static final IMatrix multiply(int b, IMatrix a)
public final boolean isEmpty()
public final int max()
public final int min()
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
public final void saveBinary(java.io.DataOutputStream outfile) throws java.io.IOException
java.io.IOException
public final void load(java.io.BufferedReader infile) throws java.io.IOException
java.io.IOException
BufferedReader
public final void load(java.io.DataInputStream infile) throws java.io.IOException
java.io.IOException
public final void save(java.lang.String filename) throws java.io.IOException
filename
- the file name.
java.io.IOException
public final void saveBinary(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 |