1 //==============================================================================================
2 //
3 //	This file is part of LiDIA --- a library for computational number theory
4 //
5 //	Copyright (c) 1994--2001 the LiDIA Group.  All rights reserved.
6 //
7 //	See http://www.informatik.tu-darmstadt.de/TI/LiDIA/
8 //
9 //----------------------------------------------------------------------------------------------
10 //
11 //	$Id$
12 //
13 //	Author	: Patrick Theobald (PT)
14 //	Changes	: See CVS log
15 //
16 //==============================================================================================
17 
18 // Application Test Routine
19 
20 
21 #include	"LiDIA/bigint.h"
22 #include	"LiDIA/bigint_matrix.h"
23 #include	<fstream>
24 
25 #define IN_NAME argv[1]
26 #define OUT_NAME argv[2]
27 
28 
29 
30 #ifdef LIDIA_NAMESPACE
31 using namespace LiDIA;
32 #endif
33 
34 
35 
main_LiDIA(int argc,char ** argv)36 int main_LiDIA(int argc, char** argv)
37 {
38 	if (argc != 3) {
39 		std::cerr << "usage: " << argv[0] << " input-file output-file" << std::endl;
40 		return 4;
41 	}
42 
43 	std::ifstream in(IN_NAME);
44 	std::ofstream dz(OUT_NAME);
45 
46 	int i, j;
47 
48 	// pointer
49 	bigint *pointer_1 = NULL;
50 	bigint *pointer_2 = NULL;
51 	bigint *pointer_3 = new bigint[4];
52 	bigint *pointer_4 = new bigint[6];
53 	bigint *pointer_5 = new bigint[4];
54 	bigint *pointer_6 = new bigint[6];
55 
56 	// vectors
57 	math_vector< bigint > v1, v2;
58 	math_vector< bigint > v3(4, 4);
59 	math_vector< bigint > v4(6, 6);
60 
61 	// scalar
62 	bigint scalar_1, scalar_2, scalar_3;
63 	in >> scalar_2 >> scalar_3;
64 	//std::cout << scalar_2 << scalar_3 << std::flush;
65 	lidia_size_t c, r;
66 
67 	// array
68 	bigint **wertearray = new bigint *[2];
69 	for (i = 0; i < 2; i++) {
70 		wertearray[i] = new bigint[3];
71 		for (j = 0; j < 3; j++) {
72 			in >> wertearray[i][j];
73 			//std::cout << wertearray[i][j] << std::flush;
74 		}
75 	}
76 
77 	std::cout << "**********************************************************" << std::endl;
78 	std::cout << "***             Test for class bigint_matrix           ***" << std::endl;
79 	std::cout << "***                     Version 2.0                    ***" << std::endl;
80 	std::cout << "**********************************************************" << std::endl;
81 	std::cout.flush();
82 
83 	std::cout << "\ntesting constructors" << std::flush;
84 	dz << "testing constructor" << std::endl << std::flush;
85 	bigint_matrix  A(3, 1);
86 	bigint_matrix  B(2, 3);
87 	bigint_matrix  C(2, 3, const_cast<const bigint **>(wertearray));
88 	bigint_matrix  D(C);
89 	bigint_matrix  E = C;
90 	bigint_matrix  F = C;
91 	dz << A << B << C << D << E << F << std::flush;
92 	std::cout << ".............................completed\n" << std::flush;
93 
94 	A.read_from_stream(in);
95 	B.read_from_stream(in);
96 	C.read_from_stream(in);
97 
98 	std::cout << "testing set_print_mode" << std::flush;
99 	dz << "testing set_print_mode\n" << std::flush;
100 	dz << " set A BEAUTY_MODE\n" << std::flush;
101 	A.set_print_mode(BEAUTY_MODE);
102 	dz << " set B LIDIA_MODE\n" << std::flush;
103 	B.set_print_mode(LIDIA_MODE);
104 	dz << " set C GP_MODE\n" << std::flush;
105 	C.set_print_mode(GP_MODE);
106 	dz << " set D MAPLE_MODE\n" << std::flush;
107 	D.set_print_mode(MAPLE_MODE);
108 	dz << " set E MATHEMATICA_MODE\n" << std::flush;
109 	E.set_print_mode(MATHEMATICA_MODE);
110 	dz << " set E KASH_MODE\n" << std::flush;
111 	E.set_print_mode(KASH_MODE);
112 	std::cout << "...........................completed\n" << std::flush;
113 
114 	std::cout << "testing get_print_mode" << std::flush;
115 	dz << "testing get_print_mode\n" << std::flush;
116 	dz << A.get_print_mode() << std::endl << std::flush;
117 	dz << B.get_print_mode() << std::endl << std::flush;
118 	dz << C.get_print_mode() << std::endl << std::flush;
119 	dz << D.get_print_mode() << std::endl << std::flush;
120 	dz << E.get_print_mode() << std::endl << std::flush;
121 	dz << F.get_print_mode() << std::endl << std::flush;
122 	std::cout << "...........................completed\n" << std::flush;
123 
124 	std::cout << "testing write_to_stream" << std::flush;
125 	dz << "testing write_to_stream\n" << std::flush;
126 	std::ofstream out1("LIDIA");
127 	D.write_to_stream(out1);
128 	out1.close();
129 	std::cout << "..........................completed\n" << std::flush;
130 
131 	std::cout << "testing write_to_gp" << std::flush;
132 	dz << "testing write_to_gp\n" << std::flush;
133 	std::ofstream out2("GP");
134 	D.write_to_gp(out2);
135 	out2.close();
136 	std::cout << "..............................completed\n" << std::flush;
137 
138 	std::cout << "testing write_to_maple" << std::flush;
139 	dz << "testing write_to_maple\n" << std::flush;
140 	std::ofstream out3("MAPLE");
141 	D.write_to_maple(out3);
142 	out3.close();
143 	std::cout << "...........................completed\n" << std::flush;
144 
145 	std::cout << "testing write_to_mathematica" << std::flush;
146 	dz << "testing write_to_mathematica\n" << std::flush;
147 	std::ofstream out4("MATHEMATICA");
148 	D.write_to_mathematica(out4);
149 	out4.close();
150 	std::cout << ".....................completed\n" << std::flush;
151 
152 	std::cout << "testing write_to_kash" << std::flush;
153 	dz << "testing write_to_kash\n" << std::flush;
154 	std::ofstream out5("KASH");
155 	D.write_to_kash(out5);
156 	out5.close();
157 	std::cout << "............................completed\n" << std::flush;
158 
159 	A.set_print_mode(BEAUTY_MODE);
160 	B.set_print_mode(BEAUTY_MODE);
161 	C.set_print_mode(BEAUTY_MODE);
162 	D.set_print_mode(BEAUTY_MODE);
163 	E.set_print_mode(BEAUTY_MODE);
164 	F.set_print_mode(BEAUTY_MODE);
165 
166 	std::cout << "testing read_from_stream" << std::flush;
167 	dz << "testing read_from_stream\n" << std::flush;
168 	std::ifstream in1("LIDIA");
169 	D.read_from_stream(in1);
170 	dz << D << std::flush;
171 	in1.close();
172 	std::cout << ".........................completed\n" << std::flush;
173 
174 	std::cout << "testing read_from_gp" << std::flush;
175 	dz << "testing read_from_gp\n" << std::flush;
176 	std::ifstream in2("GP");
177 	D.read_from_gp(in2);
178 	dz << D << std::flush;
179 	in2.close();
180 	std::cout << ".............................completed\n" << std::flush;
181 
182 	std::cout << "testing read_from_maple" << std::flush;
183 	dz << "testing read_from_maple\n" << std::flush;
184 	std::ifstream in3("MAPLE");
185 	D.read_from_maple(in3);
186 	dz << D << std::flush;
187 	in3.close();
188 	std::cout << "..........................completed\n" << std::flush;
189 
190 	std::cout << "testing read_from_mathematica" << std::flush;
191 	dz << "testing read_from_mathematica\n" << std::flush;
192 	std::ifstream in4("MATHEMATICA");
193 	D.read_from_mathematica(in4);
194 	dz << D << std::flush;
195 	in4.close();
196 	std::cout << "....................completed\n" << std::flush;
197 
198 	std::cout << "testing read_from_kash" << std::flush;
199 	dz << "testing read_from_kash\n" << std::flush;
200 	std::ifstream in5("KASH");
201 	D.read_from_kash(in5);
202 	in5.close();
203 	std::cout << "...........................completed\n" << std::flush;
204 
205 	std::cout << "testing member" << std::flush;
206 	dz << "testing member" << std::endl << std::flush;
207 	scalar_1 = A.member(2, 1);
208 	dz << scalar_1 << std::endl;
209 	scalar_1 = A(2, 1);
210 	dz << scalar_1 << std::endl << std::flush;
211 	std::cout << "...................................completed\n" << std::flush;
212 
213 	std::cout << "testing column" << std::flush;
214 	dz << "testing column" << std::endl << std::flush;
215 	v1 = A(0);
216 	dz << v1 << std::endl << std::flush;
217 	dz << "\n" << std::flush;
218 	pointer_1 = A.get_column(1);
219 	for (i = 0; i < 4; i++)
220 		dz << pointer_1[i] << " " << std::flush;
221 	dz << "\n" << std::flush;
222 	A.get_column(pointer_1, 2);
223 	for (i = 0; i < 4; i++)
224 		dz << pointer_1[i] << " " << std::flush;
225 	dz << "\n" << std::flush;
226 	A.get_column_vector(v1, 2);
227 	dz << v1 << std::endl << std::flush;
228 	std::cout << "...................................completed\n" << std::flush;
229 
230 	std::cout << "testing row" << std::flush;
231 	dz << "testing row" << std::endl << std::flush;
232 	v2 = A[0];
233 	dz << v2 << std::endl << std::flush;
234 	dz << "\n" << std::flush;
235 	pointer_2 = A.get_row(1);
236 	for (i = 0; i < 6; i++)
237 		dz << pointer_2[i] << " " << std::flush;
238 	dz << "\n" << std::flush;
239 	A.get_row(pointer_2, 2);
240 	for (i = 0; i < 6; i++)
241 		dz << pointer_2[i] << " " << std::flush;
242 	dz << "\n" << std::flush;
243 	A.get_row_vector(v2, 2);
244 	dz << v2 << std::endl << std::flush;
245 	std::cout << "......................................completed\n" << std::flush;
246 
247 	std::cout << "testing sto" << std::flush;
248 	E = A;
249 	dz << "testing sto" << std::endl << std::flush;
250 	E.sto(2, 0, 23);
251 	dz << E << std::flush;
252 	std::cout << "......................................completed\n" << std::flush;
253 
254 	std::cout << "testing sto_column" << std::flush;
255 	dz << "testing sto_column" << std::endl << std::flush;
256 	E = A;
257 	E.sto_column(pointer_1, 3, 0);
258 	dz << E << std::flush;
259 	E.sto_column_vector(v1, 3, 1);
260 	dz << E << std::flush;
261 	std::cout << "...............................completed\n" << std::flush;
262 
263 	std::cout << "testing sto_row" << std::flush;
264 	dz << "testing sto_row" << std::endl << std::flush;
265 	E = A;
266 	E.sto_row(pointer_2, 4, 0);
267 	dz << E << std::flush;
268 	E.sto_row_vector(v2, 4, 1);
269 	dz << E << std::flush;
270 	std::cout << "..................................completed\n" << std::flush;
271 
272 	std::cout << "testing get_data" << std::flush;
273 	dz << "testing get_data" << std::endl << std::flush;
274 	r = E.get_no_of_rows();
275 	c = E.get_no_of_columns();
276 	bigint **value = E.get_data();
277 	for (i = 0; i < r; i++)
278 		for (j = 0; j < c; j++)
279 			dz << value[i][j] << " ";
280 	dz << std::endl << std::flush;
281 	for (i = 0; i < r; i++)
282 		delete[] value[i];
283 	delete[] value;
284 	std::cout << ".................................completed\n" << std::flush;
285 
286 	std::cout << "testing swap" << std::flush;
287 	dz << "testing swap" << std::endl << std::flush;
288 	dz << E << A << std::flush;
289 	swap(E, A);
290 	dz << E << A << std::flush;
291 	swap(E, A);
292 	std::cout << ".....................................completed\n" << std::flush;
293 
294 	std::cout << "testing swap_columns" << std::flush;
295 	dz << "testing swap_columns" << std::endl << std::flush;
296 	E = A;
297 	E.swap_columns(0, 5);
298 	dz << E << std::flush;
299 	std::cout << ".............................completed\n" << std::flush;
300 
301 	std::cout << "testing swap_rows" << std::flush;
302 	dz << "testing swap_rows" << std::endl << std::flush;
303 	E = A;
304 	E.swap_rows(3, 0);
305 	dz << E << std::flush;
306 	std::cout << "................................completed\n" << std::flush;
307 
308 	std::cout << "testing split_t" << std::flush;
309 	dz << "testing split_t" << std::endl << std::flush;
310 	bigint_matrix  Part1(2, 4), Part2(3, 2), Part3(2, 4), Part4(1, 2);
311 	A.split_t(Part1, Part2, Part3, Part4);
312 	dz << Part1 << Part2 << Part3 << Part4 << std::flush;
313 	std::cout << "..................................completed\n" << std::flush;
314 
315 	std::cout << "testing split_h" << std::flush;
316 	dz << "testing split_h" << std::endl << std::flush;
317 	bigint_matrix  Part5(4, 4), Part6(4, 2);
318 	bigint_matrix  PartA(4, 5), PartB(4, 5), PartC(4, 5), PartD(4, 5);
319 	A.split_h(Part5, Part6);
320 	dz << Part5 << Part6 << std::flush;
321 
322 	A.split_h(pointer_1, PartA);
323 	dz << PartA;
324 	for (i = 0; i < 4; i++)
325 		dz << pointer_1[i] << " ";
326 	dz << std::endl << std::flush;
327 	A.split_h(v1, PartB);
328 	dz << PartB << v1 << std::endl << std::flush;
329 
330 	A.split_h(PartC, pointer_3);
331 	dz << PartC;
332 	for (i = 0; i < 4; i++)
333 		dz << pointer_3[i] << " ";
334 	dz << std::endl << std::flush;
335 	A.split_h(PartD, v3);
336 	dz << PartD << v3 << std::endl << std::flush;
337 	std::cout << "..................................completed\n" << std::flush;
338 
339 	std::cout << "testing split_v" << std::flush;
340 	dz << "testing split_v" << std::endl << std::flush;
341 	bigint_matrix  Part7(1, 6), Part8(3, 6);
342 	bigint_matrix  PartE(3, 6), PartF(3, 6), PartG(3, 6), PartH(3, 6);
343 	A.split_v(Part7, Part8);
344 	dz << Part7 << Part8 << std::flush;
345 
346 	A.split_v(pointer_2, PartE);
347 	dz << PartE;
348 	for (i = 0; i < 6; i++)
349 		dz << pointer_2[i] << " ";
350 	dz << std::endl << std::flush;
351 	A.split_v(v2, PartF);
352 	dz << PartF << v2 << std::endl << std::flush;
353 
354 	A.split_v(PartG, pointer_4);
355 	dz << PartG;
356 	for (i = 0; i < 6; i++)
357 		dz << pointer_4[i] << " ";
358 	dz << std::endl << std::flush;
359 	A.split_v(PartH, v4);
360 	dz << PartH << v4 << std::endl << std::flush;
361 	std::cout << "..................................completed\n" << std::flush;
362 
363 	std::cout << "testing compose_t" << std::flush;
364 	dz << "testing compose_t\n" << std::flush;
365 	{
366 		bigint_matrix  TMP(4, 6);
367 		TMP.compose_t(Part1, Part2, Part3, Part4);
368 		dz << TMP << std::flush;
369 	}
370 	std::cout << "................................completed\n" << std::flush;
371 
372 	std::cout << "testing compose_h" << std::flush;
373 	dz << "testing compose_h" << std::endl << std::flush;
374 	{
375 		bigint_matrix  TMP(4, 6);
376 		TMP.compose_h(Part5, Part6);
377 		dz << TMP << std::flush;
378 
379 		TMP.compose_h(pointer_1, PartA);
380 		dz << TMP << std::flush;
381 
382 		TMP.compose_h(v1, PartB);
383 		dz << TMP << std::flush;
384 
385 		TMP.compose_h(PartC, pointer_3);
386 		dz << TMP << std::flush;
387 
388 		TMP.compose_h(PartD, v3);
389 		dz << TMP << std::flush;
390 	}
391 	std::cout << "................................completed\n" << std::flush;
392 
393 	std::cout << "testing compose_v" << std::flush;
394 	dz << "testing compose_v" << std::endl << std::flush;
395 	{
396 		bigint_matrix TMP(4, 6);
397 		TMP.compose_v(Part7, Part8);
398 		dz << TMP << std::flush;
399 
400 		TMP.compose_v(pointer_2, PartE);
401 		dz << TMP << std::flush;
402 
403 		TMP.compose_v(v2, PartF);
404 		dz << TMP << std::flush;
405 
406 		TMP.compose_v(PartG, pointer_4);
407 		dz << TMP << std::flush;
408 
409 		TMP.compose_v(PartH, v4);
410 		dz << TMP << std::flush;
411 	}
412 	std::cout << "................................completed\n" << std::flush;
413 
414 	std::cout << "testing get_no_of_columns" << std::flush;
415 	dz << "testing get_no_of_columns" << std::endl << std::flush;
416 	scalar_1 = A.get_no_of_columns();
417 	dz << scalar_1 << std::endl << std::flush;
418 	std::cout << "........................completed\n" << std::flush;
419 
420 	std::cout << "testing get_no_of_rows" << std::flush;
421 	dz << "testing get_no_of_rows" << std::endl << std::flush;
422 	scalar_1 = A.get_no_of_rows();
423 	dz << scalar_1 << std::endl << std::flush;
424 	std::cout << "...........................completed\n" << std::flush;
425 
426 	std::cout << "testing set_no_of_columns" << std::flush;
427 	dz << "set_no_of_columns" << std::endl << std::flush;
428 	E = A;
429 	E.set_no_of_columns(3);
430 	dz << E << std::flush;
431 	std::cout << "........................completed\n" << std::flush;
432 
433 	std::cout << "testing set_no_of_rows" << std::flush;
434 	dz << "set_no_of_rows" << std::endl << std::flush;
435 	E.set_no_of_rows(3);
436 	dz << E << std::flush;
437 	std::cout << "...........................completed\n" << std::flush;
438 
439 	std::cout << "testing assign" << std::flush;
440 	dz << "testing assign" << std::endl << std::flush;
441 	E = A;
442 	dz << E << std::flush;
443 	E.assign(A);
444 	dz << E << std::flush;
445 	assign(E, A);
446 	dz << E << std::flush;
447 	std::cout << "...................................completed\n" << std::flush;
448 
449 	std::cout << "testing trans" << std::flush;
450 	dz << "testing trans" << std::endl << std::flush;
451 	E = trans(A);
452 	dz << E << std::flush;
453 	E = E.trans();
454 	dz << E << std::flush;
455 	E.trans(E);
456 	dz << E << std::flush;
457 	trans(E, E);
458 	dz << E << std::flush;
459 	std::cout << "....................................completed\n" << std::flush;
460 
461 	std::cout << "testing diag" << std::flush;
462 	dz << "diag" << std::endl << std::flush;
463 	E.diag(scalar_1, scalar_2);
464 	dz << E << std::flush;
465 	diag(E, scalar_2, scalar_3);
466 	dz << E << std::flush;
467 	std::cout << ".....................................completed\n" << std::flush;
468 
469 	//***************************** END   OF PART: BASE_MATIRX ***************
470 	//**************************** BEGIN Of PART: MATH_MATRIX ****************
471 
472 	dz << A << B << C << D << E << std::flush;
473 	dz << v1 << v2 << v3 << v4 << std::endl << std::flush;
474 
475 	std::cout << "testing addition" << std::flush;
476 	dz << "testing addition" << std::endl << std::flush;
477 	A += B;
478 	dz << A << std::flush;
479 	add(A, A, B);
480 	dz << A << std::flush;
481 	F = A + B;
482 	dz << F << std::flush;
483 	add(F, A, B);
484 	dz << F << std::flush;
485 	std::cout << ".................................completed\n" << std::flush;
486 
487 	std::cout << "testing subtraction" << std::flush;
488 	dz << "testing subtraction" << std::endl << std::flush;
489 	A -= B;
490 	dz << A << std::flush;
491 	subtract(A, A, B);
492 	dz << A << std::flush;
493 	F = A - B;
494 	dz << F << std::flush;
495 	subtract(F, A, B);
496 	dz << F << std::flush;
497 	std::cout << "..............................completed\n" << std::flush;
498 
499 	std::cout << "testing negate" << std::flush;
500 	dz << "testing negate" << std::endl << std::flush;
501 	F = -A;
502 	dz << F << std::flush;
503 	negate(F, A);
504 	dz << F << std::flush;
505 	std::cout << "...................................completed\n" << std::flush;
506 
507 	std::cout << "testing multiplication" << std::flush;
508 	dz << "testing multiplication" << std::endl << std::flush;
509 	E = A, F = A;
510 	E *= C;
511 	dz << E << std::flush;
512 	E = A * C;
513 	dz << E << std::flush;
514 	multiply(F, A, C);
515 	dz << F << std::flush;
516 	std::cout << "...........................completed\n" << std::flush;
517 
518 	std::cout << "testing addition with scalar" << std::flush;
519 	dz << "testing addition with scalar" << std::endl << std::flush;
520 	A += scalar_2;
521 	dz << A << std::flush;
522 	F = A + scalar_2;
523 	dz << F << std::flush;
524 	add(F, A, scalar_2);
525 	dz << F << std::flush;
526 	std::cout << ".....................completed\n" << std::flush;
527 
528 	std::cout << "testing subtraction with scalar" << std::flush;
529 	dz << "testing subtraction with scalar" << std::endl << std::flush;
530 	A -= scalar_2;
531 	dz << A << std::flush;
532 	F = A - scalar_2;
533 	dz << F << std::flush;
534 	subtract(F, A, scalar_2);
535 	dz << F << std::flush;
536 	std::cout << "..................completed\n" << std::flush;
537 
538 	std::cout << "testing multiplication with scalar" << std::flush;
539 	dz << "testing multiplication with scalar" << std::endl << std::flush;
540 	F = A;
541 	F *= scalar_3;
542 	dz << F << std::flush;
543 	F = A * scalar_3;
544 	dz << F << std::flush;
545 	multiply(F, A, scalar_3);
546 	dz << F << std::flush;
547 	std::cout << "...............completed\n" << std::flush;
548 
549 	std::cout << "testing multiplication with array" << std::flush;
550 	dz << "testing multiplication with array" << std::endl << std::flush;
551 	pointer_3 = A * pointer_2;
552 	for (i = 0; i < 4; i++)
553 		dz << pointer_3[i] << " ";
554 	dz << std::endl << std::flush;
555 	multiply(pointer_5, A, pointer_2);
556 	for (i = 0; i < 4; i++)
557 		dz << pointer_5[i] << " ";
558 	dz << std::endl << std::flush;
559 
560 	pointer_4 = pointer_1 * A;
561 	for (i = 0; i < 6; i++)
562 		dz << pointer_4[i] << " ";
563 	dz << std::endl << std::flush;
564 	multiply(pointer_6, pointer_1, A);
565 	for (i = 0; i < 6; i++)
566 		dz << pointer_6[i] << " ";
567 	dz << std::endl << std::flush;
568 	std::cout << "................completed\n" << std::flush;
569 
570 	std::cout << "testing multiplication with vector" << std::flush;
571 	dz << "testing multiplication with vector" << std::endl << std::flush;
572 	v3 = A * v2;
573 	dz << v3 << std::endl << std::flush;
574 	multiply(v3, A, v2);
575 	dz << v3 << std::endl << std::flush;
576 
577 	v4 = v1 * A;
578 	dz << v4 << std::endl << std::flush;
579 	multiply(v4, v1, A);
580 	dz << v4 << std::endl << std::flush;
581 	std::cout << "...............completed\n" << std::flush;
582 
583 	std::cout << "testing trace" << std::flush;
584 	dz << "testing trace" << std::endl << std::flush;
585 	F = A * trans(A);
586 	scalar_1 = F.trace();
587 	dz << scalar_1 << std::endl << std::flush;
588 	F.trace(scalar_1);
589 	dz << scalar_1 << std::endl << std::flush;
590 	scalar_1 = trace(F);
591 	dz << scalar_1 << std::endl << std::flush;
592 	std::cout << "....................................completed\n" << std::flush;
593 
594 	//***************************** END   OF PART: MATH_MATIRX ***************
595 	//**************************** BEGIN Of PART: BIGINT_MATRIX **************
596 
597 	std::cout << "testing remainder" << std::flush;
598 	dz << "testing remainder" << std::endl << std::flush;
599 	F = A;
600 	F %= 13;
601 	dz << F << std::flush;
602 	F = A % 13;
603 	dz << F << std::flush;
604 	remainder(F, A, bigint(13));
605 	dz << F << std::flush;
606 	std::cout << "................................completed\n" << std::flush;
607 
608 	std::cout << "testing equal / unequal" << std::flush;
609 	bigint_matrix G = F;
610 	dz << "testing equal/unequal" << std::endl << std::flush;
611 	dz << (F == G) << std::endl << std::flush;
612 	dz << F.equal(G) << std::endl << std::flush;
613 	dz << equal(F, G) << std::endl << std::flush;
614 	dz << (F != G) << std::endl << std::flush;
615 	dz << F.unequal(G) << std::endl << std::flush;
616 	dz << unequal(F, G) << std::endl << std::flush;
617 	std::cout << "..........................completed\n" << std::flush;
618 
619 	std::cout << "testing is_column_zero" << std::flush;
620 	D.diag(bigint(0), bigint(0));
621 	dz << "testing is_column_zero" << std::endl << std::flush;
622 
623 	//dz << D.is_column_zero(0) << std::endl << std::flush;
624 	if (D.is_column_zero(0) == true)
625 		dz << 1 << std::endl;
626 	else
627 		dz << 0 << std::endl;
628 
629 	if (F.is_column_zero(0) == true)
630 		dz << 1 << std::endl;
631 	else
632 		dz << 0 << std::endl;
633 	std::cout << "...........................completed\n" << std::flush;
634 
635 	std::cout << "testing is_row_zero" << std::flush;
636 	dz << "testing is_row_zero" << std::endl << std::flush;
637 	if (D.is_row_zero(0) == true)
638 		dz << 1 << std::endl;
639 	else
640 		dz << 0 << std::endl;
641 
642 	if (F.is_row_zero(0) == true)
643 		dz << 1 << std::endl;
644 	else
645 		dz << 0 << std::endl;
646 	std::cout << "..............................completed\n" << std::flush;
647 
648 	std::cout << "testing is_matrix_zero" << std::flush;
649 	dz << "testing is_matrix_zero" << std::endl << std::flush;
650 	if (D.is_matrix_zero() == true)
651 		dz << 1 << std::endl;
652 	else
653 		dz << 0 << std::endl;
654 
655 	if (F.is_matrix_zero() == true)
656 		dz << 1 << std::endl;
657 	else
658 		dz << 0 << std::endl;
659 	std::cout << "...........................completed\n" << std::flush;
660 
661 	std::cout << "testing max / min " << std::flush;
662 	dz << "testing max / min" << std::endl << std::flush;
663 	A.max(scalar_1);
664 	dz << scalar_1 << std::endl << std::flush;
665 	dz << A.max() << std::endl << std::flush;
666 	dz << max(A) << std::endl << std::flush;
667 	A.min(scalar_1);
668 	dz << scalar_1 << std::endl << std::flush;
669 	dz << A.min() << std::endl << std::flush;
670 	dz << min(A) << std::endl << std::flush;
671 	std::cout << "...............................completed\n" << std::flush;
672 
673 	std::cout << "testing max_pos / min_pos " << std::flush;
674 	dz << "testing min_pos / max_pos" << std::endl << std::flush;
675 	A.max_pos(scalar_1, i, j);
676 	dz << scalar_1 << " " << i << " " << j << std::endl << std::flush;
677 	dz << A.max_pos(i, j) << " " << i << " " << j << std::endl << std::flush;
678 	dz << max_pos(A, i, j) << " " << i << " " << j << std::endl << std::flush;
679 	A.min_pos(scalar_1, i, j);
680 	dz << scalar_1 << " " << i << " " << j << std::endl << std::flush;
681 	dz << A.min_pos(i, j) << " " << i << " " << j << std::endl << std::flush;
682 	dz << min_pos(A, i, j) << " " << i << " " << j << std::endl << std::flush;
683 	std::cout << ".......................completed\n" << std::flush;
684 
685 	std::cout << "testing max_abs / min_abs " << std::flush;
686 	dz << "testing min_abs / max_abs" << std::endl << std::flush;
687 	A.max_abs(scalar_1);
688 	dz << scalar_1 << std::endl << std::flush;
689 	dz << A.max_abs() << std::endl << std::flush;
690 	dz << max_abs(A) << std::endl << std::flush;
691 	A.min_abs(scalar_1);
692 	dz << scalar_1 << std::endl << std::flush;
693 	dz << A.min_abs() << std::endl << std::flush;
694 	dz << min_abs(A) << std::endl << std::flush;
695 	std::cout << ".......................completed\n" << std::flush;
696 
697 	std::cout << "testing max_abs_pos / min_abs_pos " << std::flush;
698 	dz << "testing min_abs_pos / max_abs_pos" << std::endl << std::flush;
699 	A.max_abs_pos(scalar_1, i, j);
700 	dz << scalar_1 << " " << i << " " << j << std::endl << std::flush;
701 	dz << A.max_abs_pos(i, j) << " " << i << " " << j << std::endl << std::flush;
702 	dz << max_abs_pos(A, i, j) << " " << i << " " << j << std::endl << std::flush;
703 	A.min_abs_pos(scalar_1, i, j);
704 	dz << scalar_1 << " " << i << " " << j << std::endl << std::flush;
705 	dz << A.min_abs_pos(i, j) << " " << i << " " << j << std::endl << std::flush;
706 	dz << min_abs_pos(A, i, j) << " " << i << " " << j << std::endl << std::flush;
707 	std::cout << "...............completed\n" << std::flush;
708 
709 	std::cout << "testing hadamard " << std::flush;
710 	dz << "testing hadamard" << std::endl << std::flush;
711 	A.hadamard(scalar_1);
712 	dz << scalar_1 << std::endl << std::flush;
713 	dz << A.hadamard() << std::endl << std::flush;
714 	dz << hadamard(A) << std::endl << std::flush;
715 	std::cout << "................................completed\n" << std::flush;
716 
717 	std::cout << "testing row_norm / column_norm " << std::flush;
718 	dz << "testing column_norm / row_norm" << std::endl << std::flush;
719 	A.row_norm(scalar_1, 0, 2);
720 	dz << scalar_1 << std::endl << std::flush;
721 	dz << A.row_norm(0, 2) << std::endl << std::flush;
722 	dz << row_norm(A, 0, 2) << std::endl << std::flush;
723 	A.column_norm(scalar_1, 0, 2);
724 	dz << scalar_1 << std::endl << std::flush;
725 	dz << A.column_norm(0, 2) << std::endl << std::flush;
726 	dz << column_norm(A, 0, 2) << std::endl << std::flush;
727 	std::cout << "..................completed\n" << std::flush;
728 
729 	//std::cout << A << B << C << D << E << F << std::flush;
730 
731 	std::cout << "testing rank" << std::flush;
732 	dz << "testing rank" << std::endl << std::flush;
733 	dz << rank(A) << std::endl << std::flush;
734 	dz << A.rank() << std::endl << std::flush;
735 	std::cout << ".....................................completed\n" << std::flush;
736 
737 	std::cout << "testing lininr" << std::flush;
738 	dz << "testing lininr" << std::endl << std::flush;
739 	lidia_size_t *q = lininr(F);
740 	for (i = 0; i <= q[0]; i++)
741 		dz << q[i] << " ";
742 	dz << std::endl << std::flush;
743 	delete[] q;
744 
745 	q = F.lininr();
746 	for (i = 0; i <= q[0]; i++)
747 		dz << q[i] << " ";
748 	dz << std::endl << std::flush;
749 	delete[] q;
750 	std::cout << "...................................completed\n" << std::flush;
751 
752 	std::cout << "testing lininc" << std::flush;
753 	dz << "testing lininc" << std::endl << std::flush;
754 	lidia_size_t *q1 = lininc(F);
755 	for (i = 0; i <= q1[0]; i++)
756 		dz << q1[i] << " ";
757 	dz << std::endl << std::flush;
758 	delete[] q1;
759 
760 	q1 = F.lininc();
761 	for (i = 0; i <= q1[0]; i++)
762 		dz << q1[i] << " ";
763 	dz << std::endl << std::flush;
764 	delete[] q1;
765 	std::cout << "...................................completed\n" << std::flush;
766 
767 	std::cout << "testing RegExpansion" << std::flush;
768 	dz << "testing RegExpansion" << std::endl << std::flush;
769 	F = trans(A);
770 	q = lininr(F);
771 	D = A;
772 	E = A;
773 	regexpansion(D, q);
774 	dz << D << std::flush;
775 	E.regexpansion(q);
776 	dz << E << std::flush;
777 	std::cout << ".............................completed\n" << std::flush;
778 
779 	std::cout << "testing adj" << std::flush;
780 	dz << "testing adj" << std::endl << std::flush;
781 #ifdef _MSC_VER
782 	F = A * bigint_matrix(trans(A));
783 #else
784 	F = A * trans(A);
785 #endif
786 	bigint_matrix ADJ = adj(F);
787 	dz << ADJ << ADJ * F << std::flush;
788 	ADJ.adj(F);
789 	dz << ADJ << ADJ * F << std::flush;
790 	std::cout << "......................................completed\n" << std::flush;
791 
792 	std::cout << "testing latticedet / latticedet2" << std::flush;
793 	dz << "testing latticedet / latticedet2" << std::endl << std::flush;
794 	A.latticedet(scalar_1);
795 	dz << scalar_1 << std::endl << std::flush;
796 	scalar_1 = A.latticedet();
797 	dz << scalar_1 << std::endl << std::flush;
798 	scalar_1 = latticedet(A);
799 	dz << scalar_1 << std::endl << std::flush;
800 
801 	A.latticedet2(scalar_1);
802 	dz << scalar_1 << std::endl << std::flush;
803 	A.latticedet2(scalar_1);
804 	dz << scalar_1 << std::endl << std::flush;
805 	A.latticedet2(scalar_1);
806 	dz << scalar_1 << std::endl << std::flush;
807 	std::cout << ".................completed\n" << std::flush;
808 
809 	std::cout << "testing det" << std::flush;
810 	dz << "testing det" << std::endl << std::flush;
811 	F.det(scalar_1);
812 	dz << scalar_1 << std::endl << std::flush;
813 	scalar_1 = F.det();
814 	dz << scalar_1 << std::endl << std::flush;
815 	scalar_1 = det(F);
816 	dz << scalar_1 << std::endl << std::flush;
817 	std::cout << "......................................completed\n" << std::flush;
818 
819 	std::cout << "testing charpoly" << std::flush;
820 	dz << "charpoly" << std::endl << std::flush;
821 	c = F.get_no_of_columns();
822 	pointer_5 = charpoly(F);
823 	for (i = 0; i < c + 1; i++)
824 		dz << pointer_5[i] << " ";
825 	dz << std::endl << std::flush;
826 
827 	pointer_5 = F.charpoly();
828 	for (i = 0; i < c + 1; i++)
829 		dz << pointer_5[i] << " ";
830 	dz << std::endl << std::flush;
831 	std::cout << ".................................completed\n" << std::flush;
832 
833 	std::cout << "testing hnf_havas(0) " << std::flush;
834 	dz << "testing hnf_havas(0) " << std::endl << std::flush;
835 	F = A;
836 	F.hnf_havas(0);
837 	dz << F << std::flush;
838 	F = A;
839 	F.hnf_havas(D, 0);
840 	dz << F << A*D << std::flush;
841 
842 	F = A;
843 	F.hnf_havas(0);
844 	dz << F << std::flush;
845 	F = A;
846 	F.hnf_havas(D, 0);
847 	dz << F << A*D << std::flush;
848 	std::cout << "...............................completed\n" << std::flush;
849 
850 	std::cout << "testing hnf_havas" << std::flush;
851 	dz << "testing hnf_havas" << std::endl << std::flush;
852 	F = A;
853 	F.hnf_havas(1);
854 	dz << F << std::flush;
855 	F = A;
856 	F.hnf_havas(D);
857 	dz << F << A*D << std::flush;
858 
859 	F = A;
860 	F.hnf_havas(1);
861 	dz << F << std::flush;
862 	F = A;
863 	F.hnf_havas(D, 1);
864 	dz << F << A*D << std::flush;
865 	std::cout << "................................completed\n" << std::flush;
866 
867 	std::cout << "testing hnfmod_dkt" << std::flush;
868 	dz << "testing hnfmod_dkt" << std::endl << std::flush;
869 	scalar_1 = latticedet(A);
870 	F = A;
871 	F.hnfmod_dkt(scalar_1);
872 	dz << F << std::flush;
873 	F = A;
874 	F.hnfmod_dkt();
875 	dz << F << std::flush;
876 	F = A;
877 	F.hnfmod_dkt();
878 	dz << F << std::flush;
879 	F = A;
880 	F.hnfmod_dkt(scalar_1);
881 	dz << F << std::flush;
882 	std::cout << "...............................completed\n" << std::flush;
883 
884 	std::cout << "testing hnfmod_cohen" << std::flush;
885 	dz << "testing hnfmod_cohen" << std::endl << std::flush;
886 	scalar_1 = latticedet(A);
887 	F = A;
888 	F.hnfmod_cohen(scalar_1);
889 	dz << F << std::flush;
890 	F = A;
891 	F.hnfmod_cohen();
892 	dz << F << std::flush;
893 	F = A;
894 	F.hnfmod_cohen();
895 	dz << F << std::flush;
896 	F = A;
897 	F.hnfmod_cohen(scalar_1);
898 	dz << F << std::flush;
899 	std::cout << ".............................completed\n" << std::flush;
900 
901 	std::cout << "testing hnfmod_mueller" << std::flush;
902 	dz << "testing hnfmod_mueller" << std::endl << std::flush;
903 	F = A;
904 	F.hnfmod_mueller(D);
905 	dz << F << A*D << std::flush;
906 
907 	F = A;
908 	F.hnfmod_mueller(D);
909 	dz << F << A*D << std::flush;
910 	std::cout << "...........................completed\n" << std::flush;
911 
912 	std::cout << "testing kernel / kernel2" << std::flush;
913 	dz << "testing kernel / kernel2" << std::endl << std::flush;
914 	F = kernel(A);
915 	dz << F << std::flush;
916 	D.kernel(A);
917 	dz << D << std::flush;
918 
919 	F.kernel(A);
920 	dz << F << std::flush;
921 	D.kernel(A);
922 	dz << D << std::flush;
923 	std::cout << ".........................completed\n" << std::flush;
924 
925 	std::cout << "testing reginvimage / reginvimage2" << std::flush;
926 	dz << "testing reginvimage / reginvimage2" << std::endl << std::flush;
927 	C = A * trans(A);
928 	F = reginvimage(C, B);
929 	dz << F << std::flush;
930 	D.reginvimage(C, B);
931 	dz << D << std::flush;
932 
933 	F.reginvimage(C, B);
934 	dz << F << std::flush;
935 	D.reginvimage(C, B);
936 	dz << D << std::flush;
937 	std::cout << "...............completed\n" << std::flush;
938 
939 	std::cout << "testing image" << std::flush;
940 	dz << "testing image" << std::endl << std::flush;
941 	F = image(A);
942 	dz << F << std::flush;
943 	D.image(A);
944 	dz << D << std::flush;
945 
946 	F.image2(A);
947 	dz << F << std::flush;
948 	D.image2(A);
949 	dz << D << std::flush;
950 	std::cout << "....................................completed\n" << std::flush;
951 
952 	std::cout << "testing invimage" << std::flush;
953 	dz << "testing invimage" << std::endl << std::flush;
954 	pointer_1 = new bigint[4];
955 	pointer_1[0] = 30;
956 	pointer_1[1] = 40;
957 	pointer_1[2] = 50;
958 	pointer_1[3] = 60;
959 	F = invimage(A, pointer_1);
960 	dz << F << std::flush;
961 	D.invimage(A, pointer_1);
962 	dz << D << std::flush;
963 	std::cout << ".................................completed\n" << std::flush;
964 
965 	std::cout << "testing solve" << std::flush;
966 	dz << "testing solve" << std::endl << std::flush;
967 	pointer_1[0] = 30;
968 	pointer_1[1] = 40;
969 	pointer_1[2] = 50;
970 	pointer_1[3] = 60;
971 	F = solve(A, pointer_1);
972 	dz << F << std::flush;
973 	D.solve(A, pointer_1);
974 	dz << D << std::flush;
975 	std::cout << "....................................completed\n" << std::flush;
976 
977 	std::cout << "testing snf_hartley" << std::flush;
978 	dz << "testing snf_hartley" << std::endl << std::flush;
979 	F = A;
980 	F.snf_hartley();
981 	dz << F << std::flush;
982 	F = A;
983 	F.snf_hartley(D, E);
984 	dz << F << D * A * E << std::flush;
985 	F = A;
986 	F.snf_hartley();
987 	dz << F << std::flush;
988 	F = A;
989 	F.snf_hartley(D, E);
990 	dz << F << D * A * E << std::flush;
991 	std::cout << "..............................completed\n" << std::flush;
992 
993 	std::cout << "testing snf_simple" << std::flush;
994 	dz << "testing snf_simple" << std::endl << std::flush;
995 	F = A;
996 	F.snf_simple();
997 	dz << F << std::flush;
998 	F = A;
999 	F.snf_simple(D, E);
1000 	dz << F << D * A * E << std::flush;
1001 	F = A;
1002 	F.snf_simple();
1003 	dz << F << std::flush;
1004 	F = A;
1005 	F.snf_simple(D, E);
1006 	dz << F << D * A * E << std::flush;
1007 	std::cout << "...............................completed\n" << std::flush;
1008 
1009 	std::cout << "testing snf_havas" << std::flush;
1010 	dz << "testing snf_havas" << std::endl << std::flush;
1011 	F = A;
1012 	F.snf_havas();
1013 	dz << F << std::flush;
1014 	F = A;
1015 	F.snf_havas(D, E);
1016 	dz << F << D * A * E << std::flush;
1017 	F = A;
1018 	F.snf_havas();
1019 	dz << F << std::flush;
1020 	F = A;
1021 	F.snf_havas(D, E);
1022 	dz << F << D * A * E << std::flush;
1023 	std::cout << "................................completed\n" << std::flush;
1024 
1025 	std::cout << "testing snf_mult" << std::flush;
1026 	dz << "testing snf_mult" << std::endl << std::flush;
1027 	F = A;
1028 	F.snf_mult();
1029 	dz << F << std::flush;
1030 	F = A;
1031 	F.snf_mult(D, E);
1032 	dz << F << D * A * E << std::flush;
1033 	F = A;
1034 	F.snf_mult();
1035 	dz << F << std::flush;
1036 	F = A;
1037 	F.snf_mult(D, E);
1038 	dz << F << D * A * E << std::flush;
1039 	std::cout << ".................................completed\n" << std::flush;
1040 
1041 	std::cout << "testing snf_add" << std::flush;
1042 	dz << "testing snf_add" << std::endl << std::flush;
1043 	F = A;
1044 	F.snf_add();
1045 	dz << F << std::flush;
1046 	F = A;
1047 	F.snf_add(D, E);
1048 	dz << F << D * A * E << std::flush;
1049 	F = A;
1050 	F.snf_add();
1051 	dz << F << std::flush;
1052 	F = A;
1053 	F.snf_add(D, E);
1054 	dz << F << D * A * E << std::flush;
1055 	std::cout << "..................................completed\n" << std::flush;
1056 
1057 	std::cout << "testing snf_new" << std::flush;
1058 	dz << "testing snf_new" << std::endl << std::flush;
1059 	F = A;
1060 	F.snf_new();
1061 	dz << F << std::flush;
1062 	F = A;
1063 	F.snf_new(D, E);
1064 	dz << F << D * A * E << std::flush;
1065 	F = A;
1066 	F.snf_new();
1067 	dz << F << std::flush;
1068 	F = A;
1069 	F.snf_new(D, E);
1070 	dz << F << D * A * E << std::flush;
1071 	std::cout << "..................................completed\n" << std::flush;
1072 
1073 	std::cout << "testing snfmod_dkt" << std::flush;
1074 	dz << "testing snfmod_dkt" << std::endl << std::flush;
1075 	scalar_1 = latticedet(A);
1076 	F = A;
1077 	F.snfmod_dkt(scalar_1);
1078 	dz << F << std::flush;
1079 	F = A;
1080 	F.snfmod_dkt();
1081 	dz << F << std::flush;
1082 	F = A;
1083 	F.snfmod_dkt();
1084 	dz << F << std::flush;
1085 	F = A;
1086 	F.snfmod_dkt(scalar_1);
1087 	dz << F << std::flush;
1088 	std::cout << "...............................completed\n" << std::flush;
1089 
1090 	std::cout << "testing snfmod_cohen" << std::flush;
1091 	dz << "testing snfmod_cohen" << std::endl << std::flush;
1092 	scalar_1 = latticedet(A);
1093 	F = A;
1094 	F.snfmod_cohen(scalar_1);
1095 	dz << F << std::flush;
1096 	F = A;
1097 	F.snfmod_cohen();
1098 	dz << F << std::flush;
1099 	F = A;
1100 	F.snfmod_cohen();
1101 	dz << F << std::flush;
1102 	F = A;
1103 	F.snfmod_cohen(scalar_1);
1104 	dz << F << std::flush;
1105 	std::cout << ".............................completed\n" << std::flush;
1106 
1107 	std::cout << "\nThe functions ChinRest, get_primes, mgcd, mgcd1, mgcd2 and mgcd3 are\n"
1108 		" tested by implication." << std::flush;
1109 
1110 	dz.close();
1111 	std::cout << "\nPlease use now the 'diff' or 'cmp' command to verify\n";
1112 	std::cout << "the equality of bigint_matrix_appl.dat";
1113 	std::cout << " and bigint_matrix_appl.out.\n\n" << std::flush;
1114 
1115 	return 0;
1116 }
1117 
1118 
main(int argc,char ** argv)1119 int main(int argc, char** argv) {
1120 
1121 #if defined(LIDIA_EXCEPTIONS)
1122     try {
1123 #endif
1124 
1125 	main_LiDIA(argc, argv);
1126 
1127 #if defined(LIDIA_EXCEPTIONS)
1128     }
1129     catch(basic_error const& ex) {
1130 	ex.traditional_error_handler();
1131 	return 1;
1132     }
1133     catch(std::exception const& ex) {
1134 	std::cerr << "unexpected exception: " << ex.what() << "\n";
1135 	return 1;
1136     }
1137 #endif
1138 
1139 }
1140