-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMout.cpp
executable file
·92 lines (87 loc) · 1.92 KB
/
Mout.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
/////////////////////////////////////////////////////////////////////////
// Program : mout.cpp
// Coded by : Prof. Gang-Gyoo Jin, Korea Maritime University
// Coded on : 12/12/2003
#include <stdio.h>
#include "cmatrix.h"
/////////////////////////////////////////////////////////////////////////
// outputs an INTEGER matrix a[nrl..nrh][ncl..nch]
void ms_MOut(int** a, long n1, long n2, long n3, long n4)
{
long nrl, nrh, ncl, nch;
if(n3 == 0 || n4 == 0)
{
nrl=0; nrh= n1;
ncl=0; nch= n2;
}
else
{
nrl= n1; nrh= n2+1;
ncl= n3; nch= n4+1;
}
for(long i= nrl; i < nrh; i++)
{
for(long j= ncl; j < nch; j++)
printf("%d ", a[i][j]);
printf("\n");
}
printf("\n");
return;
}
/////////////////////////////////////////////////////////////////////////
// outputs a REAL atrix a[nrl..nrh][ncl..nch]
void ms_MOut(REAL** a, long n1, long n2, long n3, long n4)
{
long nrl, nrh, ncl, nch;
if(n3 == 0 || n4 == 0)
{
nrl=0; nrh= n1;
ncl=0; nch= n2;
}
else
{
nrl= n1; nrh= n2+1;
ncl= n3; nch= n4+1;
}
for(long i= nrl; i < nrh; i++)
{
for(long j= ncl; j < nch; j++)
#ifdef TDFL
printf("%f ", a[i][j]);
#else
printf("%lf ", a[i][j]);
#endif
printf("\n");
}
printf("\n");
return;
}
/////////////////////////////////////////////////////////////////////////
// outputs a REAL matrix a(0..n-1,0..m-1)
void ms_MOut(const RMATRIX &a)
{
for(int i=0; i<a.n; i++)
{
for(int j=0; j<a.m; j++)
printf("%f ",a(i,j));
printf("\n");
}
printf("\n");
return;
}
/////////////////////////////////////////////////////////////////////////
// outputs a COMPLEX matrix a(0..n-1,0..m-1)
void ms_MOut(CMATRIX a)
{
for(int i=0; i<a.n; i++)
{
for(int j=0; j<a.m; j++)
if(a(i,j).Im >=0)
printf("%f+j%f ",a(i,j).Re, a(i,j).Im);
else
printf("%f-j%f ",a(i,j).Re, -a(i,j).Im);
printf("\n");
}
printf("\n");
return;
}