M109: Sort Rows of a Matrix

Author(s): T. Lindelöf Library: MATHLIB
Submitter: F. Carminati Submitted: 15.09.1978
Language: Fortran Revised: 09.02.1989

SORTRQ rearranges 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 desired. Row orders are not necessarily preserved in case these elements are equal. Otherwise, SORTRQ does the same job as SORTR (M107), but SORTRQ is sometimes faster.

Structure:

SUBROUTINE subprogram
User Entry Names: SORTIQ, SORTRQ, SORTDQ
External References: USWOP (not on all machines)

Usage:

For tex2html_wrap_inline79 (type INTEGER), tex2html_wrap_inline81 (type REAL), tex2html_wrap_inline83 (type DOUBLE PRECISION),

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

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

Obviously, tex2html_wrap_inline85 is a condition. If this is not met, or if tex2html_wrap_inline87 , SORTtQ will do nothing.

If tex2html_wrap_inline89 , SORTRQ reorders the rows of MX in such a way that the NCS-th element of each row is tex2html_wrap_inline91 the NCS-th element of the preceding row. If tex2html_wrap_inline93 , the rows of MX are reordered in the strict reverse order to that for tex2html_wrap_inline95 .

Based on an Algol procedure described in Ref. 1.

References:

  1. R.S. Scowen, Algorithm 271 QUICKERSORT, Collected Algorithms from CACM (1965).
tex2html_wrap_inline97

Michel Goossens Wed Jun 5 07:06:43 METDST 1996