-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathclapack_prb.cpp
1028 lines (935 loc) · 20 KB
/
clapack_prb.cpp
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 <cstdlib>
# include <iostream>
# include <iomanip>
# include <cmath>
# include <ctime>
# include <cstring>
using namespace std;
//
// I have merged the "blaswrap.h", "f2c.h" and "clapack.h" files into one.
//
# include "clapack.h"
int main ( );
void dgesv_test ( );
void dgesvd_test ( );
void dgetrf_test ( );
void dgetri_test ( );
void dnrm2_test ( );
void dsyev_test ( );
void zgesv_test ( );
double *clement2 ( int n );
void r8mat_print ( int m, int n, double a[], string title );
void r8mat_print_some ( int m, int n, double a[], int ilo, int jlo, int ihi,
int jhi, string title );
void r8vec_print ( int n, double a[], string title );
void timestamp ( );
//****************************************************************************80
int main ( )
//****************************************************************************80
//
// Purpose:
//
// MAIN is the main program for CLAPACK_PRB.
//
// Discussion:
//
// CLAPACK_PRB tests the CLAPACK library.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 30 July 2013
//
// Author:
//
// John Burkardt
//
{
timestamp ( );
cout << "\n";
cout << "CLAPACK_PRB\n";
cout << " C++ version\n";
cout << " Test the CLAPACK library.\n";
cout << " CLAPACK is a C translation of the FORTRAN77 BLAS and LAPACK libraries.\n";
//
// Call DNRM2_TEST early, and compare with result later.
//
dnrm2_test ( );
dgesv_test ( );
dgesvd_test ( );
dgetrf_test ( );
dgetri_test ( );
dnrm2_test ( );
dsyev_test ( );
zgesv_test ( );
//
// Terminate.
//
cout << "\n";
cout << "CLAPACK_PRB:\n";
cout << " Normal end of execution.\n";
cout << "\n";
timestamp ( );
return 0;
}
//****************************************************************************80
void dgesv_test ( )
//****************************************************************************80
//
// Purpose:
//
// DGESV_TEST demonstrates DGESV.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 23 July 2013
//
// Author:
//
// John Burkardt
//
{
double A[4*4] = {
1.0, 2.0, 1.0, 1.0,
-1.0, -2.0, 1.0, -1.0,
2.0, 3.0, 1.0, 4.0,
-1.0, -3.0, 0.0, 3.0 };
double B[4] = {
-8.0, -20.0, -2.0, 4.0 };
int i;
static long int INFO;
int info2;
static long int IPIV[4];
int j;
long int LDA;
long int LDB;
long int N = 4;
long int NRHS;
cout << "\n";
cout << "DGESV_TEST\n";
cout << " Demonstrate the use of DGESV to solve a linear system\n";
cout << " using double precision real arithmetic.\n";
//
// Print the coefficient matrix.
//
r8mat_print ( N, N, A, " Coefficient matrix A:" );
//
// Print the right hand side.
//
r8vec_print ( N, B, " Right hand side B:" );
//
// Call DGESV to compute the solution.
//
NRHS = 1;
LDA = N;
LDB = N;
dgesv_ ( &N, &NRHS, A, &LDA, IPIV, B, &LDB, &INFO );
cout << "\n";
cout << " Return value of error flag INFO = " << INFO << "\n";
//
// Print the solution.
//
r8vec_print ( N, B, " Computed solution X:\n" );
return;
}
//****************************************************************************80
void dgesvd_test ( )
//****************************************************************************80
//
// Purpose:
//
// DGESVD_TEST demonstrates DGESVD.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 23 July 2013
//
// Author:
//
// John Burkardt
//
{
# define MVAL 4
# define NVAL 4
//
// The entries of A are listed by columns, not rows!
//
long int LWORK = 201;
double a[MVAL*NVAL] = {
16.0, 5.0, 9.0, 4.0,
2.0, 11.0, 7.0, 14.0,
3.0, 10.0, 6.0, 15.0,
13.0, 8.0, 12.0, 1.0 };
int i;
long int INFO;
int j;
char JOBU = 'A';
char JOBVT = 'A';
long int LDA = MVAL;
long int LDU = MVAL;
long int LDVT = NVAL;
long int M = MVAL;
long int N = NVAL;
long int mn = min ( MVAL, NVAL );
long int MN = max ( MVAL, NVAL );
double s[MVAL];
double uu[MVAL*MVAL];
double vt[NVAL*NVAL];
double wk[LWORK];
cout << "\n";
cout << "DGESVD_TEST\n";
cout << " Demonstrate the use of DGESVD to compute the\n";
cout << " singular value decomposition A = U * S * V',\n";
cout << " using double precision real arithmetic.\n";
//
// Print the coefficient matrix.
//
r8mat_print ( M, N, a, " Coefficient matrix A:" );
//
// Call DGESVD for singular value decomposition A = U * S * V'.
//
dgesvd_ ( &JOBU, &JOBVT, &M, &N, a, &LDA, s, uu, &LDU, vt, &LDVT, wk,
&LWORK, &INFO );
cout << "\n";
cout << " Error flag INFO = " << INFO << "\n";
//
// Print the singular values.
//
r8vec_print ( M, s, " Singular values:\n" );
return;
# undef MVAL
# undef NVAL
}
//****************************************************************************80
void dgetrf_test ( )
//****************************************************************************80
//
// Purpose:
//
// DGETRF_TEST demonstrates DGETRF and DGETRS.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 30 July 2013
//
// Author:
//
// John Burkardt
//
{
double A[4*4] = {
1.0, 2.0, 1.0, 1.0,
-1.0, -2.0, 1.0, -1.0,
2.0, 3.0, 1.0, 4.0,
-1.0, -3.0, 0.0, 3.0 };
double B[4] = {
-8.0, -20.0, -2.0, 4.0 };
int i;
static long int INFO;
int info2;
static long int IPIV[4];
int j;
long int LDA;
long int LDB;
long int N = 4;
long int NRHS;
char TRANS;
cout << "\n";
cout << "DGETRF_TEST\n";
cout << " Demonstrate the use of:\n";
cout << " DGETRF to factor a general matrix A,\n";
cout << " DGETRS to solve A*x=b after A has been factored,\n";
cout << " using double precision real arithmetic.\n";
LDA = N;
//
// Print the coefficient matrix.
//
r8mat_print ( N, N, A, " Coefficient matrix A:" );
//
// Call DGETRF to factor the matrix.
//
dgetrf_ ( &N, &N, A, &LDA, IPIV, &INFO );
cout << "\n";
cout << " Return value of DGETRF error flag INFO = " << INFO << "\n";
//
// Set the right hand side.
//
r8vec_print ( N, B, " Right hand side B:\n" );
//
// Call DGETRS to solve the linear system A*x=b.
//
TRANS = 'N';
NRHS = 1;
LDB = N;
dgetrs_ ( &TRANS, &N, &NRHS, A, &LDA, IPIV, B, &LDB, &INFO );
cout << "\n";
cout << " Return value of DGETRS error flag INFO = " << INFO << "\n";
//
// Solution X is returned in B.
//
r8vec_print ( N, B, " Computed solution X:\n" );
return;
# undef NDIM
}
//****************************************************************************80
void dgetri_test ( )
//****************************************************************************80
//
// Purpose:
//
// DGETRI_TEST tests DGETRF and DGETRI.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 07 January 2014
//
// Author:
//
// John Burkardt
//
{
double A[3*3] = {
1.0, 4.0, 7.0,
2.0, 5.0, 8.0,
3.0, 6.0, 0.0 };
long int INFO;
long int IPIV[3];
long int LDA;
long int LWORK;
long int N = 3;
double WORK[3];
cout << "\n";
cout << "DGETRI_TEST\n";
cout << " For a double precision real matrix (D)\n";
cout << " in general storage mode (GE):\n";
cout << "\n";
cout << " DGETRF factors a general matrix;\n";
cout << " DGETRI computes the inverse.\n";
r8mat_print ( N, N, A, " The matrix A:" );
//
// Factor the matrix.
//
LDA = N;
dgetrf_ ( &N, &N, A, &LDA, IPIV, &INFO );
if ( ( int ) INFO != 0 )
{
cout << "\n";
cout << " DGETRF returned INFO = " << INFO << "\n";
cout << " The matrix is numerically singular.\n";
return;
}
//
// Compute the inverse matrix.
//
LWORK = N;
dgetri_ ( &N, A, &LDA, IPIV, WORK, &LWORK, &INFO );
if ( ( int ) INFO != 0 )
{
cout << "\n";
cout << " The inversion procedure failed!\n";
cout << " INFO = " << INFO << "\n";
return;
}
//
// Print the inverse matrix.
//
r8mat_print ( N, N, A, " The inverse matrix:" );
return;
}
//****************************************************************************80
void dnrm2_test ( )
//****************************************************************************80
//
// Purpose:
//
// DNRM2_TEST tests DNRM2.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 02 June 2015
//
// Author:
//
// John Burkardt
//
{
double X[3] = { 1.0, 2.0, 3.0 };
long int INCX;
long int N;
double VALUE;
cout << "\n";
cout << "DNRM2_TEST\n";
cout << " For a double precision real vector (D)\n";
cout << " DNRM2 computes the Euclidean norm.\n";
cout << "\n";
cout << " WARNING:\n";
cout << " The result of this computation may be wrong.\n";
cout << " The result seems to depend on when this test function\n";
cout << " is called. If it is the first thing called,\n";
cout << " it is usually correct. Hence I suspect a memory problem\n";
cout << " elsewhere.\n";
N = 3;
r8vec_print ( N, X, " The vector X:" );
VALUE = dnrm2_ ( &N, X, &INCX );
cout << "\n";
cout << " VALUE = " << VALUE << "\n";
return;
}
//****************************************************************************80
void dsyev_test ( )
//****************************************************************************80
//
// Purpose:
//
// DSYEV_TEST tests DSYEV.
//
// Discussion:
//
// For some reason, you can't use "int" variables as arguments to CLAPACK
// functions; you have to use "integer" variables, which, apparently.
// are equivalent to the standard "long int" datatype. If you also want to
// use int variables here and there, you may need to declare two versions
// of the same quantity.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 23 July 2013
//
// Author:
//
// John Burkardt
//
{
double *a;
int info;
long int INFO;
char jobz;
double *lambda;
int lwork;
long int LWORK;
int n;
long int N = 7;
char uplo;
double *work;
cout << "\n";
cout << "DSYEV_TEST\n";
cout << " For a double precision real matrix (D)\n";
cout << " in symmetric storage mode (SY):\n";
cout << "\n";
cout << " For a symmetric matrix in general storage,\n";
cout << " DSYEV computes eigenvalues and eigenvectors;\n";
//
// Set A.
//
n = ( int ) N;
a = clement2 ( n );
r8mat_print ( n, n, a, " The matrix A:" );
//
// Compute the eigenvalues and eigenvectors.
//
jobz = 'V';
uplo = 'U';
lambda = new double[N];
LWORK = 3 * N - 1;
work = new double[LWORK];
dsyev_ ( &jobz, &uplo, &N, a, &N, lambda, work, &LWORK, &INFO );
info = ( int ) INFO;
if ( info != 0 )
{
cout << "\n";
cout << " DSYEV returned nonzero INFO = " << info << "\n";
}
else
{
r8vec_print ( n, lambda, " The eigenvalues:" );
if ( jobz == 'V' )
{
r8mat_print ( n, n, a, " The eigenvector matrix:" );
}
}
delete [] a;
delete [] lambda;
delete [] work;
return;
}
//****************************************************************************80
void zgesv_test ( )
//****************************************************************************80
//
// Purpose:
//
// ZGESV_TEST demonstrates ZGESV.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 23 July 2013
//
// Author:
//
// John Burkardt
//
{
# define NDIM 2
doublecomplex *A;
doublecomplex *B;
int i;
static long int INFO;
int info2;
static long int IPIV[NDIM];
int j;
long int LDA;
long int LDB;
long int N;
long int NRHS;
const double pi = 3.141592653589793;
cout << "\n";
cout << "ZGESV_TEST\n";
cout << " Demonstrate the use of ZGESV to solve a linear system\n";
cout << " using double precision complex arithmetic.\n";
A = new doublecomplex[NDIM*NDIM];
B = new doublecomplex[NDIM];
N = NDIM;
NRHS = 1;
LDA = NDIM;
LDB = NDIM;
//
// Print the coefficient matrix.
//
cout << "\n";
cout << " Coefficient matrix A:\n";
cout << "\n";
for ( i = 0; i < N; i++ )
{
for ( j = 0; j < N; j++ )
{
A[i+N*j].r = cos ( pi * ( double ) ( i + 1 ) * 3.0 / 4.0 );
A[i+N*j].i = sin ( pi * ( double ) ( j + 1 ) / 5.0 );
cout << " " << setw(12) << A[i+N*j].r
<< " +"
<< " " << setw(12) << A[i+N*j].i << " i\n";
}
cout << "\n";
}
//
// Print the right hand side.
//
cout << "\n";
cout << " Right hand side B:\n";
cout << "\n";
B[0].r = 1.0;
B[0].i = 1.0;
B[1].r = 2.0;
B[1].i = 3.0;
for ( i = 0; i < N; i++ )
{
cout << " " << setw(12) << B[i].r
<< " + " << setw(12) << B[i].i << " i\n";
}
//
// Call ZGESV to compute the solution.
//
info2 = zgesv_ ( &N, &NRHS, A, &LDA, IPIV, B, &LDB, &INFO );
cout << "\n";
cout << " Return value of error flag INFO = " << INFO << "\n";
cout << "\n";
cout << " Computed solution X:\n";
cout << "\n";
for ( i = 0; i < N; i++ )
{
cout << " " << setw(12) << B[i].r
<< " +"
<< " " << setw(12) << B[i].i << " i\n";
}
free ( A );
free ( B );
return;
# undef NDIM
}
//****************************************************************************80
double *clement2 ( int n )
//****************************************************************************80
//
// Purpose:
//
// CLEMENT2 returns the CLEMENT2 matrix.
//
// Formula:
//
// if ( J = I + 1 )
// A(I,J) = sqrt(I*(N-I))
// else if ( I = J + 1 )
// A(I,J) = sqrt(J*(N-J))
// else
// A(I,J) = 0
//
// Example:
//
// N = 5
//
// . sqrt(4) . . .
// sqrt(4) . sqrt(6) . .
// . sqrt(6) . sqrt(6) .
// . . sqrt(6) . sqrt(4)
// . . . sqrt(4) .
//
// Properties:
//
// A is tridiagonal.
//
// A is banded, with bandwidth 3.
//
// Because A is tridiagonal, it has property A (bipartite).
//
// A is symmetric: A' = A.
//
// Because A is symmetric, it is normal.
//
// Because A is normal, it is diagonalizable.
//
// A is persymmetric: A(I,J) = A(N+1-J,N+1-I).
//
// The diagonal of A is zero.
//
// A is singular if N is odd.
//
// About 64 percent of the entries of the inverse of A are zero.
//
// The eigenvalues are plus and minus the numbers
//
// N-1, N-3, N-5, ..., (1 or 0).
//
// If N is even,
//
// det ( A ) = (-1)^(N/2) * (N-1) * (N+1)^(N/2)
//
// and if N is odd,
//
// det ( A ) = 0
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 05 June 2008
//
// Author:
//
// John Burkardt
//
// Reference:
//
// Paul Clement,
// A class of triple-diagonal matrices for test purposes,
// SIAM Review,
// Volume 1, 1959, pages 50-52.
//
// Parameters:
//
// Input, int N, the order of the matrix.
//
// Output, double CLEMENT2[N*N], the matrix.
//
{
double *a;
int i;
int j;
a = new double[n*n];
for ( i = 1; i <= n; i++ )
{
for ( j = 1; j <= n; j++ )
{
if ( j == i + 1 )
{
a[i-1+(j-1)*n] = sqrt ( ( double ) ( i * ( n - i ) ) );
}
else if ( i == j + 1 )
{
a[i-1+(j-1)*n] = sqrt ( ( double ) ( j * ( n - j ) ) );
}
else
{
a[i-1+(j-1)*n] = 0.0;
}
}
}
return a;
}
//****************************************************************************80
void r8mat_print ( int m, int n, double a[], string title )
//****************************************************************************80
//
// Purpose:
//
// R8MAT_PRINT prints an R8MAT.
//
// Discussion:
//
// An R8MAT is a doubly dimensioned array of R8 values, stored as a vector
// in column-major order.
//
// Entry A(I,J) is stored as A[I+J*M]
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 10 September 2009
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int M, the number of rows in A.
//
// Input, int N, the number of columns in A.
//
// Input, double A[M*N], the M by N matrix.
//
// Input, string TITLE, a title.
//
{
r8mat_print_some ( m, n, a, 1, 1, m, n, title );
return;
}
//****************************************************************************80
void r8mat_print_some ( int m, int n, double a[], int ilo, int jlo, int ihi,
int jhi, string title )
//****************************************************************************80
//
// Purpose:
//
// R8MAT_PRINT_SOME prints some of an R8MAT.
//
// Discussion:
//
// An R8MAT is a doubly dimensioned array of R8 values, stored as a vector
// in column-major order.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 26 June 2013
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int M, the number of rows of the matrix.
// M must be positive.
//
// Input, int N, the number of columns of the matrix.
// N must be positive.
//
// Input, double A[M*N], the matrix.
//
// Input, int ILO, JLO, IHI, JHI, designate the first row and
// column, and the last row and column to be printed.
//
// Input, string TITLE, a title.
//
{
# define INCX 5
int i;
int i2hi;
int i2lo;
int j;
int j2hi;
int j2lo;
cout << "\n";
cout << title << "\n";
if ( m <= 0 || n <= 0 )
{
cout << "\n";
cout << " (None)\n";
return;
}
//
// Print the columns of the matrix, in strips of 5.
//
for ( j2lo = jlo; j2lo <= jhi; j2lo = j2lo + INCX )
{
j2hi = j2lo + INCX - 1;
if ( n < j2hi )
{
j2hi = n;
}
if ( jhi < j2hi )
{
j2hi = jhi;
}
cout << "\n";
//
// For each column J in the current range...
//
// Write the header.
//
cout << " Col: ";
for ( j = j2lo; j <= j2hi; j++ )
{
cout << setw(7) << j - 1 << " ";
}
cout << "\n";
cout << " Row\n";
cout << "\n";
//
// Determine the range of the rows in this strip.
//
if ( 1 < ilo )
{
i2lo = ilo;
}
else
{
i2lo = 1;
}
if ( ihi < m )
{
i2hi = ihi;
}
else
{
i2hi = m;
}
for ( i = i2lo; i <= i2hi; i++ )
{
//
// Print out (up to) 5 entries in row I, that lie in the current strip.
//
cout << setw(5) << i - 1 << ": ";
for ( j = j2lo; j <= j2hi; j++ )
{
cout << setw(12) << a[i-1+(j-1)*m] << " ";
}
cout << "\n";
}
}
return;
# undef INCX
}
//****************************************************************************80
void r8vec_print ( int n, double a[], string title )
//****************************************************************************80
//
// Purpose:
//
// R8VEC_PRINT prints an R8VEC.
//
// Discussion:
//
// An R8VEC is a vector of R8's.
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 16 August 2004
//
// Author:
//
// John Burkardt
//
// Parameters:
//
// Input, int N, the number of components of the vector.
//
// Input, double A[N], the vector to be printed.
//
// Input, string TITLE, a title.
//
{
int i;
cout << "\n";
cout << title << "\n";
cout << "\n";
for ( i = 0; i < n; i++ )
{
cout << " " << setw(8) << i
<< ": " << setw(14) << a[i] << "\n";
}
return;
}
//****************************************************************************80
void timestamp ( )
//****************************************************************************80
//
// Purpose:
//
// TIMESTAMP prints the current YMDHMS date as a time stamp.
//
// Example:
//
// 31 May 2001 09:45:54 AM
//
// Licensing:
//
// This code is distributed under the GNU LGPL license.
//
// Modified:
//
// 08 July 2009