03 March 2022 03:12:05 PM R8COL_TEST C++ version Test the R8COL library. I4_LOG_10_TEST I4_LOG_10: whole part of log base 10, X I4_LOG_10(X) 0 0 1 0 2 0 3 0 9 0 10 1 11 1 99 1 101 2 -1 0 -2 0 -3 0 -9 0 I4_MAX_TEST I4_MAX returns the maximum of two I4's. A B C=I4_MAX(A,B) -57 92 92 66 12 66 -17 -87 -17 -49 -78 -49 -92 27 27 -88 -10 -10 -20 51 51 60 -100 60 80 -30 80 -81 -98 -81 I4_MIN_TEST I4_MIN returns the minimum of two I4's. A B C=I4_MIN(A,B) -57 92 -57 66 12 12 -17 -87 -87 -49 -78 -78 -92 27 -92 -88 -10 -88 -20 51 -20 60 -100 -100 80 -30 -30 -81 -98 -98 I4_POWER_TEST I4_POWER computes I^J I J I4_POWER(I,J) 0 1 0 1 2 1 2 3 8 3 3 27 10 3 1000 -1 4 1 -2 5 -32 I4_UNIFORM_AB_TEST I4_UNIFORM_AB computes pseudorandom values in an interval [A,B]. The lower endpoint A = -100 The upper endpoint B = 200 The initial seed is 123456789 1 -35 2 187 3 149 4 69 5 25 6 -81 7 -23 8 -67 9 -87 10 90 11 -82 12 35 13 20 14 127 15 139 16 -100 17 170 18 5 19 -72 20 -96 I4VEC_INDICATOR1_NEW_TEST I4VEC_INDICATOR1_NEW returns an indicator vector; The indicator1 vector: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 I4VEC_PRINT_TEST I4VEC_PRINT prints an I4VEC Here is the I4VEC: 0: 91 1: 92 2: 93 3: 94 I4VEC_TRANSPOSE_PRINT_TEST I4VEC_TRANSPOSE_PRINT prints an integer vector with 5 entries to a row, and an optional title. Output from I4VEC_PRINT: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 10: 11 11: 12 Now call I4VEC_TRANSPOSE_PRINT with a short title: My array: 1 2 3 4 5 6 7 8 9 10 11 12 Now call I4VEC_TRANSPOSE_PRINT with no title: 1 2 3 4 5 6 7 8 9 10 11 12 PERM0_CHECK_TEST PERM0_CHECK checks a permutation of 0, ..., N-1. Permutation 1: 5 2 3 4 1 PERM0_CHECK - Fatal error! Permutation is missing value 0 Permutation 2: 4 1 3 0 2 Permutation 3: 0 2 1 3 2 PERM0_CHECK - Fatal error! Permutation is missing value 4 R8_UNIFORM_AB_TEST R8_UNIFORM_AB produces a random real in a given range. Using range 10 <= A <= 25. I A 0 10.002 1 13.5421 2 22.6794 3 21.9558 4 10.8556 5 20.8346 6 21.9964 7 18.1105 8 18.2206 9 23.3467 R8COL_FIND_TEST R8COL_FIND finds a column in a table matching a given set of data. R8COL_FIND returns COL = 3 R8COL_INDICATOR_NEW_TEST R8COL_INDICATOR_NEW returns an indicator matrix. The indicator matrix: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 R8COL_INSERT_TEST R8COL_INSERT inserts new columns into a sorted R8COL. The unsorted matrix: Col: 0 1 2 3 Row 0: 2 4 1 3 1: 6 8 5 7 2: 10 12 9 11 The sorted matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 New column: 0: 3 1: 7 2: 11 The data was already in column 3 New column: 0: 3 1: 4 2: 18 The updated matrix: Col: 0 1 2 3 Row 0: 1 2 3 3 1: 5 6 4 7 2: 9 10 18 11 R8COL_MAX_TEST R8COL_MAX computes maximums of an R8COL; The array: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Column maximums: 0: 9 1: 10 2: 11 3: 12 R8COL_MEAN_TEST R8COL_MEAN computes means of an R8COL; The array: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 The column means: 0: 5 1: 6 2: 7 3: 8 R8COL_MIN_TEST R8COL_MIN computes minimums of an R8COL; The array: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Column minimums: 0: 1 1: 2 2: 3 3: 4 R8COL_PERMUTE_TEST R8COL_PERMUTE permutes an R8COL in place. A (unpermuted): Col: 0 1 2 3 4 Row 0: 11 12 13 14 15 1: 21 22 23 24 25 2: 31 32 33 34 35 The (column) permutation vector: 0: 1 1: 3 2: 4 3: 0 4: 2 A (permuted): Col: 0 1 2 3 4 Row 0: 12 14 15 11 13 1: 22 24 25 21 23 2: 32 34 35 31 33 R8COL_PRINT_TEST R8COL_PRINT prints an R8COL. The R8COL: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 3: 41 42 43 44 4: 51 52 53 54 5: 61 62 63 64 R8COL_PRINT_SOME_TEST R8COL_PRINT_SOME prints some of an R8COL. The R8COL, rows 2:4, cols 1:2: Col: 0 1 Row 1: 21 22 2: 31 32 3: 41 42 R8COL_SORT_HEAP_A_TEST R8COL_SORT_HEAP_A ascending heap sorts a table of columns. The unsorted matrix: Col: 0 1 2 3 Row 0: 2 4 1 3 1: 6 8 5 7 2: 10 12 9 11 The sorted matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 R8COL_SORT_HEAP_INDEX_A_TEST R8COL_SORT_HEAP_INDEX_A computes an index vector which ascending sorts an R8COL. The unsorted R8COL (transposed): Row: 0 1 2 Col 0: 2 6 10 1: 4 8 12 2: 1 5 9 3: 3 7 11 4: 2 6 0 5: 3 4 18 6: 0 0 0 7: 0 6 10 8: 2 6 10 9: 3 7 11 10: 2 0 10 11: 2 6 10 12: 1 5 9 13: 1 5 9.1 14: 1 5.1 9 The implicitly sorted R8COL (transposed) 6: 0 0 0 7: 0 6 10 12: 1 5 9 2: 1 5 9 13: 1 5 9.1 14: 1 5.1 9 10: 2 0 10 4: 2 6 0 11: 2 6 10 8: 2 6 10 0: 2 6 10 5: 3 4 18 9: 3 7 11 3: 3 7 11 1: 4 8 12 R8COL_SORT_QUICK_A_TEST R8COL_SORT_QUICK_A sorts a table of columns. The unsorted matrix: Col: 0 1 2 3 4 Row 0: 2.18418 5.61695 2.57578 6.33966 4.01306 1: 9.56318 4.15307 1.09957 0.617272 7.54673 2: 8.29509 0.661187 0.43829 4.49539 7.97287 Col: 5 6 7 8 9 Row 0: 0.0183837 0.945448 8.40847 2.60303 3.51629 1: 8.97504 0.136169 1.23104 9.12484 8.22887 2: 3.50752 8.59097 0.0751236 1.13664 2.67132 The sorted matrix: Col: 0 1 2 3 4 Row 0: 0.0183837 0.945448 2.18418 2.57578 2.60303 1: 8.97504 0.136169 9.56318 1.09957 9.12484 2: 3.50752 8.59097 8.29509 0.43829 1.13664 Col: 5 6 7 8 9 Row 0: 3.51629 4.01306 5.61695 6.33966 8.40847 1: 8.22887 7.54673 4.15307 0.617272 1.23104 2: 2.67132 7.97287 0.661187 4.49539 0.0751236 R8COL_SORTED_TOL_UNIQUE_TEST R8COL_SORTED_TOL_UNIQUE finds tolerably unique columns in a sorted R8COL. The unsorted R8COL (transposed): Row: 0 1 2 Col 0: 1.9 0 10 1: 2 6 10 2: 4 8 12 3: 1 5 9 4: 3 7 11 5: 2 6 0 6: 2 0 10.1 7: 2 0.1 10 8: 3 4 18 9: 1.9 8 10 10: 0 0 0 11: 0 6 10 12: 2.1 0 10 13: 2 6 10 14: 3 7 11 15: 2 0 10 16: 2 0 10 17: 2 6 10 18: 1 5 9 19: 2 0 10.1 20: 1 5 9.1 21: 1 5.1 9 The sorted R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1 5 9 4: 1 5 9.1 5: 1 5.1 9 6: 1.9 0 10 7: 1.9 8 10 8: 2 0 10 9: 2 0 10 10: 2 0 10.1 11: 2 0 10.1 12: 2 0.1 10 13: 2 6 0 14: 2 6 10 15: 2 6 10 16: 2 6 10 17: 2.1 0 10 18: 3 4 18 19: 3 7 11 20: 3 7 11 21: 4 8 12 Using tolerance = 0.25 Number of tolerably unique columns is 10 The sorted tolerably unique R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1.9 0 10 4: 1.9 8 10 5: 2 6 0 6: 2 6 10 7: 3 4 18 8: 3 7 11 9: 4 8 12 R8COL_SORTED_UNIQUE_COUNT_TEST R8COL_SORTED_UNIQUE_COUNT counts tolerably unique columns in a sorted R8COL. The unsorted R8COL (transposed): Row: 0 1 2 Col 0: 1.9 0 10 1: 2 6 10 2: 4 8 12 3: 1 5 9 4: 3 7 11 5: 2 6 0 6: 2 0 10.1 7: 2 0.1 10 8: 3 4 18 9: 1.9 8 10 10: 0 0 0 11: 0 6 10 12: 2.1 0 10 13: 2 6 10 14: 3 7 11 15: 2 0 10 16: 2 0 10 17: 2 6 10 18: 1 5 9 19: 2 0 10.1 20: 1 5 9.1 21: 1 5.1 9 The sorted R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1 5 9 4: 1 5 9.1 5: 1 5.1 9 6: 1.9 0 10 7: 1.9 8 10 8: 2 0 10 9: 2 0 10 10: 2 0 10.1 11: 2 0 10.1 12: 2 0.1 10 13: 2 6 0 14: 2 6 10 15: 2 6 10 16: 2 6 10 17: 2.1 0 10 18: 3 4 18 19: 3 7 11 20: 3 7 11 21: 4 8 12 Using tolerance = 0.25 Number of tolerably unique columns is 10 R8COL_SORTED_TOL_UNDEX_TEST R8COL_SORTED_TOL_UNDEX produces index vectors which create a sorted list of the tolerably unique columns of a sorted R8COL, and a map from the original R8COL to the (implicit) R8COL of sorted tolerably unique elements. The unsorted R8COL (transposed): Row: 0 1 2 Col 0: 1.9 0 10 1: 2 6 10 2: 4 8 12 3: 1 5 9 4: 3 7 11 5: 2 6 0 6: 2 0 10.1 7: 2 0.1 10 8: 3 4 18 9: 1.9 8 10 10: 0 0 0 11: 0 6 10 12: 2.1 0 10 13: 2 6 10 14: 3 7 11 15: 2 0 10 16: 2 0 10 17: 2 6 10 18: 1 5 9 19: 2 0 10.1 20: 1 5 9.1 21: 1 5.1 9 The sorted R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1 5 9 4: 1 5 9.1 5: 1 5.1 9 6: 1.9 0 10 7: 1.9 8 10 8: 2 0 10 9: 2 0 10 10: 2 0 10.1 11: 2 0 10.1 12: 2 0.1 10 13: 2 6 0 14: 2 6 10 15: 2 6 10 16: 2 6 10 17: 2.1 0 10 18: 3 4 18 19: 3 7 11 20: 3 7 11 21: 4 8 12 Using tolerance = 0.25 Number of tolerably unique columns is 10 XDNU points to the representative for each item. UNDX selects the representatives. I XDNU UNDX 0 0 0 1 1 1 2 2 2 3 2 6 4 2 7 5 2 13 6 3 14 7 4 18 8 3 19 9 3 21 10 3 11 3 12 3 13 5 14 6 15 6 16 6 17 3 18 7 19 8 20 8 21 9 The tolerably unique R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1.9 0 10 4: 1.9 8 10 5: 2 6 0 6: 2 6 10 7: 3 4 18 8: 3 7 11 9: 4 8 12 R8COL_SORTR_A_TEST R8COL_SORTR_A is given an array, and reorders it so that a particular column is sorted. Here, the special column is 2 Unsorted array: Col: 0 1 2 Row 0: 2.18418 0.617272 8.59097 1: 9.56318 4.49539 8.40847 2: 8.29509 4.01306 1.23104 3: 5.61695 7.54673 0.0751236 4: 4.15307 7.97287 2.60303 5: 0.661187 0.0183837 9.12484 6: 2.57578 8.97504 1.13664 7: 1.09957 3.50752 3.51629 8: 0.43829 0.945448 8.22887 9: 6.33966 0.136169 2.67132 Sorted array: Col: 0 1 2 Row 0: 0.661187 0.0183837 9.12484 1: 6.33966 0.136169 2.67132 2: 2.18418 0.617272 8.59097 3: 0.43829 0.945448 8.22887 4: 1.09957 3.50752 3.51629 5: 8.29509 4.01306 1.23104 6: 9.56318 4.49539 8.40847 7: 5.61695 7.54673 0.0751236 8: 4.15307 7.97287 2.60303 9: 2.57578 8.97504 1.13664 R8COL_SUM_TEST R8COL_SUM computes sums of an R8COL; The array: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 The column sums 0: 15 1: 18 2: 21 3: 24 R8COL_SWAP_TEST R8COL_SWAP swaps two columns of an R8COL; The array: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 Swap columns 1 and 3: The updated matrix: Col: 0 1 2 3 Row 0: 13 12 11 14 1: 23 22 21 24 2: 33 32 31 34 R8COL_TO_R8VEC_TEST R8COL_TO_R8VEC converts an array of columns to a vector. The array of columns: Col: 0 1 2 3 Row 0: 0 1 2 3 1: 10 11 12 13 2: 20 21 22 23 The resulting vector of columns: 0: 0 1: 10 2: 20 3: 1 4: 11 5: 21 6: 2 7: 12 8: 22 9: 3 10: 13 11: 23 R8COL_TOL_UNDEX_TEST R8COL_TOL_UNDEX produces index vectors which create a sorted list of the tolerably unique columns of an R8COL, and a map from the original R8COL to the (implicit) R8COL of sorted tolerably unique elements. The unsorted R8COL (transposed): Row: 0 1 2 Col 0: 1.9 0 10 1: 2 6 10 2: 4 8 12 3: 1 5 9 4: 3 7 11 5: 2 6 0 6: 2 0 10.1 7: 2 0.1 10 8: 3 4 18 9: 1.9 8 10 10: 0 0 0 11: 0 6 10 12: 2.1 0 10 13: 2 6 10 14: 3 7 11 15: 2 0 10 16: 2 0 10 17: 2 6 10 18: 1 5 9 19: 2 0 10.1 20: 1 5 9.1 21: 1 5.1 9 Using tolerance = 0.25 Number of tolerably unique columns is 10 XDNU points to the representative for each item. UNDX selects the representatives. I XDNU UNDX 0 3 10 1 6 11 2 9 18 3 2 0 4 8 9 5 5 5 6 3 13 7 3 8 8 7 14 9 4 2 10 0 11 1 12 3 13 6 14 8 15 3 16 3 17 6 18 2 19 3 20 2 21 2 The tolerably unique R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1.9 0 10 4: 1.9 8 10 5: 2 6 0 6: 2 6 10 7: 3 4 18 8: 3 7 11 9: 4 8 12 R8COL_TRANSPOSE_PRINT_TEST R8COL_TRANSPOSE_PRINT prints an R8MAT, transposed. Matrix row order M = 7 Matrix column order N = 12 The transposed matrix A: Row: 0 1 2 3 4 Col 0: 101 201 301 401 501 1: 102 202 302 402 502 2: 103 203 303 403 503 3: 104 204 304 404 504 4: 105 205 305 405 505 5: 106 206 306 406 506 6: 107 207 307 407 507 7: 108 208 308 408 508 8: 109 209 309 409 509 9: 110 210 310 410 510 10: 111 211 311 411 511 11: 112 212 312 412 512 Row: 5 6 Col 0: 601 701 1: 602 702 2: 603 703 3: 604 704 4: 605 705 5: 606 706 6: 607 707 7: 608 708 8: 609 709 9: 610 710 10: 611 711 11: 612 712 R8COL_TRANSPOSE_PRINT_SOME_TEST R8COL_TRANSPOSE_PRINT_SOME prints some of an R8MAT, transposed. Matrix row order M = 7 Matrix column order N = 12 Rows 3:5, Cols 4:8: Row: 2 3 4 Col 3: 304 404 504 4: 305 405 505 5: 306 406 506 6: 307 407 507 7: 308 408 508 R8COL_UNDEX_TEST R8COL_UNDEX produces index vectors which create a sorted list of the unique columns of an (unsorted) R8COL, and a map from the original R8COL to the (implicit) R8COL of sorted unique elements. The R8COL (transposed): Row: 0 1 2 Col 0: 1.9 0 10 1: 2 6 10 2: 4 8 12 3: 1 5 9 4: 3 7 11 5: 2 6 0 6: 2 0 10.1 7: 2 0.1 10 8: 3 4 18 9: 1.9 8 10 10: 0 0 0 11: 0 6 10 12: 2.1 0 10 13: 2 6 10 14: 3 7 11 15: 2 0 10 16: 2 0 10 17: 2 6 10 18: 1 5 9 19: 2 0 10.1 20: 1 5 9.1 21: 1 5.1 9 Number of unique columns is 16 XDNU points to the representative for each item. UNDX selects the representatives. I XDNU UNDX 0 5 10 1 11 11 2 15 18 3 2 20 4 14 21 5 10 0 6 8 9 7 9 15 8 13 6 9 6 7 10 0 5 11 1 13 12 12 12 13 11 8 14 14 14 15 7 2 16 7 17 11 18 2 19 8 20 3 21 4 The Unique R8COL (transposed): Row: 0 1 2 Col 0: 0 0 0 1: 0 6 10 2: 1 5 9 3: 1 5 9.1 4: 1 5.1 9 5: 1.9 0 10 6: 1.9 8 10 7: 2 0 10 8: 2 0 10.1 9: 2 0.1 10 10: 2 6 0 11: 2 6 10 12: 2.1 0 10 13: 3 4 18 14: 3 7 11 15: 4 8 12 R8COL_UNIFORM_01_NEW_TEST R8COL_UNIFORM_01_NEW returns a random R8COL in [0,1]. The random R8COL: Col: 0 1 2 3 Row 0: 0.218418 0.0661187 0.0617272 0.00183837 1: 0.956318 0.257578 0.449539 0.897504 2: 0.829509 0.109957 0.401306 0.350752 3: 0.561695 0.043829 0.754673 0.0945448 4: 0.415307 0.633966 0.797287 0.0136169 R8COL_UNIFORM_AB_NEW_TEST R8COL_UNIFORM_AB_NEW returns a random R8COL in [A,B]. The random R8COL: Col: 0 1 2 3 Row 0: 3.74735 2.52895 2.49382 2.01471 1: 9.65054 4.06062 5.59631 9.18003 2: 8.63607 2.87965 5.21045 4.80602 3: 6.49356 2.35063 8.03739 2.75636 4: 5.32246 7.07173 8.3783 2.10894 R8COL_UNIQUE_COUNT_TEST R8COL_UNIQUE_COUNT counts unique columns. The R8COL (transposed): Row: 0 1 2 Col 0: 1.9 0 10 1: 2 6 10 2: 4 8 12 3: 1 5 9 4: 3 7 11 5: 2 6 0 6: 2 0 10.1 7: 2 0.1 10 8: 3 4 18 9: 1.9 8 10 10: 0 0 0 11: 0 6 10 12: 2.1 0 10 13: 2 6 10 14: 3 7 11 15: 2 0 10 16: 2 0 10 17: 2 6 10 18: 1 5 9 19: 2 0 10.1 20: 1 5 9.1 21: 1 5.1 9 Number of unique columns is 16 R8COL_VARIANCE_TEST R8COL_VARIANCE computes variances of an R8COL; The array: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Column variance: 0 16 1 16 2 16 3 16 R8VEC_PRINT_TEST R8VEC_PRINT prints an R8VEC. The R8VEC: 0: 123.456 1: 5e-06 2: -1e+06 3: 3.14159 R8COL_TEST Normal end of execution. 03 March 2022 03:12:05 PM