Revision 795 branches/replacement/src/linad99/dvsort.cpp

dvsort.cpp (revision 795)
3 3
 *
4 4
 * Copyright (c) 2009 ADMB Foundation
5 5
 */
6
/**
7
 * \file
8
 * Has routines for sorting a dvector
9
 */
10

  
6 11
#include <fvar.hpp>
7 12
#include "qsort.h"
8 13

  
9
void double_qsort(double *arr, unsigned n) {
14
/**
15
 * A subroutine used in Quicksort
16
 */
17
void double_qsort(double *arr, unsigned n)
18
{
10 19
  #define double_lt(a,b) ((*a)<(*b))
11
    QSORT(double, arr, n, double_lt);
12
  }
20
  QSORT(double, arr, n, double_lt);
21
}
13 22

  
14
void double_qsort2(double *arr, int *arr2, unsigned n) {
23
/**
24
 * A subroutine used in Quicksort
25
 */
26
void double_qsort2(double *arr, int *arr2, unsigned n)
27
{
15 28
  #define double_lt(a,b) ((*a)<(*b))
16
    QSORT2(double, int, arr, arr2, n, double_lt);
17
  }
29
  QSORT2(double, int, arr, arr2, n, double_lt);
30
}
18 31

  
19
/** Quicksort.
20
    \param v A dvector to be sorted.
21
    \param NSTACK Not used.
22
    \return dvector object containing the input vector sorted in ascending order.
23

  
24
    \n\n Adopted from the GNU C Library. http://www.corpit.ru/mjt/qsort.html
25
*/
32
/**
33
 * Quicksort.
34
 * \param v A dvector to be sorted.
35
 * \param NSTACK Not used.
36
 * \return dvector object containing the input vector sorted in ascending order.
37
 *
38
 * \n\n Adopted from the GNU C Library. http://www.corpit.ru/mjt/qsort.html
39
 */
26 40
dvector sort(_CONST dvector & v, int NSTACK)
27 41
{
28 42
   int lb=v.indexmin();
......
49 63
   return arr;
50 64
}
51 65

  
52
/** Quicksort.
53
    \param _v A dvector to be sorted.
54
    \param _index ivector on return containing the input order of the original vector.
55
    \param NSTACK Not used.
56
    \return ivector object containing the input vector sorted in ascending order.
57

  
58
    \n\n Adopted from the GNU C Library. http://www.corpit.ru/mjt/qsort.html
59
*/   
66
/** 
67
 * Quicksort.
68
 * \param _v A dvector to be sorted.
69
 * \param _index ivector on return containing the input order of the original vector.
70
 * \param NSTACK Not used.
71
 * \return ivector object containing the input vector sorted in ascending order.
72
 *
73
 * \n\n Adopted from the GNU C Library. http://www.corpit.ru/mjt/qsort.html
74
 */   
60 75
dvector sort(_CONST dvector & _v, BOR_CONST ivector & _index, int NSTACK)
61 76
{
62 77
   ivector & index = (ivector &) _index;
......
104 119

  
105 120
   return arr;
106 121
}
107

  
108

  
109

  
110

  
111

  
112

  
113

  
114

  
115

  
116

  
117

  
118

  
119

  
120

  
121

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff