Fast Auxiliary Space Preconditioning 2.7.7 Aug/28/2022
Loading...
Searching...
No Matches
AuxSort.c File Reference

Array sorting/merging and removing duplicated integers. More...

#include "fasp.h"
#include "fasp_functs.h"

Go to the source code of this file.

Functions

INT fasp_aux_BiSearch (const INT nlist, const INT *list, const INT value)
 Binary Search. More...
 
INT fasp_aux_unique (INT numbers[], const INT size)
 Remove duplicates in an sorted (ascending order) array. More...
 
void fasp_aux_merge (INT numbers[], INT work[], INT left, INT mid, INT right)
 Merge two sorted arrays. More...
 
void fasp_aux_msort (INT numbers[], INT work[], INT left, INT right)
 Sort the INT array in ascending order with the merge sort algorithm. More...
 
void fasp_aux_iQuickSort (INT *a, INT left, INT right)
 Sort the array (INT type) in ascending order with the quick sorting algorithm. More...
 
void fasp_aux_dQuickSort (REAL *a, INT left, INT right)
 Sort the array (REAL type) in ascending order with the quick sorting algorithm. More...
 
void fasp_aux_iQuickSortIndex (INT *a, INT left, INT right, INT *index)
 Reorder the index of (INT type) so that 'a' is in ascending order. More...
 
void fasp_aux_dQuickSortIndex (REAL *a, INT left, INT right, INT *index)
 Reorder the index of (REAL type) so that 'a' is ascending in such order. More...
 

Detailed Description

Array sorting/merging and removing duplicated integers.

Note
This file contains Level-0 (Aux) functions. It requires: AuxMemory.c

Copyright (C) 2009–Present by the FASP team. All rights reserved.

Released under the terms of the GNU Lesser General Public License 3.0 or later.

Definition in file AuxSort.c.

Function Documentation

◆ fasp_aux_BiSearch()

INT fasp_aux_BiSearch ( const INT  nlist,
const INT list,
const INT  value 
)

Binary Search.

Parameters
nlistLength of the array list
listPointer to a set of values
valueThe target
Returns
The location of value in array list if succeeded; otherwise, return -1.
Author
Chunsheng Feng
Date
03/01/2011

Definition at line 42 of file AuxSort.c.

◆ fasp_aux_dQuickSort()

void fasp_aux_dQuickSort ( REAL a,
INT  left,
INT  right 
)

Sort the array (REAL type) in ascending order with the quick sorting algorithm.

Parameters
aPointer to the array needed to be sorted
leftStarting index
rightEnding index
Author
Zhiyang Zhou
Date
2009/11/28
Note
'left' and 'right' are usually set to be 0 and n-1, respectively where n is the length of 'a'.

Definition at line 246 of file AuxSort.c.

◆ fasp_aux_dQuickSortIndex()

void fasp_aux_dQuickSortIndex ( REAL a,
INT  left,
INT  right,
INT index 
)

Reorder the index of (REAL type) so that 'a' is ascending in such order.

Parameters
aPointer to the array
leftStarting index
rightEnding index
indexIndex of 'a' (out)
Author
Zhiyang Zhou
Date
2009/12/02
Note
'left' and 'right' are usually set to be 0 and n-1, respectively, where n is the length of 'a'. 'index' should be initialized in the nature order and it has the same length as 'a'.

Definition at line 327 of file AuxSort.c.

◆ fasp_aux_iQuickSort()

void fasp_aux_iQuickSort ( INT a,
INT  left,
INT  right 
)

Sort the array (INT type) in ascending order with the quick sorting algorithm.

Parameters
aPointer to the array needed to be sorted
leftStarting index
rightEnding index
Author
Zhiyang Zhou
Date
11/28/2009
Note
'left' and 'right' are usually set to be 0 and n-1, respectively where n is the length of 'a'.

Definition at line 208 of file AuxSort.c.

◆ fasp_aux_iQuickSortIndex()

void fasp_aux_iQuickSortIndex ( INT a,
INT  left,
INT  right,
INT index 
)

Reorder the index of (INT type) so that 'a' is in ascending order.

Parameters
aPointer to the array
leftStarting index
rightEnding index
indexIndex of 'a' (out)
Author
Zhiyang Zhou
Date
2009/12/02
Note
'left' and 'right' are usually set to be 0 and n-1,respectively,where n is the length of 'a'. 'index' should be initialized in the nature order and it has the same length as 'a'.

Definition at line 286 of file AuxSort.c.

◆ fasp_aux_merge()

void fasp_aux_merge ( INT  numbers[],
INT  work[],
INT  left,
INT  mid,
INT  right 
)

Merge two sorted arrays.

Parameters
numbersPointer to the array needed to be sorted
workPointer to the work array with same size as numbers
leftStarting index of array 1
midStarting index of array 2
rightEnding index of array 1 and 2
Author
Chensong Zhang
Date
11/21/2010
Note
Both arrays are stored in numbers! Arrays should be pre-sorted!

Definition at line 115 of file AuxSort.c.

◆ fasp_aux_msort()

void fasp_aux_msort ( INT  numbers[],
INT  work[],
INT  left,
INT  right 
)

Sort the INT array in ascending order with the merge sort algorithm.

Parameters
numbersPointer to the array needed to be sorted
workPointer to the work array with same size as numbers
leftStarting index
rightEnding index
Author
Chensong Zhang
Date
11/21/2010
Note
'left' and 'right' are usually set to be 0 and n-1, respectively

Definition at line 177 of file AuxSort.c.

◆ fasp_aux_unique()

INT fasp_aux_unique ( INT  numbers[],
const INT  size 
)

Remove duplicates in an sorted (ascending order) array.

Parameters
numbersPointer to the array needed to be sorted (in/out)
sizeLength of the target array
Returns
New size after removing duplicates
Author
Chensong Zhang
Date
11/21/2010
Note
Operation is in place. Does not use any extra or temporary storage.

Definition at line 82 of file AuxSort.c.