linalg 1.8.2
A linear algebra library that provides a user-friendly interface to several BLAS and LAPACK routines.
Loading...
Searching...
No Matches
linalg::sort Interface Reference

Sorts an array. More...

Public Member Functions

 sort_dbl_array
 
 sort_dbl_array_ind
 
 sort_cmplx_array
 
 sort_cmplx_array_ind
 
 sort_eigen_cmplx
 
 sort_eigen_dbl
 
 sort_int32_array
 
 sort_int32_array_ind
 

Detailed Description

Sorts an array.

Syntax 1
subroutine sort(real(real64) x(:), optional logical ascend)
subroutine sort(complex(real64) x(:), optional logical ascend)
Parameters
[in,out]xOn input, the array to sort. On output, the sorted array.
[in]ascendAn optional input that, if specified, controls if the the array is sorted in an ascending order (default), or a descending order.
Remarks
The routine utilizes a quick sort algorithm unless the size of the array is less than or equal to 20. For such small arrays an insertion sort algorithm is utilized.
Notes
This routine utilizes the LAPACK routine DLASRT.
Syntax 2
subroutine sort(real(real64) x(:), integer(int32) ind(:), optional logical ascend, optional class(errors) err)
subroutine sort(complex(real64) x(:), integer(int32) ind(:), optional logical ascend, optional class(errors) err)
Parameters
[in,out]xOn input, the array to sort. On output, the sorted array.
[in,out]indOn input, an integer array. On output, the contents of this array are shifted in the same order as that of x as a means of tracking the sorting operation. It is often useful to set this array to an ascending group of values (1, 2, ... n) such that this array tracks the original positions of the sorted array. Such an array can then be used to align other arrays. This array must be the same size as x.
[in]ascendAn optional input that, if specified, controls if the the array is sorted in an ascending order (default), or a descending order.
[in,out]errAn optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling. Possible errors and warning messages that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if ind is not sized to match x.
Remarks
This routine utilizes a quick sort algorithm explained at http://www.fortran.com/qsort_c.f95.
Syntax 3 (Eigen sorting)
A sorting routine specifically tailored for sorting of eigenvalues and their associated eigenvectors using a quick-sort approach.
subroutine sort(real(real64) vals(:), real(real64) vecs(:,:), optional logical ascend, optional class(errors) err)
subroutine sort(complex(real64) vals(:), complex(real64) vecs(:,:), optional logical ascend, optional class(errors) err)
Parameters
[in,out]valsOn input, an N-element array containing the eigenvalues. On output, the sorted eigenvalues.
[in,out]vecsOn input, an N-by-N matrix containing the eigenvectors associated with vals (one vector per column). On output, the sorted eigenvector matrix.
[in]ascendAn optional input that, if specified, controls if the the array is sorted in an ascending order (default), or a descending order.
[in,out]errAn optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling. Possible errors and warning messages that may be encountered are as follows.
  • LA_ARRAY_SIZE_ERROR: Occurs if vecs is not sized to match vals.
  • LA_OUT_OF_MEMORY_ERROR: Occurs if there is insufficient memory available to comoplete this operation.

Definition at line 3454 of file linalg.f90.


The documentation for this interface was generated from the following file: