next up previous index
Next: M109 Sort Rows Up: CERNLIB Previous: M104 Sort One-Dimensional

M107 Sort Rows of a Matrix

Routine ID: M107
Author(s): F. CarminatiLibrary: KERNLIB
Submitter: Submitted: 09.02.1989
Language: FortranRevised:

SORTR re-arranges the row order of a matrix in such a way that the elements of a selected column are either in increasing or decreasing order as described. When these elements are equal, the rows are kept in their original order.

Structure:

SUBROUTINE subprogram
User Entry Names: SORTR, SORTI, SORTD
External References: VECMAN (F121), USWOP (V301) (not on all machines)

Usage:

For t=I (type INTEGER), t=R (type REAL), t=D (type DOUBLE PRECISION),

    CALL SORTt(MX,NC,NR,NCS)
performs an ordering operation on the matrix MX of type t, dimensioned (NC,NR), using the NCS-th element of each row as ordering criterion.

The matrix MX is stored by rows, the first element of a row following immediately after the last element of the preceding row.

Obviously, 1 ≤|NCS| ≤NC is a condition. If this is not met or if NR ≤1 , SORTX will do nothing.

If NCS > 0 , the subroutine re-orders the rows of MX in such a way that the NCS-th element of each row is greater than or equal to the NCS-th element of the preceding row. If NCS < 0 , the rows of MX are re-ordered in such a way that the NCS-th element of each row is smaller than or equal to the NCS-th element of the preceding row.

M109


Janne Saarela
Mon Apr 3 15:06:23 METDST 1995