NeoPZ
vsrtp1.cpp
Go to the documentation of this file.
1 #include <stdint.h>
2 
3 /* Subroutine */
4 int vsrtp1_ (int64_t *a, int64_t *ir, int64_t *la)
5 {
6  /* System generated locals */
7  int64_t i__1;
8  /* Local variables */
9  static int64_t i, j, k, l, m, r, t, ij, il[21], it, iu[21], tt, itt;
10 
11 
12 /* SPECIFICATIONS FOR ARGUMENTS */
13 /* SPECIFICATIONS FOR LOCAL VARIABLES */
14 /* FIRST EXECUTABLE STATEMENT */
15 /* FIND ABSOLUTE VALUES OF ARRAY A */
16  /* Parameter adjustments */
17  --ir;
18  --a;
19 
20  /* Function Body */
21  if (*la <= 0)
22  {
23  return 0;
24  }
25  i__1 = *la;
26  for (i = 1; i <= i__1; ++i)
27  {
28 /* IF (A(I) .LT. 0.0) A(I)=-A(I) */
29  ir[i] = i;
30 /* L5: */
31  }
32  m = 1;
33  i = 1;
34  j = *la;
35  r = (float) .375;
36 L10:
37  if (i == j)
38  {
39  goto L55;
40  }
41 /* L15: */
42  if ((double) r > (float) .5898437)
43  {
44  r += (float) -.21875;
45  } else
46  {
47  r += (float) .0390625;
48  }
49 L25:
50  k = i;
51 /* SELECT A CENTRAL ELEMENT OF THE */
52 /* ARRAY AND SAVE IT IN LOCATION T */
53  ij = i + (j - i) * r;
54  t = a[ij];
55  it = ir[ij];
56 /* IF FIRST ELEMENT OF ARRAY IS GREATER
57 */
58 /* THAN T, INTERCHANGE WITH T */
59  if (a[i] > t)
60  {
61  a[ij] = a[i];
62  a[i] = t;
63  t = a[ij];
64  ir[ij] = ir[i];
65  ir[i] = it;
66  it = ir[ij];
67  }
68  l = j;
69 /* IF LAST ELEMENT OF ARRAY IS LESS THAN
70 */
71 /* T, INTERCHANGE WITH T */
72  if (a[j] < t)
73  {
74  a[ij] = a[j];
75  a[j] = t;
76  t = a[ij];
77  ir[ij] = ir[j];
78  ir[j] = it;
79  it = ir[ij];
80 /* IF FIRST ELEMENT OF ARRAY IS GREAT
81 ER */
82 /* THAN T, INTERCHANGE WITH T */
83  if (a[i] > t)
84  {
85  a[ij] = a[i];
86  a[i] = t;
87  t = a[ij];
88  ir[ij] = ir[i];
89  ir[i] = it;
90  it = ir[ij];
91  }
92  }
93  goto L40;
94 L35:
95  if (a[l] != a[k])
96  {
97  tt = a[l];
98  a[l] = a[k];
99  a[k] = tt;
100  itt = ir[l];
101  ir[l] = ir[k];
102  ir[k] = itt;
103  }
104 /* FIND AN ELEMENT IN THE SECOND HALF OF
105 */
106 /* THE ARRAY WHICH IS SMALLER THAN T */
107 L40:
108  --l;
109  if (a[l] > t)
110  {
111  goto L40;
112  }
113 /* FIND AN ELEMENT IN THE FIRST HALF OF
114 */
115 /* THE ARRAY WHICH IS GREATER THAN T */
116 L45:
117  ++k;
118  if (a[k] < t)
119  {
120  goto L45;
121  }
122 /* INTERCHANGE THESE ELEMENTS */
123  if (k <= l)
124  {
125  goto L35;
126  }
127 /* SAVE UPPER AND LOWER SUBSCRIPTS OF */
128 /* THE ARRAY YET TO BE SORTED */
129  if (l - i > j - k)
130  {
131  il[m - 1] = i;
132  iu[m - 1] = l;
133  i = k;
134  ++m;
135  } else
136  {
137  il[m - 1] = k;
138  iu[m - 1] = j;
139  j = l;
140  ++m;
141  }
142  goto L60;
143 /* BEGIN AGAIN ON ANOTHER PORTION OF */
144 /* THE UNSORTED ARRAY */
145 L55:
146  --m;
147  if (m == 0)
148  {
149  return 0;
150  }
151  i = il[m - 1];
152  j = iu[m - 1];
153 L60:
154  if (j - i >= 11)
155  {
156  goto L25;
157  }
158  if (i == 1)
159  {
160  goto L10;
161  }
162  --i;
163 L65:
164  ++i;
165  if (i == j)
166  {
167  goto L55;
168  }
169  t = a[i + 1];
170  it = ir[i + 1];
171  if (a[i] <= t)
172  {
173  goto L65;
174  }
175  k = i;
176 L70:
177  a[k + 1] = a[k];
178  ir[k + 1] = ir[k];
179  --k;
180  if (t < a[k])
181  {
182  goto L70;
183  }
184  a[k + 1] = t;
185  ir[k + 1] = it;
186  goto L65;
187 } /* vsrtp1_ */
int vsrtp1_(int64_t *a, int64_t *ir, int64_t *la)
Definition: vsrtp1.cpp:4
clarg::argString m("-m", "input matrix file name (text format)", "matrix.txt")