36 cout <<
"b = " << b <<
"\n";
39 cout <<
"a = " << a <<
"\n";
42 cout <<
"a = " << a <<
"\n";
43 cout <<
"a.abs() = " <<
abs(a) <<
"\n";
44 cout <<
"a.arg()= " << arg(a) * 57.2957914331333 <<
" degree"
49 cout <<
"c = " << c <<
"\n";
51 cout <<
"a += b: " << (a += b) <<
"\n";
53 cout <<
"c + 3 = " << (c + 3.) <<
"\n";
55 cout <<
"c + 3i = c + Complex (0,3) = " << (c +
Complex(0., 3.)) <<
"\n";
61 cout <<
"d = " << d <<
"\n";
64 cout <<
"e = " << e <<
"\n";
67 cout <<
"f = " << f <<
"\n";
70 cout <<
"g = " << g <<
"\n";
73 cout <<
"h = " << h <<
"\n";
80 for (
Index i = 0; i < 4; i++) {
83 for (
Index j = 0; j < 4; j++) {
98 <<
"Same matrix can be both input and output, here is the above to the power of 4:\n"
127 static_assert(tre + a == 3 + a,
"Bad operator+ int Complex");
128 static_assert(tre - a == 3 - a,
"Bad operator- int Complex");
129 static_assert(tre * a == 3 * a,
"Bad operator* int Complex");
130 static_assert(tre / a == 3 / a,
"Bad operator/ int Complex");
131 static_assert(a + fyr == a + 4,
"Bad operator+ Complex int");
132 static_assert(a - fyr == a - 4,
"Bad operator- Complex int");
133 static_assert(a * fyr == a * 4,
"Bad operator* Complex int");
134 static_assert(a / fyr == a / 4,
"Bad operator/ Complex int");
135 static_assert(tre + a == 3.f + a,
"Bad operator+ float Complex");
136 static_assert(tre - a == 3.f - a,
"Bad operator- float Complex");
137 static_assert(tre * a == 3.f * a,
"Bad operator* float Complex");
138 static_assert(tre / a == 3.f / a,
"Bad operator/ float Complex");
139 static_assert(a + fyr == a + 4.f,
"Bad operator+ Complex float");
140 static_assert(a - fyr == a - 4.f,
"Bad operator- Complex float");
141 static_assert(a * fyr == a * 4.f,
"Bad operator* Complex float");
142 static_assert(a / fyr == a / 4.f,
"Bad operator/ Complex float");
145 static_assert(r * a ==
Complex(one * one, one * two),
146 "Bad Complex(1, 0) Complex ");
147 static_assert(i * a ==
Complex(-one * two, one * one),
148 "Bad Complex(0, 1) Complex ");
151 static_assert(
abs2(c) == tre * tre + fyr * fyr,
"Bad Numeric abs2(Complex)");
154 static_assert(a + b ==
Complex(one + tre, two + two),
155 "Bad operator+ Complex Complex");
156 static_assert(a - b ==
Complex(one - tre, two - two),
157 "Bad operator- Complex Complex");
158 static_assert(a * b ==
Complex(one * tre - two * two, one * two + two * tre),
159 "Bad operator* Complex Complex");
161 a / b ==
Complex(one * tre + two * two, two * tre - one * two) /
abs2(b),
162 "Bad operator/ Complex Complex");
168 constexpr
Index col=2;
169 constexpr
Index row=2;
170 static_assert(n>=4,
"Req for size of val to follow");
171 static_assert(col<n,
"Req for size of val to follow");
172 static_assert(row<n,
"Req for size of val to follow");
180 const auto ranges={r0, r1, r2, r3, r4, r5};
183 for (
Index i=0; i<n; i++)
188 for (
Index i=0; i<n; i++)
189 for (
Index j=0; j<n; j++)
193 std::cout<<
"Vector: ";
195 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
197 std::cout<<
"Matrix:\n";
199 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
200 std::cout<<
"Vector\n";
201 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
202 for (
auto r: ranges) {
203 std::cout<<
"Vector["<<r<<
"]: "<<
MapToEigen(V[r]).transpose()<<
'\n';
204 std::cout<<
"Real: "<<
MapToEigen(V[r].real()).transpose()<<
'\n';
205 std::cout<<
"Imag: "<<
MapToEigen(V[r].imag()).transpose()<<
'\n';
206 std::cout<<
"---------------------------------------------------\n";
208 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
209 std::cout<<
"const Vector\n";
210 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
211 for (
auto r: ranges) {
212 std::cout<<
"const Vector["<<r<<
"]: "<<
MapToEigen(cV[r]).transpose()<<
'\n';
213 std::cout<<
"Real: "<<
MapToEigen(V[r].real()).transpose()<<
'\n';
214 std::cout<<
"Imag: "<<
MapToEigen(V[r].imag()).transpose()<<
'\n';
215 std::cout<<
"---------------------------------------------------\n";
217 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
218 std::cout<<
"RowView Matrix\n";
219 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
220 for (
auto r: ranges) {
221 std::cout<<
"Matrix("<<row<<
", "<<r<<
"): "<<
MapToEigen(
M(row,r)).transpose()<<
'\n';
222 std::cout<<
"Real: "<<
MapToEigen(
M(row,r).real()).transpose()<<
'\n';
223 std::cout<<
"Imag: "<<
MapToEigen(
M(row,r).imag()).transpose()<<
'\n';
224 std::cout<<
"---------------------------------------------------\n";
226 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
227 std::cout<<
"ColView Matrix\n";
228 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
229 for (
auto r: ranges) {
230 std::cout<<
"Matrix("<<r<<
", "<<col<<
"): "<<
MapToEigen(
M(r, col)).transpose()<<
'\n';
231 std::cout<<
"Real: "<<
MapToEigen(
M(r, col).real()).transpose()<<
'\n';
232 std::cout<<
"Imag: "<<
MapToEigen(
M(r, col).imag()).transpose()<<
'\n';
233 std::cout<<
"---------------------------------------------------\n";
235 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
236 std::cout<<
"RowView Matrix-transpose\n";
237 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
238 for (
auto r: ranges) {
239 std::cout<<
"transpose(Matrix)("<<row<<
", "<<r<<
"): "<<
MapToEigen(
transpose(
M)(row,r)).transpose()<<
'\n';
242 std::cout<<
"---------------------------------------------------\n";
244 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
245 std::cout<<
"ColView Matrix transpose\n";
246 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
247 for (
auto r: ranges) {
248 std::cout<<
"transpose(Matrix)("<<r<<
", "<<col<<
"): "<<
MapToEigen(
transpose(
M)(r, col)).transpose()<<
'\n';
251 std::cout<<
"---------------------------------------------------\n";
253 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
254 std::cout<<
"Sub-Matrix\n";
255 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
256 for (
auto rr: ranges) {
257 for (
auto rc: ranges) {
258 std::cout<<
"Matrix("<<rr<<
", "<<rc<<
"):\n"<<
MapToEigen(
M(rr,rc)).transpose()<<
'\n';
259 std::cout<<
"Real:\n"<<
MapToEigen(
M(rr,rc).real()).transpose()<<
'\n';
260 std::cout<<
"Imag:\n"<<
MapToEigen(
M(rr,rc).imag()).transpose()<<
'\n';
261 std::cout<<
"---------------------------------------------------\n";
264 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
265 std::cout<<
"Sub-Matrix transpose\n";
266 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
267 for (
auto rr: ranges) {
268 for (
auto rc: ranges) {
269 std::cout<<
"transpose(Matrix)("<<rr<<
", "<<rc<<
"):\n"<<
MapToEigen(
transpose(
M)(rr,rc)).transpose()<<
'\n';
272 std::cout<<
"---------------------------------------------------\n";
275 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
276 std::cout<<
"RowView Matrix const\n";
277 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
278 for (
auto r: ranges) {
279 std::cout<<
"const Matrix("<<row<<
", "<<r<<
"): "<<
MapToEigen(cM(row,r)).transpose()<<
'\n';
280 std::cout<<
"Real: "<<
MapToEigen(cM(row,r).real()).transpose()<<
'\n';
281 std::cout<<
"Imag: "<<
MapToEigen(cM(row,r).imag()).transpose()<<
'\n';
282 std::cout<<
"---------------------------------------------------\n";
284 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
285 std::cout<<
"ColView Matrix const\n";
286 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
287 for (
auto r: ranges) {
288 std::cout<<
"const Matrix("<<r<<
", "<<col<<
"): "<<
MapToEigen(cM(r, col)).transpose()<<
'\n';
289 std::cout<<
"Real: "<<
MapToEigen(cM(r, col).real()).transpose()<<
'\n';
290 std::cout<<
"Imag: "<<
MapToEigen(cM(r, col).imag()).transpose()<<
'\n';
291 std::cout<<
"---------------------------------------------------\n";
293 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
294 std::cout<<
"RowView Matrix-transpose const\n";
295 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
296 for (
auto r: ranges) {
297 std::cout<<
"transpose(const Matrix)("<<row<<
", "<<r<<
"): "<<
MapToEigen(
transpose(cM)(row,r)).transpose()<<
'\n';
300 std::cout<<
"---------------------------------------------------\n";
302 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
303 std::cout<<
"ColView Matrix-transpose const\n";
304 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
305 for (
auto r: ranges) {
306 std::cout<<
"transpose(const Matrix)("<<r<<
", "<<col<<
"): "<<
MapToEigen(
transpose(cM)(r, col)).transpose()<<
'\n';
309 std::cout<<
"---------------------------------------------------\n";
311 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
312 std::cout<<
"Sub-Matrix const\n";
313 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
314 for (
auto rr: ranges) {
315 for (
auto rc: ranges) {
316 std::cout<<
"Matrix("<<rr<<
", "<<rc<<
"):\n"<<
MapToEigen(
M(rr,rc)).transpose()<<
'\n';
317 std::cout<<
"Real:\n"<<
MapToEigen(
M(rr,rc).real()).transpose()<<
'\n';
318 std::cout<<
"Imag:\n"<<
MapToEigen(
M(rr,rc).imag()).transpose()<<
'\n';
319 std::cout<<
"---------------------------------------------------\n";
322 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
323 std::cout<<
"Sub-Matrix transpose const\n";
324 std::cout<<
"----------------------------------------------------------------------------------------------------\n";
325 for (
auto rr: ranges) {
326 for (
auto rc: ranges) {
327 std::cout<<
"transpose(const Matrix)("<<rr<<
", "<<rc<<
"):\n"<<
MapToEigen(
transpose(cM)(rr,rc)).transpose()<<
'\n';
330 std::cout<<
"---------------------------------------------------\n";