|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjal.doubles.Numeric
A class that encapsulates generalized numeric algorithms on one and two arrays. All methods are static and all variables are static and final, so this class has no constructors.
Most methods operate on a range of elements. A range is described
by the index of its first element and an index that is
one past its last element. So, for example,
[n, n+1)
is a range that contains one element,
[n, n)
is a range that contains zero elements,
and [n, n-1)
is not a valid range.
Copyright © 1996
Silicon Graphics, Inc.
Permission to use, copy, modify, distribute and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear
in supporting documentation. Silicon Graphics makes no
representations about the suitability of this software for any
purpose. It is provided "as is" without express or
implied warranty.
Inspection
,
Modification
,
Sorting
Method Summary | |
static double |
accumulate(double[] array,
int first,
int last,
double init)
Add all elements in a range. |
static double |
accumulate(double[] array,
int first,
int last,
double init,
BinaryOperator op)
Generalized accumulation. |
static int |
adjacent_difference(double[] source,
double[] dest,
int first,
int last,
int to)
Computes the difference between each pair of adjacent elements in the input range and assigns them to an output range. |
static int |
adjacent_difference(double[] source,
double[] dest,
int first,
int last,
int to,
BinaryOperator op)
Computes a binary operation op for each pair of adjacent elements in
the input range and assigns the results to an output range. |
static double |
inner_product(double[] array1,
double[] array2,
int first1,
int last1,
int first2,
double init)
Computes the inner product of two ranges. |
static double |
inner_product(double[] array1,
double[] array2,
int first1,
int last1,
int first2,
double init,
BinaryOperator op1,
BinaryOperator op2)
Computes the generalized inner product of two ranges. |
static int |
partial_sum(double[] source,
double[] dest,
int first,
int last,
int to)
Computes the partial sums of elements in an input range and assigns them to elements in an output range. |
static int |
partial_sum(double[] source,
double[] dest,
int first,
int last,
int to,
BinaryOperator op)
Computes the generalized partial sums of elements in an input range and assigns them to elements in an output range. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static double accumulate(double[] array, int first, int last, double init)
acc
is set to
an initial value and, for each index i
in the range,
it is set to acc + array[i]
.
array
- Array containing the range.first
- Beginning of the range.last
- Last element of the range.init
- Initial value of the accumulation.
init + array[first] + ... + array[last-1]
.public static double accumulate(double[] array, int first, int last, double init, BinaryOperator op)
acc
is set to
an initial value and, for each index i
in the range,
it is set to op.apply(acc, array[i])
.
array
- Array containing the range.first
- Beginning of the range.last
- Last element of the range.init
- Initial value of the accumulation.op
- Binary operation.
public static double inner_product(double[] array1, double[] array2, int first1, int last1, int first2, double init)
acc
is set to an initial value, and, for each index i
in
the range [first, last)
, acc
is set to
acc + array1[i] * array2[first2 + (i - first1)]
.
array1
- Array containing the first range.array2
- Array containing the second range.first1
- Beginning of the first range.last1
- One past the end of the first range.first2
- Beginning of the second range.init
- Initial value for the result.
public static double inner_product(double[] array1, double[] array2, int first1, int last1, int first2, double init, BinaryOperator op1, BinaryOperator op2)
op1
and op2
. Specifically, the result
acc
is set to an initial value, and, for each index
i
in the range [first, last)
,
acc
is set to
op1.apply(acc, op2.apply(array1[i] * array2[first2 + (i - first1)]))
.
array1
- Array containing the first range.array2
- Array containing the second range.first1
- Beginning of the first range.last1
- One past the end of the first range.first2
- Beginning of the second range.init
- Initial value for the result.op1
- Binary operation that plays the role of addition.public static int partial_sum(double[] source, double[] dest, int first, int last, int to)
dest[to]
= source[first]
,
dest[to+1]
= source[first] + source[first+1]
,
etc.
There must be
enough space in the destination array, and existing elements
will be overwritten.
source
- Array containing the input range.dest
- Array containing the output range.first
- Beginning of the input range.last
- One past the end of the input range.to
- Beginning of the output range.
to + (last - first)
.public static int partial_sum(double[] source, double[] dest, int first, int last, int to, BinaryOperator op)
op
.
dest[to]
= source[first]
,
dest[to+1]
= op.apply(source[first], source[first+1])
,
etc.
There must be
enough space in the destination array, and existing elements
will be overwritten.
source
- Array containing the input range.dest
- Array containing the output range.first
- Beginning of the input range.last
- One past the end of the input range.to
- Beginning of the output range.op
- Binary operation that plays the role of addition.
to + (last - first)
.public static int adjacent_difference(double[] source, double[] dest, int first, int last, int to)
dest[to] = source[first]
,
dest[to+1] = source[first+1] - source[first]
,...,
dest[to + (last-first)] = source[last-1] - source[last-2]
.
There must be
enough space in the destination array, and existing elements
will be overwritten.
source
- Array containing the input range.dest
- Array containing the output range.first
- Beginning of the input range.last
- One past the end of the input range.to
- Beginning of the output range.
to + (last - first)
.public static int adjacent_difference(double[] source, double[] dest, int first, int last, int to, BinaryOperator op)
op
for each pair of adjacent elements in
the input range and assigns the results to an output range. Assigns
dest[to] = source[first]
,
dest[to+1] = op.apply(source[first+1], source[first])
,...,
dest[to + (last-first)] = op.apply(source[last-1], source[last-2])
.
There must be
enough space in the destination array, and existing elements
will be overwritten.
source
- Array containing the input range.dest
- Array containing the output range.first
- Beginning of the input range.last
- One past the end of the input range.to
- Beginning of the output range.op
- Binary operation.
to + (last - first)
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |