|
JMSLTM Numerical Library 4.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.imsl.stat.Sort
A collection of sorting functions.
Class Sort contains ascending and descending methods for sorting elements
of an array or a matrix. The array ascending method sorts the elements of
an array, A, into ascending order by algebraic value.
The array A is divided into two parts by picking a
central element T of the array. The first and last
elements of A are compared with T
and exchanged until the three values appear in the array in ascending order.
The elements of the array are rearranged until all elements greater than or
equal to the central element appear in the second part of the array and all
those less than or equal to the central element appear in the first part.
The upper and lower subscripts of one of the segments are saved, and the
process continues iteratively on the other segment. When one segment is
finally sorted, the process begins again by retrieving the subscripts of
another unsorted portion of the array. On completion,
for
.
For more details, see Singleton (1969), Griffin and Redish (1970), and Petro (1970).
The matrix ascending method sorts the rows of real matrix x using a
particular row in x as the keys. The sort is algebraic with the
first key as the most significant, the second key as the next most significant,
etc. When x is sorted in ascending order, the resulting sorted array is such
that the following is true:
The observations also can be sorted in descending order.
The rows ofx containing the missing value code NaN in at least one of the
specified columns are considered as an additional group. These rows are
moved to the end of the sorted x. The sorting algorithm is based on a
quicksort method given by Singleton (1969) with modifications by Griffen and
Redish (1970) and Petro (1970).
All other methods in this class work off of the ascending methods.
| Constructor Summary | |
Sort()
|
|
| Method Summary | |
static void |
ascending(double[] ra)
Sort an array into ascending order. |
static void |
ascending(double[][] ra,
int nKeys)
Sort a matrix into ascending order by specified keys. |
static void |
ascending(double[][] ra,
int[] indkeys)
Sort a matrix into ascending order by specified keys. |
static void |
ascending(double[][] ra,
int[] indkeys,
int[] iperm)
Sort a matrix into ascending order by specified keys. |
static void |
ascending(double[][] ra,
int nKeys,
int[] iperm)
Sort an array into ascending order by specified keys. |
static void |
ascending(double[] ra,
int[] iperm)
Sort an array into ascending order. |
static void |
ascending(int[] ra)
Function to sort an integer array into ascending order. |
static void |
ascending(int[] ra,
int[] iperm)
Sort an array into ascending order. |
static void |
descending(double[] ra)
Sort an array into descending order. |
static void |
descending(double[][] ra,
int nKeys)
Function to sort a matrix into descending order by specified keys. |
static void |
descending(double[][] ra,
int[] indkeys)
Function to sort a matrix into descending order by specified keys. |
static void |
descending(double[][] ra,
int[] indkeys,
int[] iperm)
Function to sort a matrix into descending order by specified keys. |
static void |
descending(double[][] ra,
int nKeys,
int[] iperm)
Function to sort an array into descending order by specified keys. |
static void |
descending(double[] ra,
int[] iperm)
Sort an array into descending order. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Sort()
| Method Detail |
public static void ascending(double[] ra)
ra - double array to be sorted into ascending order
public static void ascending(double[][] ra,
int nKeys)
ra - double matrix to be sorted into ascending order.nKeys - int containing the first nKeys
columns of ra to be used as the sorting keys.
public static void ascending(double[][] ra,
int[] indkeys)
ra - double matrix to be sorted into ascending order.indkeys - int array containing the order the columns
of ra are to be sorted.
public static void ascending(double[][] ra,
int[] indkeys,
int[] iperm)
ra - double matrix to be sorted into ascending order.indkeys - int array containing the order the columns
of ra are to be sorted.iperm - int array specifying the rearrangement
(permutation) of the observations (rows) of ra.
public static void ascending(double[][] ra,
int nKeys,
int[] iperm)
ra - double array to be sorted into ascending order.nKeys - int containing the first nKeys
columns of ra to be used as the sorting keys.iperm - int array specifying the rearrangement
(permutation) of the observations (rows) of ra.
public static void ascending(double[] ra,
int[] iperm)
ra - double array to be sorted into ascending orderiperm - int array specifying the rearrangement
(permutation) of the observations (rows) of ra.public static void ascending(int[] ra)
ra - int array to be sorted into ascending order
public static void ascending(int[] ra,
int[] iperm)
ra - int array to be sorted into ascending orderiperm - int array to be sorted using the same permutations
applied to ra. Typically, you would initialize this
to 0, 1, ...public static void descending(double[] ra)
ra - double array to be sorted into descending order
public static void descending(double[][] ra,
int nKeys)
ra - double matrix to be sorted into descending order.nKeys - int containing the first nKeys
columns of ra to be used as the sorting keys.
public static void descending(double[][] ra,
int[] indkeys)
ra - double matrix to be sorted into descending order.indkeys - int array containing the order the columns
of ra are to be sorted.
public static void descending(double[][] ra,
int[] indkeys,
int[] iperm)
ra - double matrix to be sorted into descending order.indkeys - int array containing the order the columns
of ra are to be sorted.iperm - int array specifying the rearrangement
(permutation) of the observations (rows) of ra.
public static void descending(double[][] ra,
int nKeys,
int[] iperm)
ra - double array to be sorted into descending order.nKeys - int containing the first nKeys
columns of ra to be used as the sorting keys.iperm - int array specifying the rearrangement
(permutation) of the observations (rows) of ra.
public static void descending(double[] ra,
int[] iperm)
ra - double array to be sorted into descending orderiperm - int array specifying the rearrangement
(permutation) of the observations (rows) of ra.
|
JMSLTM Numerical Library 4.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||