| 1 |
func real c00(real c) { real a=c; |
| 2 |
|
| 3 |
if(abs(4*a-round(4*a))<1e-13) a=round(a*4)/4.; |
| 4 |
return a; } |
| 5 |
|
| 6 |
func bool CC(string t,real[int] & v) |
| 7 |
{ |
| 8 |
cout << "\n double "<< t<< "[] = "; |
| 9 |
string s = "{ "; |
| 10 |
for(int i=0; i< v.n; ++i) |
| 11 |
{ |
| 12 |
cout << s << c00(v[i]) ; |
| 13 |
s = ", " ; |
| 14 |
} |
| 15 |
cout << " }; \n"; |
| 16 |
return 1; |
| 17 |
} |
| 18 |
|
| 19 |
func bool CC(string t,int[int] & v) |
| 20 |
{ |
| 21 |
cout << "\n int "<< t<< "[] = "; |
| 22 |
string s = "{ "; |
| 23 |
for(int i=0; i< v.n; ++i) |
| 24 |
{ |
| 25 |
cout << s << v[i] ; |
| 26 |
s = ", " ; |
| 27 |
} |
| 28 |
cout << " }; \n"; |
| 29 |
return 1; |
| 30 |
} |
| 31 |
|
| 32 |
func bool CC(string t,real[int,int] & v) |
| 33 |
{ |
| 34 |
cout << "\n double "<< t<< "[]["<<v.n<<"] = "; |
| 35 |
string s = "{\n"; |
| 36 |
for(int j=0; j< v.m; ++j) |
| 37 |
{ |
| 38 |
cout << s; |
| 39 |
s=",\n"; |
| 40 |
string ss = "\t\t{ "; |
| 41 |
for(int i=0; i< v.n; ++i) |
| 42 |
{ |
| 43 |
cout << ss << c00(v(i,j)) ; |
| 44 |
ss = ", " ; |
| 45 |
} |
| 46 |
cout << " } /* "<< j << " */ " ; |
| 47 |
} |
| 48 |
cout << " }; \n"; |
| 49 |
return 1; |
| 50 |
} |
| 51 |
func bool CC(string t,int[int,int] & v) |
| 52 |
{ |
| 53 |
cout << "\n int "<< t<< "[]["<<v.n<<"] = "; |
| 54 |
string s = "{\n"; |
| 55 |
for(int j=0; j< v.m; ++j) |
| 56 |
{ |
| 57 |
cout << s; |
| 58 |
s=",\n"; |
| 59 |
string ss = "\t\t{ "; |
| 60 |
for(int i=0; i< v.n; ++i) |
| 61 |
{ |
| 62 |
cout << ss << (v(i,j)) ; |
| 63 |
ss = ", " ; |
| 64 |
} |
| 65 |
cout << " } /* "<< j << " */ " ; |
| 66 |
} |
| 67 |
cout << " }; \n"; |
| 68 |
return 1; |
| 69 |
} |
| 70 |
func int [int,int] renum(int [int,int] & v,int[int] &I,int[int] &J) |
| 71 |
{ |
| 72 |
int [int,int] w(I.n,J.n); |
| 73 |
w=0; |
| 74 |
for(int i=0; i<I.n;++i) |
| 75 |
for(int j=0; j<J.n;++j) |
| 76 |
{ |
| 77 |
int iv = I[i]; |
| 78 |
int jv= J[j]; |
| 79 |
if( iv >=0 && jv>=0) |
| 80 |
w(i,j) = v(iv,jv); |
| 81 |
} |
| 82 |
return w; |
| 83 |
} |
| 84 |
|
| 85 |
func int [int,int] renum1(int [int,int] & v,int[int] &I,int[int] &J) |
| 86 |
{ |
| 87 |
int [int,int] w(I.n,J.n); |
| 88 |
w=0; |
| 89 |
for(int i=0; i<I.n;++i) |
| 90 |
for(int j=0; j<J.n;++j) |
| 91 |
{ |
| 92 |
int iv = I[i]; |
| 93 |
int jv= J[j]; |
| 94 |
if( iv >=0 && jv>=0) |
| 95 |
w(iv,jv) = v(i,j); |
| 96 |
} |
| 97 |
return w; |
| 98 |
} |
| 99 |
|
| 100 |
func int [int] renum(int [int] & v,int[int] &I) |
| 101 |
{ |
| 102 |
int [int] w(I.n); |
| 103 |
w=0; |
| 104 |
for(int i=0; i<I.n;++i) |
| 105 |
{ |
| 106 |
int iv = I[i]; |
| 107 |
if( iv >=0 ) |
| 108 |
w(i) = v(iv); |
| 109 |
} |
| 110 |
return w; |
| 111 |
} |
| 112 |
|
| 113 |
func int [int] renum1(int [int] & v,int[int] &I) |
| 114 |
{ |
| 115 |
int [int] w(I.n); |
| 116 |
w=0; |
| 117 |
for(int i=0; i<I.n;++i) |
| 118 |
{ |
| 119 |
int iv = I[i]; |
| 120 |
if( iv >=0 ) |
| 121 |
w(iv) = v(i); |
| 122 |
} |
| 123 |
return w; |
| 124 |
} |
| 125 |
|
| 126 |
func bool CCt(string t,real[int,int] & v) |
| 127 |
{ real[int,int] vt = v'; |
| 128 |
CC(t,vt); |
| 129 |
} |
| 130 |
func bool CCt(string t,int[int,int] & v) |
| 131 |
{ int[int,int] vt = v'; |
| 132 |
CC(t,vt); |
| 133 |
} |