Coverage Report

Created: 2023-06-07 06:06

/src/igraph/vendor/lapack/dsesrt.c
Line
Count
Source (jump to first uncovered line)
1
/*  -- translated by f2c (version 20191129).
2
   You must link the resulting object file with libf2c:
3
  on Microsoft Windows system, link with libf2c.lib;
4
  on Linux or Unix systems, link with .../path/to/libf2c.a -lm
5
  or, if you install libf2c.a in a standard place, with -lf2c -lm
6
  -- in that order, at the end of the command line, as in
7
    cc *.o -lf2c -lm
8
  Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
9
10
    http://www.netlib.org/f2c/libf2c.zip
11
*/
12
13
#include "f2c.h"
14
15
/* Table of constant values */
16
17
static integer c__1 = 1;
18
19
/* -----------------------------------------------------------------------   
20
   \BeginDoc   
21
22
   \Name: dsesrt   
23
24
   \Description:   
25
    Sort the array X in the order specified by WHICH and optionally   
26
    apply the permutation to the columns of the matrix A.   
27
28
   \Usage:   
29
    call dsesrt   
30
       ( WHICH, APPLY, N, X, NA, A, LDA)   
31
32
   \Arguments   
33
    WHICH   Character*2.  (Input)   
34
            'LM' -> X is sorted into increasing order of magnitude.   
35
            'SM' -> X is sorted into decreasing order of magnitude.   
36
            'LA' -> X is sorted into increasing order of algebraic.   
37
            'SA' -> X is sorted into decreasing order of algebraic.   
38
39
    APPLY   Logical.  (Input)   
40
            APPLY = .TRUE.  -> apply the sorted order to A.   
41
            APPLY = .FALSE. -> do not apply the sorted order to A.   
42
43
    N       Integer.  (INPUT)   
44
            Dimension of the array X.   
45
46
    X      Double precision array of length N.  (INPUT/OUTPUT)   
47
            The array to be sorted.   
48
49
    NA      Integer.  (INPUT)   
50
            Number of rows of the matrix A.   
51
52
    A      Double precision array of length NA by N.  (INPUT/OUTPUT)   
53
54
    LDA     Integer.  (INPUT)   
55
            Leading dimension of A.   
56
57
   \EndDoc   
58
59
   -----------------------------------------------------------------------   
60
61
   \BeginLib   
62
63
   \Routines   
64
       dswap  Level 1 BLAS that swaps the contents of two vectors.   
65
66
   \Authors   
67
       Danny Sorensen               Phuong Vu   
68
       Richard Lehoucq              CRPC / Rice University   
69
       Dept. of Computational &     Houston, Texas   
70
       Applied Mathematics   
71
       Rice University   
72
       Houston, Texas   
73
74
   \Revision history:   
75
       12/15/93: Version ' 2.1'.   
76
                 Adapted from the sort routine in LANSO and   
77
                 the ARPACK code dsortr   
78
79
   \SCCS Information: @(#)   
80
   FILE: sesrt.F   SID: 2.3   DATE OF SID: 4/19/96   RELEASE: 2   
81
82
   \EndLib   
83
84
   -----------------------------------------------------------------------   
85
86
   Subroutine */ int igraphdsesrt_(char *which, logical *apply, integer *n, 
87
  doublereal *x, integer *na, doublereal *a, integer *lda)
