|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.numericalmethod.suanshu.datastructure.MathTable
public class MathTable
This class represents a mathematical table of numbers. The rows are indexed by real numbers.
| Nested Class Summary | |
|---|---|
class |
MathTable.Row
This class represents a row in a mathematical table. |
| Constructor Summary | |
|---|---|
MathTable(int nColumns)
Construct an empty table with a fixed number of columns. |
|
MathTable(java.lang.String... headers)
Construct an empty table with headers. |
|
| Method Summary | |
|---|---|
void |
addRow(double rowValue,
double[] columnValues)
Add a row to the table. |
void |
addRows(double[][] data)
Add rows by a 2D double array, double[][]. |
double |
get(double rowValue,
int columnIndex)
Get a particular table entry at [rowValue, columnIndex]. |
double |
get(double rowValue,
java.lang.String header)
Get a particular table entry at [rowValue, "header"]. |
MathTable.Row |
getRowOnOrAfter(double rowValue)
Get the row corresponding to the row index value. |
MathTable.Row |
getRowOnOrBefore(double rowValue)
Get the row corresponding to the row index value. |
java.util.Iterator<MathTable.Row> |
getRowsOnOrAfter(double rowValue)
Get the rows having a row index value equal to or bigger than the specified rowValue. |
java.util.Iterator<MathTable.Row> |
getRowsOnOrBefore(double rowValue)
Get the rows having a row index value equal to or smaller than the specified rowValue. |
java.lang.String[] |
headers()
Get the set of the names of the columns. |
double[] |
keys()
Get a copy of the set of row index values. |
int |
nColumns()
Get the number of columns in the table. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MathTable(java.lang.String... headers)
headers - the names of the columns; they must be uniquepublic MathTable(int nColumns)
The headers will be given default names.
nColumns - the number of columns| Method Detail |
|---|
public java.lang.String[] headers()
public int nColumns()
public void addRow(double rowValue,
double[] columnValues)
rowValue - the row index valuecolumnValues - the values in the rowpublic void addRows(double[][] data)
For example, new double[][]{ {1.0, 1.1, 1.2, 1.3}, {2.0, 2.1, 2.2, 2.3}, {3.0, 3.1, 3.2, 3.3}, {4.0, 4.1, 4.2, 4.3} }; represents 1.0: {1.1, 1.2, 1.3}//row 1 2.0: {2.1, 2.2, 2.3}//row 2 3.0: {3.1, 3.2, 3.3}//row 3 4.0: {4.1, 4.2, 4.3}//row 4
data - a double[][] of table entries.public double[] keys()
public MathTable.Row getRowOnOrBefore(double rowValue)
null is returned.
rowValue - a row index value
java.util.NoSuchElementException - if rowValue is smaller than the smallest row index valuepublic MathTable.Row getRowOnOrAfter(double rowValue)
null is returned.
rowValue - a row index value
java.util.NoSuchElementException - if rowValue is bigger than the biggest row index valuepublic java.util.Iterator<MathTable.Row> getRowsOnOrBefore(double rowValue)
rowValue.
The user can iterate the rows using the returned Iterator in reversed order starting from the matching row.
rowValue - the row index value
public java.util.Iterator<MathTable.Row> getRowsOnOrAfter(double rowValue)
rowValue.
The user can iterate the rows using the returned Iterator starting from the matching row.
rowValue - the row index value
public double get(double rowValue,
int columnIndex)
rowValue, by default, we use linear interpolation between the row above and below.
A subclass may override this behavior to provide customized interpolation.
rowValue - a row value indexcolumnIndex - a column index, counting from 1
java.util.NoSuchElementException - if rowValue is outside the table range
public double get(double rowValue,
java.lang.String header)
rowValue, by default, we use linear interpolation between the row above and below.
A subclass may override this behavior to provide customized interpolation.
rowValue - a row value indexheader - the name of a column
java.util.NoSuchElementException - if rowValue is outside the table range
|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||