|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object
|
+--jumbo.euclid.Status
|
+--jumbo.euclid.RealArray
RealArray - array of doubles
RealArray represents a 1-dimensional vector/array of doubles and is basically a wrapper for double[] in Java There are a lot of useful member functions (sorting, ranges, parallel operations, etc. - have a look)
The default is an array with zero points. All arrays are valid objects.
Attempting to create an array with < 0 points creates a default array (zero points).
Since double[] knows its length (unlike C), there are many cases where double[] can be safely used. However it is not a first-class object and RealArray supplies this feature. double[] is referenceable through getArray().
| Constructor Summary | |
RealArray()
default is an array of zero points |
|
RealArray(double[] arr)
from an existing double[] (which knows its length) |
|
RealArray(int n)
creates n-element array initialised to 0.0 |
|
RealArray(IntArray ia)
convert an IntArray to a RealArray |
|
RealArray(int n,
double elem1)
set all elements of the array to a given value |
|
RealArray(int n,
double[] arr)
Formed by feeding in an existing array; requires the size. |
|
RealArray(int n,
double elem1,
double delta)
This gives a nelem-element array initialised to elem1+(i-1)*delta |
|
RealArray(int nn,
java.lang.String shape,
double maxval)
Create a given 'shape' of array for data filtering. |
|
RealArray(RealArray m)
copy constructor |
|
RealArray(RealArray m,
int low,
int high)
subarray of another array - inclusive; if low > high or other silly indices, creates default array |
|
RealArray(java.lang.String string)
from a String with space-separated strings representing Reals |
|
RealArray(java.lang.String[] strings)
from an array of Strings (which must represent Reals) |
|
| Method Summary | |
double |
absSumAllElements()
absolute sum of all elements |
void |
addArray(RealArray f)
append elements |
void |
addElement(double f)
append element |
RealArray |
applyFilter(RealArray filter)
apply filter (i.e. |
void |
clearArray()
clear all elements of array |
java.lang.Object |
clone()
clones another RealArray |
static double[] |
copy(double[] f)
copy a double[] into a new one |
RealArray |
cumulativeSum()
cumulative sum of array (new RA contains elem[i] = sum(k = 0 to i) f[k] |
void |
deleteElement(int elem)
delete element and close up; if outside range, take no action |
static double[] |
deleteElements(double[] f,
int low,
int hi)
delete elements (lo - > hi inclusive) in a float[] and close up; if hi >= float.length hi is reset to float.length-1. |
void |
deleteElements(int low,
int high)
delete elements and close up; if outside range take no action |
double |
dotProduct(RealArray f)
dot product of two RealArrays - if of same length - else zero |
double |
elementAt(int elem)
extracts a given element from the array |
boolean |
equals(RealArray f)
are two arrays equal in all elements? |
boolean |
equals(RealArray f,
double epsilon)
are two arrays equal in all elements? (use epsilon as tolerance) |
double |
euclideanLength()
Euclidean length of vector |
double[] |
getArray()
return the array as a double[]; this has to resize the array to the precise length used , or confusion will result! Note that this gives the user access to the actual array, so that they can alter its contents. |
RealArray |
getReorderedArray(IntSet idx)
reorder by index in IntSet; does NOT modify array |
double[] |
getReverseArray()
return the elements in reverse order as double[] |
java.lang.String[] |
getStringValues()
returns values as strings |
RealArray |
getSubArray(int start,
int end)
RHS: get a subRealArray from element start to end |
int |
indexOfLargestElement()
index of largest element; returns -1 if zero element array |
int |
indexOfSmallestElement()
index of smallest element |
IntSet |
indexSortAscending()
|
IntSet |
indexSortDescending()
sort array into descending order via indexes; array NOT MODIFIED |
double |
innerProduct()
inner product - same as dotProduct |
IntSet |
inRange(RealRange r)
return index of elements within a given range |
void |
insertArray(int elem,
RealArray f)
insert a RealArray at position elem and expand |
void |
insertElementAt(int elem,
double f)
insert element and expand; if outside range, take no action |
boolean |
isClear()
is the array filled with zeros? |
double |
largestElement()
value of largest element |
static void |
main(java.lang.String[] args)
|
RealArray |
multiplyBy(double f)
array multiplication by a scalar; does NOT modify 'this' |
void |
negative()
change the sign of all elements; MODIFIES this |
IntSet |
outOfRange(RealRange r)
return index of elements outside a given range |
RealArray |
plus(RealArray f)
array addition - adds conformable arrays |
RealRange |
range()
range of array (default RealRange for zero array) |
void |
reverse()
MODIFIES array to be in reverse order |
double |
rms()
root mean square sqrt(sigma(x(i)**2)/n) |
void |
setAllElements(double f)
initialise array to given double[] |
void |
setElementAt(int elem,
double f)
set a given element into the array; must be less than current max index |
void |
setElements(int start,
double[] a)
copy a smaller array into the array statrting at start |
void |
setMaxIndex(int max)
reset the maximum index (for when poking elements) (no other effect) |
void |
shallowCopy(RealArray m)
shallowCopy |
int |
size()
get actual number of elements |
double |
smallestElement()
value of smallest element |
void |
sortAscending()
MODIFIES array to be in ascending order |
void |
sortDescending()
MODIFIES array to be in ascending order |
RealArray |
subtract(RealArray f)
array subtraction - subtracts conformable arrays |
double |
sumAllElements()
sum all elements |
static void |
test()
|
java.lang.String |
toString()
concatenates values with spaces |
RealArray |
unitVector()
get unit vector |
| Methods inherited from class jumbo.euclid.Status |
NYI |
| Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Constructor Detail |
public RealArray()
public RealArray(int n)
public RealArray(int n,
double elem1,
double delta)
public RealArray(int n,
double elem1)
public RealArray(int n,
double[] arr)
public RealArray(double[] arr)
public RealArray(IntArray ia)
public RealArray(RealArray m,
int low,
int high)
public RealArray(RealArray m)
public RealArray(int nn,
java.lang.String shape,
double maxval)
public RealArray(java.lang.String[] strings)
throws java.lang.NumberFormatException
public RealArray(java.lang.String string)
throws java.lang.NumberFormatException
| Method Detail |
public java.lang.Object clone()
public void shallowCopy(RealArray m)
public double elementAt(int elem)
throws java.lang.ArrayIndexOutOfBoundsException
public int size()
public double[] getArray()
public void clearArray()
public double[] getReverseArray()
public void setMaxIndex(int max)
public boolean equals(RealArray f)
throws UnequalArraysException
public boolean equals(RealArray f,
double epsilon)
throws UnequalArraysException
public RealArray plus(RealArray f)
throws UnequalArraysException
public RealArray subtract(RealArray f)
throws UnequalArraysException
public void negative()
public RealArray multiplyBy(double f)
public void setElementAt(int elem,
double f)
throws java.lang.ArrayIndexOutOfBoundsException
public RealArray getSubArray(int start,
int end)
public void setElements(int start,
double[] a)
public boolean isClear()
public void setAllElements(double f)
public double sumAllElements()
public double absSumAllElements()
public double innerProduct()
public double dotProduct(RealArray f)
throws UnequalArraysException
public double euclideanLength()
public double rms()
throws ArrayTooSmallException
public RealArray unitVector()
throws ZeroVectorException
public RealArray cumulativeSum()
does not modify 'this'
public RealArray applyFilter(RealArray filter)
The filter can be created with a RealArray constructor
public int indexOfLargestElement()
public int indexOfSmallestElement()
public double largestElement()
public double smallestElement()
public RealRange range()
public void deleteElement(int elem)
public void deleteElements(int low,
int high)
public void insertElementAt(int elem,
double f)
public void insertArray(int elem,
RealArray f)
public void addElement(double f)
public void addArray(RealArray f)
public RealArray getReorderedArray(IntSet idx)
throws BadSubscriptException
public IntSet inRange(RealRange r)
public IntSet outOfRange(RealRange r)
public java.lang.String[] getStringValues()
public java.lang.String toString()
public static double[] deleteElements(double[] f,
int low,
int hi)
public static double[] copy(double[] f)
public void sortAscending()
public void sortDescending()
public void reverse()
public IntSet indexSortAscending()
public IntSet indexSortDescending()
public static void test()
public static void main(java.lang.String[] args)
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||