public class RealArray extends ArrayBase implements Iterable<Double>
| Modifier and Type | Class and Description |
|---|---|
static class |
RealArray.Filter
filter
|
static class |
RealArray.Monotonicity |
ArrayBase.TrimARRAY_REGEXC_AMP, C_APOS, C_ATSIGN, C_BACKSLASH, C_BACKSPACE, C_CARET, C_COLON, C_COMMA, C_DEL, C_DOLLAR, C_EQUALS, C_FORMFEED, C_HASH, C_LANGLE, C_LBRAK, C_LCURLY, C_LSQUARE, C_MINUS, C_NBSP, C_NEWLINE, C_NL, C_PERCENT, C_PERIOD, C_PIPE, C_PLUS, C_POUND, C_QUERY, C_QUOT, C_RANGLE, C_RBRAK, C_RCURLY, C_RETURN, C_RSQUARE, C_SEMICOLON, C_SHRIEK, C_SLASH, C_SPACE, C_STAR, C_TAB, C_TILDE, C_UNDER, EPS, F_S, NONWHITEPUNC, NONWHITEPUNC0, NONWHITEPUNC0REGEX, ONE_THIRD, PUNC, S_AMP, S_APOS, S_ATSIGN, S_BACKSLASH, S_CARET, S_COLON, S_COMMA, S_DOLLAR, S_EMPTY, S_EQUALS, S_FORMFEED, S_HASH, S_LANGLE, S_LBRAK, S_LCURLY, S_LSQUARE, S_MINUS, S_NEWLINE, S_NL, S_PERCENT, S_PERIOD, S_PIPE, S_PLUS, S_POUND, S_QUERY, S_QUOT, S_RANGLE, S_RBRAK, S_RCURLY, S_RETURN, S_RSQUARE, S_SEMICOLON, S_SHRIEK, S_SLASH, S_SPACE, S_STAR, S_TAB, S_TILDE, S_UNDER, S_WHITEREGEX, TWO_THIRDS, U_S, WHITESPACE| Constructor and Description |
|---|
RealArray()
create default Array.
|
RealArray(double[] arr)
create Array from java array.
|
RealArray(int n)
creates n-element array.
|
RealArray(IntArray ia)
create from IntArray.
|
RealArray(int n,
double elem1)
create Array initialized to constant value.
|
RealArray(int n,
double[] arr)
create Array from part of java array.
|
RealArray(int n,
double elem1,
double delta)
create n-element array initialised linearly.
|
RealArray(int nn,
String shape,
double maxval)
Create customized array.
|
RealArray(RealArray m)
copy constructor.
|
RealArray(RealArray ref,
IntArray sub)
create mixed sliced array.
|
RealArray(RealArray m,
int low,
int high)
create from subarray of another Array.
|
RealArray(String string)
create from a space-separated string of doubles.
|
RealArray(String[] strings)
construct from an array of Strings.
|
| Modifier and Type | Method and Description |
|---|---|
double |
absSumAllElements()
sum of all absolute element values.
|
void |
addArray(RealArray f)
append elements.
|
void |
addElement(double f)
append element.
|
RealArray |
addScalar(double f)
add a scalar to all elements.
|
RealArray |
applyFilter(RealArray filter)
apply filter.
|
RealArray |
calculateDifferences()
calculate differences between elements i and i+1
|
static void |
check(RealArray array,
int size)
checks RealArray is not null and is of given size.
|
void |
clearArray()
clear all elements of array.
|
Object |
clone()
clone.
|
IntArray |
createIntArray()
converts RealArray into IntArray.
|
static RealArray |
createRealArray(int[] integers)
casts an integer array to RealArray
|
static RealArray |
createRealArray(IntArray intArray)
casts an integer array to RealArray
|
static RealArray |
createRealArray(List<String> stringList)
interprets list of Strings as numbers.
|
RealArray |
createReorderedArray(IntSet intSet)
create new reordered array.
|
RealArray |
createScaledArrayToRange(double x0,
double x1)
creates scaled array so it runs spans new Range.
|
RealArray |
createScaledArrayToRange(double thisX0,
double thisX1,
double targetX0,
double targetX1)
creates scaled array so it runs spans new Range.
|
RealArray |
cumulativeSum()
cumulative sum of array.
|
void |
deleteElement(int elem)
delete element and close up.
|
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.
|
double |
dotProduct(RealArray f)
dot product of two arrays.
|
double |
elementAt(int elem)
get element by index.
|
boolean |
equals(RealArray f,
double epsilon)
are two arrays equal.
|
double |
euclideanLength()
Euclidean length of vector
|
double |
findFirstLocalMaximumafter(int start,
double cutoff)
if RA is an autocorrelation array find first maximum after origin.
|
RealArray |
format(int places)
round to decimal places.
|
double |
get(int elem)
get element by index.
|
double[] |
getArray()
get java array.
|
double |
getBaseLine()
find baseline.
|
static RealArray |
getFilter(int halfWidth,
RealArray.Filter function)
creates a filter based on Gaussian and derivatives.
|
DecimalFormat |
getFormat()
get output format.
|
double |
getLast()
gets last element in array
|
double |
getMax()
value of largest element.
|
Double |
getMean()
calculates mean as sum of all elements divided by number of elements
|
double |
getMin()
value of smallest element.
|
RealArray.Monotonicity |
getMonotonicity() |
RealArray |
getNormalDistribution(double sigma)
creates a normal distribution about a mean.
|
double |
getRandomVariate(RealArray distribution,
RealArray cumulativeDistribution)
gets a variate from a distribution.
|
RealRange |
getRange()
range of array.
|
RealArray |
getReorderedArray(IntSet idx)
get reordered Array.
|
double[] |
getReverseArray()
get java array in reverse order.
|
String |
getStringArray() |
String[] |
getStringValues()
returns values as strings.
|
RealArray |
getSubArray(int start,
int end)
get array slice.
|
static RealArray |
getSymmetricalArray(double mid,
int nsteps,
double halfrange)
gets range distributed about a midpoint.
|
int |
indexOfLargestElement()
index of largest element.
|
int |
indexOfSmallestElement()
index of smallest element.
|
IntSet |
indexSortAscending()
get indexes of ascending sorted array.
|
IntSet |
indexSortDescending()
get indexes of descending sorted array.
|
double |
innerProduct()
inner product.
|
IntSet |
inRange(RealRange r)
get elements within a range.
|
void |
insertArray(int elem,
RealArray f)
insert an array and expand.
|
void |
insertElementAt(int elem,
double f)
insert element and expand.
|
boolean |
isClear()
is the array filled with zeros.
|
boolean |
isEqualTo(RealArray f)
are two arrays equal.
|
static boolean |
isFloatArray(String s,
String delimiterRegex)
parse string as realArray.
|
Iterator<Double> |
iterator() |
double |
largestElement()
value of largest element.
|
double |
lineSearch(double probe,
RealArray distribution)
binary search on monotonic increasing distribution.
|
RealArray |
multiplyBy(double f)
array multiplication by a scalar.
|
void |
negative()
change the sign of all elements.
|
IntSet |
outOfRange(RealRange r)
get elements outside a range.
|
RealArray |
plus(double f)
add a scalar to each element.
|
RealArray |
plus(RealArray f)
adds arrays.
|
void |
plusEquals(RealArray f)
adds arrays.
|
void |
replaceNaN(double d)
replace all values of NaN with given value.
|
void |
reverse()
puts array into reverse order.
|
double |
rms()
root mean square sqrt(sigma(x(i)**2)/n)
|
static void |
round(double[] dd,
int ndec)
normalize to given number of places
replaces each element by (nint(elem*10^ndec))/10^ndec
|
RealArray |
scaleAndInterpolate(int newNelem)
Deprecated.
|
void |
setAllElements(double f)
initialise array to given value.
|
void |
setElementAt(int elem,
double f)
set element value.
|
void |
setElements(double[] a)
set array.
|
void |
setElements(int start,
double[] a)
set array slice.
|
void |
setFormat(DecimalFormat f)
set output format.
|
void |
shiftArrayRight(int nplaces)
shift array and fill with end elements.
|
RealArray |
shiftOriginToRight(double delta)
assumes all elements are equally spaced with "x" separation of 1.0.
|
RealArray |
shiftOriginToRightOld(double delta)
assumes all elements are equally spaced with "x" separation of 1.0.
|
int |
size()
get actual number of elements.
|
double |
smallestElement()
value of smallest element.
|
void |
sortAscending()
sorts array into ascending order.
|
void |
sortDescending()
sorts array into descending order.
|
RealArray |
subtract(RealArray f)
subtracts arrays.
|
void |
subtractEquals(RealArray f)
array subtraction.
|
double |
sumAllElements()
sum all elements.
|
double |
sumProductOfAllElements(RealArray yarr)
sum all product of elements.
|
String |
toString()
gets values as string.
|
RealArray |
trim(ArrayBase.Trim flag,
double limit)
trims array to lie within limit.
|
RealArray |
unitVector()
get unit vector
|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic RealArray()
public RealArray(int n)
n - size of arraypublic RealArray(int n,
double elem1,
double delta)
n - size of arrayelem1 - starting valuedelta - setpsizepublic RealArray(int n,
double elem1)
n - size of arrayelem1 - value to setpublic RealArray(int n,
double[] arr)
throws EuclidRuntimeException
n - number of elements to usearr - array to read fromEuclidRuntimeException - n larger than arraysizepublic RealArray(double[] arr)
arr - array to read frompublic RealArray(IntArray ia)
ia - IntArray to copy frompublic RealArray(RealArray m, int low, int high) throws EuclidRuntimeException
m - array to slicelow - inclusive start index of arrayhigh - inclusive end index of arrayEuclidRuntimeException - low > high or negative indices or outside size of mpublic RealArray(RealArray ref, IntArray sub) throws EuclidRuntimeException
ref - matrix to slicesub - subscripts.EuclidRuntimeException - if any of I(sub) lies outside 0...refmax-1public RealArray(RealArray m)
m - array to copypublic RealArray(int nn,
String shape,
double maxval)
nn - number of elementsshape - TRIANGLE or ZIGZAGmaxval - used to compute steppublic RealArray(String[] strings) throws EuclidRuntimeException
strings - values as StringsEuclidRuntimeException - a string could not be interpreted as doublespublic RealArray(String string) throws NumberFormatException
string - of form "1.1 -3.2 0.56E-04 2..."NumberFormatException - a substring could not be interpreted as doublepublic static RealArray getSymmetricalArray(double mid, int nsteps, double halfrange)
mid - midpoint of rangensteps - odd number of stepshalfrange - public static RealArray createRealArray(List<String> stringList)
stringList - public void setFormat(DecimalFormat f)
f - public DecimalFormat getFormat()
public void replaceNaN(double d)
d - default valuepublic static RealArray getFilter(int halfWidth, RealArray.Filter function)
halfWidth - function - public RealArray getNormalDistribution(double sigma)
sigma - standard deviationpublic double getRandomVariate(RealArray distribution, RealArray cumulativeDistribution)
distribution - cumulativeDistribution - initially clea, then used as cachepublic double lineSearch(double probe,
RealArray distribution)
probe - distribution - public double elementAt(int elem)
throws ArrayIndexOutOfBoundsException
elem - the indexArrayIndexOutOfBoundsException - elem >= size of thispublic double get(int elem)
throws ArrayIndexOutOfBoundsException
elem - the indexArrayIndexOutOfBoundsException - elem >= size of thispublic int size()
public double[] getArray()
public void clearArray()
public double[] getReverseArray()
public boolean isEqualTo(RealArray f)
f - array to comparepublic boolean equals(RealArray f, double epsilon)
f - array to compareepsilon - tolerancepublic RealArray plus(RealArray f) throws EuclidRuntimeException
f - array to addEuclidRuntimeException - f is different size from thispublic void plusEquals(RealArray f) throws EuclidRuntimeException
f - array to addEuclidRuntimeException - f is different size from thispublic RealArray subtract(RealArray f) throws EuclidRuntimeException
f - array to substractEuclidRuntimeException - f is different size from thispublic void subtractEquals(RealArray f) throws EuclidRuntimeException
f - array to subtractEuclidRuntimeException - f is different size from thispublic void negative()
public RealArray addScalar(double f)
f - to addpublic RealArray multiplyBy(double f)
f - multiplierpublic RealArray plus(double f)
f - multiplierpublic void setElementAt(int elem,
double f)
throws ArrayIndexOutOfBoundsException
elem - indexf - valueArrayIndexOutOfBoundsException - elem >= size of thispublic RealArray getSubArray(int start, int end)
start - index inclusiveend - index inclusivepublic void setElements(int start,
double[] a)
start - index in thisa - array to copyArrayIndexOutOfBoundsException - start < 0 or start+a.length > this.size()public void setElements(double[] a)
a - array to copypublic boolean isClear()
public void setAllElements(double f)
f - value to setpublic double sumAllElements()
public double sumProductOfAllElements(RealArray yarr)
public double absSumAllElements()
public double innerProduct()
public double dotProduct(RealArray f) throws EuclidRuntimeException
f - array to multiplyEuclidRuntimeException - f is different size from thispublic double euclideanLength()
public double rms()
throws EuclidRuntimeException
EuclidRuntimeException - must have at least 1 pointpublic RealArray unitVector() throws EuclidRuntimeException
EuclidRuntimeException - elements of this are all zeropublic RealArray cumulativeSum()
public RealArray applyFilter(RealArray filter)
filter has <= 1 element, return this
unchanged. filter should have an odd number of elements. The
filter can be created with a IntArray constructor filter is moved along
stepwisefilter - to apply normally smaller than thispublic RealArray trim(ArrayBase.Trim flag, double limit)
flag - BELOW or ABOVElimit - value to constrainpublic int indexOfLargestElement()
ArrayIndexOutOfBoundsException - array is zero lengthpublic int indexOfSmallestElement()
ArrayIndexOutOfBoundsException - array is zero lengthpublic double largestElement()
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException - array is zero lengthpublic double getMax()
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException - array is zero lengthpublic double smallestElement()
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException - array is zero lengthpublic double getMin()
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException - array is zero lengthpublic Double getMean()
public RealRange getRange() throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException - array is zero lengthpublic void deleteElement(int elem)
throws ArrayIndexOutOfBoundsException
elem - to deleteArrayIndexOutOfBoundsException - elem out of rangepublic void deleteElements(int low,
int high)
throws ArrayIndexOutOfBoundsException
low - lowest index inclusivehigh - highest index inclusiveArrayIndexOutOfBoundsException - low or high out of range or low > highpublic void insertElementAt(int elem,
double f)
throws ArrayIndexOutOfBoundsException
elem - index of element to insertf - value of elementArrayIndexOutOfBoundsException - elem out of rangepublic void insertArray(int elem,
RealArray f)
throws ArrayIndexOutOfBoundsException
elem - index of element to insertf - value of elementArrayIndexOutOfBoundsException - elem out of rangepublic void addElement(double f)
f - element to appendpublic void addArray(RealArray f)
f - elements to appendpublic RealArray getReorderedArray(IntSet idx) throws EuclidRuntimeException
idx - array of indexesEuclidRuntimeException - an element of idx is outside range of thispublic static void round(double[] dd,
int ndec)
dd - arrayndec - number of placespublic IntSet inRange(RealRange r)
r - within which element values must liepublic IntSet outOfRange(RealRange r)
r - outside which element values must liepublic String[] getStringValues()
public String getStringArray()
public String toString()
public static double[] deleteElements(double[] f,
int low,
int hi)
f - hi - low - public double findFirstLocalMaximumafter(int start,
double cutoff)
cutoff - public double getBaseLine()
public RealArray format(int places)
places - public void sortAscending()
public void sortDescending()
public void reverse()
public RealArray createReorderedArray(IntSet intSet)
intSet - public IntSet indexSortAscending()
public IntSet indexSortDescending()
public RealArray.Monotonicity getMonotonicity()
public static void check(RealArray array, int size) throws EuclidRuntimeException
array - to checksize - required sizeEuclidRuntimeException - if null or wrong sizepublic static boolean isFloatArray(String s, String delimiterRegex)
s - delimiterRegex - public RealArray createScaledArrayToRange(double thisX0, double thisX1, double targetX0, double targetX1)
thisX0 - low map point of thisthisX1 - high map point of thistargetX0 - low map point of targettargetX1 - high map point of targetpublic RealArray createScaledArrayToRange(double x0, double x1)
public static RealArray createRealArray(int[] integers)
integers - public static RealArray createRealArray(IntArray intArray)
intArray - integer arraypublic RealArray calculateDifferences()
public IntArray createIntArray()
public RealArray shiftOriginToRight(double delta)
delta - distance to shift by@Deprecated public RealArray scaleAndInterpolate(int newNelem)
newNelem - new array lengthpublic RealArray shiftOriginToRightOld(double delta)
delta - distance to shift bypublic void shiftArrayRight(int nplaces)
nplaces - if positive sift right; if negative shift leftpublic double getLast()
Copyright © 1994–2024 Peter Murray-Rust. All rights reserved.