package com.imsl.test.example.stat; import com.imsl.math.*; import com.imsl.stat.*; /** *
* Sorts an array and computes the permutation.
* An array is sorted by increasing value. A permutation array is also computed. * Note that the permutation array begins at 0 in this example. * * @see Code * @see Output */ public class SortEx1 { public static void main(String args[]) { double ra[] = {10., -9., 8., -7., 6., 5., 4., -3., -2., -1.}; int iperm[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; PrintMatrix pm = new PrintMatrix("The Input Array"); PrintMatrixFormat mf = new PrintMatrixFormat(); mf.setNoRowLabels(); mf.setNoColumnLabels(); // Print the array pm.print(mf, ra); System.out.println(); // Sort the array Sort.ascending(ra, iperm); pm = new PrintMatrix("The Sorted Array - Lowest to Highest"); mf = new PrintMatrixFormat(); mf.setNoRowLabels(); mf.setNoColumnLabels(); // Print the array pm.print(mf, ra); pm = new PrintMatrix("The Resulting Permutation Array"); mf = new PrintMatrixFormat(); mf.setNoRowLabels(); mf.setNoColumnLabels(); // Print the array pm.print(mf, iperm); } }