Debian Codegraph @

debian/external_deps/fetk/punc/src/pmg/mblasd.c

raw
1 /* ./src_f77/mblasd.f -- translated by f2c (version 20030320).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include <punc/vf2c.h>
7
8 /* * /////////////////////////////////////////////////////////////////////////// */
9 /* * @file mblasd.f */
10 /* * @author Michael Holst */
11 /* * @brief Micro version of the BLAS needed for low-level PMG support. */
12 /* * @version $Id: mblasd.c,v 1.3 2010/08/12 05:45:22 fetk Exp $ */
13 /* * @attention */
14 /* * @verbatim */
15 /* * */
16 /* * PMG -- Parallel algebraic MultiGrid */
17 /* * Copyright (C) 1994-- Michael Holst. */
18 /* * */
19 /* * Michael Holst <[email protected]> */
20 /* * University of California, San Diego */
21 /* * Department of Mathematics, 5739 AP&M */
22 /* * 9500 Gilman Drive, Dept. 0112 */
23 /* * La Jolla, CA 92093-0112 USA */
24 /* * http://math.ucsd.edu/~mholst */
25 /* * */
26 /* * This file is part of PMG. */
27 /* * */
28 /* * PMG is free software; you can redistribute it and/or modify */
29 /* * it under the terms of the GNU General Public License as published by */
30 /* * the Free Software Foundation; either version 2 of the License, or */
31 /* * (at your option) any later version. */
32 /* * */
33 /* * PMG is distributed in the hope that it will be useful, */
34 /* * but WITHOUT ANY WARRANTY; without even the implied warranty of */
35 /* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
36 /* * GNU General Public License for more details. */
37 /* * */
38 /* * You should have received a copy of the GNU General Public License */
39 /* * along with PMG; if not, write to the Free Software */
40 /* * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
41 /* * */
42 /* * Linking PMG statically or dynamically with other modules is making a */
43 /* * combined work based on PMG. Thus, the terms and conditions of the GNU */
44 /* * General Public License cover the whole combination. */
45 /* * */
46 /* * SPECIAL GPL EXCEPTION */
47 /* * In addition, as a special exception, the copyright holders of PMG */
48 /* * give you permission to combine the PMG program with free software */
49 /* * programs and libraries that are released under the GNU LGPL or with */
50 /* * code included in releases of ISIM, PMV, PyMOL, SMOL, VMD, and Vision. */
51 /* * Such combined software may be linked with PMG and redistributed together */
52 /* * in original or modified form as mere aggregation without requirement that */
53 /* * the entire work be under the scope of the GNU General Public License. */
54 /* * This special exception permission is also extended to any software listed */
55 /* * in the SPECIAL GPL EXCEPTION clauses by the FEtk and APBS libraries. */
56 /* * */
57 /* * Note that people who make modified versions of PMG are not obligated */
58 /* * to grant this special exception for their modified versions; it is */
59 /* * their choice whether to do so. The GNU General Public License gives */
60 /* * permission to release a modified version without this exception; this */
61 /* * exception also makes it possible to release a modified version which */
62 /* * carries forward this exception. */
63 /* * */
64 /* * @endverbatim */
65 /* * /////////////////////////////////////////////////////////////////////////// */
66 /* Subroutine */ int daxpy_(integer *n, doublereal *alpha, doublereal *x,
67 integer *istep, doublereal *y, integer *jstep)
68 {
69 /* System generated locals */
70 integer i__1;
71
72 /* Local variables */
73 static integer i__, ii, ipara, ivect;
74
75 /* * ********************************************************************* */
76 /* * purpose: */
77 /* * */
78 /* * parallel/vector vector saxpy. */
79 /* * */
80 /* * author: michael holst */
81 /* * ********************************************************************* */
82 /* * */
83 /* mdir 0 0 */
84 /* * */
85 /* * *** find parallel loops (ipara), remainder (ivect) *** */
86 /* Parameter adjustments */
87 --y;
88 --x;
89
90 /* Function Body */
91 ipara = *n;
92 ivect = *n % 1;
93 /* * */
94 /* * *** do parallel loops *** */
95 /* mdir 2 1 */
96 for (ii = 1; ii <= 1; ++ii) {
97 /* mdir 2 2 */
98 i__1 = ipara * ii;
99 for (i__ = ipara * (ii - 1) + 1; i__ <= i__1; ++i__) {
100 y[i__] += *alpha * x[i__];
101 /* L11: */
102 }
103 /* L10: */
104 }
105 /* * */
106 /* * *** do vector loops *** */
107 /* mdir 1 1 */
108 i__1 = *n;
109 for (i__ = ipara + 1; i__ <= i__1; ++i__) {
110 y[i__] += *alpha * x[i__];
111 /* L20: */
112 }
113 /* * */
114 /* * *** return and end *** */
115 return 0;
116 } /* daxpy_ */
117
118 /* Subroutine */ int dcopy_(integer *n, doublereal *x, integer *istep,
119 doublereal *y, integer *jstep)
120 {
121 /* System generated locals */
122 integer i__1;
123
124 /* Local variables */
125 static integer i__, ii, ipara, ivect;
126
127 /* * ********************************************************************* */
128 /* * purpose: */
129 /* * */
130 /* * parallel/vector vector copy. */
131 /* * */
132 /* * author: michael holst */
133 /* * ********************************************************************* */
134 /* * */
135 /* mdir 0 0 */
136 /* * */
137 /* * *** find parallel loops (ipara), remainder (ivect) *** */
138 /* Parameter adjustments */
139 --y;
140 --x;
141
142 /* Function Body */
143 ipara = *n;
144 ivect = *n % 1;
145 /* * */
146 /* * *** do parallel loops *** */
147 /* mdir 2 1 */
148 for (ii = 1; ii <= 1; ++ii) {
149 /* mdir 2 2 */
150 i__1 = ipara * ii;
151 for (i__ = ipara * (ii - 1) + 1; i__ <= i__1; ++i__) {
152 y[i__] = x[i__];
153 /* L11: */
154 }
155 /* L10: */
156 }
157 /* * */
158 /* * *** do vector loops *** */
159 /* mdir 1 1 */
160 i__1 = *n;
161 for (i__ = ipara + 1; i__ <= i__1; ++i__) {
162 y[i__] = x[i__];
163 /* L20: */
164 }
165 /* * */
166 /* * *** return and end *** */
167 return 0;
168 } /* dcopy_ */
169
170 doublereal dasum_(integer *n, doublereal *x, integer *istep)
171 {
172 /* System generated locals */
173 doublereal ret_val;
174
175 /* Local variables */
176 extern doublereal dnrm1_(integer *, doublereal *, integer *);
177
178 /* * ********************************************************************* */
179 /* * purpose: */
180 /* * */
181 /* * parallel/vector sum of vector components. */
182 /* * */
183 /* * author: michael holst */
184 /* * ********************************************************************* */
185 /* * */
186 /* mdir 0 0 */
187 /* * */
188 /* * *** call the max-norm function *** */
189 /* Parameter adjustments */
190 --x;
191
192 /* Function Body */
193 ret_val = dnrm1_(n, &x[1], istep);
194 /* * */
195 /* * *** return and end *** */
196 return ret_val;
197 } /* dasum_ */
198
199 doublereal dnrm1_(integer *n, doublereal *x, integer *istep)
200 {
201 /* System generated locals */
202 integer i__1;
203 doublereal ret_val, d__1;
204
205 /* Local variables */
206 static integer i__, ii;
207 static doublereal tmp;
208 static integer ipara, ivect;
209
210 /* * ********************************************************************* */
211 /* * purpose: */
212 /* * */
213 /* * parallel/vector vector norm. */
214 /* * */
215 /* * author: michael holst */
216 /* * ********************************************************************* */
217 /* * */
218 /* mdir 0 0 */
219 /* * */
220 /* * *** initialize *** */
221 /* Parameter adjustments */
222 --x;
223
224 /* Function Body */
225 tmp = 0.;
226 /* * */
227 /* * *** find parallel loops (ipara), remainder (ivect) *** */
228 ipara = *n;
229 ivect = *n % 1;
230 /* * */
231 /* * *** do parallel loops *** */
232 /* mdir 2 1 */
233 for (ii = 1; ii <= 1; ++ii) {
234 /* mdir 2 2 */
235 i__1 = ipara * ii;
236 for (i__ = ipara * (ii - 1) + 1; i__ <= i__1; ++i__) {
237 tmp += (d__1 = x[i__], abs(d__1));
238 /* L11: */
239 }
240 /* L10: */
241 }
242 /* * */
243 /* * *** do vector loops *** */
244 /* mdir 1 1 */
245 i__1 = *n;
246 for (i__ = ipara + 1; i__ <= i__1; ++i__) {
247 tmp += (d__1 = x[i__], abs(d__1));
248 /* L20: */
249 }
250 /* * */
251 /* * *** finish up *** */
252 ret_val = tmp;
253 /* * */
254 /* * *** return and end *** */
255 return ret_val;
256 } /* dnrm1_ */
257
258 doublereal dnrm2_(integer *n, doublereal *x, integer *istep)
259 {
260 /* System generated locals */
261 integer i__1;
262 doublereal ret_val;
263
264 /* Builtin functions */
265 double sqrt(doublereal);
266
267 /* Local variables */
268 static integer i__, ii;
269 static doublereal tmp;
270 static integer ipara, ivect;
271
272 /* * ********************************************************************* */
273 /* * purpose: */
274 /* * */
275 /* * parallel/vector vector norm. */
276 /* * */
277 /* * author: michael holst */
278 /* * ********************************************************************* */
279 /* * */
280 /* mdir 0 0 */
281 /* * */
282 /* * *** initialize *** */
283 /* Parameter adjustments */
284 --x;
285
286 /* Function Body */
287 tmp = 0.;
288 /* * */
289 /* * *** find parallel loops (ipara), remainder (ivect) *** */
290 ipara = *n;
291 ivect = *n % 1;
292 /* * */
293 /* * *** do parallel loops *** */
294 /* mdir 2 1 */
295 for (ii = 1; ii <= 1; ++ii) {
296 /* mdir 2 2 */
297 i__1 = ipara * ii;
298 for (i__ = ipara * (ii - 1) + 1; i__ <= i__1; ++i__) {
299 tmp += x[i__] * x[i__];
300 /* L11: */
301 }
302 /* L10: */
303 }
304 /* * */
305 /* * *** do vector loops *** */
306 /* mdir 1 1 */
307 i__1 = *n;
308 for (i__ = ipara + 1; i__ <= i__1; ++i__) {
309 tmp += x[i__] * x[i__];
310 /* L20: */
311 }
312 /* * */
313 /* * *** finish up *** */
314 ret_val = sqrt(tmp);
315 /* * */
316 /* * *** return and end *** */
317 return ret_val;
318 } /* dnrm2_ */
319
320 doublereal dnrm8_(integer *n, doublereal *x, integer *istep)
321 {
322 /* System generated locals */
323 integer i__1;
324 doublereal ret_val, d__1, d__2, d__3;
325
326 /* Local variables */
327 static integer i__, ii;
328 static doublereal tmp;
329 static integer ipara, ivect;
330
331 /* * ********************************************************************* */
332 /* * purpose: */
333 /* * */
334 /* * parallel/vector vector norm. */
335 /* * */
336 /* * author: michael holst */
337 /* * ********************************************************************* */
338 /* * */
339 /* mdir 0 0 */
340 /* * */
341 /* * *** initialize *** */
342 /* Parameter adjustments */
343 --x;
344
345 /* Function Body */
346 tmp = 0.;
347 /* * */
348 /* * *** find parallel loops (ipara), remainder (ivect) *** */
349 ipara = *n;
350 ivect = *n % 1;
351 /* * */
352 /* * *** do parallel loops *** */
353 /* mdir 2 1 */
354 for (ii = 1; ii <= 1; ++ii) {
355 /* mdir 2 2 */
356 i__1 = ipara * ii;
357 for (i__ = ipara * (ii - 1) + 1; i__ <= i__1; ++i__) {
358 /* Computing MAX */
359 d__2 = tmp, d__3 = (d__1 = x[i__], abs(d__1));
360 tmp = max(d__2,d__3);
361 /* L11: */
362 }
363 /* L10: */
364 }
365 /* * */
366 /* * *** do vector loops *** */
367 /* mdir 1 1 */
368 i__1 = *n;
369 for (i__ = ipara + 1; i__ <= i__1; ++i__) {
370 /* Computing MAX */
371 d__2 = tmp, d__3 = (d__1 = x[i__], abs(d__1));
372 tmp = max(d__2,d__3);
373 /* L20: */
374 }
375 /* * */
376 /* * *** finish up *** */
377 ret_val = tmp;
378 /* * */
379 /* * *** return and end *** */
380 return ret_val;
381 } /* dnrm8_ */
382
383 /* Subroutine */ int dscal_(integer *n, doublereal *fac, doublereal *x,
384 integer *istep)
385 {
386 /* System generated locals */
387 integer i__1;
388
389 /* Local variables */
390 static integer i__, ii, ipara, ivect;
391
392 /* * ********************************************************************* */
393 /* * purpose: */
394 /* * */
395 /* * parallel/vector vector scale. */
396 /* * */
397 /* * author: michael holst */
398 /* * ********************************************************************* */
399 /* * */
400 /* mdir 0 0 */
401 /* * */
402 /* * *** find parallel loops (ipara), remainder (ivect) *** */
403 /* Parameter adjustments */
404 --x;
405
406 /* Function Body */
407 ipara = *n;
408 ivect = *n % 1;
409 /* * */
410 /* * *** do parallel loops *** */
411 /* mdir 2 1 */
412 for (ii = 1; ii <= 1; ++ii) {
413 /* mdir 2 2 */
414 i__1 = ipara * ii;
415 for (i__ = ipara * (ii - 1) + 1; i__ <= i__1; ++i__) {
416 x[i__] = *fac * x[i__];
417 /* L11: */
418 }
419 /* L10: */
420 }
421 /* * */
422 /* * *** do vector loops *** */
423 /* mdir 1 1 */
424 i__1 = *n;
425 for (i__ = ipara + 1; i__ <= i__1; ++i__) {
426 x[i__] = *fac * x[i__];
427 /* L20: */
428 }
429 /* * */
430 /* * *** return and end *** */
431 return 0;
432 } /* dscal_ */
433
434 doublereal ddot_(integer *n, doublereal *x, integer *istep, doublereal *y,
435 integer *jstep)
436 {
437 /* System generated locals */
438 integer i__1;
439 doublereal ret_val;
440
441 /* Local variables */
442 static integer i__, ii, ipara, ivect;
443
444 /* * ********************************************************************* */
445 /* * purpose: */
446 /* * */
447 /* * parallel/vector dot product. */
448 /* * */
449 /* * author: michael holst */
450 /* * ********************************************************************* */
451 /* * */
452 /* mdir 0 0 */
453 /* * */
454 /* * *** initialize *** */
455 /* Parameter adjustments */
456 --y;
457 --x;
458
459 /* Function Body */
460 ret_val = 0.;
461 /* * */
462 /* * *** find parallel loops (ipara), remainder (ivect) *** */
463 ipara = *n;
464 ivect = *n % 1;
465 /* * */
466 /* * *** do parallel loops *** */
467 /* mdir 2 1 */
468 for (ii = 1; ii <= 1; ++ii) {
469 /* mdir 2 2 */
470 i__1 = ipara * ii;
471 for (i__ = ipara * (ii - 1) + 1; i__ <= i__1; ++i__) {
472 ret_val += x[i__] * y[i__];
473 /* L11: */
474 }
475 /* L10: */
476 }
477 /* * */
478 /* * *** do vector loops *** */
479 /* mdir 1 1 */
480 i__1 = *n;
481 for (i__ = ipara + 1; i__ <= i__1; ++i__) {
482 ret_val += x[i__] * y[i__];
483 /* L20: */
484 }
485 /* * */
486 /* * *** return and end *** */
487 return ret_val;
488 } /* ddot_ */
489
490 integer idamax_(integer *n, doublereal *sx, integer *incx)
491 {
492 /* System generated locals */
493 integer ret_val, i__1, i__2;
494 doublereal d__1;
495
496 /* Local variables */
497 static integer i__, ii, ns;
498 static doublereal xmag, smax;
499
500 /* * ********************************************************************* */
501 /* * purpose: */
502 /* * */
503 /* * parallel/vector icamax. */
504 /* * */
505 /* * author: michael holst */
506 /* * ********************************************************************* */
507 /* * */
508 /* mdir 0 0 */
509 /* * */
510 /* Parameter adjustments */
511 --sx;
512
513 /* Function Body */
514 ret_val = 0;
515 if (*n <= 0) {
516 return ret_val;
517 }
518 ret_val = 1;
519 if (*n <= 1) {
520 return ret_val;
521 }
522 if (*incx == 1) {
523 goto L20;
524 }
525 /* * */
526 /* * code for increments not equal to 1. */
527 /* * */
528 smax = abs(sx[1]);
529 ns = *n * *incx;
530 ii = 1;
531 i__1 = ns;
532 i__2 = *incx;
533 for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
534 xmag = (d__1 = sx[i__], abs(d__1));
535 if (xmag <= smax) {
536 goto L40;
537 }
538 ret_val = ii;
539 smax = xmag;
540 L40:
541 ++ii;
542 /* L10: */
543 }
544 return ret_val;
545 /* * */
546 /* * code for increments equal to 1. */
547 /* * */
548 L20:
549 smax = abs(sx[1]);
550 i__2 = *n;
551 for (i__ = 2; i__ <= i__2; ++i__) {
552 xmag = (d__1 = sx[i__], abs(d__1));
553 if (xmag <= smax) {
554 goto L30;
555 }
556 ret_val = i__;
557 smax = xmag;
558 L30:
559 ;
560 }
561 return ret_val;
562 } /* idamax_ */
563