-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathc_zblat2c.c
4121 lines (3669 loc) · 116 KB
/
c_zblat2c.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <complex.h>
#ifdef complex
#undef complex
#endif
#ifdef I
#undef I
#endif
#include "common.h"
typedef blasint integer;
typedef unsigned int uinteger;
typedef char *address;
typedef short int shortint;
typedef float real;
typedef double doublereal;
typedef struct { real r, i; } complex;
typedef struct { doublereal r, i; } doublecomplex;
#ifdef _MSC_VER
static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
#else
static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
#endif
#define pCf(z) (*_pCf(z))
#define pCd(z) (*_pCd(z))
typedef int logical;
typedef short int shortlogical;
typedef char logical1;
typedef char integer1;
#define TRUE_ (1)
#define FALSE_ (0)
/* Extern is for use with -E */
#ifndef Extern
#define Extern extern
#endif
/* I/O stuff */
typedef int flag;
typedef int ftnlen;
typedef int ftnint;
/*external read, write*/
typedef struct
{ flag cierr;
ftnint ciunit;
flag ciend;
char *cifmt;
ftnint cirec;
} cilist;
/*internal read, write*/
typedef struct
{ flag icierr;
char *iciunit;
flag iciend;
char *icifmt;
ftnint icirlen;
ftnint icirnum;
} icilist;
/*open*/
typedef struct
{ flag oerr;
ftnint ounit;
char *ofnm;
ftnlen ofnmlen;
char *osta;
char *oacc;
char *ofm;
ftnint orl;
char *oblnk;
} olist;
/*close*/
typedef struct
{ flag cerr;
ftnint cunit;
char *csta;
} cllist;
/*rewind, backspace, endfile*/
typedef struct
{ flag aerr;
ftnint aunit;
} alist;
/* inquire */
typedef struct
{ flag inerr;
ftnint inunit;
char *infile;
ftnlen infilen;
ftnint *inex; /*parameters in standard's order*/
ftnint *inopen;
ftnint *innum;
ftnint *innamed;
char *inname;
ftnlen innamlen;
char *inacc;
ftnlen inacclen;
char *inseq;
ftnlen inseqlen;
char *indir;
ftnlen indirlen;
char *infmt;
ftnlen infmtlen;
char *inform;
ftnint informlen;
char *inunf;
ftnlen inunflen;
ftnint *inrecl;
ftnint *innrec;
char *inblank;
ftnlen inblanklen;
} inlist;
#define VOID void
union Multitype { /* for multiple entry points */
integer1 g;
shortint h;
integer i;
/* longint j; */
real r;
doublereal d;
complex c;
doublecomplex z;
};
typedef union Multitype Multitype;
struct Vardesc { /* for Namelist */
char *name;
char *addr;
ftnlen *dims;
int type;
};
typedef struct Vardesc Vardesc;
struct Namelist {
char *name;
Vardesc **vars;
int nvars;
};
typedef struct Namelist Namelist;
#define abs(x) ((x) >= 0 ? (x) : -(x))
#define dabs(x) (fabs(x))
#define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
#define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
#define dmin(a,b) (f2cmin(a,b))
#define dmax(a,b) (f2cmax(a,b))
#define bit_test(a,b) ((a) >> (b) & 1)
#define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
#define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
#define abort_() { sig_die("Fortran abort routine called", 1); }
#define c_abs(z) (cabsf(Cf(z)))
#define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
#ifdef _MSC_VER
#define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
#define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/Cd(b)._Val[1]);}
#else
#define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
#define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
#endif
#define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
#define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
#define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
//#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
#define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
#define d_abs(x) (fabs(*(x)))
#define d_acos(x) (acos(*(x)))
#define d_asin(x) (asin(*(x)))
#define d_atan(x) (atan(*(x)))
#define d_atn2(x, y) (atan2(*(x),*(y)))
#define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
#define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
#define d_cos(x) (cos(*(x)))
#define d_cosh(x) (cosh(*(x)))
#define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
#define d_exp(x) (exp(*(x)))
#define d_imag(z) (cimag(Cd(z)))
#define r_imag(z) (cimagf(Cf(z)))
#define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
#define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
#define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
#define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
#define d_log(x) (log(*(x)))
#define d_mod(x, y) (fmod(*(x), *(y)))
#define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
#define d_nint(x) u_nint(*(x))
#define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
#define d_sign(a,b) u_sign(*(a),*(b))
#define r_sign(a,b) u_sign(*(a),*(b))
#define d_sin(x) (sin(*(x)))
#define d_sinh(x) (sinh(*(x)))
#define d_sqrt(x) (sqrt(*(x)))
#define d_tan(x) (tan(*(x)))
#define d_tanh(x) (tanh(*(x)))
#define i_abs(x) abs(*(x))
#define i_dnnt(x) ((integer)u_nint(*(x)))
#define i_len(s, n) (n)
#define i_nint(x) ((integer)u_nint(*(x)))
#define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
#define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
#define pow_si(B,E) spow_ui(*(B),*(E))
#define pow_ri(B,E) spow_ui(*(B),*(E))
#define pow_di(B,E) dpow_ui(*(B),*(E))
#define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
#define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
#define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
#define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
#define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
#define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
#define sig_die(s, kill) { exit(1); }
#define s_stop(s, n) {exit(0);}
#define z_abs(z) (cabs(Cd(z)))
#define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
#define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
#define myexit_() break;
#define mycycle_() continue;
#define myceiling_(w) {ceil(w)}
#define myhuge_(w) {HUGE_VAL}
//#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
#define mymaxloc_(w,s,e,n) dmaxloc_(w,*(s),*(e),n)
/* procedure parameter types for -A and -C++ */
#define F2C_proc_par_types 1
/* Common Block Declarations */
struct {
integer infot, noutc;
logical ok;
} infoc_;
#define infoc_1 infoc_
struct {
char srnamt[12];
} srnamc_;
#define srnamc_1 srnamc_
/* Table of constant values */
static doublecomplex c_b1 = {0.,0.};
static doublecomplex c_b2 = {1.,0.};
static integer c__1 = 1;
static integer c__65 = 65;
static integer c__2 = 2;
static doublereal c_b125 = 1.;
static integer c__6 = 6;
static logical c_true = TRUE_;
static integer c_n1 = -1;
static integer c__0 = 0;
static logical c_false = FALSE_;
/* Main program */ int main(void)
{
/* Initialized data */
static char snames[17][13] = { "cblas_zgemv " , "cblas_zgbmv " , "cblas_zhemv ",
"cblas_zhbmv ", "cblas_zhpmv ", "cblas_ztrmv " , "cblas_ztbmv " , "cblas_ztpmv ",
"cblas_ztrsv ", "cblas_ztbsv ", "cblas_ztpsv " , "cblas_zgerc " , "cblas_zgeru ",
"cblas_zher ", "cblas_zhpr ", "cblas_zher2 " , "cblas_zhpr2 " };
/* System generated locals */
integer i__1, i__2, i__3, i__4, i__5;
doublereal d__1;
/* Local variables */
static integer nalf, idim[9];
static logical same;
static integer ninc, nbet, ntra;
static logical rewi;
extern /* Subroutine */ int zchk1_(char*, doublereal*, doublereal*, integer*, integer*, logical*, logical*, logical*, integer*, integer*, integer*, integer*, integer*, doublecomplex*, integer*, doublecomplex*, integer*, integer*, integer*, integer*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublereal*, integer*, ftnlen);
extern /* Subroutine */ int zchk2_(char*, doublereal*, doublereal*, integer*, integer*, logical*, logical*, logical*, integer*, integer*, integer*, integer*, integer*, doublecomplex*, integer*, doublecomplex*, integer*, integer*, integer*, integer*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublereal*, integer*, ftnlen);
extern /* Subroutine */ int zchk3_(char*, doublereal*, doublereal*, integer*, integer*, logical*, logical*, logical*, integer*, integer*, integer*, integer*, integer*, integer*, integer*, integer*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublereal*, doublecomplex*, integer*, ftnlen);
extern /* Subroutine */ int zchk4_(char*, doublereal*, doublereal*, integer*, integer*, logical*, logical*, logical*, integer*, integer*, integer*, doublecomplex*, integer*, integer*, integer*, integer*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublereal*, doublecomplex*, integer*, ftnlen);
extern /* Subroutine */ int zchk5_(char*, doublereal*, doublereal*, integer*, integer*, logical*, logical*, logical*, integer*, integer*, integer*, doublecomplex*, integer*, integer*, integer*, integer*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublereal*, doublecomplex*, integer*, ftnlen);
extern /* Subroutine */ int zchk6_(char*, doublereal*, doublereal*, integer*, integer*, logical*, logical*, logical*, integer*, integer*, integer*, doublecomplex*, integer*, integer*, integer*, integer*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublecomplex*, doublereal*, doublecomplex*, integer*, ftnlen);
static doublecomplex a[4225] /* was [65][65] */;
static doublereal g[65];
static integer i__, j;
extern doublereal ddiff_(doublereal*, doublereal*);
static integer n;
static logical fatal;
static doublecomplex x[65], y[65], z__[130];
static logical trace;
static integer nidim;
static char snaps[32], trans[1];
extern /* Subroutine */ int zmvch_(char*, integer*, integer*, doublecomplex*, doublecomplex*, integer*, doublecomplex*, integer*, doublecomplex*, doublecomplex*, integer*, doublecomplex*, doublereal*, doublecomplex*, doublereal*, doublereal*, logical*, integer*, logical*, ftnlen);
static integer isnum;
static logical ltest[17];
static doublecomplex aa[4225];
static integer kb[7];
static doublecomplex as[4225];
static logical sfatal;
static doublecomplex xs[130], ys[130];
static logical corder;
static doublecomplex xx[130], yt[65], yy[130];
static char snamet[12];
static doublereal thresh;
static logical rorder;
static integer layout;
static logical ltestt, tsterr;
extern /* Subroutine */ void cz2chke_(char*, ftnlen);
static doublecomplex alf[7];
static integer inc[7], nkb;
static doublecomplex bet[7];
static doublereal eps, err;
extern logical lze_(doublecomplex*, doublecomplex*, integer*);
char tmpchar;
/* Test program for the DOUBLE PRECISION COMPLEX Level 2 Blas. */
/* The program must be driven by a short data file. The first 17 records */
/* of the file are read using list-directed input, the last 17 records */
/* are read using the format ( A12, L2 ). An annotated example of a data */
/* file can be obtained by deleting the first 3 characters from the */
/* following 34 lines: */
/* 'CBLAT2.SNAP' NAME OF SNAPSHOT OUTPUT FILE */
/* -1 UNIT NUMBER OF SNAPSHOT FILE (NOT USED IF .LT. 0) */
/* F LOGICAL FLAG, T TO REWIND SNAPSHOT FILE AFTER EACH RECORD. */
/* F LOGICAL FLAG, T TO STOP ON FAILURES. */
/* T LOGICAL FLAG, T TO TEST ERROR EXITS. */
/* 2 0 TO TEST COLUMN-MAJOR, 1 TO TEST ROW-MAJOR, 2 TO TEST BOTH */
/* 16.0 THRESHOLD VALUE OF TEST RATIO */
/* 6 NUMBER OF VALUES OF N */
/* 0 1 2 3 5 9 VALUES OF N */
/* 4 NUMBER OF VALUES OF K */
/* 0 1 2 4 VALUES OF K */
/* 4 NUMBER OF VALUES OF INCX AND INCY */
/* 1 2 -1 -2 VALUES OF INCX AND INCY */
/* 3 NUMBER OF VALUES OF ALPHA */
/* (0.0,0.0) (1.0,0.0) (0.7,-0.9) VALUES OF ALPHA */
/* 3 NUMBER OF VALUES OF BETA */
/* (0.0,0.0) (1.0,0.0) (1.3,-1.1) VALUES OF BETA */
/* cblas_zgemv T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_zgbmv T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_zhemv T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_zhbmv T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_zhpmv T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_ztrmv T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_ztbmv T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_ztpmv T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_ztrsv T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_ztbsv T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_ztpsv T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_zgerc T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_zgeru T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_zher T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_zhpr T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_zher2 T PUT F FOR NO TEST. SAME COLUMNS. */
/* cblas_zhpr2 T PUT F FOR NO TEST. SAME COLUMNS. */
/* See: */
/* Dongarra J. J., Du Croz J. J., Hammarling S. and Hanson R. J.. */
/* An extended set of Fortran Basic Linear Algebra Subprograms. */
/* Technical Memoranda Nos. 41 (revision 3) and 81, Mathematics */
/* and Computer Science Division, Argonne National Laboratory, */
/* 9700 South Cass Avenue, Argonne, Illinois 60439, US. */
/* Or */
/* NAG Technical Reports TR3/87 and TR4/87, Numerical Algorithms */
/* Group Ltd., NAG Central Office, 256 Banbury Road, Oxford */
/* OX2 7DE, UK, and Numerical Algorithms Group Inc., 1101 31st */
/* Street, Suite 100, Downers Grove, Illinois 60515-1263, USA. */
/* -- Written on 10-August-1987. */
/* Richard Hanson, Sandia National Labs. */
/* Jeremy Du Croz, NAG Central Office. */
/* .. Parameters .. */
/* .. Local Scalars .. */
/* .. Local Arrays .. */
/* .. External Functions .. */
/* .. External Subroutines .. */
/* .. Intrinsic Functions .. */
/* .. Scalars in Common .. */
/* .. Common blocks .. */
/* .. Data statements .. */
/* .. Executable Statements .. */
infoc_1.noutc = 6;
/* Read name and unit number for summary output file and open file. */
char line[80];
fgets(line,80,stdin);
sscanf(line,"'%s'",snaps);
fgets(line,80,stdin);
#ifdef USE64BITINT
sscanf(line,"%ld",&ntra);
#else
sscanf(line,"%d",&ntra);
#endif
trace = ntra >= 0;
if (trace) {
/* o__1.oerr = 0;
o__1.ounit = ntra;
o__1.ofnmlen = 32;
o__1.ofnm = snaps;
o__1.orl = 0;
o__1.osta = 0;
o__1.oacc = 0;
o__1.ofm = 0;
o__1.oblnk = 0;
f_open(&o__1);*/
}
/* Read the flag that directs rewinding of the snapshot file. */
fgets(line,80,stdin);
sscanf(line,"%d",&rewi);
rewi = rewi && trace;
/* Read the flag that directs stopping on any failure. */
fgets(line,80,stdin);
sscanf(line,"%c",&tmpchar);
/* Read the flag that indicates whether error exits are to be tested. */
sfatal=FALSE_;
if (tmpchar=='T')sfatal=TRUE_;
fgets(line,80,stdin);
sscanf(line,"%c",&tmpchar);
/* Read the flag that indicates whether error exits are to be tested. */
tsterr=FALSE_;
if (tmpchar=='T')tsterr=TRUE_;
/* Read the flag that indicates whether row-major data layout to be tested. */
fgets(line,80,stdin);
sscanf(line,"%d",&layout);
/* Read the threshold value of the test ratio */
fgets(line,80,stdin);
sscanf(line,"%lf",&thresh);
/* Read and check the parameter values for the tests. */
/* Values of N */
fgets(line,80,stdin);
#ifdef USE64BITINT
sscanf(line,"%ld",&nidim);
#else
sscanf(line,"%d",&nidim);
#endif
if (nidim < 1 || nidim > 9) {
fprintf(stderr,"NUMBER OF VALUES OF N IS LESS THAN 1 OR GREATER THAN 9");
goto L230;
}
fgets(line,80,stdin);
#ifdef USE64BITINT
sscanf(line,"%ld %ld %ld %ld %ld %ld %ld %ld %ld",&idim[0],&idim[1],&idim[2],
&idim[3],&idim[4],&idim[5],&idim[6],&idim[7],&idim[8]);
#else
sscanf(line,"%d %d %d %d %d %d %d %d %d",&idim[0],&idim[1],&idim[2],
&idim[3],&idim[4],&idim[5],&idim[6],&idim[7],&idim[8]);
#endif
i__1 = nidim;
for (i__ = 1; i__ <= i__1; ++i__) {
if (idim[i__ - 1] < 0 || idim[i__ - 1] > 65) {
fprintf(stderr,"VALUE OF N IS LESS THAN 0 OR GREATER THAN 65\n");
goto L230;
}
/* L10: */
}
/* Values of K */
fgets(line,80,stdin);
#ifdef USE64BITINT
sscanf(line,"%ld",&nkb);
#else
sscanf(line,"%d",&nkb);
#endif
if (nkb < 1 || nkb > 7) {
fprintf(stderr,"NUMBER OF VALUES OF K IS LESS THAN 1 OR GREATER THAN 7");
goto L230;
}
fgets(line,80,stdin);
#ifdef USE64BITINT
sscanf(line,"%ld %ld %ld %ld %ld %ld %ld",&kb[0],&kb[1],&kb[2],&kb[3],&kb[4],&kb[5],&kb[6]);
#else
sscanf(line,"%d %d %d %d %d %d %d",&kb[0],&kb[1],&kb[2],&kb[3],&kb[4],&kb[5],&kb[6]);
#endif
i__1 = nkb;
for (i__ = 1; i__ <= i__1; ++i__) {
if (kb[i__ - 1] < 0 ) {
fprintf(stderr,"VALUE OF K IS LESS THAN 0\n");
goto L230;
}
/* L20: */
}
/* Values of INCX and INCY */
fgets(line,80,stdin);
#ifdef USE64BITINT
sscanf(line,"%ld",&ninc);
#else
sscanf(line,"%d",&ninc);
#endif
if (ninc < 1 || ninc > 7) {
fprintf(stderr,"NUMBER OF VALUES OF INCX AND INCY IS LESS THAN 1 OR GREATER THAN 7");
goto L230;
}
fgets(line,80,stdin);
#ifdef USE64BITINT
sscanf(line,"%ld %ld %ld %ld %ld %ld %ld",&inc[0],&inc[1],&inc[2],&inc[3],&inc[4],&inc[5],&inc[6]);
#else
sscanf(line,"%d %d %d %d %d %d %d",&inc[0],&inc[1],&inc[2],&inc[3],&inc[4],&inc[5],&inc[6]);
#endif
i__1 = ninc;
for (i__ = 1; i__ <= i__1; ++i__) {
if (inc[i__ - 1] == 0 || (i__2 = inc[i__ - 1], abs(i__2)) > 2) {
fprintf (stderr,"ABSOLUTE VALUE OF INCX OR INCY IS 0 OR GREATER THAN 2\n");
goto L230;
}
/* L30: */
}
/* Values of ALPHA */
fgets(line,80,stdin);
sscanf(line,"%d",&nalf);
if (nalf < 1 || nalf > 7) {
fprintf(stderr,"VALUE OF ALPHA IS LESS THAN 0 OR GREATER THAN 7\n");
goto L230;
}
fgets(line,80,stdin);
sscanf(line,"(%lf,%lf) (%lf,%lf) (%lf,%lf) (%lf,%lf) (%lf,%lf) (%lf,%lf) (%lf,%lf)",&alf[0].r,&alf[0].i,&alf[1].r,&alf[1].i,&alf[2].r,&alf[2].i,&alf[3].r,&alf[3].i,
&alf[4].r,&alf[4].i,&alf[5].r,&alf[5].i,&alf[6].r,&alf[6].i);
/* Values of BETA */
fgets(line,80,stdin);
sscanf(line,"%d",&nbet);
if (nbet < 1 || nbet > 7) {
fprintf(stderr,"VALUE OF BETA IS LESS THAN 0 OR GREATER THAN 7\n");
goto L230;
}
fgets(line,80,stdin);
sscanf(line,"(%lf,%lf) (%lf,%lf) (%lf,%lf) (%lf,%lf) (%lf,%lf) (%lf,%lf) (%lf,%lf)",&bet[0].r,&bet[0].i,&bet[1].r,&bet[1].i,&bet[2].r,&bet[2].i,&bet[3].r,&bet[3].i,
&bet[4].r,&bet[4].i,&bet[5].r,&bet[5].i,&bet[6].r,&bet[6].i);
/* Report values of parameters. */
printf("TESTS OF THE DOUBLE PRECISION COMPLEX LEVEL 2 BLAS\nTHE FOLLOWING PARAMETER VALUES WILL BE USED:\n");
printf(" FOR N");
for (i__ =1; i__ <=nidim;++i__) printf(" %d",idim[i__-1]);
printf("\n");
printf(" FOR K");
for (i__ =1; i__ <=nkb;++i__) printf(" %d",kb[i__-1]);
printf("\n");
printf(" FOR INCX AND INCY");
for (i__ =1; i__ <=ninc;++i__) printf(" %d",inc[i__-1]);
printf("\n");
printf(" FOR ALPHA");
for (i__ =1; i__ <=nalf;++i__) printf(" (%f,%f)",alf[i__-1].r,alf[i__-1].i);
printf("\n");
printf(" FOR BETA");
for (i__ =1; i__ <=nbet;++i__) printf(" (%f,%f)",bet[i__-1].r,bet[i__-1].i);
printf("\n");
if (! tsterr) {
printf(" ERROR-EXITS WILL NOT BE TESTED\n");
}
printf("ROUTINES PASS COMPUTATIONAL TESTS IF TEST RATIO IS LESS THAN %f\n",thresh);
rorder = FALSE_;
corder = FALSE_;
if (layout == 2) {
rorder = TRUE_;
corder = TRUE_;
printf("COLUMN-MAJOR AND ROW-MAJOR DATA LAYOUTS ARE TESTED\n");
} else if (layout == 1) {
rorder = TRUE_;
printf("ROW-MAJOR DATA LAYOUT IS TESTED\n");
} else if (layout == 0) {
corder = TRUE_;
printf("COLUMN-MAJOR DATA LAYOUT IS TESTED\n");
}
/* Read names of subroutines and flags which indicate */
/* whether they are to be tested. */
for (i__ = 1; i__ <= 17; ++i__) {
ltest[i__ - 1] = FALSE_;
/* L40: */
}
L50:
if (! fgets(line,80,stdin)) {
goto L80;
}
i__1 = sscanf(line,"%12c %c",snamet,&tmpchar);
ltestt=FALSE_;
if (tmpchar=='T')ltestt=TRUE_;
if (i__1 < 2) {
goto L80;
}
for (i__ = 1; i__ <= 17; ++i__) {
if (s_cmp(snamet, snames[i__ - 1], (ftnlen)12, (ftnlen)12) ==
0) {
goto L70;
}
/* L60: */
}
printf("SUBPROGRAM NAME %s NOT RECOGNIZED\n****** TESTS ABANDONED ******\n",snamet);
exit(1);
L70:
ltest[i__ - 1] = ltestt;
goto L50;
L80:
/* cl__1.cerr = 0;
cl__1.cunit = 5;
cl__1.csta = 0;
f_clos(&cl__1);*/
/* Compute EPS (the machine precision). */
eps = 1.;
L90:
d__1 = eps + 1.;
if (ddiff_(&d__1, &c_b125) == 0.) {
goto L100;
}
eps *= .5;
goto L90;
L100:
eps += eps;
printf("RELATIVE MACHINE PRECISION IS TAKEN TO BE %9.1g\n",eps);
/* Check the reliability of ZMVCH using exact data. */
n = 32;
i__1 = n;
for (j = 1; j <= i__1; ++j) {
i__2 = n;
for (i__ = 1; i__ <= i__2; ++i__) {
i__3 = i__ + j * 65 - 66;
/* Computing MAX */
i__5 = i__ - j + 1;
i__4 = f2cmax(i__5,0);
a[i__3].r = (doublereal) i__4, a[i__3].i = 0.;
/* L110: */
}
i__2 = j - 1;
x[i__2].r = (doublereal) j, x[i__2].i = 0.;
i__2 = j - 1;
y[i__2].r = 0., y[i__2].i = 0.;
/* L120: */
}
i__1 = n;
for (j = 1; j <= i__1; ++j) {
i__2 = j - 1;
i__3 = j * ((j + 1) * j) / 2 - (j + 1) * j * (j - 1) / 3;
yy[i__2].r = (doublereal) i__3, yy[i__2].i = 0.;
/* L130: */
}
/* YY holds the exact result. On exit from CMVCH YT holds */
/* the result computed by CMVCH. */
*(unsigned char *)trans = 'N';
zmvch_(trans, &n, &n, &c_b2, a, &c__65, x, &c__1, &c_b1, y, &c__1, yt, g,
yy, &eps, &err, &fatal, &c__6, &c_true, (ftnlen)1);
same = lze_(yy, yt, &n);
if (! same || err != (float)0.) {
printf("ERROR IN ZMVCH - IN-LINE DOT PRODUCTS ARE BEING EVALUATED WRONGLY\n");
printf("ZMVCH WAS CALLED WITH TRANS = %s ", trans);
printf("AND RETURNED SAME = %c AND ERR = %12.3f.\n",(same==FALSE_? 'F':'T'),err);
printf("THIS MAY BE DUE TO FAULTS IN THE ARITHMETIC OR THE COMPILER.\n");
printf("****** TESTS ABANDONED ******\n");
exit(1);
}
*(unsigned char *)trans = 'T';
zmvch_(trans, &n, &n, &c_b2, a, &c__65, x, &c_n1, &c_b1, y, &c_n1, yt, g,
yy, &eps, &err, &fatal, &c__6, &c_true, (ftnlen)1);
same = lze_(yy, yt, &n);
if (! same || err != 0.) {
printf("ERROR IN ZMVCH - IN-LINE DOT PRODUCTS ARE BEING EVALUATED WRONGLY\n");
printf("ZMVCH WAS CALLED WITH TRANS = %s ", trans);
printf("AND RETURNED SAME = %c AND ERR = %12.3f.\n",(same==FALSE_? 'F':'T'),err);
printf("THIS MAY BE DUE TO FAULTS IN THE ARITHMETIC OR THE COMPILER.\n");
printf("****** TESTS ABANDONED ******\n");
exit(1);
}
/* Test each subroutine in turn. */
for (isnum = 1; isnum <= 17; ++isnum) {
if (! ltest[isnum - 1]) {
/* Subprogram is not to be tested. */
printf("%12s WAS NOT TESTED\n",snames[isnum-1]);
} else {
s_copy(srnamc_1.srnamt, snames[isnum - 1], (ftnlen)12, (
ftnlen)12);
/* Test error exits. */
if (tsterr) {
cz2chke_(snames[isnum - 1], (ftnlen)12);
}
/* Test computations. */
infoc_1.infot = 0;
infoc_1.ok = TRUE_;
fatal = FALSE_;
switch ((int)isnum) {
case 1: goto L140;
case 2: goto L140;
case 3: goto L150;
case 4: goto L150;
case 5: goto L150;
case 6: goto L160;
case 7: goto L160;
case 8: goto L160;
case 9: goto L160;
case 10: goto L160;
case 11: goto L160;
case 12: goto L170;
case 13: goto L170;
case 14: goto L180;
case 15: goto L180;
case 16: goto L190;
case 17: goto L190;
}
/* Test ZGEMV, 01, and ZGBMV, 02. */
L140:
if (corder) {
zchk1_(snames[isnum - 1], &eps, &thresh, &c__6, &ntra,
&trace, &rewi, &fatal, &nidim, idim, &nkb, kb, &nalf,
alf, &nbet, bet, &ninc, inc, &c__65, &c__2, a, aa,
as, x, xx, xs, y, yy, ys, yt, g, &c__0, (ftnlen)12);
}
if (rorder) {
zchk1_(snames[isnum - 1], &eps, &thresh, &c__6, &ntra,
&trace, &rewi, &fatal, &nidim, idim, &nkb, kb, &nalf,
alf, &nbet, bet, &ninc, inc, &c__65, &c__2, a, aa,
as, x, xx, xs, y, yy, ys, yt, g, &c__1, (ftnlen)12);
}
goto L200;
/* Test ZHEMV, 03, ZHBMV, 04, and ZHPMV, 05. */
L150:
if (corder) {
zchk2_(snames[isnum - 1], &eps, &thresh, &c__6, &ntra,
&trace, &rewi, &fatal, &nidim, idim, &nkb, kb, &nalf,
alf, &nbet, bet, &ninc, inc, &c__65, &c__2, a, aa,
as, x, xx, xs, y, yy, ys, yt, g, &c__0, (ftnlen)12);
}
if (rorder) {
zchk2_(snames[isnum - 1], &eps, &thresh, &c__6, &ntra,
&trace, &rewi, &fatal, &nidim, idim, &nkb, kb, &nalf,
alf, &nbet, bet, &ninc, inc, &c__65, &c__2, a, aa,
as, x, xx, xs, y, yy, ys, yt, g, &c__1, (ftnlen)12);
}
goto L200;
/* Test ZTRMV, 06, ZTBMV, 07, ZTPMV, 08, */
/* ZTRSV, 09, ZTBSV, 10, and ZTPSV, 11. */
L160:
if (corder) {
zchk3_(snames[isnum - 1], &eps, &thresh, &c__6, &ntra,
&trace, &rewi, &fatal, &nidim, idim, &nkb, kb, &ninc,
inc, &c__65, &c__2, a, aa, as, y, yy, ys, yt, g, z__,
&c__0, (ftnlen)12);
}
if (rorder) {
zchk3_(snames[isnum - 1], &eps, &thresh, &c__6, &ntra,
&trace, &rewi, &fatal, &nidim, idim, &nkb, kb, &ninc,
inc, &c__65, &c__2, a, aa, as, y, yy, ys, yt, g, z__,
&c__1, (ftnlen)12);
}
goto L200;
/* Test ZGERC, 12, ZGERU, 13. */
L170:
if (corder) {
zchk4_(snames[isnum - 1], &eps, &thresh, &c__6, &ntra,
&trace, &rewi, &fatal, &nidim, idim, &nalf, alf, &
ninc, inc, &c__65, &c__2, a, aa, as, x, xx, xs, y, yy,
ys, yt, g, z__, &c__0, (ftnlen)12);
}
if (rorder) {
zchk4_(snames[isnum - 1], &eps, &thresh, &c__6, &ntra,
&trace, &rewi, &fatal, &nidim, idim, &nalf, alf, &
ninc, inc, &c__65, &c__2, a, aa, as, x, xx, xs, y, yy,
ys, yt, g, z__, &c__1, (ftnlen)12);
}
goto L200;
/* Test ZHER, 14, and ZHPR, 15. */
L180:
if (corder) {
zchk5_(snames[isnum - 1], &eps, &thresh, &c__6, &ntra,
&trace, &rewi, &fatal, &nidim, idim, &nalf, alf, &
ninc, inc, &c__65, &c__2, a, aa, as, x, xx, xs, y, yy,
ys, yt, g, z__, &c__0, (ftnlen)12);
}
if (rorder) {
zchk5_(snames[isnum - 1], &eps, &thresh, &c__6, &ntra,
&trace, &rewi, &fatal, &nidim, idim, &nalf, alf, &
ninc, inc, &c__65, &c__2, a, aa, as, x, xx, xs, y, yy,
ys, yt, g, z__, &c__1, (ftnlen)12);
}
goto L200;
/* Test ZHER2, 16, and ZHPR2, 17. */
L190:
if (corder) {
zchk6_(snames[isnum - 1], &eps, &thresh, &c__6, &ntra,
&trace, &rewi, &fatal, &nidim, idim, &nalf, alf, &
ninc, inc, &c__65, &c__2, a, aa, as, x, xx, xs, y, yy,
ys, yt, g, z__, &c__0, (ftnlen)12);
}
if (rorder) {
zchk6_(snames[isnum - 1], &eps, &thresh, &c__6, &ntra,
&trace, &rewi, &fatal, &nidim, idim, &nalf, alf, &
ninc, inc, &c__65, &c__2, a, aa, as, x, xx, xs, y, yy,
ys, yt, g, z__, &c__1, (ftnlen)12);
}
L200:
if (fatal && sfatal) {
goto L220;
}
}
/* L210: */
}
printf("\nEND OF TESTS\n");
goto L240;
L220:
printf("\n****** FATAL ERROR - TESTS ABANDONED ******\n");
goto L240;
L230:
printf("AMEND DATA FILE OR INCREASE ARRAY SIZES IN PROGRAM\n");
printf("****** TESTS ABANDONED ******\n");
L240:
if (trace) {
/* cl__1.cerr = 0;
cl__1.cunit = ntra;
cl__1.csta = 0;
f_clos(&cl__1);*/
}
/* cl__1.cerr = 0;
cl__1.cunit = 6;
cl__1.csta = 0;
f_clos(&cl__1);*/
exit(0);
/* End of ZBLAT2. */
} /* MAIN__ */
/* Subroutine */ int zchk1_(char* sname, doublereal* eps, doublereal* thresh, integer* nout, integer* ntra, logical* trace, logical* rewi, logical* fatal, integer* nidim, integer* idim, integer* nkb, integer* kb, integer* nalf, doublecomplex* alf, integer* nbet, doublecomplex* bet, integer* ninc, integer* inc, integer* nmax, integer* incmax, doublecomplex* a, doublecomplex* aa, doublecomplex* as, doublecomplex* x, doublecomplex* xx, doublecomplex* xs, doublecomplex* y, doublecomplex* yy, doublecomplex* ys, doublecomplex* yt, doublereal* g, integer* iorder, ftnlen sname_len)
{
/* Initialized data */
static char ich[3+1] = "NTC";
/* System generated locals */
integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7, i__8,
i__9;
/* Local variables */
static doublecomplex beta;
static integer ldas;
static logical same;
static integer incx, incy;
static logical full, tran, null;
static integer i__, m, n;
static doublecomplex alpha;
static logical isame[13];
extern /* Subroutine */ int zmake_(char*, char*, char*, integer*, integer*, doublecomplex*, integer*, doublecomplex*, integer*, integer*, integer*, logical*, doublecomplex*, ftnlen, ftnlen, ftnlen);
static integer nargs;
static logical reset;
static integer incxs, incys;
static char trans[1];
extern /* Subroutine */ int zmvch_(char*, integer*, integer*, doublecomplex*, doublecomplex*, integer*, doublecomplex*, integer*, doublecomplex*, doublecomplex*, integer*, doublecomplex*, doublereal*, doublecomplex*, doublereal*, doublereal*, logical*, integer*, logical*, ftnlen);
static integer ia, ib, ic;
static logical banded;
static integer nc, nd, im, in, kl, ml, nk, nl, ku, ix, iy, ms, lx, ly, ns;
extern /* Subroutine */ void czgbmv_(integer*, char*, integer*, integer*, integer*, integer*, doublecomplex*, doublecomplex*, integer*, doublecomplex*, integer*, doublecomplex*, doublecomplex*, integer*, ftnlen);
static char ctrans[14];
extern /* Subroutine */ void czgemv_(integer*, char*, integer*, integer*, doublecomplex*, doublecomplex*, integer*, doublecomplex*, integer*, doublecomplex*, doublecomplex*, integer*, ftnlen);
static doublereal errmax;
static doublecomplex transl;
extern logical lzeres_(char*, char*, integer*, integer*, doublecomplex*, doublecomplex*, integer*, ftnlen, ftnlen);
static char transs[1];
static integer laa, lda;
static doublecomplex als, bls;
static doublereal err;
static integer iku, kls;
extern logical lze_(doublecomplex*, doublecomplex*, integer*);
static integer kus;
/* Tests CGEMV and CGBMV. */
/* Auxiliary routine for test program for Level 2 Blas. */
/* -- Written on 10-August-1987. */
/* Richard Hanson, Sandia National Labs. */
/* Jeremy Du Croz, NAG Central Office. */
/* .. Parameters .. */
/* .. Scalar Arguments .. */
/* .. Array Arguments .. */
/* .. Local Scalars .. */
/* .. Local Arrays .. */
/* .. External Functions .. */
/* .. External Subroutines .. */
/* .. Intrinsic Functions .. */
/* .. Scalars in Common .. */
/* .. Common blocks .. */
/* .. Data statements .. */
/* Parameter adjustments */
--idim;
--kb;
--alf;
--bet;
--inc;
--g;
--yt;
--y;
--x;
--as;
--aa;
a_dim1 = *nmax;
a_offset = 1 + a_dim1 * 1;
a -= a_offset;
--ys;
--yy;
--xs;
--xx;
/* Function Body */
/* .. Executable Statements .. */
full = *(unsigned char *)&sname[8] == 'e';
banded = *(unsigned char *)&sname[8] == 'b';
/* Define the number of arguments. */
if (full) {
nargs = 11;
} else if (banded) {
nargs = 13;
}
nc = 0;
reset = TRUE_;
errmax = 0.;
i__1 = *nidim;
for (in = 1; in <= i__1; ++in) {
n = idim[in];
nd = n / 2 + 1;
for (im = 1; im <= 2; ++im) {
if (im == 1) {
/* Computing MAX */
i__2 = n - nd;
m = f2cmax(i__2,0);
}
if (im == 2) {
/* Computing MIN */
i__2 = n + nd;
m = f2cmin(i__2,*nmax);
}
if (banded) {
nk = *nkb;
} else {
nk = 1;
}
i__2 = nk;
for (iku = 1; iku <= i__2; ++iku) {
if (banded) {
ku = kb[iku];
/* Computing MAX */
i__3 = ku - 1;
kl = f2cmax(i__3,0);
} else {
ku = n - 1;
kl = m - 1;
}
/* Set LDA to 1 more than minimum value if room. */
if (banded) {
lda = kl + ku + 1;