linalg  1.4.3
A linear algebra library that provides a user-friendly interface to several BLAS and LAPACK routines.
linalg_sorting Module Reference

linalg_sorting More...

Data Types

interface  sort
 Sorts an array. More...
 

Functions/Subroutines

subroutine sort_dbl_array (x, ascend)
 Sorts an array. More...
 
subroutine sort_dbl_array_ind (x, ind, ascend, err)
 Sorts an array. More...
 
subroutine sort_cmplx_array (x, ascend)
 Sorts an array. More...
 
subroutine sort_cmplx_array_ind (x, ind, ascend, err)
 Sorts an array. More...
 
subroutine sort_eigen_cmplx (vals, vecs, ascend, err)
 A sorting routine specifically tailored for sorting of eigenvalues and their associated eigenvectors using a quick-sort approach. More...
 
subroutine sort_eigen_dbl (vals, vecs, ascend, err)
 A sorting routine specifically tailored for sorting of eigenvalues and their associated eigenvectors using a quick-sort approach. More...
 
recursive subroutine qsort_dbl_ind (ascend, x, ind)
 A recursive quick sort algorithm. More...
 
subroutine dbl_partition_ind (ascend, x, ind, marker)
 A routine to perform the partioning necessary for the quick sort algorithm. More...
 
recursive subroutine qsort_cmplx (ascend, x)
 A recursive quick sort algorithm. More...
 
subroutine cmplx_partition (ascend, x, marker)
 A routine to perform the partioning necessary for the quick sort algorithm. More...
 
recursive subroutine qsort_cmplx_ind (ascend, x, ind)
 A recursive quick sort algorithm. More...
 
subroutine cmplx_partition_ind (ascend, x, ind, marker)
 A routine to perform the partioning necessary for the quick sort algorithm. More...
 

Detailed Description

linalg_sorting

Purpose
Provides sorting routines.

Function/Subroutine Documentation

◆ cmplx_partition()

subroutine linalg_sorting::cmplx_partition ( logical, intent(in)  ascend,
complex(real64), dimension(:), intent(inout)  x,
integer(int32), intent(out)  marker 
)
private

A routine to perform the partioning necessary for the quick sort algorithm.

Parameters
[in]ascendSet to true to sort in ascending order; else, false to sort in descending order.
[in,out]xOn input, the array to sort. On output, the sorted array.
[out]markerThe partioning marker.
Remarks
As this routine operates on complex valued items, the complex values are sorted based upon the real component of the number.
Notes
This implementation is a slight modification of the code presented at http://www.fortran.com/qsort_c.f95.

Definition at line 579 of file linalg_sorting.f90.

◆ cmplx_partition_ind()

subroutine linalg_sorting::cmplx_partition_ind ( logical, intent(in)  ascend,
complex(real64), dimension(:), intent(inout)  x,
integer(int32), dimension(:), intent(inout)  ind,
integer(int32), intent(out)  marker 
)
private

A routine to perform the partioning necessary for the quick sort algorithm.

Parameters
[in]ascendSet to true to sort in ascending order; else, false to sort in descending order.
[in,out]xOn input, the array to sort. On output, the sorted array.
[in,out]indOn input, a tracking array of the same length as x. On output, the same array, but shuffled to match the sorting order of x.
[out]markerThe partioning marker.
Remarks
As this routine operates on complex valued items, the complex values are sorted based upon the real component of the number.
Notes
This implementation is a slight modification of the code presented at http://www.fortran.com/qsort_c.f95.

Definition at line 704 of file linalg_sorting.f90.

◆ dbl_partition_ind()

subroutine linalg_sorting::dbl_partition_ind ( logical, intent(in)  ascend,
real(real64), dimension(:), intent(inout)  x,
integer(int32), dimension(:), intent(inout)  ind,
integer(int32), intent(out)  marker 
)
private

A routine to perform the partioning necessary for the quick sort algorithm.

Parameters
[in]ascendSet to true to sort in ascending order; else, false to sort in descending order.
[in,out]xOn input, the array to sort. On output, the sorted array.
[in,out]indOn input, a tracking array of the same length as x. On output, the same array, but shuffled to match the sorting order of x.
[out]markerThe partioning marker.
Notes
This implementation is a slight modification of the code presented at http://www.fortran.com/qsort_c.f95

Definition at line 453 of file linalg_sorting.f90.

◆ qsort_cmplx()

recursive subroutine linalg_sorting::qsort_cmplx ( logical, intent(in)  ascend,
complex(real64), dimension(:), intent(inout)  x 
)
private

A recursive quick sort algorithm.

