source: src/main/java/agents/anac/y2015/agentBuyogV2/flanagan/io/PrintToScreen.java

Last change on this file was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 22.5 KB
Line 
1/*
2* Class PrintToScreen
3*
4* USAGE: Methods for writing one and two dimensional arrays to the sceen
5*
6* WRITTEN BY: Dr Michael Thomas Flanagan
7*
8* DATE: 13 April 2008 (Most methods taken from existing classes to make a separate print to screen class)
9* AMENDED: 11 August 2008, 14 September 2008, 18 January 2011
10*
11* DOCUMENTATION:
12* See Michael Thomas Flanagan's Java library on-line web pages:
13* http://www.ee.ucl.ac.uk/~mflanaga/java/PrintToScreen.html
14* http://www.ee.ucl.ac.uk/~mflanaga/java/
15*
16* Copyright (c) 2008 - 2011 Michael Thomas Flanagan
17*
18* PERMISSION TO COPY:
19*
20* Permission to use, copy and modify this software and its documentation for NON-COMMERCIAL purposes is granted, without fee,
21* provided that an acknowledgement to the author, Dr Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies
22* and associated documentation or publications.
23*
24* Redistributions of the source code of this source code, or parts of the source codes, must retain the above copyright notice, this list of conditions
25* and the following disclaimer and requires written permission from the Michael Thomas Flanagan:
26*
27* Redistribution in binary form of all or parts of this class must reproduce the above copyright notice, this list of conditions and
28* the following disclaimer in the documentation and/or other materials provided with the distribution and requires written permission from the Michael Thomas Flanagan:
29*
30* Dr Michael Thomas Flanagan makes no representations about the suitability or fitness of the software for any or for a particular purpose.
31* Dr Michael Thomas Flanagan shall not be liable for any damages suffered as a result of using, modifying or distributing this software
32* or its derivatives.
33*
34***************************************************************************************/
35
36package agents.anac.y2015.agentBuyogV2.flanagan.io;
37
38import java.math.*;
39
40import agents.anac.y2015.agentBuyogV2.flanagan.circuits.Phasor;
41import agents.anac.y2015.agentBuyogV2.flanagan.complex.Complex;
42import agents.anac.y2015.agentBuyogV2.flanagan.math.ArrayMaths;
43import agents.anac.y2015.agentBuyogV2.flanagan.math.Conv;
44import agents.anac.y2015.agentBuyogV2.flanagan.math.Fmath;
45
46public class PrintToScreen{
47
48 // 1D ARRAYS
49
50 // print an array of doubles to screen
51 // No line returns except at the end
52 public static void print(double[] aa){
53 for(int i=0; i<aa.length; i++){
54 System.out.print(aa[i]+" ");
55 }
56 System.out.println();
57 }
58
59 // print an array of doubles to screen with truncation
60 // No line returns except at the end
61 public static void print(double[] aa, int trunc){
62 for(int i=0; i<aa.length; i++){
63 System.out.print(Fmath.truncate(aa[i], trunc)+" ");
64 }
65 System.out.println();
66 }
67
68 // print an array of doubles to screen
69 // with line returns
70 public static void println(double[] aa){
71 for(int i=0; i<aa.length; i++){
72 System.out.println(aa[i]+" ");
73 }
74 }
75
76 // print an array of doubles to screen with truncation
77 // with line returns
78 public static void println(double[] aa, int trunc){
79 for(int i=0; i<aa.length; i++){
80 System.out.println(Fmath.truncate(aa[i], trunc)+" ");
81 }
82 }
83
84 // print an array of floats to screen
85 // No line returns except at the end
86 public static void print(float[] aa){
87 for(int i=0; i<aa.length; i++){
88 System.out.print(aa[i]+" ");
89 }
90 System.out.println();
91 }
92
93 // print an array of floats to screen with truncation
94 // No line returns except at the end
95 public static void print(float[] aa, int trunc){
96 for(int i=0; i<aa.length; i++){
97 System.out.print(Fmath.truncate(aa[i], trunc)+" ");
98 }
99 System.out.println();
100 }
101
102 // print an array of floats to screen
103 // with line returns
104 public static void println(float[] aa){
105 for(int i=0; i<aa.length; i++){
106 System.out.println(aa[i]+" ");
107 }
108 }
109
110 // print an array of floats to screen with truncation
111 // with line returns
112 public static void println(float[] aa, int trunc){
113 for(int i=0; i<aa.length; i++){
114 System.out.println(Fmath.truncate(aa[i], trunc)+" ");
115 }
116 }
117
118 // print an array of ints to screen
119 // No line returns except at the end
120 public static void print(int[] aa){
121 for(int i=0; i<aa.length; i++){
122 System.out.print(aa[i]+" ");
123 }
124 System.out.println();
125 }
126
127 // print an array of ints to screen
128 // with line returns
129 public static void println(int[] aa){
130 for(int i=0; i<aa.length; i++){
131 System.out.println(aa[i]+" ");
132 }
133 }
134
135 // print an array of longs to screen
136 // No line returns except at the end
137 public static void print(long[] aa){
138 for(int i=0; i<aa.length; i++){
139 System.out.print(aa[i]+" ");
140 }
141 System.out.println();
142 }
143
144 // print an array of longs to screen
145 // with line returns
146 public static void println(long[] aa){
147 for(int i=0; i<aa.length; i++){
148 System.out.println(aa[i]+" ");
149 }
150 }
151
152 // print an array of shorts to screen
153 // No line returns except at the end
154 public static void print(short[] aa){
155 for(int i=0; i<aa.length; i++){
156 System.out.print(aa[i]+" ");
157 }
158 System.out.println();
159 }
160
161 // print an array of shorts to screen
162 // with line returns
163 public static void println(short[] aa){
164 for(int i=0; i<aa.length; i++){
165 System.out.println(aa[i]+" ");
166 }
167 }
168
169 // print an array of char to screen
170 // No line returns except at the end
171 public static void print(char[] aa){
172 for(int i=0; i<aa.length; i++){
173 System.out.print(aa[i]+" ");
174 }
175 System.out.println();
176 }
177
178 // print an array of char to screen
179 // with line returns
180 public static void println(char[] aa){
181 for(int i=0; i<aa.length; i++){
182 System.out.println(aa[i]+" ");
183 }
184 }
185
186
187 // print an array of bytes to screen
188 // No line returns except at the end
189 public static void print(byte[] aa){
190 for(int i=0; i<aa.length; i++){
191 System.out.print(aa[i]+" ");
192 }
193 System.out.println();
194 }
195
196 // print an array of bytes to screen
197 // with line returns
198 public static void println(byte[] aa){
199 for(int i=0; i<aa.length; i++){
200 System.out.println(aa[i]+" ");
201 }
202 }
203
204
205 // print an array of Doubles to screen
206 // No line returns except at the end
207 public static void print(Double[] aa){
208 for(int i=0; i<aa.length; i++){
209 System.out.print(aa[i]+" ");
210 }
211 System.out.println();
212 }
213
214 // print an array of Doubles to screen with truncation
215 // No line returns except at the end
216 public static void print(Double[] aa, int trunc){
217 ArrayMaths am = new ArrayMaths(aa);
218 am = am.truncate(trunc);
219 Double[] aaa = am.array_as_Double();
220 for(int i=0; i<aa.length; i++){
221 System.out.print(aaa[i]+" ");
222 }
223 System.out.println();
224 }
225
226 // print an array of Doubles to screen
227 // with line returns
228 public static void println(Double[] aa){
229 for(int i=0; i<aa.length; i++){
230 System.out.println(aa[i]+" ");
231 }
232 }
233
234 // print an array of Doubles to screen with truncation
235 // with line returns
236 public static void println(Double[] aa, int trunc){
237 ArrayMaths am = new ArrayMaths(aa);
238 am = am.truncate(trunc);
239 Double[] aaa = am.array_as_Double();
240 for(int i=0; i<aa.length; i++){
241 System.out.println(aaa[i]+" ");
242 }
243 }
244
245 // print an array of Floats to screen
246 // No line returns except at the end
247 public static void print(Float[] aa){
248 for(int i=0; i<aa.length; i++){
249 System.out.print(aa[i]+" ");
250 }
251 System.out.println();
252 }
253
254 // print an array of Floats to screen
255 // No line returns except at the end
256 public static void print(Float[] aa, int trunc){
257 ArrayMaths am = new ArrayMaths(aa);
258 am = am.truncate(trunc);
259 Float[] aaa = am.array_as_Float();
260 for(int i=0; i<aa.length; i++){
261 System.out.print(aaa[i]+" ");
262 }
263 System.out.println();
264 }
265
266 // print an array of Floats to screen
267 // with line returns
268 public static void println(Float[] aa){
269 for(int i=0; i<aa.length; i++){
270 System.out.println(aa[i]+" ");
271 }
272 }
273
274 // print an array of Floats to screen with truncation
275 // with line returns
276 public static void println(Float[] aa, int trunc){
277 ArrayMaths am = new ArrayMaths(aa);
278 am = am.truncate(trunc);
279 Float[] aaa = am.array_as_Float();
280 for(int i=0; i<aa.length; i++){
281 System.out.println(aaa[i]+" ");
282 }
283 }
284
285 // print an array of Integers to screen
286 // No line returns except at the end
287 public static void print(Integer[] aa){
288 for(int i=0; i<aa.length; i++){
289 System.out.print(aa[i]+" ");
290 }
291 System.out.println();
292 }
293
294 // print an array of Integers to screen
295 // with line returns
296 public static void println(Integer[] aa){
297 for(int i=0; i<aa.length; i++){
298 System.out.println(aa[i]+" ");
299 }
300 }
301
302 // print an array of Longs to screen
303 // No line returns except at the end
304 public static void print(Long[] aa){
305 for(int i=0; i<aa.length; i++){
306 System.out.print(aa[i]+" ");
307 }
308 System.out.println();
309 }
310
311 // print an array of Longs to screen
312 // with line returns
313 public static void println(Long[] aa){
314 for(int i=0; i<aa.length; i++){
315 System.out.println(aa[i]+" ");
316 }
317 }
318
319 // print an array of Shorts to screen
320 // No line returns except at the end
321 public static void print(Short[] aa){
322 for(int i=0; i<aa.length; i++){
323 System.out.print(aa[i]+" ");
324 }
325 System.out.println();
326 }
327
328 // print an array of Shorts to screen
329 // with line returns
330 public static void println(Short[] aa){
331 for(int i=0; i<aa.length; i++){
332 System.out.println(aa[i]+" ");
333 }
334 }
335
336 // print an array of Character to screen
337 // No line returns except at the end
338 public static void print(Character[] aa){
339 for(int i=0; i<aa.length; i++){
340 System.out.print(aa[i]+" ");
341 }
342 System.out.println();
343 }
344
345 // print an array of Character to screen
346 // with line returns
347 public static void println(Character[] aa){
348 for(int i=0; i<aa.length; i++){
349 System.out.println(aa[i]+" ");
350 }
351 }
352
353
354 // print an array of Bytes to screen
355 // No line returns except at the end
356 public static void print(Byte[] aa){
357 for(int i=0; i<aa.length; i++){
358 System.out.print(aa[i]+" ");
359 }
360 System.out.println();
361 }
362
363 // print an array of Bytes to screen
364 // with line returns
365 public static void println(Byte[] aa){
366 for(int i=0; i<aa.length; i++){
367 System.out.println(aa[i]+" ");
368 }
369 }
370
371 // print an array of String to screen
372 // No line returns except at the end
373 public static void print(String[] aa){
374 for(int i=0; i<aa.length; i++){
375 System.out.print(aa[i]+" ");
376 }
377 System.out.println();
378 }
379
380 // print an array of Strings to screen
381 // with line returns
382 public static void println(String[] aa){
383 for(int i=0; i<aa.length; i++){
384 System.out.println(aa[i]+" ");
385 }
386 }
387
388 // print an array of Complex to screen
389 // No line returns except at the end
390 public static void print(Complex[] aa){
391 for(int i=0; i<aa.length; i++){
392 System.out.print(aa[i]+" ");
393 }
394 System.out.println();
395 }
396
397 // print an array of Complex to screen with truncation
398 // No line returns except at the end
399 public static void print(Complex[] aa, int trunc){
400 for(int i=0; i<aa.length; i++){
401 System.out.print(Complex.truncate(aa[i], trunc)+" ");
402 }
403 System.out.println();
404 }
405
406 // print an array of Complex to screen
407 // with line returns
408 public static void println(Complex[] aa){
409 for(int i=0; i<aa.length; i++){
410 System.out.println(aa[i]+" ");
411 }
412 }
413
414 // print an array of Complex to screen with truncation
415 // with line returns
416 public static void println(Complex[] aa, int trunc){
417 for(int i=0; i<aa.length; i++){
418 System.out.println(Complex.truncate(aa[i], trunc)+" ");
419 }
420 }
421
422
423 // print an array of Phasor to screen
424 // No line returns except at the end
425 public static void print(Phasor[] aa){
426 for(int i=0; i<aa.length; i++){
427 System.out.print(aa[i]+" ");
428 }
429 System.out.println();
430 }
431
432 // print an array of Phasor to screen with truncation
433 // No line returns except at the end
434 public static void print(Phasor[] aa, int trunc){
435 for(int i=0; i<aa.length; i++){
436 System.out.print(Phasor.truncate(aa[i], trunc)+" ");
437 }
438 System.out.println();
439 }
440
441 // print an array of Phasor to screen
442 // with line returns
443 public static void println(Phasor[] aa){
444 for(int i=0; i<aa.length; i++){
445 System.out.println(aa[i]+" ");
446 }
447 }
448
449 // print an array of Phasor to screen with truncation
450 // with line returns
451 public static void println(Phasor[] aa, int trunc){
452 for(int i=0; i<aa.length; i++){
453 System.out.println(Phasor.truncate(aa[i], trunc)+" ");
454 }
455 }
456
457
458 // print an array of BigDecimal to screen
459 // No line returns except at the end
460 public static void print(BigDecimal[] aa){
461 for(int i=0; i<aa.length; i++){
462 System.out.print(aa[i]+" ");
463 }
464 System.out.println();
465 }
466
467 // print an array of BigDecimal to screen
468 // with line returns
469 public static void println(BigDecimal[] aa){
470 for(int i=0; i<aa.length; i++){
471 System.out.println(aa[i]+" ");
472 }
473 }
474
475 // print an array of BigInteger to screen
476 // No line returns except at the end
477 public static void print(BigInteger[] aa){
478 for(int i=0; i<aa.length; i++){
479 System.out.print(aa[i]+" ");
480 }
481 System.out.println();
482 }
483
484 // print an array of BigInteger to screen
485 // with line returns
486 public static void println(BigInteger[] aa){
487 for(int i=0; i<aa.length; i++){
488 System.out.println(aa[i]+" ");
489 }
490 }
491
492 // print an array of boolean to screen
493 // No line returns except at the end
494 public static void print(boolean[] aa){
495 for(int i=0; i<aa.length; i++){
496 System.out.print(aa[i]+" ");
497 }
498 System.out.println();
499 }
500
501 // print an array of boolean to screen
502 // with line returns
503 public static void println(boolean[] aa){
504 for(int i=0; i<aa.length; i++){
505 System.out.println(aa[i]+" ");
506 }
507 }
508
509
510 // 2D ARRAYS
511
512 // print a 2D array of doubles to screen
513 public static void print(double[][] aa){
514 for(int i=0; i<aa.length; i++){
515 PrintToScreen.print(aa[i]);
516 }
517 }
518
519 // print a 2D array of doubles to screen with truncation
520 public static void print(double[][] aa, int trunc){
521 for(int i=0; i<aa.length; i++){
522 PrintToScreen.print(aa[i], trunc);
523 }
524 }
525
526 // print a 2D array of floats to screen
527 public static void print(float[][] aa){
528 for(int i=0; i<aa.length; i++){
529 PrintToScreen.print(aa[i]);
530 }
531 }
532
533 // print a 2D array of floats to screen with truncation
534 public static void print(float[][] aa, int trunc){
535 for(int i=0; i<aa.length; i++){
536 PrintToScreen.print(aa[i], trunc);
537 }
538 }
539
540 // print a 2D array of ints to screen
541 public static void print(int[][] aa){
542 for(int i=0; i<aa.length; i++){
543 PrintToScreen.print(aa[i]);
544 }
545 }
546
547 // print a 2D array of longs to screen
548 public static void print(long[][] aa){
549 for(int i=0; i<aa.length; i++){
550 PrintToScreen.print(aa[i]);
551 }
552 }
553 // print a 2D array of chars to screen
554 public static void print(char[][] aa){
555 for(int i=0; i<aa.length; i++){
556 PrintToScreen.print(aa[i]);
557 }
558 }
559
560 // print a 2D array of bytes to screen
561 public static void print(byte[][] aa){
562 for(int i=0; i<aa.length; i++){
563 PrintToScreen.print(aa[i]);
564 }
565 }
566
567 // print a 2D array of shorts to screen
568 public static void print(short[][] aa){
569 for(int i=0; i<aa.length; i++){
570 PrintToScreen.print(aa[i]);
571 }
572 }
573
574 // print a 2D array of Doubles to screen
575 public static void print(Double[][] aa){
576 for(int i=0; i<aa.length; i++){
577 PrintToScreen.print(aa[i]);
578 }
579 }
580
581 // print a 2D array of Doubles to screen with truncation
582 public static void print(Double[][] aa, int trunc){
583 for(int i=0; i<aa.length; i++){
584 PrintToScreen.print(aa[i], trunc);
585 }
586 }
587
588 // print a 2D array of Floats to screen
589 public static void print(Float[][] aa){
590 for(int i=0; i<aa.length; i++){
591 PrintToScreen.print(aa[i]);
592 }
593 }
594
595 // print a 2D array of Floats to screen with truncation
596 public static void print(Float[][] aa, int trunc){
597 for(int i=0; i<aa.length; i++){
598 PrintToScreen.print(aa[i], trunc);
599 }
600 }
601
602
603 // print a 2D array of Integers to screen
604 public static void print(Integer[][] aa){
605 for(int i=0; i<aa.length; i++){
606 PrintToScreen.print(aa[i]);
607 }
608 }
609
610 // print a 2D array of Longs to screen
611 public static void print(Long[][] aa){
612 for(int i=0; i<aa.length; i++){
613 PrintToScreen.print(aa[i]);
614 }
615 }
616 // print a 2D array of Characters to screen
617 public static void print(Character[][] aa){
618 for(int i=0; i<aa.length; i++){
619 PrintToScreen.print(aa[i]);
620 }
621 }
622
623 // print a 2D array of Bytes to screen
624 public static void print(Byte[][] aa){
625 for(int i=0; i<aa.length; i++){
626 PrintToScreen.print(aa[i]);
627 }
628 }
629
630 // print a 2D array of Shorts to screen
631 public static void print(Short[][] aa){
632 for(int i=0; i<aa.length; i++){
633 PrintToScreen.print(aa[i]);
634 }
635 }
636
637 // print a 2D array of Strings to screen
638 public static void print(String[][] aa){
639 for(int i=0; i<aa.length; i++){
640 PrintToScreen.print(aa[i]);
641 }
642 }
643
644 // print a 2D array of Complex to screen
645 public static void print(Complex[][] aa){
646 for(int i=0; i<aa.length; i++){
647 Complex.print(aa[i]);
648 }
649 }
650
651 // print a 2D array of Complex to screen with truncation
652 public static void print(Complex[][] aa, int trunc){
653 for(int i=0; i<aa.length; i++){
654 PrintToScreen.print(aa[i], trunc);
655 }
656 }
657
658 // print a 2D array of Phasor to screen
659 public static void print(Phasor[][] aa){
660 for(int i=0; i<aa.length; i++){
661 Phasor.print(aa[i]);
662 }
663 }
664
665 // print a 2D array of Phasor to screen
666 public static void print(Phasor[][] aa, int trunc){
667
668 Phasor[][] aam = Conv.copy(aa);
669 for(int i=0; i<aam.length; i++){
670 for(int j=0; j<aam[i].length; j++){
671 aam[i][j] = Phasor.truncate(aam[i][j], trunc);
672 }
673 }
674 for(int i=0; i<aa.length; i++){
675 Phasor.print(aam[i]);
676 }
677 }
678
679 // print a 2D array of BigDecimal to screen
680 public static void print(BigDecimal[][] aa){
681 for(int i=0; i<aa.length; i++){
682 PrintToScreen.print(aa[i]);
683 }
684 }
685
686 // print a 2D array of BigInteger to screen
687 public static void print(BigInteger[][] aa){
688 for(int i=0; i<aa.length; i++){
689 PrintToScreen.print(aa[i]);
690 }
691 }
692
693 // print a 2D array of boolean to screen
694 public static void print(boolean[][] aa){
695 for(int i=0; i<aa.length; i++){
696 PrintToScreen.print(aa[i]);
697 }
698 }
699}
700
701
702
Note: See TracBrowser for help on using the repository browser.