88
0
{
89
    /* System generated locals */
90
0
    integer a_dim1, a_offset, i__1;
91
0
    doublereal d__1, d__2;
92
93
    /* Builtin functions */
94
0
    integer s_cmp(char *, char *, ftnlen, ftnlen);
95
96
    /* Local variables */
97
0
    integer i__, j, igap;
98
0
    doublereal temp;
99
0
    extern /* Subroutine */ int igraphdswap_(integer *, doublereal *, integer *, 
100
0
      doublereal *, integer *);
101
102
103
/*     %------------------%   
104
       | Scalar Arguments |   
105
       %------------------%   
106
107
108
       %-----------------%   
109
       | Array Arguments |   
110
       %-----------------%   
111
112
113
       %---------------%   
114
       | Local Scalars |   
115
       %---------------%   
116
117
118
       %----------------------%   
119
       | External Subroutines |   
120
       %----------------------%   
121
122
123
       %-----------------------%   
124
       | Executable Statements |   
125
       %-----------------------%   
126
127
       Parameter adjustments */
128
0
    a_dim1 = *lda;
129
0
    a_offset = 1 + a_dim1 * 0;
130
0
    a -= a_offset;
131
132
    /* Function Body */
133
0
    igap = *n / 2;
134
135
0
    if (s_cmp(which, "SA", (ftnlen)2, (ftnlen)2) == 0) {
136
137
/*        X is sorted into decreasing order of algebraic. */
138
139
0
L10:
140
0
  if (igap == 0) {
141
0
      goto L9000;
142
0
  }
143
0
  i__1 = *n - 1;
144
0
  for (i__ = igap; i__ <= i__1; ++i__) {
145
0
      j = i__ - igap;
146
0
L20:
147
148
0
      if (j < 0) {
149
0
    goto L30;
150
0
      }
151
152
0
      if (x[j] < x[j + igap]) {
153
0
    temp = x[j];
154
0
    x[j] = x[j + igap];
155
0
    x[j + igap] = temp;
156
0
    if (*apply) {
157
0
        igraphdswap_(na, &a[j * a_dim1 + 1], &c__1, &a[(j + igap) * 
158
0
          a_dim1 + 1], &c__1);
159
0
    }
160
0
      } else {
161
0
    goto L30;
162
0
      }
163
0
      j -= igap;
164
0
      goto L20;
165
0
L30:
166
0
      ;
167
0
  }
168
0
  igap /= 2;
169
0
  goto L10;
170
171
0
    } else if (s_cmp(which, "SM", (ftnlen)2, (ftnlen)2) == 0) {
172
173
/*        X is sorted into decreasing order of magnitude. */
174
175
0
L40:
176
0
  if (igap == 0) {
177
0
      goto L9000;
178
0
  }
179
0
  i__1 = *n - 1;
180
0
  for (i__ = igap; i__ <= i__1; ++i__) {
181
0
      j = i__ - igap;
182
0
L50:
183
184
0
      if (j < 0) {
185
0
    goto L60;
186
0
      }
187
188
0
      if ((d__1 = x[j], abs(d__1)) < (d__2 = x[j + igap], abs(d__2))) {
189
0
    temp = x[j];
190
0
    x[j] = x[j + igap];
191
0
    x[j + igap] = temp;
192
0
    if (*apply) {
193
0
        igraphdswap_(na, &a[j * a_dim1 + 1], &c__1, &a[(j + igap) * 
194
0
          a_dim1 + 1], &c__1);
195
0
    }
196
0
      } else {
197
0
    goto L60;
198
0
      }
199
0
      j -= igap;
200
0
      goto L50;
201
0
L60:
202
0
      ;
203
0
  }
204
0
  igap /= 2;
205
0
  goto L40;
206
207
0
    } else if (s_cmp(which, "LA", (ftnlen)2, (ftnlen)2) == 0) {
208
209
/*        X is sorted into increasing order of algebraic. */
210
211
0
L70:
212
0
  if (igap == 0) {
213
0
      goto L9000;
214
0
  }
215
0
  i__1 = *n - 1;
216
0
  for (i__ = igap; i__ <= i__1; ++i__) {
217
0
      j = i__ - igap;
218
0
L80:
219
220
0
      if (j < 0) {
221
0
    goto L90;
222
0
      }
223
224
0
      if (x[j] > x[j + igap]) {
225
0
    temp = x[j];
226
0
    x[j] = x[j + igap];
227
0
    x[j + igap] = temp;
228
0
    if (*apply) {
229
0
        igraphdswap_(na, &a[j * a_dim1 + 1], &c__1, &a[(j + igap) * 
230
0
          a_dim1 + 1], &c__1);
231
0
    }
232
0
      } else {
233
0
    goto L90;
234
0
      }
235
0
      j -= igap;
236
0
      goto L80;
237
0
L90:
238
0
      ;
239
0
  }
240
0
  igap /= 2;
241
0
  goto L70;
242
243
0
    } else if (s_cmp(which, "LM", (ftnlen)2, (ftnlen)2) == 0) {
244
245
/*        X is sorted into increasing order of magnitude. */
246
247
0
L100:
248
0
  if (igap == 0) {
249
0
      goto L9000;
250
0
  }
251
0
  i__1 = *n - 1;
252
0
  for (i__ = igap; i__ <= i__1; ++i__) {
253
0
      j = i__ - igap;
254
0
L110:
255
256
0
      if (j < 0) {
257
0
    goto L120;
258
0
      }
259
260
0
      if ((d__1 = x[j], abs(d__1)) > (d__2 = x[j + igap], abs(d__2))) {
261
0
    temp = x[j];
262
0
    x[j] = x[j + igap];
263
0
    x[j + igap] = temp;
264
0
    if (*apply) {
265
0
        igraphdswap_(na, &a[j * a_dim1 + 1], &c__1, &a[(j + igap) * 
266
0
          a_dim1 + 1], &c__1);
267
0
    }
268
0
      } else {
269
0
    goto L120;
270
0
      }
271
0
      j -= igap;
272
0
      goto L110;
273
0
L120:
274
0
      ;
275
0
  }
276
0
  igap /= 2;
277
0
  goto L100;
278
0
    }
279
280
0
L9000:
281
0
    return 0;
282
283
/*     %---------------%   
284
       | End of dsesrt |   
285
       %---------------% */
286
287
0
} /* igraphdsesrt_ */
288