

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object jal.strings.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, n1)
is not a valid range.
Unless otherwise specified, the test for equality uses
the ==
operator by default. Any different notion of
equality may be represented as a BinaryPredicate. You can use the
predefined class Equals, which implements BinaryPredicate, if you want
to use the Object.equals()
method.
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 String 
accumulate(String[] array,
int first,
int last,
String init,
BinaryOperator op)
Generalized accumulation. 
static int 
adjacent_difference(String[] source,
String[] 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 String 
inner_product(String[] array1,
String[] array2,
int first1,
int last1,
int first2,
String init,
BinaryOperator op1,
BinaryOperator op2)
Computes the generalized inner product of two ranges. 
static int 
partial_sum(String[] source,
String[] 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 String accumulate(String[] array, int first, int last, String 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 String inner_product(String[] array1, String[] array2, int first1, int last1, int first2, String 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(String[] source, String[] 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(String[] source, String[] 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 + (lastfirst)] = op.apply(source[last1], source[last2])
.
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 