Parameters
[in]ascendSet to true to sort in ascending order; else, false to sort in descending order.
[in,out]xOn input, the array to sort. On output, the sorted array.
Remarks
As this routine operates on complex valued items, the complex values are sorted based upon the real component of the number.
Notes
This implementation is a slight modification of the code presented at http://www.fortran.com/qsort_c.f95

Definition at line 546 of file linalg_sorting.f90.

◆ qsort_cmplx_ind()

recursive subroutine linalg_sorting::qsort_cmplx_ind ( logical, intent(in)  ascend,
complex(real64), dimension(:), intent(inout)  x,
integer(int32), dimension(:), intent(inout)  ind 
)
private

A recursive quick sort algorithm.

Parameters
[in]ascendSet to true to sort in ascending order; else, false to sort in descending order.
[in,out]xOn input, the array to sort. On output, the sorted array.
[in,out]indOn input, a tracking array of the same length as x. On output, the same array, but shuffled to match the sorting order of x.
Remarks
As this routine operates on complex valued items, the complex values are sorted based upon the real component of the number.
Notes
This implementation is a slight modification of the code presented at http://www.fortran.com/qsort_c.f95

Definition at line 667 of file linalg_sorting.f90.

◆ qsort_dbl_ind()

recursive subroutine linalg_sorting::qsort_dbl_ind ( logical, intent(in)  ascend,
real(real64), dimension(:), intent(inout)  x,
integer(int32), dimension(:), intent(inout)  ind 
)
private

A recursive quick sort algorithm.

Parameters
[in]ascendSet to true to sort in ascending order; else, false to sort in descending order.
[in,out]xOn input, the array to sort. On output, the sorted array.
[in,out]indOn input, a tracking array of the same length as x. On output, the same array, but shuffled to match the sorting order of x.
Notes
This implementation is a slight modification of the code presented at http://www.fortran.com/qsort_c.f95.

Definition at line 420 of file linalg_sorting.f90.

◆ sort_cmplx_array()

subroutine linalg_sorting::sort_cmplx_array ( complex(real64), dimension(:), intent(inout)  x,
logical, intent(in), optional  ascend 
)
private

Sorts an array.

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
This routine utilizes a quick sort algorithm. As this routine operates on complex valued items, the complex values are sorted based upon the real component of the number.
Notes
This implementation is a slight modification of the code presented at http://www.fortran.com/qsort_c.f95.

Definition at line 157 of file linalg_sorting.f90.

◆ sort_cmplx_array_ind()

subroutine linalg_sorting::sort_cmplx_array_ind ( complex(real64), dimension(:), intent(inout)  x,
integer(int32), dimension(:), intent(inout)  ind,
logical, intent(in), optional  ascend,
class(errors), intent(inout), optional, target  err 
)
private

Sorts an array.

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.
[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. As this routine operates on complex valued items, the complex values are sorted based upon the real component of the number.
Notes
This implementation is a slight modification of the code presented at http://www.fortran.com/qsort_c.f95.

Definition at line 206 of file linalg_sorting.f90.

◆ sort_dbl_array()

subroutine linalg_sorting::sort_dbl_array ( real(real64), dimension(:), intent(inout)  x,
logical, intent(in), optional  ascend 
)
private

Sorts an array.

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.

Definition at line 48 of file linalg_sorting.f90.

◆ sort_dbl_array_ind()

subroutine linalg_sorting::sort_dbl_array_ind ( real(real64), dimension(:), intent(inout)  x,
integer(int32), dimension(:), intent(inout)  ind,
logical, intent(in), optional  ascend,
class(errors), intent(inout), optional, target  err 
)
private

Sorts an array.

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.
[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.

Definition at line 98 of file linalg_sorting.f90.

◆ sort_eigen_cmplx()

subroutine linalg_sorting::sort_eigen_cmplx ( complex(real64), dimension(:), intent(inout)  vals,
complex(real64), dimension(:,:), intent(inout)  vecs,
logical, intent(in), optional  ascend,
class(errors), intent(inout), optional, target  err 
)
private

A sorting routine specifically tailored for sorting of eigenvalues and their associated eigenvectors using a quick-sort approach.

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.
[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 268 of file linalg_sorting.f90.

◆ sort_eigen_dbl()

subroutine linalg_sorting::sort_eigen_dbl ( real(real64), dimension(:), intent(inout)  vals,
real(real64), dimension(:,:), intent(inout)  vecs,
logical, intent(in), optional  ascend,
class(errors), intent(inout), optional, target  err 
)
private

A sorting routine specifically tailored for sorting of eigenvalues and their associated eigenvectors using a quick-sort approach.

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.
[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 346 of file linalg_sorting.f90.