13-Dec-2023 14:46:48 subset_test() MATLAB/Octave version 9.14.0.2306882 (R2023a) Update 4 Test subset(). asm_enum_test(): asm_enum() returns the number of alternating sign matrices of a given order. 0 1 1 1 2 2 3 7 4 42 5 429 6 7436 7 218348 asm_triangle_test(): asm_triangle() returns a row of the alternating sign matrix triangle. 0 1 1 1 1 2 2 3 2 3 7 14 14 7 4 42 105 135 105 42 5 429 1287 2002 2002 1287 429 6 7436 26026 47320 56784 47320 26026 7436 7 218348 873392 1813968 2519400 2519400 1813968 873392 218348 bell_test(): bell() computes Bell numbers. N exact C(I) computed C(I) 0 1 1 1 1 1 2 2 2 3 5 5 4 15 15 5 52 52 6 203 203 7 877 877 8 4140 4140 9 21147 21147 10 115975 115975 catalan_test(): catalan() computes Catalan numbers. N exact C(I) computed C(I) 0 1 1 1 1 1 2 2 2 3 5 5 4 14 14 5 42 42 6 132 132 7 429 429 8 1430 1430 9 4862 4862 10 16796 16796 catalan_row_next_test(): catalan_row_next() computes a row of Catalan's triangle. First, compute row 7: 7 1 7 27 75 165 297 429 429 Now compute rows one at a time: 0 1 1 1 1 2 1 2 2 3 1 3 5 5 4 1 4 9 14 14 5 1 5 14 28 42 42 6 1 6 20 48 90 132 132 7 1 7 27 75 165 297 429 429 8 1 8 35 110 275 572 1001 1430 1430 9 1 9 44 154 429 1001 2002 3432 4862 4862 10 1 10 54 208 637 1638 3640 7072 11934 16796 16796 cfrac_to_rat_test(): cfrac_to_rat() continued fraction => fraction. Regular fraction is 4096 / 15625 Continued fraction coefficients: 1: 0 2: 3 3: 1 4: 4 5: 2 6: 1 7: 1 8: 11 9: 13 The continued fraction convergents. The last row contains the value of the continued fraction, written as a common fraction. I, P(I), Q(I), P(I)/Q(I) 1 0 1 0.000000 2 1 3 0.333333 3 1 4 0.250000 4 5 19 0.263158 5 11 42 0.261905 6 16 61 0.262295 7 27 103 0.262136 8 313 1194 0.262144 9 4096 15625 0.262144 cfrac_to_rfrac_test(): cfrac_to_rfrac(): continued fraction to ratio; Rational polynomial fraction coefficients: P: 1.000000 1.000000 2.000000 Q: 1.000000 3.000000 1.000000 1.000000 Continued fraction coefficients: 1: 1 2: 0.5 3: 1.33333 4: -0.5 5: -1.5 6: 2 Recovered rational polynomial: P: 1.000000 1.000000 2.000000 Q: 1.000000 3.000000 1.000000 1.000000 ch_to_digit_test(): ch_to_digit(): character -> decimal digit -2 "*" -1 -1 "*" -1 0 "0" 0 1 "1" 1 2 "2" 2 3 "3" 3 4 "4" 4 5 "5" 5 6 "6" 6 7 "7" 7 8 "8" 8 9 "9" 9 10 "*" -1 11 "*" -1 change_greedy_test(): change_greedy() makes change using the biggest coins first. The total for which change is to be made: 73 The available coins are: 1 5 10 25 50 100 6 5 3 3 1 1 1 73 50 10 10 1 1 1 change_next_test(): change_next() displays the next possible way to make change for a given total. The total for which change is to be made: 50 The available coins are: 1 5 10 25 50 100 1: 50 2: 25 25 3: 25 10 10 5 4: 25 10 10 1 1 1 1 1 5: 25 10 5 5 5 6: 25 10 5 5 1 1 1 1 1 7: 25 10 5 1 1 1 1 1 1 1 1 1 1 8: 25 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9: 25 5 5 5 5 5 10: 25 5 5 5 5 1 1 1 1 1 chinese_check_test(): chinese_check() checks a set of moduluses for use with the Chinese Remainder representation. Modulus set #1: 1: 1 2: 3 3: 8 4: 25 IERROR = 0 Modulus set #2: 1: 1 2: 3 3: -8 4: 25 IERROR = 1 Modulus set #3: 1: 1 2: 3 3: 1 4: 25 IERROR = 2 Modulus set #4: 1: 1 2: 3 3: 8 4: 24 IERROR = 3 chinese_to_i4_test(): chinese_to_i4() computes an integer with the given Chinese Remainder representation. The moduli: 1: 3 2: 4 3: 5 4: 7 The number being analyzed is 37 The remainders: 1: 1 2: 1 3: 2 4: 2 The reconstructed number is 37 The remainders of the reconstructed number are: 1: 1 2: 1 3: 2 4: 2 comb_next_test(): comb_next() produces combinations. Combinations of size 1: 1 2 3 4 5 Combinations of size 2: 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5 Combinations of size 3: 1 2 3 1 2 4 1 2 5 1 3 4 1 3 5 1 4 5 2 3 4 2 3 5 2 4 5 3 4 5 Combinations of size 4: 1 2 3 4 1 2 3 5 1 2 4 5 1 3 4 5 2 3 4 5 Combinations of size 5: 1 2 3 4 5 comb_row_next_test(): comb_row_next() computes a row of Pascal's triangle. 0 1 1 1 1 2 1 2 1 3 1 3 3 1 4 1 4 6 4 1 5 1 5 10 10 5 1 6 1 6 15 20 15 6 1 7 1 7 21 35 35 21 7 1 8 1 8 28 56 70 56 28 8 1 9 1 9 36 84 126 126 84 36 9 1 10 1 10 45 120 210 252 210 120 45 10 1 comp_enum_test(): comp_enum() counts compositions; 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7 8 9 10 1 3 6 10 15 21 28 36 45 55 1 4 10 20 35 56 84 120 165 220 1 5 15 35 70 126 210 330 495 715 1 6 21 56 126 252 462 792 1287 2002 1 7 28 84 210 462 924 1716 3003 5005 1 8 36 120 330 792 1716 3432 6435 11440 1 9 45 165 495 1287 3003 6435 12870 24310 1 10 55 220 715 2002 5005 11440 24310 48620 1 11 66 286 1001 3003 8008 19448 43758 92378 comp_next_test(): comp_next() generates compositions. 1 6 0 0 2 5 1 0 3 4 2 0 4 3 3 0 5 2 4 0 6 1 5 0 7 0 6 0 8 5 0 1 9 4 1 1 10 3 2 1 11 2 3 1 12 1 4 1 13 0 5 1 14 4 0 2 15 3 1 2 16 2 2 2 17 1 3 2 18 0 4 2 19 3 0 3 20 2 1 3 21 1 2 3 22 0 3 3 23 2 0 4 24 1 1 4 25 0 2 4 26 1 0 5 27 0 1 5 28 0 0 6 comp_random_test(): comp_random() generates random compositions. Seeking compositions of 10 into 5 parts. 2 2 4 2 0 1 5 4 0 0 1 1 1 0 7 2 1 4 3 0 1 2 0 4 3 comp_to_ksub_test(): comp_to_ksub() returns the K subset corresponding to a composition. COMP: 1 5 0 2 2 KSUB: 2 8 9 12 COMP: 1 5 0 2 2 COMP: 1 2 6 1 0 KSUB: 2 5 12 14 COMP: 1 2 6 1 0 COMP: 4 0 3 2 1 KSUB: 5 6 10 13 COMP: 4 0 3 2 1 COMP: 1 3 1 4 1 KSUB: 2 6 8 13 COMP: 1 3 1 4 1 COMP: 0 1 3 1 5 KSUB: 1 3 7 9 COMP: 0 1 3 1 5 comb_unrank_test(): comb_unrank() returns a combination of N things out of M, given the lexicographic rank. The total set size is M = 10 The subset size is N = 5 The number of combinations of N out of M is 252 Rank Combination 1 1 2 3 4 5 2 1 2 3 4 6 3 1 2 3 4 7 6 1 2 3 4 10 7 1 2 3 5 6 8 1 2 3 5 7 250 5 6 8 9 10 251 5 7 8 9 10 252 6 7 8 9 10 comp_next_grlex_test(): comp_next_grlex() determines the next COMP in graded lexicographic (grlex) order. A COMP is a composition of an integer N into K parts. Each part is nonnegative. The order matters. Rank: NC COMP ----: -- ------------ 1: 0 = 0 + 0 + 0 ----: -- ------------ 2: 1 = 0 + 0 + 1 3: 1 = 0 + 1 + 0 4: 1 = 1 + 0 + 0 ----: -- ------------ 5: 2 = 0 + 0 + 2 6: 2 = 0 + 1 + 1 7: 2 = 0 + 2 + 0 8: 2 = 1 + 0 + 1 9: 2 = 1 + 1 + 0 10: 2 = 2 + 0 + 0 ----: -- ------------ 11: 3 = 0 + 0 + 3 12: 3 = 0 + 1 + 2 13: 3 = 0 + 2 + 1 14: 3 = 0 + 3 + 0 15: 3 = 1 + 0 + 2 16: 3 = 1 + 1 + 1 17: 3 = 1 + 2 + 0 18: 3 = 2 + 0 + 1 19: 3 = 2 + 1 + 0 20: 3 = 3 + 0 + 0 ----: -- ------------ 21: 4 = 0 + 0 + 4 22: 4 = 0 + 1 + 3 23: 4 = 0 + 2 + 2 24: 4 = 0 + 3 + 1 25: 4 = 0 + 4 + 0 26: 4 = 1 + 0 + 3 27: 4 = 1 + 1 + 2 28: 4 = 1 + 2 + 1 29: 4 = 1 + 3 + 0 30: 4 = 2 + 0 + 2 31: 4 = 2 + 1 + 1 32: 4 = 2 + 2 + 0 33: 4 = 3 + 0 + 1 34: 4 = 3 + 1 + 0 35: 4 = 4 + 0 + 0 ----: -- ------------ 36: 5 = 0 + 0 + 5 37: 5 = 0 + 1 + 4 38: 5 = 0 + 2 + 3 39: 5 = 0 + 3 + 2 40: 5 = 0 + 4 + 1 41: 5 = 0 + 5 + 0 42: 5 = 1 + 0 + 4 43: 5 = 1 + 1 + 3 44: 5 = 1 + 2 + 2 45: 5 = 1 + 3 + 1 46: 5 = 1 + 4 + 0 47: 5 = 2 + 0 + 3 48: 5 = 2 + 1 + 2 49: 5 = 2 + 2 + 1 50: 5 = 2 + 3 + 0 51: 5 = 3 + 0 + 2 52: 5 = 3 + 1 + 1 53: 5 = 3 + 2 + 0 54: 5 = 4 + 0 + 1 55: 5 = 4 + 1 + 0 56: 5 = 5 + 0 + 0 ----: -- ------------ 57: 6 = 0 + 0 + 6 58: 6 = 0 + 1 + 5 59: 6 = 0 + 2 + 4 60: 6 = 0 + 3 + 3 61: 6 = 0 + 4 + 2 62: 6 = 0 + 5 + 1 63: 6 = 0 + 6 + 0 64: 6 = 1 + 0 + 5 65: 6 = 1 + 1 + 4 66: 6 = 1 + 2 + 3 67: 6 = 1 + 3 + 2 68: 6 = 1 + 4 + 1 69: 6 = 1 + 5 + 0 70: 6 = 2 + 0 + 4 71: 6 = 2 + 1 + 3 comp_random_grlex_test(): comp_random_grlex() selects a random composition of an integer into K parts, using graded lexicographic (grlex) order between indices RANK1 and RANK2. 59: 6 = 0 + 2 + 4 20: 3 = 3 + 0 + 0 51: 5 = 3 + 0 + 2 53: 5 = 3 + 2 + 0 55: 5 = 4 + 1 + 0 comp_rank_grlex_test(): comp_rank_grlex() determines the rank of a COMP from its parts. A COMP is a composition of an integer N into K parts. Each part is nonnegative. The order matters. Actual Inferred Test Rank Rank 1 23 23 2 36 36 3 30 30 4 52 52 5 37 37 comp_unrank_grlex_test(): comp_unrank_grlex() determines the parts of a COMP from its rank. A COMP is a composition of an integer N into K parts. Each part is nonnegative. The order matters. Rank: -> NC COMP ----: -- ------------ 1: 0 = 0 + 0 + 0 ----: -- ------------ 2: 1 = 0 + 0 + 1 3: 1 = 0 + 1 + 0 4: 1 = 1 + 0 + 0 ----: -- ------------ 5: 2 = 0 + 0 + 2 6: 2 = 0 + 1 + 1 7: 2 = 0 + 2 + 0 8: 2 = 1 + 0 + 1 9: 2 = 1 + 1 + 0 10: 2 = 2 + 0 + 0 ----: -- ------------ 11: 3 = 0 + 0 + 3 12: 3 = 0 + 1 + 2 13: 3 = 0 + 2 + 1 14: 3 = 0 + 3 + 0 15: 3 = 1 + 0 + 2 16: 3 = 1 + 1 + 1 17: 3 = 1 + 2 + 0 18: 3 = 2 + 0 + 1 19: 3 = 2 + 1 + 0 20: 3 = 3 + 0 + 0 ----: -- ------------ 21: 4 = 0 + 0 + 4 22: 4 = 0 + 1 + 3 23: 4 = 0 + 2 + 2 24: 4 = 0 + 3 + 1 25: 4 = 0 + 4 + 0 26: 4 = 1 + 0 + 3 27: 4 = 1 + 1 + 2 28: 4 = 1 + 2 + 1 29: 4 = 1 + 3 + 0 30: 4 = 2 + 0 + 2 31: 4 = 2 + 1 + 1 32: 4 = 2 + 2 + 0 33: 4 = 3 + 0 + 1 34: 4 = 3 + 1 + 0 35: 4 = 4 + 0 + 0 ----: -- ------------ 36: 5 = 0 + 0 + 5 37: 5 = 0 + 1 + 4 38: 5 = 0 + 2 + 3 39: 5 = 0 + 3 + 2 40: 5 = 0 + 4 + 1 41: 5 = 0 + 5 + 0 42: 5 = 1 + 0 + 4 43: 5 = 1 + 1 + 3 44: 5 = 1 + 2 + 2 45: 5 = 1 + 3 + 1 46: 5 = 1 + 4 + 0 47: 5 = 2 + 0 + 3 48: 5 = 2 + 1 + 2 49: 5 = 2 + 2 + 1 50: 5 = 2 + 3 + 0 51: 5 = 3 + 0 + 2 52: 5 = 3 + 1 + 1 53: 5 = 3 + 2 + 0 54: 5 = 4 + 0 + 1 55: 5 = 4 + 1 + 0 56: 5 = 5 + 0 + 0 ----: -- ------------ 57: 6 = 0 + 0 + 6 58: 6 = 0 + 1 + 5 59: 6 = 0 + 2 + 4 60: 6 = 0 + 3 + 3 61: 6 = 0 + 4 + 2 62: 6 = 0 + 5 + 1 63: 6 = 0 + 6 + 0 64: 6 = 1 + 0 + 5 65: 6 = 1 + 1 + 4 66: 6 = 1 + 2 + 3 67: 6 = 1 + 3 + 2 68: 6 = 1 + 4 + 1 69: 6 = 1 + 5 + 0 70: 6 = 2 + 0 + 4 71: 6 = 2 + 1 + 3 compnz_enum_test(): compnz_enum() counts compositions with nonzero parts; 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 0 0 1 3 3 1 0 0 0 0 0 0 1 4 6 4 1 0 0 0 0 0 1 5 10 10 5 1 0 0 0 0 1 6 15 20 15 6 1 0 0 0 1 7 21 35 35 21 7 1 0 0 1 8 28 56 70 56 28 8 1 0 1 9 36 84 126 126 84 36 9 1 compnz_next_test(): compnz_next() generates compositions with nonzero parts. Seeking all compositions of N = 6 using 3 nonzero parts. 4 1 1 3 2 1 2 3 1 1 4 1 3 1 2 2 2 2 1 3 2 2 1 3 1 2 3 1 1 4 compnz_random_test(): compnz_random() generates random compositions using nonzero parts. Seeking random compositions of N = 10 using 5 nonzero parts. 1 1 2 3 3 1 2 2 3 2 1 1 1 1 6 3 1 2 1 3 1 1 2 5 1 compnz_to_ksub_test(): compnz_to_ksub() returns the K subset corresponding to a nonzero composition. COMPNZ: 1 1 2 4 2 KSUB: 1 2 4 8 COMPNZ: 1 1 2 4 2 COMPNZ: 2 1 2 4 1 KSUB: 2 3 5 9 COMPNZ: 2 1 2 4 1 COMPNZ: 2 3 2 1 2 KSUB: 2 5 7 8 COMPNZ: 2 3 2 1 2 COMPNZ: 5 1 2 1 1 KSUB: 5 6 8 9 COMPNZ: 5 1 2 1 1 COMPNZ: 5 1 1 1 2 KSUB: 5 6 7 8 COMPNZ: 5 1 1 1 2 congruence_test(): congruence() solves a congruence equation: A * X = C mod ( B ) I A B C X Mod ( A*X-C,B) 1 1027 712 7 269 0 2 1027 712 -7 443 0 3 1027 -712 7 -1155 0 4 1027 -712 -7 -981 0 5 -1027 712 7 443 0 6 -1027 712 -7 269 0 7 -1027 -712 7 -981 0 8 -1027 -712 -7 -1155 0 9 6 8 50 7 0 10 0 0 0 0 0 11 0 1 0 0 0 12 0 1 1 0 0 13 1 0 0 0 0 14 1 0 1 1 0 15 1 1 0 0 0 16 1024 -15625 11529 -15629 0 17 0 0 1 0 0 18 0 3 11 0 1 19 5 0 19 3.800000e+00 0 20 2 4 7 0 1 count_pose_random_test(): count_pose_random() poses a random problem for the game "The Count is Good". Problem #1 The goal number: 307 The available numbers are 3 4 5 7 50 100 Problem #2 The goal number: 467 The available numbers are 1 3 4 8 9 10 Problem #3 The goal number: 820 The available numbers are 1 3 6 9 25 75 Problem #4 The goal number: 661 The available numbers are 2 5 6 10 75 100 Problem #5 The goal number: 222 The available numbers are 2 7 10 25 75 100 debruijn_test(): debruijn() computes a de Bruijn string. The alphabet size is M = 2 The string length is N = 3 21222111 The alphabet size is M = 3 The string length is N = 3 212221132131232231332333111 The alphabet size is M = 2 The string length is N = 4 2121122122221111 dec_add_test(): dec_add() adds two decimals. Number of decimal places is 3 A = 12.8 B = 4.38 C = 17.2 dec_div_test(): dec_div() divides two decimals. Number of decimal places is 3 A = 52.3 B = 13400 C = 0.0039 dec_mul_test(): dec_mul() multiplies two decimals. Number of decimal places is 2 A = 0.0014 B = 1600 C = 2.2 dec_round_test(): dec_round() "rounds" a decimal to a number of digits. -----Before------- -----After-------- Digits Mantissa Exponent Mantissa Exponent 1 523 -1 5 1 2 523 -1 52 0 3 523 -1 523 -1 4 523 -1 523 -1 2 6340 2 63 4 3 6340 2 634 3 4 6340 2 634 3 dec_to_r8_test(): dec_to_r8() converts a decimal to a real number. The number of decimal digits is 5 R => A * 10^B => R2 -0.401557 -40156 -5 -0.401560 8.094445 80944 -4 8.094400 2.197333 21973 -4 2.197300 2.353328 23533 -4 2.353300 7.188846 71888 -4 7.188800 6.109788 61098 -4 6.109800 1.534430 15344 -4 1.534400 -6.341551 -63416 -4 -6.341600 -5.201360 -52014 -4 -5.201400 7.730239 77302 -4 7.730200 dec_to_rat_test(): dec_to_rat() converts decimal => fraction. In this test, choose the top and bottom of a rational at random, and compute the equivalent real number. Then convert to decimal, and the equivalent real. Then convert back to rational and the equivalent real. [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In dec_to_rat_test (line 39) In subset_test (line 76) In run (line 91)] -1.924490 = -943 / 490 -1.924490 = -19244897959183672 * 10^-16 -1.924490 = -2405612244897959 / 1250000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In dec_to_rat_test (line 39) In subset_test (line 76) In run (line 91)] -0.678243 = -664 / 979 -0.678243 = -6782431052093972 * 10^-16 -0.678243 = -1695607763023493 / 2500000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In dec_to_rat_test (line 39) In subset_test (line 76) In run (line 91)] 0.850299 = 426 / 501 0.850299 = 8502994011976048 * 10^-16 0.850299 = 531437125748503 / 625000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In dec_to_rat_test (line 39) In subset_test (line 76) In run (line 91)] -0.966667 = -58 / 60 -0.966667 = -9666666666666664 * 10^-16 -0.966667 = -1208333333333333 / 1250000000000000 8.465116 = 364 / 43 8.465116 = 8465116279069769 * 10^-15 8.465116 = 8465116279069769 / 1000000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In dec_to_rat_test (line 39) In subset_test (line 76) In run (line 91)] -1.643678 = -858 / 522 -1.643678 = -16436781609195404 * 10^-16 -1.643678 = -4109195402298851 / 2500000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In dec_to_rat_test (line 39) In subset_test (line 76) In run (line 91)] -0.985348 = -807 / 819 -0.985348 = -9853479853479856 * 10^-16 -0.985348 = -615842490842491 / 625000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In dec_to_rat_test (line 39) In subset_test (line 76) In run (line 91)] 0.878285 = 635 / 723 0.878285 = 8782849239280775 * 10^-16 0.878285 = 351313969571231 / 400000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In dec_to_rat_test (line 39) In subset_test (line 76) In run (line 91)] -1.062121 = -701 / 660 -1.062121 = -10621212121212122 * 10^-16 -1.062121 = -5310606060606061 / 5000000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In dec_to_rat_test (line 39) In subset_test (line 76) In run (line 91)] 0.038027 = 37 / 973 0.038027 = 3802672147995889 * 10^-17 0.038027 = 3802672147995889 / 100000000000000000 dec_to_s_test(): dec_to_s() prints a decimal value. Mantissa Exponent String 523 -1 52.3 134 2 13400 -134 2 -13400 0 10 0 123456 -8 0.00123456 123456 -7 0.0123456 123456 -6 0.123456 123456 -5 1.23456 123456 -4 12.3456 123456 -3 123.456 123456 -2 1234.56 123456 -1 12345.6 123456 0 123456 123456 1 1234560 123456 2 12345600 123456 3 123456000 dec_width_test(): dec_width() determines the "width" of a decimal. Mantissa Exponent Width 523 -1 4 134 2 5 -134 2 6 0 10 1 123456 -8 10 123456 -7 9 123456 -6 8 123456 -5 7 123456 -4 7 123456 -3 7 123456 -2 7 123456 -1 7 123456 0 6 123456 1 7 123456 2 8 123456 3 9 decmat_det_test(): decmat_det(): determinant of a decimal matrix. The 123/456/789 matrix: 1 2 3 4 5 6 7 8 9 Determinant of the 123/456/789 matrix 0*10^0 The Hilbert matrix: 0.5 0.3333333333 0.25 0.2 0.3333333333 0.25 0.2 0.1666666667 0.25 0.2 0.1666666667 0.1428571429 0.2 0.1666666667 0.1428571429 0.125 Determinant of the Hilbert matrix: 2366*10^-12 The -1,2,-1 matrix: 2 -1 0 -1 2 -1 0 -1 2 Determinant of the -1,2,-1 matrix: 4*10^0 decmat_print_test(): decmat_print() prints a decimal matrix. The Hilbert matrix: 0.5 0.3333333 0.25 0.3333333 0.25 0.2 0.25 0.2 0.1666667 0.2 0.1666667 0.1428571 derange_enum_test(): derange_enum() counts derangements; N # of derangements 0 1 1 0 2 1 3 2 4 9 5 44 6 265 7 1854 8 14833 9 133496 10 1334961 derange_enum2_test(): derange_enum2() counts derangements. N # of derangements 0 1 1 0 2 1 3 2 4 9 5 44 6 265 7 1854 8 14833 9 133496 10 1334961 derange_enum3_test(): derange_enum3() counts derangements. N # of derangements 0 1 1 0 2 1 3 2 4 9 5 44 6 265 7 1854 8 14833 9 133496 10 1334961 derange1_back_next_test(): derange1_back_next() generates derangements using backtracking. Here, we seek all derangments of order N = 5 1 5 4 2 3 1 2 5 4 2 1 3 3 5 4 1 3 2 4 5 4 1 2 3 5 5 3 4 2 1 6 5 3 4 1 2 7 5 3 2 1 4 8 5 3 1 2 4 9 5 1 4 3 2 10 5 1 4 2 3 11 5 1 2 3 4 12 4 5 2 3 1 13 4 5 2 1 3 14 4 5 1 3 2 15 4 5 1 2 3 16 4 3 5 2 1 17 4 3 5 1 2 18 4 3 2 5 1 19 4 3 1 5 2 20 4 1 5 3 2 21 4 1 5 2 3 22 4 1 2 5 3 23 3 5 4 2 1 24 3 5 4 1 2 25 3 5 2 1 4 26 3 5 1 2 4 27 3 4 5 2 1 28 3 4 5 1 2 29 3 4 2 5 1 30 3 4 1 5 2 31 3 1 5 2 4 32 3 1 4 5 2 33 3 1 2 5 4 34 2 5 4 3 1 35 2 5 4 1 3 36 2 5 1 3 4 37 2 4 5 3 1 38 2 4 5 1 3 39 2 4 1 5 3 40 2 3 5 1 4 41 2 3 4 5 1 42 2 3 1 5 4 43 2 1 5 3 4 44 2 1 4 5 3 derange1_check_test(): derange1_check()_checks whether a vector of N objects represents a derangement of (1,...,N). Potential derangement: 2 3 4 5 1 CHECK = 1 Potential derangement: 2 5 3 1 4 CHECK = 0 Potential derangement: 2 3 4 1 4 CHECK = 0 Potential derangement: 0 3 4 5 1 CHECK = 0 Potential derangement: 1 4 9 2 3 CHECK = 0 derange1_weed_next_test(): derange1_weed_next() generates derangements by generating ALL permutations, and "weeding out" the ones that are not derangements. Here, we seek all derangements of order N = 5 1: 2 1 4 5 3 2: 2 1 5 3 4 3: 2 3 1 5 4 4: 2 3 4 5 1 5: 2 3 5 1 4 6: 2 4 1 5 3 7: 2 4 5 1 3 8: 2 4 5 3 1 9: 2 5 1 3 4 10: 2 5 4 1 3 11: 2 5 4 3 1 12: 3 1 2 5 4 13: 3 1 4 5 2 14: 3 1 5 2 4 15: 3 4 1 5 2 16: 3 4 2 5 1 17: 3 4 5 1 2 18: 3 4 5 2 1 19: 3 5 1 2 4 20: 3 5 2 1 4 21: 3 5 4 1 2 22: 3 5 4 2 1 23: 4 1 2 5 3 24: 4 1 5 2 3 25: 4 1 5 3 2 26: 4 3 1 5 2 27: 4 3 2 5 1 28: 4 3 5 1 2 29: 4 3 5 2 1 30: 4 5 1 2 3 31: 4 5 1 3 2 32: 4 5 2 1 3 33: 4 5 2 3 1 34: 5 1 2 3 4 35: 5 1 4 2 3 36: 5 1 4 3 2 37: 5 3 1 2 4 38: 5 3 2 1 4 39: 5 3 4 1 2 40: 5 3 4 2 1 41: 5 4 1 2 3 42: 5 4 1 3 2 43: 5 4 2 1 3 44: 5 4 2 3 1 digit_to_ch_test(): digit_to_ch(): decimal digit -> character. -2 "*" -1 -1 "*" -1 0 "0" 0 1 "1" 1 2 "2" 2 3 "3" 3 4 "4" 4 5 "5" 5 6 "6" 6 7 "7" 7 8 "8" 8 9 "9" 9 10 "*" -1 11 "*" -1 digraph_arc_euler_test(): digraph_arc_euler() finds an Euler circuit of a digraph. The arc list of the digraph: 1 2 5 2 1 4 3 2 3 4 1 2 5 3 1 6 5 1 7 4 2 The edge list of the Euler circuit: 1: 6 2: 4 3: 3 4: 5 5: 2 6: 7 7: 1 The node list of the Euler circuit: I Edge Node 1 6 1 2 4 2 3 3 3 4 5 1 5 2 4 6 7 2 7 1 5 digraph_arc_print_test(): digraph_arc_print() prints a digraph. The arc list of the digraph: 1 2 5 2 1 4 3 2 3 4 1 2 5 3 1 6 5 1 7 4 2 diophantine_test(): diophantine() solves a Diophantine equation: A * X + B * Y = C A B C X Y Error 1027 712 7 269 -388 0 1027 712 -7 -269 388 0 1027 -712 7 269 388 0 1027 -712 -7 -269 -388 0 -1027 712 7 -269 -388 0 -1027 712 -7 269 388 0 -1027 -712 7 -269 388 0 -1027 -712 -7 269 -388 0 6 8 50 3 4 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 1 1 0 0 1 1 0 1 -1 0 1024 -15625 11529 -4 -1 0 0 0 1 Error code = 1 0 3 11 Error code = 2 5 0 19 Error code = 3 2 4 7 Error code = 4 diophantine_solution_minimize_test(): diophantine_solution_minimize() computes a minimal Euclidean norm solution of a Diophantine equation: A * X + B * Y = C Coefficients: A = 4096 B = -15625 C = 46116 Solution: X = 665499996 Y = 174456828 Residual R = A * X + B * Y - C: R = 0 The minimized solution: X = -4 Y = -4 Residual R = A * X + B * Y - C: R = 0 The minimal positive solution: X = 15621 Y = 4092 Residual R = A * X + B * Y - C: R = 0 dvec_add_test() dvec_add() adds decimal vectors representing integers; I J K = I + J 30 60 Directly: 90 DVEC_ADD 90 -9 -14 Directly: -23 DVEC_ADD -23 65 -84 Directly: -19 DVEC_ADD -19 -74 -66 Directly: -140 DVEC_ADD -140 -22 67 Directly: 45 DVEC_ADD 45 61 -88 Directly: -27 DVEC_ADD -27 -20 5 Directly: -15 DVEC_ADD -15 -17 32 Directly: 15 DVEC_ADD 15 26 -42 Directly: -16 DVEC_ADD -16 -14 -97 Directly: -111 DVEC_ADD -111 dvec_complementx_test(): dvec_complementx() returns the ten's complement of a (signed) decimal vector; I = 97 J = -97 +000000097 -999999903 I = -67 J = 67 -999999933 +000000067 I = -79 J = 79 -999999921 +000000079 I = -26 J = 26 -999999974 +000000026 I = -61 J = 61 -999999939 +000000061 dvec_mul_test(): dvec_mul() multiplies decimal vectors representing integers; I J K = I * J -21 -321 Directly: 6741 DVEC_MUL 6741 904 841 Directly: 760264 DVEC_MUL 760264 -895 476 Directly: -426020 DVEC_MUL -426020 -462 -154 Directly: 71148 DVEC_MUL 71148 96 886 Directly: 85056 DVEC_MUL 85056 -165 967 Directly: -159555 DVEC_MUL -159555 -397 402 Directly: -159594 DVEC_MUL -159594 333 78 Directly: 25974 DVEC_MUL 25974 396 333 Directly: 131868 DVEC_MUL 131868 -644 -744 Directly: 479136 DVEC_MUL 479136 NOW REPEAT THE TEST... but use too few digits to represent big products. This corresponds to an "overflow". The result here should get the final decimal digits correctly, though. I J K = I * J 999 -658 Directly: -657342 DVEC_MUL -57342 -935 122 Directly: -114070 DVEC_MUL -14070 764 339 Directly: 258996 DVEC_MUL 58996 -619 -262 Directly: 162178 DVEC_MUL 62178 -79 964 Directly: -76156 DVEC_MUL -76156 -688 711 Directly: -489168 DVEC_MUL -89168 290 -248 Directly: -71920 DVEC_MUL -71920 -618 -144 Directly: 88992 DVEC_MUL 88992 -36 -759 Directly: 27324 DVEC_MUL 27324 179 -548 Directly: -98092 DVEC_MUL -98092 dvec_print_test(): dvec_print() prints a (signed) decimal vector; The DVEC: -0055771439876543210 dvec_sub_test(): dvec_sub() subtracts decimal vectors representing integers; I J L = I - J -23 17 Directly: -40 DVEC_SUB -40 -50 -42 Directly: -8 DVEC_SUB -8 24 -47 Directly: 71 DVEC_SUB 71 65 97 Directly: -32 DVEC_SUB -32 46 -31 Directly: 77 DVEC_SUB 77 17 -79 Directly: 96 DVEC_SUB 96 82 76 Directly: 6 DVEC_SUB 6 64 -48 Directly: 112 DVEC_SUB 112 19 -96 Directly: 115 DVEC_SUB 115 -15 -38 Directly: 23 DVEC_SUB 23 dvec_to_i4_test(): dvec_to_i4() converts a DVEC to an I4. I4 => DVEC => I4 -6771 9 9 3 2 2 9 -6771 equiv_next_test(): equiv_next() generates all partitions of a set. Rank/element: 1 2 3 4 1 1 1 1 1 2 1 1 1 2 3 1 1 2 1 4 1 1 2 2 5 1 1 2 3 6 1 2 1 1 7 1 2 1 2 8 1 2 1 3 9 1 2 2 1 10 1 2 2 2 11 1 2 2 3 12 1 2 3 1 13 1 2 3 2 14 1 2 3 3 15 1 2 3 4 equiv_next2_test(): equiv_next2() generates all partitions of a set. Here, N = 4 Rank/element: 1 2 3 4 1 1 1 1 1 2 1 1 1 2 3 1 1 2 1 4 1 1 2 2 5 1 1 2 3 6 1 2 1 1 7 1 2 1 2 8 1 2 1 3 9 1 2 2 1 10 1 2 2 2 11 1 2 2 3 12 1 2 3 1 13 1 2 3 2 14 1 2 3 3 15 1 2 3 4 equiv_print_test(): equiv_print() prints a set partition. The partition: Set Size 1 1 :: 3 2 2 :: 1 4 3 1 :: 2 The partition: Set Size 1 2 :: 3 4 2 2 :: 1 2 The partition: Set Size 1 2 :: 2 4 2 2 :: 1 3 The partition: Set Size 1 4 :: 1 2 3 4 The partition: Set Size 1 2 :: 3 4 2 2 :: 1 2 equiv_print2_test(): equiv_print2() prints a set partition. The partition: (2)(4)(1)(3) The partition: (1,2,3,4) The partition: (1,4)(2)(3) The partition: (2)(1,4)(3) The partition: (1)(2,3)(4) equiv_random_test(): equiv_random() selects a random set partition. The partition: (2,3)(1)(4) The partition: (4)(3)(1,2) The partition: (2,3)(4)(1) The partition: (1,3,4)(2) The partition: (2,3)(1,4) euler_row_test(): euler_row() gets rows of Euler's triangle. 1 1 0 1 1 0 1 4 1 0 1 11 11 1 0 1 26 66 26 1 0 1 57 302 302 57 1 0 1 120 1191 2416 1191 120 1 0 1 247 4293 15619 15619 4293 247 1 0 1 502 14608 88234 156190 88234 14608 502 1 0 frobenius_number_order2_test(): frobenius_number_order2() computes Frobenius numbers of order 2. C1 C1 exact F comput F 2 5 3 3 3 17 31 31 4 19 23 53 5 13 47 47 12 11 109 109 99 100 9701 9701 gray_next_test(): gray_next() returns the index of the single item to be changed in order to get the next Gray code. K Change Gray Code 1 0 0000 2 1 1000 3 2 1100 4 -1 0100 5 3 0110 6 1 1110 7 -2 1010 8 -1 0010 9 4 0011 10 1 1011 11 2 1111 12 -1 0111 13 -3 0101 14 1 1101 15 -2 1001 16 -1 0001 gray_rank2_test(): gray_rank2() ranks a Gray code; R = RANK G = GRAY_UNRANK2(RANK) R2 = GRAY_RANK2(GRAY_UNRANK2(RANK)) R G R2 0 0 0 1 1 1 2 3 2 3 2 3 4 6 4 5 7 5 6 5 6 7 4 7 8 12 8 9 13 9 10 15 10 11 14 11 12 10 12 13 11 13 14 9 14 15 8 15 16 24 16 17 25 17 18 27 18 19 26 19 20 30 20 21 31 21 22 29 22 23 28 23 24 20 24 gray_unrank2_test(): gray_unrank2() unranks a Gray code. R = RANK G = GRAY_UNRANK2(RANK) R2 = GRAY_RANK2(GRAY_UNRANK2(RANK)) R G R2 0 0 0 1 1 1 2 3 2 3 2 3 4 6 4 5 7 5 6 5 6 7 4 7 8 12 8 9 13 9 10 15 10 11 14 11 12 10 12 13 11 13 14 9 14 15 8 15 16 24 16 17 25 17 18 27 18 19 26 19 20 30 20 21 31 21 22 29 22 23 28 23 24 20 24 i4_bclr_test(): i4_bclr() sets a given bit to 0. Working on I4 = 101 Pos I4_BCLR 0 100 1 101 2 97 3 101 4 101 5 69 6 37 7 101 8 101 9 101 10 101 11 101 12 101 13 101 14 101 15 101 16 101 17 101 18 101 19 101 20 101 21 101 22 101 23 101 24 101 25 101 26 101 27 101 28 101 29 101 30 101 31 101 Working on I4 = -31 Pos I4_BCLR 0 -32 1 -31 2 -31 3 -31 4 -31 5 -63 6 -95 7 -159 8 -287 9 -543 10 -1055 11 -2079 12 -4127 13 -8223 14 -16415 15 -32799 16 -65567 17 -131103 18 -262175 19 -524319 20 -1048607 21 -2097183 22 -4194335 23 -8388639 24 -16777247 25 -33554463 26 -67108895 27 -134217759 28 -268435487 29 -536870943 30 -1073741855 31 2147483617 i4_bset_test(): i4_bset() sets a given bit to 1. Working on I4 = 101 Pos I4_BSET 0 101 1 103 2 101 3 109 4 117 5 101 6 101 7 229 8 357 9 613 10 1125 11 2149 12 4197 13 8293 14 16485 15 32869 16 65637 17 131173 18 262245 19 524389 20 1048677 21 2097253 22 4194405 23 8388709 24 16777317 25 33554533 26 67108965 27 134217829 28 268435557 29 536871013 30 1073741925 31 -2147483547 Working on I4 = -31 Pos I4_BSET 0 -31 1 -29 2 -27 3 -23 4 -15 5 -31 6 -31 7 -31 8 -31 9 -31 10 -31 11 -31 12 -31 13 -31 14 -31 15 -31 16 -31 17 -31 18 -31 19 -31 20 -31 21 -31 22 -31 23 -31 24 -31 25 -31 26 -31 27 -31 28 -31 29 -31 30 -31 31 -31 i4_btest_test(): i4_btest() reports whether a given bit is 0 or 1. Analyze the integer I4 = 101 Pos I4_BTEST(I4,POS) 0 1 1 0 2 1 3 0 4 0 5 1 6 1 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 Analyze the integer I4 = -31 Pos I4_BTEST(I4,POS) 0 1 1 0 2 0 3 0 4 0 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 i4_factor_test(): i4_factor() factors an integer. The integer is 2516 Prime representation: I, FACTOR(I), POWER(I) 1 2 2 2 17 1 3 37 1 i4_fall_test() i4_fall() evaluates the falling factorial function. M N Exact I4_FALL(M,N) 5 0 1 1 5 1 5 5 5 2 20 20 5 3 60 60 5 4 120 120 5 5 120 120 5 6 0 0 50 0 1 1 10 1 10 10 4000 1 4000 4000 10 2 90 90 18 3 4896 4896 4 4 24 24 98 3 912576 912576 1 7 0 0 i4_gpf_test() i4_gpf() evaluates the greatest prime factor function. N Exact I4_gpf(N) 1 1 1 2 2 2 3 3 3 4 2 2 5 5 5 6 3 3 7 7 7 8 2 2 9 3 3 10 5 5 11 11 11 12 3 3 13 13 13 14 7 7 15 5 5 16 2 2 17 17 17 18 3 3 19 19 19 20 5 5 21 7 7 22 11 11 23 23 23 24 3 3 25 5 5 26 13 13 27 3 3 28 7 7 29 29 29 30 5 5 31 31 31 32 2 2 33 11 11 34 17 17 35 7 7 36 3 3 37 37 37 38 19 19 39 13 13 40 5 5 41 41 41 42 7 7 43 43 43 44 11 11 45 5 5 46 23 23 47 47 47 48 3 3 49 7 7 50 5 5 51 17 17 52 13 13 53 53 53 54 3 3 55 11 11 56 7 7 57 19 19 58 29 29 59 59 59 60 5 5 61 61 61 62 31 31 63 7 7 64 2 2 65 13 13 66 11 11 67 67 67 68 17 17 69 23 23 70 7 7 71 71 71 72 3 3 73 73 73 74 37 37 75 5 5 76 19 19 77 11 11 78 13 13 79 79 79 80 5 5 81 3 3 82 41 41 83 83 83 84 7 7 85 17 17 86 43 43 i4_log_10_test(): i4_log_10(): whole part of log base 10, X, I4_LOG_10 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_modp_test(): i4_modp() factors a number into a multiple and a remainder. Number Divisor Multiple Remainder 107 50 2 7 107 -50 -2 7 -107 50 -3 43 -107 -50 3 43 Repeat using MOD: 107 50 2 7 107 -50 -3 -43 -107 50 -3 43 -107 -50 2 -7 i4_moebius_test(): i4_moebius() evaluates the Moebius function: N Exact I4_MOEBIUS(N) 1 1 1 2 -1 -1 3 -1 -1 4 0 0 5 -1 -1 6 1 1 7 -1 -1 8 0 0 9 0 0 10 1 1 11 -1 -1 12 0 0 13 -1 -1 14 1 1 15 1 1 16 0 0 17 -1 -1 18 0 0 19 -1 -1 20 0 0 i4_partition_conj_test(): i4_partition_conj() conjugates an integer partition. Original partition: 14 = 1 * 2 + 1 * 5 + 3 * 1 + 1 * 4 Conjugate partition: 14 = 1 * 6 + 1 * 3 + 2 * 2 + 1 * 1 i4_partition_count_test(): i4_partition_count() counts partitions of an integer. N Exact Count 0 1 1 1 1 1 2 2 2 3 3 3 4 5 5 5 7 7 6 11 11 7 15 15 8 22 22 9 30 30 10 42 42 11 56 56 12 77 77 13 101 101 14 135 135 15 176 176 16 231 231 17 297 297 18 385 385 19 490 490 20 627 627 i4_partition_count2_test(): i4_partition_count2() counts partitions of an integer. N Exact Count 0 1 1 1 1 1 2 2 2 3 3 3 4 5 5 5 7 7 6 11 11 7 15 15 8 22 22 9 30 30 10 42 42 11 56 56 12 77 77 13 101 101 14 135 135 15 176 176 16 231 231 17 297 297 18 385 385 19 490 490 20 627 627 i4_partition_next_test(): i4_partition_next() generates partitions of an integer. Here N = 7 7 = 1 * 7 7 = 1 * 6 + 1 * 1 7 = 1 * 5 + 1 * 2 7 = 1 * 5 + 2 * 1 7 = 1 * 4 + 1 * 3 7 = 1 * 4 + 1 * 2 + 1 * 1 7 = 1 * 4 + 3 * 1 7 = 2 * 3 + 1 * 1 7 = 1 * 3 + 2 * 2 7 = 1 * 3 + 1 * 2 + 2 * 1 7 = 1 * 3 + 4 * 1 7 = 3 * 2 + 1 * 1 7 = 2 * 2 + 3 * 1 7 = 1 * 2 + 5 * 1 7 = 7 * 1 i4_partition_next2_test(): i4_partition_next2() produces partitions of an integer. 7 = 1 * 7 7 = 1 * 6 + 1 * 1 7 = 1 * 5 + 1 * 2 7 = 1 * 5 + 2 * 1 7 = 1 * 4 + 1 * 3 7 = 1 * 4 + 1 * 2 + 1 * 1 7 = 1 * 4 + 3 * 1 7 = 2 * 3 + 1 * 1 7 = 1 * 3 + 2 * 2 7 = 1 * 3 + 1 * 2 + 2 * 1 7 = 1 * 3 + 4 * 1 7 = 3 * 2 + 1 * 1 7 = 2 * 2 + 3 * 1 7 = 1 * 2 + 5 * 1 7 = 7 * 1 i4_partition_print_test(): i4_partition_print() prints an integer partition. 14 = 1 * 2 + 1 * 5 + 3 * 1 + 1 * 4 i4_partition_random_test(): i4_partition_random() generates a random partition. The number of partitions of N N Number of partitions 1 1 2 1 3 2 4 3 5 5 6 7 7 11 8 15 8 = 2 * 2 + 1 * 4 8 = 1 * 8 8 = 4 * 1 + 2 * 2 8 = 8 * 1 8 = 4 * 2 i4_partitions_next_test(): i4_partitions_next() produces the next nondecreasing partitions of an integer, and if necessary, increments the integer to keep on going. I Sum Partition 0 0 0 0 0 1 1 1 0 0 2 2 2 0 0 3 2 1 1 0 4 3 3 0 0 5 3 2 1 0 6 3 1 1 1 7 4 4 0 0 8 4 3 1 0 9 4 2 2 0 10 4 2 1 1 11 5 5 0 0 12 5 4 1 0 13 5 3 2 0 14 5 3 1 1 15 5 2 2 1 You can start from any legal partition. Here, we restart at ( 2, 1, 0 ). I Sum Partition 0 3 2 1 0 1 3 1 1 1 2 4 4 0 0 3 4 3 1 0 4 4 2 2 0 5 4 2 1 1 6 5 5 0 0 7 5 4 1 0 8 5 3 2 0 9 5 3 1 1 10 5 2 2 1 11 6 6 0 0 12 6 5 1 0 13 6 4 2 0 14 6 3 3 0 15 6 4 1 1 i4_rise_test(): i4_rise() evaluates the rising factorial function. M N Exact I4_RISE(M,N) 5 0 1 1 5 1 5 5 5 2 30 30 5 3 210 210 5 4 1680 1680 5 5 15120 15120 5 6 151200 151200 50 0 1 1 i4_sign_test(): i4_sign() returns the sign of a number. I4 I4_SIGN(I4) -10 -1 -7 -1 0 1 5 1 9 1 i4_sqrt_test(): i4_sqrt() computes the square root of an integer. N Sqrt(N) Remainder -5 2 1 -4 2 0 -3 1 2 -2 1 1 -1 1 0 0 0 0 1 1 0 2 1 1 3 1 2 4 2 0 5 2 1 6 2 2 7 2 3 8 2 4 9 3 0 10 3 1 11 3 2 12 3 3 13 3 4 14 3 5 15 3 6 16 4 0 17 4 1 18 4 2 19 4 3 20 4 4 i4_sqrt_cf_test(): i4_sqrt_cf() computes the continued fraction form of the square root of an integer. N Period Whole Repeating Part 1 1 0 0 2 1 1 2 3 2 2 -4 4 4 2 0 0 0 5 2 1 0 0 6 2 2 2 4 7 2 3 -3 6 8 2 4 -1 8 9 2 0 0 0 10 2 1 0 0 11 2 2 0 0 12 2 3 2 6 13 3 4 -3 2 7 14 100 5 -1 5 -9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 100 6 -1 2 -11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 2 0 0 0 17 2 1 0 0 18 2 2 0 0 19 2 3 0 0 20 2 4 2 8 i4_to_chinese_test(): i4_to_chinese() computes the Chinese Remainder representation of an integer. The moduli: 1: 3 2: 4 3: 5 4: 7 The number being analyzed is 37 The remainders: 1: 1 2: 1 3: 2 4: 2 The reconstructed number is 37 The remainders of the reconstructed number are: 1: 1 2: 1 3: 2 4: 2 i4_to_dvec_test(): i4_to_dvec() converts an I4 to a DVEC. I4 => DVEC => I4 -826 9 9 9 1 7 4 -826 i4_to_i4poly_test(): i4_to_i4poly() converts an integer to a polynomial in a given base; I BASE DEGREE Coefficients 1 2 0 1 6 2 2 1 1 0 23 2 4 1 0 1 1 1 23 3 2 2 1 2 23 4 2 1 1 3 23 5 1 4 3 23 6 1 3 5 23 23 1 1 0 23 24 0 23 Now let I4_TO_I4POLY convert I to a polynomial, use I4POLY_TO_I4 to evaluate it, and compare. I I2 1 1 6 6 23 23 23 23 23 23 23 23 23 23 23 23 23 23 i4_to_van_der_corput_test(): i4_to_van_der_corput() computes the elements of a van der Corput sequence. The sequence depends on the prime numbers used as a base. Bases: 2 3 5 7 11 1 0.500000 0.333333 0.200000 0.142857 0.090909 2 0.250000 0.666667 0.400000 0.285714 0.181818 3 0.750000 0.111111 0.600000 0.428571 0.272727 4 0.125000 0.444444 0.800000 0.571429 0.363636 5 0.625000 0.777778 0.040000 0.714286 0.454545 6 0.375000 0.222222 0.240000 0.857143 0.545455 7 0.875000 0.555556 0.440000 0.020408 0.636364 8 0.062500 0.888889 0.640000 0.163265 0.727273 9 0.562500 0.037037 0.840000 0.306122 0.818182 10 0.312500 0.370370 0.080000 0.448980 0.909091 i4mat_01_rowcolsum_test(): i4mat_01_rowcolsum() constructs a 01 matrix with given row and column sums. The rowsum vector: 1: 3 2: 2 3: 2 4: 1 5: 1 The columnsum vector: 1: 2 2: 2 3: 2 4: 2 5: 1 The rowcolsum matrix: Col: 1 2 3 4 5 Row 1: 1 0 1 0 1 2: 1 0 0 1 0 3: 0 1 0 1 0 4: 0 1 0 0 0 5: 0 0 1 0 0 i4mat_perm1_test i4mat_perm1() reorders an integer matrix in place. The rows and columns use the same permutation. The input matrix: Col: 1 2 3 4 5 6 7 8 9 Row 1: 11 12 13 14 15 16 17 18 19 2: 21 22 23 24 25 26 27 28 29 3: 31 32 33 34 35 36 37 38 39 4: 41 42 43 44 45 46 47 48 49 5: 51 52 53 54 55 56 57 58 59 6: 61 62 63 64 65 66 67 68 69 7: 71 72 73 74 75 76 77 78 79 8: 81 82 83 84 85 86 87 88 89 9: 91 92 93 94 95 96 97 98 99 The row and column permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 The permuted matrix: Col: 1 2 3 4 5 6 7 8 9 Row 1: 99 91 92 98 97 94 95 96 93 2: 19 11 12 18 17 14 15 16 13 3: 29 21 22 28 27 24 25 26 23 4: 89 81 82 88 87 84 85 86 83 5: 79 71 72 78 77 74 75 76 73 6: 49 41 42 48 47 44 45 46 43 7: 59 51 52 58 57 54 55 56 53 8: 69 61 62 68 67 64 65 66 63 9: 39 31 32 38 37 34 35 36 33 i4mat_2perm1_test(): i4mat_2perm1() reorders an integer matrix in place. Rows and columns use different permutations. The input matrix: Col: 1 2 3 4 5 6 7 Row 1: 11 12 13 14 15 16 17 2: 21 22 23 24 25 26 27 3: 31 32 33 34 35 36 37 4: 41 42 43 44 45 46 47 5: 51 52 53 54 55 56 57 6: 61 62 63 64 65 66 67 7: 71 72 73 74 75 76 77 8: 81 82 83 84 85 86 87 9: 91 92 93 94 95 96 97 The row permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 The column permutation: 1 2 3 4 5 6 7 3 4 5 6 7 1 2 The permuted matrix: Col: 1 2 3 4 5 6 7 Row 1: 96 97 91 92 93 94 95 2: 16 17 11 12 13 14 15 3: 26 27 21 22 23 24 25 4: 86 87 81 82 83 84 85 5: 76 77 71 72 73 74 75 6: 46 47 41 42 43 44 45 7: 56 57 51 52 53 54 55 8: 66 67 61 62 63 64 65 9: 36 37 31 32 33 34 35 i4mat_u1_inverse_test(): i4mat_u1_inverse() inverts a unit upper triangular matrix. The original matrix: Col: 1 2 3 4 5 6 Row 1: 1 2 0 5 0 75 2: 0 1 0 0 0 0 3: 0 0 1 3 0 0 4: 0 0 0 1 0 6 5: 0 0 0 0 1 4 6: 0 0 0 0 0 1 The inverse matrix: Col: 1 2 3 4 5 6 Row 1: 1 -2 0 -5 0 -45 2: 0 1 0 0 0 0 3: 0 0 1 -3 0 18 4: 0 0 0 1 0 -6 5: 0 0 0 0 1 -4 6: 0 0 0 0 0 1 The product: Col: 1 2 3 4 5 6 Row 1: 1 0 0 0 0 0 2: 0 1 0 0 0 0 3: 0 0 1 0 0 0 4: 0 0 0 1 0 0 5: 0 0 0 0 1 0 6: 0 0 0 0 0 1 i4mat_print_test(): i4mat_print() prints an I4MAT. The I4MAT: Col: 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 4: 41 42 43 44 5: 51 52 53 54 6: 61 62 63 64 i4mat_print_some_test(): i4mat_print_some() prints some of an I4MAT. The I4MAT, rows 2:4, cols 1:2: Col: 1 2 Row 2: 21 22 3: 31 32 4: 41 42 i4poly_test(): i4poly() converts between power sum, factorial and Taylor forms, and can evaluate a polynomial All calls have input A as follows: 0 0 0 0 0 1 Option IOPT = -3 Output array: 0 24 -50 35 -10 1 Option IOPT = -2 Output array: 0 1 15 25 10 1 Option IOPT = -1 X0 = 2 Value = 0 Option IOPT = 0 X0 = 2 Value = 32 Option IOPT = 6 X0 = 2 Output array: 32 80 80 40 10 1 Option IOPT = 6 X0 = -2 Output array: -32 80 -80 40 -10 1 i4poly_add_test(): i4poly_add() adds two I4POLY's. Polynomial A: p(x) = 5 * x^5 +4 * x^4 +3 * x^3 +2 * x^2 +1 * x Polynomial B: p(x) = -5 * x^5 +8 * x^3 +7 * x^2 -2 * x +1 Polynomial C = A+B: p(x) = 4 * x^4 +11 * x^3 +9 * x^2 -1 * x +1 i4poly_cyclo_test(): i4poly_cyclo() computes cyclotomic polynomials. N = 0 The cyclotomic polynomial: p(x) = 1 N = 1 The cyclotomic polynomial: p(x) = 1 * x -1 N = 2 The cyclotomic polynomial: p(x) = 1 * x +1 N = 3 The cyclotomic polynomial: p(x) = 1 * x^2 +1 * x +1 N = 4 The cyclotomic polynomial: p(x) = 1 * x^2 +1 N = 5 The cyclotomic polynomial: p(x) = 1 * x^4 +1 * x^3 +1 * x^2 +1 * x +1 N = 6 The cyclotomic polynomial: p(x) = 1 * x^2 -1 * x +1 N = 7 The cyclotomic polynomial: p(x) = 1 * x^6 +1 * x^5 +1 * x^4 +1 * x^3 +1 * x^2 +1 * x +1 N = 8 The cyclotomic polynomial: p(x) = 1 * x^4 +1 N = 9 The cyclotomic polynomial: p(x) = 1 * x^6 +1 * x^3 +1 N = 10 The cyclotomic polynomial: p(x) = 1 * x^4 -1 * x^3 +1 * x^2 -1 * x +1 i4poly_degree_test(): i4poly_degree() returns the degree of an I4POLY. The polynomial: p(x) = 7 * x^7 +6 * x^6 +4 * x^4 +3 * x^3 +1 * x The polynomial degree is 7 i4poly_dif_test(): i4poly_dif() computes derivatives of an I4POLY. The polynomial A: p(x) = 1 * x^3 +2 * x^2 -5 * x -6 Differentiate A 1 times. The derivative, B: p(x) = 3 * x^2 +4 * x -5 The polynomial A: p(x) = 1 * x^4 +3 * x^3 +2 * x^2 +5 * x -2 Differentiate A 3 times. The derivative, B: p(x) = 24 * x +18 i4poly_div_test(): i4poly_div() computes the quotient and remainder for polynomial division. The polynomial to be divided, A: p(x) = 1 * x^3 +2 * x^2 -5 * x -6 The divisor polynomial, B: p(x) = 1 * x -2 The quotient polynomial, Q: p(x) = 1 * x^2 +4 * x +3 The remainder polynomial, R: p(x) = 0 The polynomial to be divided, A: p(x) = 1 * x^4 +3 * x^3 +2 * x^2 +5 * x -2 The divisor polynomial, B: p(x) = 1 * x^2 +1 * x -3 The quotient polynomial, Q: p(x) = 1 * x^2 +2 * x +3 The remainder polynomial, R: p(x) = 8 * x +7 i4poly_mul_test(): i4poly_mul() multiplies two polynomials. The factor A: p(x) = 1 * x +1 The factor B: p(x) = -1 * x +1 The product C = A*B: p(x) = -1 * x^2 +1 The factor A: p(x) = 3 * x^2 +2 * x +1 The factor B: p(x) = -2 * x +1 The product C = A*B: p(x) = -6 * x^3 -1 * x^2 +1 i4poly_print_test(): i4poly_print() prints an I4POLY. The polynomial: p(x) = 1 * x^4 +3 * x^3 +2 * x^2 +5 * x -2 i4poly_to_i4_test(): i4poly_to_i4() evaluates an integer polynomial. I BASE DEGREE Coefficients 1 2 0 1 6 2 2 1 1 0 23 2 4 1 0 1 1 1 23 3 2 2 1 2 23 4 2 1 1 3 23 5 1 4 3 23 6 1 3 5 23 23 1 1 0 23 24 0 23 Now let I4_TO_I4POLY convert I to a polynomial, use I4POLY_TO_I4 to evaluate it, and compare. I I2 1 1 6 6 23 23 23 23 23 23 23 23 23 23 23 23 23 23 i4vec_backtrack_test(): i4vec_backtrack() uses backtracking, seeking a vector X of N values which satisfies some condition. In this demonstration, we have 8 integers W(I). We seek all subsets that sum to 53. X(I) is 0 or 1 if the entry is skipped or used. 1 53: 15 22 16 2 53: 15 14 16 8 3 53: 22 14 9 8 Done! i4vec_frac_test(): i4vec_frac(): K-th smallest integer vector entry. The array to search: 1: 14 2: 16 3: 8 4: 14 5: 9 6: 17 7: 17 8: 6 9: 13 10: 12 Fractile Value 1 6 6 14 i4vec_index_test(): i4vec_index(): first index of given value; Input vector: 1: 1 2: 8 3: -5 4: -4 5: -8 6: 9 7: 3 8: 0 9: 3 10: 1 Index of first occurrence of -8 is 5 Index of first occurrence of -7 is -1 i4vec_indicator0_test(): i4vec_indicator0() returns an indicator vector. The "indicator0" vector: 1: 0 2: 1 3: 2 4: 3 5: 4 6: 5 7: 6 8: 7 9: 8 10: 9 i4vec_indicator1_test(): i4vec_indicator1() returns an indicator vector. The "indicator1" vector: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 i4vec_is_ascending_test(): i4vec_is_ascending() determines if an integer vector ascends. Test vector: 1: 1 2: 3 3: 2 4: 4 I4VEC_IS_ASCENDING = 0 Test vector: 1: 2 2: 2 3: 2 4: 2 I4VEC_IS_ASCENDING = 1 Test vector: 1: 1 2: 2 3: 2 4: 4 I4VEC_IS_ASCENDING = 1 Test vector: 1: 1 2: 2 3: 3 4: 4 I4VEC_IS_ASCENDING = 1 Test vector: 1: 4 2: 4 3: 3 4: 1 I4VEC_IS_ASCENDING = 0 Test vector: 1: 9 2: 7 3: 3 4: 0 I4VEC_IS_ASCENDING = 0 i4vec_is_descending_test(): i4vec_is_descending() determines if an integer vector descends. Test vector: 1: 1 2: 3 3: 2 4: 4 I4VEC_IS_DESCENDING = 0 Test vector: 1: 2 2: 2 3: 2 4: 2 I4VEC_IS_DESCENDING = 1 Test vector: 1: 1 2: 2 3: 2 4: 4 I4VEC_IS_DESCENDING = 0 Test vector: 1: 1 2: 2 3: 3 4: 4 I4VEC_IS_DESCENDING = 0 Test vector: 1: 4 2: 4 3: 3 4: 1 I4VEC_IS_DESCENDING = 1 Test vector: 1: 9 2: 7 3: 3 4: 0 I4VEC_IS_DESCENDING = 1 i4vec_max_index_last_test(): i4vec_max_index_last(): last maximal index; Input vector: 1: 3 2: 1 3: 5 4: 0 5: 10 6: -6 7: -8 8: -8 9: -9 10: -2 Last maximum index: 5 i4vec_pairwise_prime_test(): i4vec_pairwise_prime() determines if a vector of integers is pairwise prime. Pairwise Row Vector Prime? 1 3 2 4 0 2 2 2 2 0 5 7 12 29 1 1 13 1 11 1 1 4 9 16 0 6 35 13 77 0 i4vec_print_test(): i4vec_print() prints an I4VEC The I4VEC: 1: 91 2: 92 3: 93 4: 94 i4vec_reverse_test(): i4vec_reverse() reverses a list of integers. Original vector: 1: 14 2: 11 3: 23 4: 19 5: 24 6: 28 7: 30 8: 6 9: 5 10: 21 Reversed: 1: 21 2: 5 3: 6 4: 30 5: 28 6: 24 7: 19 8: 23 9: 11 10: 14 i4vec_sort_bubble_a_test(): i4vec_sort_bubble_a() ascending sorts, Unsorted: 1: 5 2: 32 3: 32 4: 52 5: 29 6: 24 7: 40 8: 45 9: 31 10: 21 11: 9 12: 35 13: 15 14: 2 15: 46 16: 14 17: 26 18: 41 19: 21 20: 44 Ascending sorted: 1: 2 2: 5 3: 9 4: 14 5: 15 6: 21 7: 21 8: 24 9: 26 10: 29 11: 31 12: 32 13: 32 14: 35 15: 40 16: 41 17: 44 18: 45 19: 46 20: 52 i4vec_sort_heap_index_d_test(): i4vec_sort_heap_index_d() creates a descending sort index for an integer array. Unsorted array: 1: 24 2: 41 3: 42 4: 26 5: 1 6: 20 7: 25 8: 16 9: 12 10: 50 11: 26 12: 54 13: 23 14: 46 15: 24 16: 49 17: 46 18: 23 19: 13 20: 48 Sort vector INDX: 1: 12 2: 10 3: 16 4: 20 5: 17 6: 14 7: 3 8: 2 9: 11 10: 4 11: 7 12: 15 13: 1 14: 13 15: 18 16: 6 17: 8 18: 19 19: 9 20: 5 I, INDX(I), A(INDX(I)) 1 12 54 2 10 50 3 16 49 4 20 48 5 17 46 6 14 46 7 3 42 8 2 41 9 11 26 10 4 26 11 7 25 12 15 24 13 1 24 14 13 23 15 18 23 16 6 20 17 8 16 18 19 13 19 9 12 20 5 1 i4vec_transpose_print_test(): i4vec_transpose_print() prints an integer vector with 5 entries to a row, and a title. Output from I4VEC_PRINT: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 11: 11 12: 12 My array: 1 2 3 4 5 6 7 8 9 10 11 12 index_box_next_2d_test(): index_box_next_2d() produces IJ indices that lie on the surface of a box in 2D. The box has logical dimensions: 5 by 3 # I J 1 1 1 2 1 2 3 1 3 4 2 1 5 2 3 6 3 1 7 3 3 8 4 1 9 4 3 10 5 1 11 5 2 12 5 3 index_box_next_3d_test(): index_box_next_3d() produces IJK indices that lie on the surface of a box. The box has logical dimensions: 5 3 4 # I J K 1 1 1 1 2 1 1 2 3 1 1 3 4 1 1 4 5 1 2 1 6 1 2 2 7 1 2 3 8 1 2 4 9 1 3 1 10 1 3 2 11 1 3 3 12 1 3 4 13 2 1 1 14 2 1 2 15 2 1 3 16 2 1 4 17 2 2 1 18 2 2 4 19 2 3 1 20 2 3 2 21 2 3 3 22 2 3 4 23 3 1 1 24 3 1 2 25 3 1 3 26 3 1 4 27 3 2 1 28 3 2 4 29 3 3 1 30 3 3 2 31 3 3 3 32 3 3 4 33 4 1 1 34 4 1 2 35 4 1 3 36 4 1 4 37 4 2 1 38 4 2 4 39 4 3 1 40 4 3 2 41 4 3 3 42 4 3 4 43 5 1 1 44 5 1 2 45 5 1 3 46 5 1 4 47 5 2 1 48 5 2 2 49 5 2 3 50 5 2 4 51 5 3 1 52 5 3 2 53 5 3 3 54 5 3 4 index_box2_next_2d_test(): index_box2_next_2d() produces IJ indices that lie on the surface of a box2 in 2D. The box has half-widths: 4 3 and has center cell: 10 20 # I J 1 6 17 2 6 18 3 6 19 4 6 20 5 6 21 6 6 22 7 6 23 8 7 17 9 7 23 10 8 17 11 8 23 12 9 17 13 9 23 14 10 17 15 10 23 16 11 17 17 11 23 18 12 17 19 12 23 20 13 17 21 13 23 22 14 17 23 14 18 24 14 19 25 14 20 26 14 21 27 14 22 28 14 23 index_box2_next_3d_test(): index_box2_next_3d() produces IJK indices that lie on the surface of a box. The box has half widths: 5 3 4 and central cell: 10 20 30 We will only print a PORTION of the data! # I J K 1 5 17 26 2 5 17 27 3 5 17 28 4 5 17 29 5 5 17 30 6 5 17 31 7 5 17 32 8 5 17 33 9 5 17 34 10 5 18 26 370 15 23 26 371 15 23 27 372 15 23 28 373 15 23 29 374 15 23 30 375 15 23 31 376 15 23 32 377 15 23 33 378 15 23 34 index_next0_test(): index_next0() generates all indices of an array of given shape, with lower limit 1 and given upper limit. Number of index entries = 3 Coordinate maximum HI = 3 Index arrays: 1 1 1 2 1 1 3 1 1 1 2 1 2 2 1 3 2 1 1 3 1 2 3 1 3 3 1 1 1 2 2 1 2 3 1 2 1 2 2 2 2 2 3 2 2 1 3 2 2 3 2 3 3 2 1 1 3 2 1 3 3 1 3 1 2 3 2 2 3 3 2 3 1 3 3 2 3 3 3 3 3 index_next1_test(): index_next1() generates all indices of an array of given shape, with lower limit 1 and given upper limits. Number of index entries = 3 Coordinate maximum indices: 1: 4 2: 2 3: 3 Index arrays: 1 1 1 2 1 1 3 1 1 4 1 1 1 2 1 2 2 1 3 2 1 4 2 1 1 1 2 2 1 2 3 1 2 4 1 2 1 2 2 2 2 2 3 2 2 4 2 2 1 1 3 2 1 3 3 1 3 4 1 3 1 2 3 2 2 3 3 2 3 4 2 3 index_next2_test(): index_next2() generates all indices of an array of given shape with given lower and upper limits. Number of index entries = 3 Coordinate, Maximum Index 1 10 11 2 -5 -3 3 0 1 Index arrays: 10 -5 0 11 -5 0 10 -4 0 11 -4 0 10 -3 0 11 -3 0 10 -5 1 11 -5 1 10 -4 1 11 -4 1 10 -3 1 11 -3 1 index_rank0_test(): index_rank0() ranks an index with lower limit 1 and given upper limit. Number of index entries = 3 Coordinate maximum Index = 3 The index array: 1: 3 2: 1 3: 2 The rank of this object is 12 index_rank1_test(): index_rank1() ranks an index with lower limit 1 and given upper limits. Number of index entries = 3 Coordinate, Maximum Index 1 4 2 2 3 3 The index array: 1: 4 2: 1 3: 2 The rank of this object is 12 index_rank2_test(): index_rank2() ranks an index with given lower and upper limits. Number of index entries = 3 Coordinate, Minimum index, Maximum Index 1 1 2 2 10 11 3 4 6 The index array: 1: 1 2: 11 3: 5 The rank of this object is 7 index_unrank0_test(): index_unrank0() unranks a multi-index. The multi-index has dimension 3 The upper limit is HI = 3 Rank, Multi-Index: 1 1 1 1 2 2 1 1 3 3 1 1 4 1 2 1 5 2 2 1 6 3 2 1 7 1 3 1 8 2 3 1 9 3 3 1 10 1 1 2 11 2 1 2 12 3 1 2 13 1 2 2 14 2 2 2 15 3 2 2 16 1 3 2 17 2 3 2 18 3 3 2 19 1 1 3 20 2 1 3 21 3 1 3 22 1 2 3 23 2 2 3 24 3 2 3 25 1 3 3 26 2 3 3 27 3 3 3 index_unrank1_test(): index_unrank1() unranks a multi-index. The multi-index has dimension 3 The upper limits are: 1 4 2 2 3 3 Rank, Multi-Index: 1 1 1 1 2 2 1 1 3 3 1 1 4 4 1 1 5 1 2 1 6 2 2 1 7 3 2 1 8 4 2 1 9 1 1 2 10 2 1 2 11 3 1 2 12 4 1 2 13 1 2 2 14 2 2 2 15 3 2 2 16 4 2 2 17 1 1 3 18 2 1 3 19 3 1 3 20 4 1 3 21 1 2 3 22 2 2 3 23 3 2 3 24 4 2 3 index_unrank2_test(): index_unrank2() unranks a multi-index. The multi-index has dimension 3 The lower and upper limits are: 1 1 2 2 10 11 3 4 6 Rank, Multi-Index: 7 1 11 5 inverse_mod_n_test(): inverse_mod_n() seeks Y, the inverse of B mod N, so that mod ( B * Y, N ) = 1, but returns 0 if the inverse does not exist. B N Y Z = mod ( B * Y, N ) 1 2 1 1 1 3 1 1 2 3 2 1 1 4 1 1 2 4 0 0 3 4 3 1 1 5 1 1 2 5 3 1 3 5 2 1 4 5 4 1 1 6 1 1 2 6 0 0 3 6 0 0 4 6 0 0 5 6 5 1 1 7 1 1 2 7 4 1 3 7 5 1 4 7 2 1 5 7 3 1 6 7 6 1 1 8 1 1 2 8 0 0 3 8 3 1 4 8 0 0 5 8 5 1 6 8 0 0 7 8 7 1 1 9 1 1 2 9 5 1 3 9 0 0 4 9 7 1 5 9 2 1 6 9 0 0 7 9 4 1 8 9 8 1 1 10 1 1 2 10 0 0 3 10 7 1 4 10 0 0 5 10 0 0 6 10 0 0 7 10 3 1 8 10 0 0 9 10 9 1 inversion_to_perm1_test(): inversion_to_perm1(): inversion => permutation (1,...,N). 1 2 3 4 5 3 5 1 4 2 0 0 2 1 3 3 5 1 4 2 involute_enum_test(): involute_enum() counts involutions; N # of involutions 0 1 1 1 2 2 3 4 4 10 5 26 6 76 7 232 8 764 9 2620 10 9496 jfrac_to_rfrac_test(): jfrac_to_rfrac() converts a J fraction to a rational polynomial fraction. The original rational polynomial coefficients: 0.949304 0.327565 0.671264 0.438645 0.833501 0.768854 1.080782 5.570064 6.396492 3.324172 5.714169 3.799788 1.000000 The J fraction coefficients: 0.768854 2.199604 -1.342249 3.043480 0.035078 1091.570825 2.715706 0.674125 -0.837976 0.399929 33.476780 -32.628777 The recovered rational polynomial: 0.949304 0.327565 0.671264 0.438645 0.833501 0.768854 1.080782 5.570064 6.396492 3.324172 5.714169 3.799788 1.000000 josephus_test(): josephus() solves Josephus problems. N M K X 41 3 41 31 41 -38 41 31 41 3 40 16 64 2 64 1 1000 2 1000 977 ksub_next_test(): ksub_next() generates all K subsets of an N set in lexicographic order. 1 1 2 3 2 1 2 4 3 1 2 5 4 1 3 4 5 1 3 5 6 1 4 5 7 2 3 4 8 2 3 5 9 2 4 5 10 3 4 5 ksub_next2_test(): ksub_next2() generates the next K subset of an N set by the revolving door method. Rank Subset Added Removed 1 1 2 3 0 0 2 1 3 4 4 2 3 2 3 4 2 1 4 1 2 4 1 3 5 1 4 5 5 2 6 2 4 5 2 1 7 3 4 5 3 2 8 1 3 5 1 4 9 2 3 5 2 1 10 1 2 5 1 3 ksub_next3_test(): ksub_next3() generates all K subsets of an N set using the revolving door method. Rank Subset Added Removed 1 1 2 3 0 0 2 1 3 4 4 2 3 2 3 4 2 1 4 1 2 4 1 3 5 1 4 5 5 2 6 2 4 5 2 1 7 3 4 5 3 2 8 1 3 5 1 4 9 2 3 5 2 1 10 1 2 5 1 3 ksub_next4_test(): ksub_next4() generates K subsets of an N set. N = 5 K = 3 Rank Subset 1 1 2 3 2 1 2 4 3 1 3 4 4 2 3 4 5 1 2 5 6 1 3 5 7 2 3 5 8 1 4 5 9 2 4 5 10 3 4 5 ksub_random_test(): ksub_random() generates a random K subset of an N set. Set size is N = 5 Subset size is K = 3 1 3 5 1 2 4 1 3 5 1 4 5 2 3 4 ksub_random2_test(): ksub_random2() generates a random K subset of an N set. Set size is N = 5 Subset size is K = 3 1 4 5 2 3 5 3 4 5 1 2 3 2 4 5 ksub_random3_test(): ksub_random3() generates a random K-subset of an N-set. Set size is N = 5 Subset size is K = 3 1 1 0 1 0 1 1 1 0 0 1 1 0 1 0 1 0 0 1 1 0 1 1 1 0 0 1 1 0 1 1 1 1 0 0 0 1 1 1 0 1 0 1 1 0 1 1 0 0 1 ksub_random4_test(): ksub_random4() generates a random K-subset of an N-set. Set size is N = 5 Subset size is K = 3 3 4 5 1 3 5 1 2 5 1 2 3 1 2 3 3 4 5 2 4 5 1 3 4 1 2 5 3 4 5 ksub_random5_test(): ksub_random5() generates a random K-subset of an N-set. Set size is N = 52 Subset size is K = 5 9 18 35 47 52 18 24 29 38 52 8 13 25 40 43 4 13 19 20 29 2 11 26 36 48 ksub_rank_test(): ksub_rank() returns rank of a K subset of an N set. For N = 5 and K = 3 the subset is: 1 3 5 The rank is 6 ksub_to_comp_test(): ksub_to_comp() returns the composition corresponding to a K subset. COMP: 0 3 2 2 3 KSUB: 1 5 8 11 COMP: 0 3 2 2 3 COMP: 0 0 1 2 7 KSUB: 1 2 4 7 COMP: 0 0 1 2 7 COMP: 2 2 0 1 5 KSUB: 3 6 7 9 COMP: 2 2 0 1 5 COMP: 3 0 3 2 2 KSUB: 4 5 9 12 COMP: 3 0 3 2 2 COMP: 1 0 6 2 1 KSUB: 2 3 10 13 COMP: 1 0 6 2 1 ksub_to_compnz_test(): ksub_to_compnz() returns the nonzero composition corresponding to a K subset. KSUB: 1 6 7 13 COMPNZ: 1 5 1 6 2 KSUB: 1 2 6 8 COMPNZ: 1 1 4 2 7 KSUB: 1 8 12 13 COMPNZ: 1 7 4 1 2 KSUB: 5 6 7 12 COMPNZ: 5 1 1 5 3 KSUB: 3 5 7 9 COMPNZ: 3 2 2 2 6 ksub_unrank_test(): ksub_unrank() finds the K-subset of an N set of a given rank. N is 5 K is 3 and the desired rank is 8 The subset of the given rank is: 1 4 5 l4vec_next_test(): l4vec_next() generates logical vectors. 000 001 010 011 100 101 110 111 matrix_product_opt_test(): matrix_product_opt() seeks the optimal order for a chain of matrix products. Matrix ranks: I R C 1 4 2 2 2 3 3 3 1 4 1 2 5 2 2 6 2 3 Optimal cost is 36 Ordering: 1: 2 2: 1 3: 4 4: 5 5: 3 moebius_matrix_test(): moebius_matrix() computes the Moebius matrix. The input matrix: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 0 0 0 0 0 1 0 0 0 1 2: 0 0 1 1 0 0 0 0 0 0 3: 1 0 0 0 0 0 0 0 1 0 4: 1 0 0 0 1 0 0 0 1 0 5: 0 0 0 0 0 1 0 0 0 0 6: 0 0 0 0 0 0 1 0 0 0 7: 0 0 0 0 0 0 0 0 0 0 8: 0 1 0 0 0 0 0 0 0 0 9: 0 0 0 0 0 1 0 0 0 1 10: 0 0 0 0 0 0 1 0 0 0 11: 0 0 0 0 0 0 1 0 0 0 Col: 11 Row 1: 0 2: 0 3: 0 4: 0 5: 0 6: 0 7: 0 8: 0 9: 1 10: 0 11: 0 mu = 1 1 1 1 2 1 2 5 4 2 11 0 1 1 1 2 1 2 5 4 2 11 0 0 1 0 1 0 1 2 2 1 5 0 0 0 1 1 1 1 3 2 1 6 0 0 0 0 1 0 0 1 1 0 2 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 1 1 1 1 3 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 The Moebius matrix: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 1 0 0 0 0 -1 1 0 0 -1 2: 1 1 -1 -1 0 -1 1 0 1 -1 3: -1 0 1 0 0 1 -1 0 -1 1 4: -1 0 0 1 -1 2 -1 0 -1 1 5: 0 0 0 0 1 -1 0 0 0 0 6: 0 0 0 0 0 1 -1 0 0 0 7: 0 0 0 0 0 0 1 0 0 0 8: 0 -1 0 0 0 0 0 1 0 0 9: 0 0 0 0 0 -1 2 0 1 -1 10: 0 0 0 0 0 0 -1 0 0 1 11: 0 0 0 0 0 0 -1 0 0 0 Col: 11 Row 1: 0 2: 0 3: 0 4: 0 5: 0 6: 0 7: 0 8: 0 9: -1 10: 0 11: 1 monomial_count_test(): monomial_count() counts the number of monomials of degrees 0 through DEGREE_MAX in a space of dimension DIM. Dim Count 1 10 2 55 3 220 4 715 5 2002 6 5005 monomial_counts_test(): monomial_counts() counts the number of monomials of degrees 0 through DEGREE_MAX in a space of dimension DIM. DIM = 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 Total 10 DIM = 2 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 Total 55 DIM = 3 0 1 1 3 2 6 3 10 4 15 5 21 6 28 7 36 8 45 9 55 Total 220 DIM = 4 0 1 1 4 2 10 3 20 4 35 5 56 6 84 7 120 8 165 9 220 Total 715 DIM = 5 0 1 1 5 2 15 3 35 4 70 5 126 6 210 7 330 8 495 9 715 Total 2002 DIM = 6 0 1 1 6 2 21 3 56 4 126 5 252 6 462 7 792 8 1287 9 2002 Total 5005 morse_thue_test(): morse_thue() computes the Morse-Thue numbers. 0110100110 0101101001 0110011010 0110010110 0110100101 1010011001 0110100101 1001101001 0110100110 0101100110 1 multinomial_coef1_test(): multinomial_coef1() computes multinomial coefficients using the Gamma function; Line 10 of the BINOMIAL table: 0 10 1 1 9 10 2 8 45 3 7 120 4 6 210 5 5 252 6 4 210 7 3 120 8 2 45 9 1 10 10 0 1 Level 5 of the TRINOMIAL coefficients: 0 0 5 1 0 1 4 5 0 2 3 10 0 3 2 10 0 4 1 5 0 5 0 1 1 0 4 5 1 1 3 20 1 2 2 30 1 3 1 20 1 4 0 5 2 0 3 10 2 1 2 30 2 2 1 30 2 3 0 10 3 0 2 10 3 1 1 20 3 2 0 10 4 0 1 5 4 1 0 5 5 0 0 1 multinomial_coef2_test(): multinomial_coef2() computes multinomial coefficients directly. Line 10 of the BINOMIAL table: 0 10 1 1 9 10 2 8 45 3 7 120 4 6 210 5 5 252 6 4 210 7 3 120 8 2 45 9 1 10 10 0 1 Level 5 of the TRINOMIAL coefficients: 0 0 5 1 0 1 4 5 0 2 3 10 0 3 2 10 0 4 1 5 0 5 0 1 1 0 4 5 1 1 3 20 1 2 2 30 1 3 1 20 1 4 0 5 2 0 3 10 2 1 2 30 2 2 1 30 2 3 0 10 3 0 2 10 3 1 1 20 3 2 0 10 4 0 1 5 4 1 0 5 5 0 0 1 multiperm_enum_test(): multiperm_enum() enumerates multipermutations. N is the number of objects to be permuted. K is the number of distinct types of objects. COUNTS is the number of objects of each type. NUMBER is the number of multipermutations. Number N K Counts(1:K) 30 5 3 2 1 2 120 5 5 1 1 1 1 1 30 5 3 1 2 2 60 5 4 1 1 1 2 1 5 1 5 multiperm_next_test(): multiperm_next() computes multipermutations in lexical order. 1 1 2 2 3 3 3 2 1 2 3 2 3 3 3 1 2 3 3 2 3 4 1 2 3 3 3 2 5 1 3 2 2 3 3 6 1 3 2 3 2 3 7 1 3 2 3 3 2 8 1 3 3 2 2 3 9 1 3 3 2 3 2 10 1 3 3 3 2 2 11 2 1 2 3 3 3 12 2 1 3 2 3 3 13 2 1 3 3 2 3 14 2 1 3 3 3 2 15 2 2 1 3 3 3 16 2 2 3 1 3 3 17 2 2 3 3 1 3 18 2 2 3 3 3 1 19 2 3 1 2 3 3 20 2 3 1 3 2 3 21 2 3 1 3 3 2 22 2 3 2 1 3 3 23 2 3 2 3 1 3 24 2 3 2 3 3 1 25 2 3 3 1 2 3 26 2 3 3 1 3 2 27 2 3 3 2 1 3 28 2 3 3 2 3 1 29 2 3 3 3 1 2 30 2 3 3 3 2 1 31 3 1 2 2 3 3 32 3 1 2 3 2 3 33 3 1 2 3 3 2 34 3 1 3 2 2 3 35 3 1 3 2 3 2 36 3 1 3 3 2 2 37 3 2 1 2 3 3 38 3 2 1 3 2 3 39 3 2 1 3 3 2 40 3 2 2 1 3 3 41 3 2 2 3 1 3 42 3 2 2 3 3 1 43 3 2 3 1 2 3 44 3 2 3 1 3 2 45 3 2 3 2 1 3 46 3 2 3 2 3 1 47 3 2 3 3 1 2 48 3 2 3 3 2 1 49 3 3 1 2 2 3 50 3 3 1 2 3 2 51 3 3 1 3 2 2 52 3 3 2 1 2 3 53 3 3 2 1 3 2 54 3 3 2 2 1 3 55 3 3 2 2 3 1 56 3 3 2 3 1 2 57 3 3 2 3 2 1 58 3 3 3 1 2 2 59 3 3 3 2 1 2 60 3 3 3 2 2 1 nim_sum_test(): nim_sum() computes the Nim sum of two integers. I J Nim(I+J) I1, I2, I3 in decimal: 130 92 222 I1, I2, I3 in binary: 00000000000000000000000010000010 00000000000000000000000001011100 00000000000000000000000011011110 I1, I2, I3 in decimal: 7 423 416 I1, I2, I3 in binary: 00000000000000000000000000000111 00000000000000000000000110100111 00000000000000000000000110100000 I1, I2, I3 in decimal: 656 723 67 I1, I2, I3 in binary: 00000000000000000000001010010000 00000000000000000000001011010011 00000000000000000000000001000011 I1, I2, I3 in decimal: 531 108 639 I1, I2, I3 in binary: 00000000000000000000001000010011 00000000000000000000000001101100 00000000000000000000001001111111 I1, I2, I3 in decimal: 632 126 518 I1, I2, I3 in binary: 00000000000000000000001001111000 00000000000000000000000001111110 00000000000000000000001000000110 padovan_test(): padovan() computes the Padovan numbers. N P(N) 0 1 1 1 2 1 3 2 4 2 5 3 6 4 7 5 8 7 9 9 pell_basic_test(): pell_basic() solves the basic Pell equation. D X Y R 2 3 2 1 3 -7 -4 1 5 1 0 1 6 5 2 1 7 -8 -3 1 8 -3 -1 1 10 1 0 1 11 1 0 1 12 7 2 1 13 649 180 1 14 131 35 11 15 39 10 21 17 1 0 1 18 1 0 1 19 1 0 1 20 9 2 1 pell_next_test(): pell_next() computes the "next" solution of the Pell equation. D X Y R 2 3 2 1 17 12 1 3 -7 -4 1 97 56 1 5 1 0 1 1 0 1 6 5 2 1 49 20 1 7 -8 -3 1 127 48 1 8 -3 -1 1 17 6 1 10 1 0 1 1 0 1 11 1 0 1 1 0 1 12 7 2 1 97 28 1 13 649 180 1 842401 233640 1 14 131 35 11 34311 9170 121 15 39 10 21 3021 780 441 17 1 0 1 1 0 1 18 1 0 1 1 0 1 19 1 0 1 1 0 1 20 9 2 1 161 36 1 pell_number_test(): pell_number() evaluates the N-th Pell number. N P(N) 0 0 1 1 2 2 3 5 4 12 5 29 6 70 7 169 8 408 9 985 10 2378 pent_enum_test(): pent_enum() counts points in pentagons. N Pent(N) 0 0 1 1 2 5 3 12 4 22 5 35 6 51 7 70 8 92 9 117 10 145 perm_ascend_test(): perm_ascend() determines the length of the longest increasing subsequence in a permutation. The permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 The longest increasing subsequence has length 5 A longest increasing subsequence: 1: 2 2: 3 3: 6 4: 7 5: 8 perm_fixed_enum_test(): perm_fixed_enum() enumerates the permutations of N objects that leave M unchanged. For this test, N = 10 M F(N,M) 0 1334961 1 1334960 2 667485 3 222480 4 55650 5 11088 6 1890 7 240 8 45 9 0 10 1 perm0_check_test(): perm0_check() checks a permutation of 0,...,N-1. Permutation 1: 0 1 2 3 4 5 2 3 4 1 PERM0_CHECK - Warning! Permutation is missing the value 0. Permutation 2: 0 1 2 3 4 4 1 3 0 2 Permutation 3: 0 1 2 3 4 0 2 1 3 2 PERM0_CHECK - Warning! Permutation is missing the value 4. perm0_lex_next_test(): perm0_lex_next() generates permutations of (0,...,N-1). 0 1 2 3 0 1 3 2 0 2 1 3 0 2 3 1 0 3 1 2 0 3 2 1 1 0 2 3 1 0 3 2 1 2 0 3 1 2 3 0 1 3 0 2 1 3 2 0 2 0 1 3 2 0 3 1 2 1 0 3 2 1 3 0 2 3 0 1 2 3 1 0 3 0 1 2 3 0 2 1 3 1 0 2 3 1 2 0 3 2 0 1 3 2 1 0 perm0_print_test(): perm0_print() prints a permutation of (0,...,N-1). A 0-based permutation: 0 1 2 3 4 5 6 6 1 3 0 4 2 5 perm1_break_count_test(): perm1_break_count() counts the breaks in a permutation. The permutation: 1 2 3 4 5 6 4 5 2 1 6 3 The number of breaks is 5 perm1_canon_to_cycle_test(): perm1_canon_to_cycle() converts a permutation of (1,...,N) from canonical to cycle form. The permutation in canonical form: 1 2 3 4 5 6 4 5 2 1 6 3 The permutation in cycle form: 1 2 3 4 5 6 -4 5 -2 -1 6 3 perm1_check_test(): perm1_check() checks a permutation of (1,...,N). Permutation 1: 1 2 3 4 5 5 2 3 4 1 Permutation 2: 1 2 3 4 5 4 1 3 0 2 PERM1_CHECK - Warning! Permutation is missing the value 5. Permutation 3: 1 2 3 4 5 0 2 1 3 2 PERM1_CHECK - Warning! Permutation is missing the value 4. perm1_cycle_test(): perm1_cycle() analyzes a permutation of (1,...,N). The permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 NCYCLE = 3 ISGN = 1 The permutation in cycle form: 1 2 3 4 5 6 7 8 9 -2 3 9 -6 -7 8 5 4 1 perm1_cycle_max_test(): perm1_cycle_max() finds the length of a longest cycle in a permutation of 1 through N. The standard index form permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 The permutation in cycle form: 1 2 3 4 5 6 7 8 9 -1 2 3 9 -4 6 8 -5 7 The longest cycle length is 4 Now average over 1000 permutations of length 100: Cycle max probabilities: 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 0 0 7 0 0 8 0 0 9 0 0 10 0 0 11 0 0 12 0 0 13 0 0 14 0 0 15 0 0 16 0 0 17 0 0 18 0 0 19 0 0 20 0.001 0.001 21 0 0.001 22 0.001 0.002 23 0.001 0.003 24 0.003 0.006 25 0.004 0.01 26 0.004 0.014 27 0.001 0.015 28 0.004 0.019 29 0.006 0.025 30 0.005 0.03 31 0.01 0.04 32 0.011 0.051 33 0.009 0.06 34 0.009 0.069 35 0.009 0.078 36 0.014 0.092 37 0.012 0.104 38 0.009 0.113 39 0.015 0.128 40 0.019 0.147 41 0.016 0.163 42 0.029 0.192 43 0.014 0.206 44 0.009 0.215 45 0.023 0.238 46 0.017 0.255 47 0.015 0.27 48 0.018 0.288 49 0.018 0.306 50 0.018 0.324 51 0.017 0.341 52 0.018 0.359 53 0.011 0.37 54 0.018 0.388 55 0.016 0.404 56 0.026 0.43 57 0.015 0.445 58 0.014 0.459 59 0.018 0.477 60 0.013 0.49 61 0.012 0.502 62 0.013 0.515 63 0.017 0.532 64 0.018 0.55 65 0.01 0.56 66 0.013 0.573 67 0.015 0.588 68 0.015 0.603 69 0.019 0.622 70 0.016 0.638 71 0.011 0.649 72 0.015 0.664 73 0.012 0.676 74 0.013 0.689 75 0.017 0.706 76 0.011 0.717 77 0.008 0.725 78 0.008 0.733 79 0.012 0.745 80 0.009 0.754 81 0.014 0.768 82 0.021 0.789 83 0.01 0.799 84 0.011 0.81 85 0.014 0.824 86 0.01 0.834 87 0.012 0.846 88 0.014 0.86 89 0.007 0.867 90 0.021 0.888 91 0.019 0.907 92 0.015 0.922 93 0.01 0.932 94 0.013 0.945 95 0.011 0.956 96 0.005 0.961 97 0.01 0.971 98 0.008 0.979 99 0.011 0.99 100 0.01 1 perm1_cycle_stats_test(): perm1_cycle_stats() counts cycles of each length in a permutation of 1 through N. The standard index form permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 Cycle lengths: 1 0 2 1 3 1 4 1 5 0 6 0 7 0 8 0 9 0 Now average over 1000 permutations of length 100: Cycle length averages: 1 0.986 1 2 0.478 0.5 3 0.296 0.333333 4 0.261 0.25 5 0.187 0.2 6 0.183 0.166667 7 0.127 0.142857 8 0.124 0.125 9 0.094 0.111111 10 0.093 0.1 11 0.1 0.0909091 12 0.088 0.0833333 13 0.065 0.0769231 14 0.06 0.0714286 15 0.078 0.0666667 16 0.072 0.0625 17 0.069 0.0588235 18 0.047 0.0555556 19 0.04 0.0526316 20 0.053 0.05 21 0.054 0.047619 22 0.048 0.0454545 23 0.037 0.0434783 24 0.053 0.0416667 25 0.033 0.04 26 0.038 0.0384615 27 0.043 0.037037 28 0.045 0.0357143 29 0.041 0.0344828 30 0.034 0.0333333 31 0.029 0.0322581 32 0.035 0.03125 33 0.029 0.030303 34 0.032 0.0294118 35 0.031 0.0285714 36 0.035 0.0277778 37 0.019 0.027027 38 0.026 0.0263158 39 0.022 0.025641 40 0.032 0.025 41 0.018 0.0243902 42 0.031 0.0238095 43 0.024 0.0232558 44 0.026 0.0227273 45 0.02 0.0222222 46 0.028 0.0217391 47 0.02 0.0212766 48 0.025 0.0208333 49 0.022 0.0204082 50 0.021 0.02 51 0.015 0.0196078 52 0.017 0.0192308 53 0.028 0.0188679 54 0.014 0.0185185 55 0.021 0.0181818 56 0.015 0.0178571 57 0.012 0.0175439 58 0.014 0.0172414 59 0.016 0.0169492 60 0.016 0.0166667 61 0.018 0.0163934 62 0.019 0.016129 63 0.022 0.015873 64 0.018 0.015625 65 0.019 0.0153846 66 0.018 0.0151515 67 0.026 0.0149254 68 0.013 0.0147059 69 0.016 0.0144928 70 0.016 0.0142857 71 0.012 0.0140845 72 0.011 0.0138889 73 0.012 0.0136986 74 0.011 0.0135135 75 0.012 0.0133333 76 0.008 0.0131579 77 0.015 0.012987 78 0.016 0.0128205 79 0.012 0.0126582 80 0.012 0.0125 81 0.014 0.0123457 82 0.008 0.0121951 83 0.009 0.0120482 84 0.009 0.0119048 85 0.013 0.0117647 86 0.008 0.0116279 87 0.01 0.0114943 88 0.008 0.0113636 89 0.015 0.011236 90 0.011 0.0111111 91 0.007 0.010989 92 0.011 0.0108696 93 0.012 0.0107527 94 0.011 0.0106383 95 0.012 0.0105263 96 0.008 0.0104167 97 0.006 0.0103093 98 0.011 0.0102041 99 0.008 0.010101 100 0.011 0.01 perm1_cycle_to_canon_test(): perm1_cycle_to_canon() converts a permutation of (1,...,N) from cycle to canonical form. The permutation in cycle form: 1 2 3 4 5 6 -6 3 1 -5 4 -2 The permutation in canonical form: 1 2 3 4 5 6 4 5 2 1 6 3 perm1_cycle_to_index_test(): perm1_cycle_to_index() converts a permutation of (1,...,N) from cycle to standard index form. The standard index form permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 The permutation in cycle form: 1 2 3 4 5 6 7 8 9 -1 2 3 9 -4 6 8 -5 7 The standard index form permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 perm1_distance_test(): perm1_distance() computes the Ulam metric distance between two permutations of (1,...,N). Permutation P1 1 2 3 4 5 6 7 8 9 10 3 7 1 5 6 4 8 9 10 2 Permutation P2 1 2 3 4 5 6 7 8 9 10 6 7 9 2 8 5 1 4 3 10 Permutation P3 1 2 3 4 5 6 7 8 9 10 1 4 8 10 7 5 6 9 2 3 K(P1,P1) should be 0. K(P1,P1) = 0 K(P1,P2) should equal K(P2,P1). K(P1,P2) = 6 K(P2,P1) = 6 K(P1,P3) <= K(P1,P2) + K(P2,P3). K(P1,P3) = 5 K(P1,P2) = 6 K(P2,P3) = 6 K(P1,P2) + K(P2,P3) = 12 perm1_free_test(): perm1_free() returns the unused values in a partial permutation of (1,...,N). Partial permutation: (None) Values not yet used: 1 2 3 4 5 Partial permutation: 5 Values not yet used: 1 2 3 4 Partial permutation: 5 2 Values not yet used: 1 3 4 Partial permutation: 5 2 3 Values not yet used: 1 4 Partial permutation: 5 2 3 4 Values not yet used: 1 Partial permutation: 5 2 3 4 1 Values not yet used: (None) perm1_index_to_cycle_test(): perm1_index_to_cycle() converts a permutation of (1,...,N) from standard index to cycle form. The standard index form permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 The permutation in cycle form: 1 2 3 4 5 6 7 8 9 -1 2 3 9 -4 6 8 -5 7 The standard index form permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 perm1_inverse_test(): perm1_inverse() inverts a permutation of (1,...,N); The original permutation: 1 2 3 4 5 6 7 4 3 5 1 7 6 2 The inverted permutation: 1 2 3 4 5 6 7 4 7 2 1 3 6 5 perm1_inverse2_test(): perm1_inverse2() inverts a permutation of (1,...,N). The original permutation: 1 2 3 4 5 6 7 4 3 5 1 7 6 2 The inverted permutation: 1 2 3 4 5 6 7 4 7 2 1 3 6 5 perm1_inverse3_test(): perm1_inverse3() inverts a permutation of (1,...,N). The original permutation: 1 2 3 4 5 6 7 4 3 5 1 7 6 2 The inverted permutation: 1 2 3 4 5 6 7 4 7 2 1 3 6 5 perm1_lex_next_test(): perm1_lex_next() generates permutations of (1,...,N). 1 2 3 4 1 2 4 3 1 3 2 4 1 3 4 2 1 4 2 3 1 4 3 2 2 1 3 4 2 1 4 3 2 3 1 4 2 3 4 1 2 4 1 3 2 4 3 1 3 1 2 4 3 1 4 2 3 2 1 4 3 2 4 1 3 4 1 2 3 4 2 1 4 1 2 3 4 1 3 2 4 2 1 3 4 2 3 1 4 3 1 2 4 3 2 1 perm1_mul_test(): perm1_mul() multiplies two permutations of (1,...,N). Permutation P1: 1 2 3 4 5 2 1 5 4 3 Permutation P2: 1 2 3 4 5 5 2 1 3 4 Product permutation: 1 2 3 4 5 2 5 4 3 1 perm1_next_test(): perm1_next() generates permutations of (1,...,N). 1 2 3 4 2 1 3 4 3 1 2 4 1 3 2 4 2 3 1 4 3 2 1 4 4 2 1 3 2 4 1 3 1 4 2 3 4 1 2 3 2 1 4 3 1 2 4 3 1 3 4 2 3 1 4 2 4 1 3 2 1 4 3 2 3 4 1 2 4 3 1 2 4 3 2 1 3 4 2 1 2 4 3 1 4 2 3 1 3 2 4 1 2 3 4 1 perm1_next2_test(): perm1_next2() generates permutations of (1,...,N). 1 2 3 4 1 2 4 3 1 4 2 3 4 1 2 3 4 1 3 2 1 4 3 2 1 3 4 2 1 3 2 4 3 1 2 4 3 1 4 2 3 4 1 2 4 3 1 2 4 3 2 1 3 4 2 1 3 2 4 1 3 2 1 4 2 3 1 4 2 3 4 1 2 4 3 1 4 2 3 1 4 2 1 3 2 4 1 3 2 1 4 3 2 1 3 4 perm1_next3_test(): perm1_next3() generates permutations of (1,...,N). 1: 1 2 3 4 2: 1 2 4 3 3: 1 4 2 3 4: 4 1 2 3 5: 4 1 3 2 6: 1 4 3 2 7: 1 3 4 2 8: 1 3 2 4 9: 3 1 2 4 10: 3 1 4 2 11: 3 4 1 2 12: 4 3 1 2 13: 4 3 2 1 14: 3 4 2 1 15: 3 2 4 1 16: 3 2 1 4 17: 2 3 1 4 18: 2 3 4 1 19: 2 4 3 1 20: 4 2 3 1 21: 4 2 1 3 22: 2 4 1 3 23: 2 1 4 3 24: 2 1 3 4 perm1_print_test(): perm1_print() prints a permutation of (1,...,N). A 1-based permutation: 1 2 3 4 5 6 7 7 2 4 1 5 3 6 perm1_random_test(): perm1_random() produces a random permutation of (1,...,N); For this test, N = 4 1 2 3 4 2 1 3 4 2 1 3 4 3 1 2 4 3 2 4 1 perm1_random2_test() perm1_random2() produces a random permutation of (1,...,N). For this test, N = 4 1 4 3 2 1 4 2 3 1 2 3 4 2 3 1 4 1 3 4 2 perm1_rank_test(): perm1_rank() ranks a permutation of (1,...,N). The permutation: 1 2 3 4 1 4 2 3 The rank is: 3 perm1_sign_test(): perm1_sign() computes the sign of a permutation of (1,...,N). RANK SIGN Permutation 0 1 1 2 3 4 1 -1 1 2 4 3 2 1 1 3 2 4 3 1 1 3 4 2 4 1 1 4 2 3 5 -1 1 4 3 2 6 1 2 1 3 4 7 -1 2 1 4 3 8 -1 2 3 1 4 9 -1 2 3 4 1 10 -1 2 4 1 3 11 1 2 4 3 1 12 -1 3 1 2 4 13 -1 3 1 4 2 14 1 3 2 1 4 15 1 3 2 4 1 16 -1 3 4 1 2 17 -1 3 4 2 1 18 -1 4 1 2 3 19 1 4 1 3 2 20 1 4 2 1 3 21 -1 4 2 3 1 22 -1 4 3 1 2 23 -1 4 3 2 1 perm1_to_equiv_test(): perm1_to_equiv() returns the set partition or equivalence classes determined by a permutation of (1,...,N). The input permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 The partition: Set Size 1 4 :: 1 2 3 9 2 3 :: 4 6 8 3 2 :: 5 7 perm1_to_inversion_test(): perm1_to_inversion(): permutation (1,...,N) => inversion. 1 2 3 4 5 3 5 1 4 2 0 0 2 1 3 3 5 1 4 2 perm1_to_ytb_test(): perm1_to_ytb() converts a permutation of (1,...,N) to a Young tableau. The permutation: 1 2 3 4 5 6 7 7 2 4 1 5 3 6 The Young tableau: 1 3 5 6 2 4 7 perm1_unrank_test(): perm1_unrank() given a rank, computes the corresponding permutation of (1,...,N). The requested rank is 6 The permutation: 1 2 3 4 1 4 3 2 perrin_test(): perrin() computes the Perrin numbers. N P(N) 0 3 1 0 2 2 3 3 4 2 5 5 6 5 7 7 8 10 9 12 pord_check_test(): pord_check() checks a partial ordering. The partial ordering matrix: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 1 0 0 0 0 0 0 0 0 0 2: 0 1 0 1 0 1 0 1 0 0 3: 1 0 1 1 0 0 0 0 0 0 4: 0 0 0 1 0 0 0 0 0 0 5: 1 1 1 1 1 1 1 1 0 1 6: 0 0 0 1 0 1 0 1 0 0 7: 1 0 1 1 0 1 1 1 0 1 8: 0 0 0 1 0 0 0 1 0 0 9: 0 0 0 0 0 0 0 0 0 0 10: 1 0 1 1 0 0 0 1 0 1 CHECK FLAG = 0 0 means no error. 1 means illegal value of N. 2 means some A(I,J) and A(J,I) are both nonzero. power_mod_test(): power_mod() computes the remainder of a power of an integer modulo another integer. A = 7 N = 50 M = 11 mod ( A^N, M ) = 1 A = 3 N = 118 M = 119 mod ( A^N, M ) = 32 power_series1_test(): power_series1() composes a power series; Power series of G(x) = (1+F(x))^alpha N = 10 ALPHA = 7.000000 Series for F(x): 1.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 Series for G(x): 7.000000 21.000000 35.000000 35.000000 21.000000 7.000000 1.000000 0.000000 0.000000 0.000000 power_series2_test(): power_series2() composes a power series; Here we compute the power series of G(x) = exp(F(x))-1 The number of terms is N = 4 Series for F(x): -4.000000 0.000000 0.000000 0.000000 Series for G(x): -4.000000 8.000000 -10.666667 10.666667 power_series3_test(): power_series3() composes a power series; Power series of H(x) = G(F(x)) Number of terms, N = 4 Series for F(x): 1.000000 1.000000 0.000000 0.000000 Series for G(x): 1.000000 1.000000 0.000000 0.000000 Series for H(x): 1.000000 2.000000 2.000000 3.000000 power_series4_test(): power_series4() composes a power series; Power series of H(x) = G(1/F(x)) N = 10 Series for F(x): 1.000000 0.500000 0.333333 0.250000 0.200000 0.166667 0.142857 0.125000 0.111111 0.100000 Series for G(x): 1.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 Series for H(x): 1.000000 -0.500000 0.166667 -0.041667 0.008333 -0.001389 0.000198 -0.000025 0.000003 -0.000000 prime_test(): prime() returns primes from a table. Number of primes stored is 1600 I Prime(I) 1 2 2 3 3 5 4 7 5 11 6 13 7 17 8 19 9 23 10 29 1590 13411 1591 13417 1592 13421 1593 13441 1594 13451 1595 13457 1596 13463 1597 13469 1598 13477 1599 13487 1600 13499 pythag_triple_ijk_test(): pythag_triple_ijk() computes a primitive Pythagorean triple from i, j, k "coordinates". I J K A B C A^2+B^2 C^2 0 0 0 3 4 5 25 25 0 0 1 5 12 13 169 169 0 0 2 7 24 25 625 625 0 0 3 9 40 41 1681 1681 0 1 0 15 8 17 289 289 0 1 1 45 28 53 2809 2809 0 1 2 91 60 109 11881 11881 0 1 3 153 104 185 34225 34225 0 2 0 35 12 37 1369 1369 0 2 1 117 44 125 15625 15625 0 2 2 247 96 265 70225 70225 0 2 3 425 168 457 208849 208849 0 3 0 63 16 65 4225 4225 0 3 1 221 60 229 52441 52441 0 3 2 475 132 493 243049 243049 0 3 3 825 232 857 734449 734449 1 0 0 21 20 29 841 841 1 0 1 55 48 73 5329 5329 1 0 2 105 88 137 18769 18769 1 0 3 171 140 221 48841 48841 1 1 0 65 72 97 9409 9409 1 1 1 207 224 305 93025 93025 1 1 2 429 460 629 395641 395641 1 1 3 731 780 1069 1142761 1142761 1 2 0 133 156 205 42025 42025 1 2 1 455 528 697 485809 485809 1 2 2 969 1120 1481 2193361 2193361 1 2 3 1675 1932 2557 6538249 6538249 1 3 0 225 272 353 124609 124609 1 3 1 799 960 1249 1560001 1560001 1 3 2 1725 2068 2693 7252249 7252249 1 3 3 3003 3596 4685 21949225 21949225 2 0 0 119 120 169 28561 28561 2 0 1 297 304 425 180625 180625 2 0 2 555 572 797 635209 635209 2 0 3 893 924 1285 1651225 1651225 2 1 0 403 396 565 319225 319225 2 1 1 1265 1248 1777 3157729 3157729 2 1 2 2607 2576 3665 13432225 13432225 2 1 3 4429 4380 6229 38800441 38800441 2 2 0 855 832 1193 1423249 1423249 2 2 1 2905 2832 4057 16459249 16459249 2 2 2 6171 6020 8621 74321641 74321641 2 2 3 10653 10396 14885 221563225 221563225 2 3 0 1475 1428 2053 4214809 4214809 2 3 1 5217 5056 7265 52780225 52780225 2 3 2 11247 10904 15665 245392225 245392225 2 3 3 19565 18972 27253 742726009 742726009 3 0 0 697 696 985 970225 970225 3 0 1 1755 1748 2477 6135529 6135529 3 0 2 3293 3276 4645 21576025 21576025 3 0 3 5311 5280 7489 56085121 56085121 3 1 0 2325 2332 3293 10843849 10843849 3 1 1 7315 7332 10357 107267449 107267449 3 1 2 15089 15120 21361 456292321 456292321 3 1 3 25647 25696 36305 1318053025 1318053025 3 2 0 4905 4928 6953 48344209 48344209 3 2 1 16683 16756 23645 559086025 559086025 3 2 2 35453 35604 50245 2524560025 2524560025 3 2 3 61215 61472 86753 7526083009 7526083009 3 3 0 8437 8484 11965 143161225 143161225 3 3 1 29859 30020 42341 1792760281 1792760281 3 3 2 64385 64728 91297 8335142209 8335142209 3 3 3 112015 112608 158833 25227921889 25227921889 pythag_triple_next_test(): pythag_triple_next() computes the "next" Pythagorean triple. I J A B C A^2+B^2 C^2 2 1 3 4 5 25 25 3 2 5 12 13 169 169 4 1 15 8 17 289 289 4 3 7 24 25 625 625 5 2 21 20 29 841 841 5 4 9 40 41 1681 1681 6 1 35 12 37 1369 1369 6 3 27 36 45 2025 2025 6 5 11 60 61 3721 3721 7 2 45 28 53 2809 2809 7 4 33 56 65 4225 4225 7 6 13 84 85 7225 7225 8 1 63 16 65 4225 4225 8 3 55 48 73 5329 5329 8 5 39 80 89 7921 7921 8 7 15 112 113 12769 12769 9 2 77 36 85 7225 7225 9 4 65 72 97 9409 9409 9 6 45 108 117 13689 13689 9 8 17 144 145 21025 21025 10 1 99 20 101 10201 10201 r8_agm_test(): r8_agm() computes the arithmetic-geometric mean (AGM) of two nonnegative real numbers. X Y R8_AGM(X,Y) 4.495983 1.050189 2.463863 3.643373 3.465764 3.554014 8.695539 2.308269 4.977905 2.698475 7.081561 4.627091 6.315576 4.103083 5.149751 2.568734 5.040778 3.700854 5.492072 7.946544 6.662677 6.906778 4.206326 5.472962 6.849154 9.616849 8.174329 6.147766 2.595867 4.181206 r8_fall_test(): r8_fall() evaluates the falling factorial Fall(X,N). X N Exact Computed 5.0000 4 120 120 5.2500 4 163.16015625 163.16015625 5.5000 4 216.5625 216.5625 5.7500 4 281.66015625 281.66015625 6.0000 4 360 360 7.5000 0 1 1 7.5000 1 7.5 7.5 7.5000 2 48.75 48.75 7.5000 3 268.125 268.125 7.5000 4 1206.5625 1206.5625 7.5000 5 4222.96875 4222.96875 7.5000 6 10557.421875 10557.421875 7.5000 7 15836.1328125 15836.1328125 7.5000 8 7918.06640625 7918.06640625 7.5000 9 -3959.033203125 -3959.033203125 r8_rise_test(): r8_rise() evaluates the rising factorial Rise(X,N). X N Exact Computed 5.0000 4 1680 1680 5.2500 4 1962.59765625 1962.59765625 5.5000 4 2279.0625 2279.0625 5.7500 4 2631.97265625 2631.97265625 6.0000 4 3024 3024 7.5000 0 1 1 7.5000 1 7.5 7.5 7.5000 2 63.75 63.75 7.5000 3 605.625 605.625 7.5000 4 6359.0625 6359.0625 7.5000 5 73129.21875 73129.21875 7.5000 6 914115.234375 914115.234375 7.5000 7 12340555.6640625 12340555.6640625 7.5000 8 178938057.1289063 178938057.1289062 7.5000 9 2773539885.498047 2773539885.498047 r8_to_cfrac_test(): r8_to_cfrac() converts a real number to a sequence of continued fraction convergents. Use the real number R = 6.283185 6 6 1 6.000000 0.283185 3 19 3 6.333333 -0.050148 1 25 4 6.250000 0.033185 1 44 7 6.285714 -0.002529 7 333 53 6.283019 0.000166 2 710 113 6.283186 -0.000001 146 103993 16551 6.283185 0.000000 3 312689 49766 6.283185 -0.000000 r8_to_dec_test(): r8_to_dec() converts a real number to a decimal; The number of decimal digits is 5 R => A * 10^B => R2 -9.093055 -90931 -4 -9.093100 9.030268 90303 -4 9.030300 -5.043095 -50431 -4 -5.043100 -2.645035 -2645 -3 -2.645000 -8.939813 -89398 -4 -8.939800 0.925785 92579 -5 0.925790 7.852312 78523 -4 7.852300 -8.147556 -81476 -4 -8.147600 0.630521 63052 -5 0.630520 8.224223 82242 -4 8.224200 r8_to_rat_test(): r8_to_rat() converts a real number to a rational; The maximum number of digits allowed is 4 R => A / B => R2 -0.427975 -107 250 -0.428 1.52578 7629 5000 1.5258 -0.0788537 -789 10000 -0.0789 1.63367 16337 10000 1.6337 -1.29692 -12969 10000 -1.2969 -2.33716 -5843 2500 -2.3372 1.94615 19461 10000 1.9461 3.01985 30199 10000 3.0199 3.43636 8591 2500 3.4364 4.03265 20163 5000 4.0326 r8mat_det_test(): r8mat_det(): determinant of a real matrix. The 123/456/789 matrix: Col: 1 2 3 Row 1 : 1 2 3 2 : 4 5 6 3 : 7 8 9 Determinant of the 123/456/789 matrix is 0 The Hilbert matrix: Col: 1 2 3 4 Row 1 : 0.5 0.333333 0.25 0.2 2 : 0.333333 0.25 0.2 0.166667 3 : 0.25 0.2 0.166667 0.142857 4 : 0.2 0.166667 0.142857 0.125 Determinant of the Hilbert matrix is 2.36206e-09 The -1,2,-1 matrix: Col: 1 2 3 Row 1 : 2 -1 0 2 : -1 2 -1 3 : 0 -1 2 Determinant of the -1,2,-1 matrix is 4 r8mat_perm1_test(): r8mat_perm1() reorders a real matrix in place. The rows and columns use the same permutation. The original matrix Col: 1 2 3 4 5 Row 1 : 11 12 13 14 15 2 : 21 22 23 24 25 3 : 31 32 33 34 35 4 : 41 42 43 44 45 5 : 51 52 53 54 55 6 : 61 62 63 64 65 7 : 71 72 73 74 75 8 : 81 82 83 84 85 9 : 91 92 93 94 95 Col: 6 7 8 9 Row 1 : 16 17 18 19 2 : 26 27 28 29 3 : 36 37 38 39 4 : 46 47 48 49 5 : 56 57 58 59 6 : 66 67 68 69 7 : 76 77 78 79 8 : 86 87 88 89 9 : 96 97 98 99 The row and column permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 The permuted matrix Col: 1 2 3 4 5 Row 1 : 99 91 92 98 97 2 : 19 11 12 18 17 3 : 29 21 22 28 27 4 : 89 81 82 88 87 5 : 79 71 72 78 77 6 : 49 41 42 48 47 7 : 59 51 52 58 57 8 : 69 61 62 68 67 9 : 39 31 32 38 37 Col: 6 7 8 9 Row 1 : 94 95 96 93 2 : 14 15 16 13 3 : 24 25 26 23 4 : 84 85 86 83 5 : 74 75 76 73 6 : 44 45 46 43 7 : 54 55 56 53 8 : 64 65 66 63 9 : 34 35 36 33 r8mat_2perm1_test(): r8mat_2perm1() reorders a real matrix in place. Rows and columns use different permutations. The original matrix Col: 1 2 3 4 5 Row 1 : 11 12 13 14 15 2 : 21 22 23 24 25 3 : 31 32 33 34 35 4 : 41 42 43 44 45 5 : 51 52 53 54 55 6 : 61 62 63 64 65 7 : 71 72 73 74 75 8 : 81 82 83 84 85 9 : 91 92 93 94 95 Col: 6 7 Row 1 : 16 17 2 : 26 27 3 : 36 37 4 : 46 47 5 : 56 57 6 : 66 67 7 : 76 77 8 : 86 87 9 : 96 97 The row permutation: 1 2 3 4 5 6 7 8 9 2 3 9 6 7 8 5 4 1 The column permutation: 1 2 3 4 5 6 7 3 4 5 6 7 1 2 The permuted matrix Col: 1 2 3 4 5 Row 1 : 96 97 91 92 93 2 : 16 17 11 12 13 3 : 26 27 21 22 23 4 : 86 87 81 82 83 5 : 76 77 71 72 73 6 : 46 47 41 42 43 7 : 56 57 51 52 53 8 : 66 67 61 62 63 9 : 36 37 31 32 33 Col: 6 7 Row 1 : 94 95 2 : 14 15 3 : 24 25 4 : 84 85 5 : 74 75 6 : 44 45 7 : 54 55 8 : 64 65 9 : 34 35 r8mat_permanent_test(): r8mat_permanent(): the matrix permanent function. We will analyze matrices with 0 diagonal and 1 on all offdiagonals. Order Permanent. 2 1.000000 3 2.000000 4 9.000000 5 44.000000 6 265.000000 7 1854.000000 8 14833.000000 9 133496.000000 10 1334961.000000 11 14684570.000000 12 176214841.000000 r8mat_print_test(): r8mat_print() prints an R8MAT. The R8MAT: Col: 1 2 3 4 Row 1 : 11 12 13 14 2 : 21 22 23 24 3 : 31 32 33 34 4 : 41 42 43 44 5 : 51 52 53 54 6 : 61 62 63 64 r8mat_print_some_test(): r8mat_print_some() prints some of an R8MAT. The R8MAT, rows 2:4, cols 1:2: Col: 1 2 Row 2 : 21 22 3 : 31 32 4 : 41 42 r8poly_test(): r8poly() converts between power sum, factorial and Taylor forms, and can evaluate a polynomial All calls have input A as follows: 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000 Option IOPT = -3 Output array = 0.000000 24.000000 -50.000000 35.000000 -10.000000 1.000000 Option IOPT = -2 Output array = 0.000000 1.000000 15.000000 25.000000 10.000000 1.000000 Option IOPT = -1 X0 = 2.000000 Value = 0.000000 Option IOPT = 0 X0 = 2.000000 Value = 32.000000 Option IOPT = 6 X0 = 2.000000 Output array = 32.000000 80.000000 80.000000 40.000000 10.000000 1.000000 Option IOPT = 6 X0 = -2.000000 Output array = -32.000000 80.000000 -80.000000 40.000000 -10.000000 1.000000 r8poly_f2p_test(): r8poly_f2p(): factorial => power sum. The power sum polynomial: = +4.000000 * x^3 +3.000000 * x^2 +2.000000 * x +1.000000 The factorial polynomial coefficients: 1: 1 2: 9 3: 15 4: 4 The recovered power sum polynomial: = +4.000000 * x^3 +3.000000 * x^2 +2.000000 * x +1.000000 r8poly_fval_test(): r8poly_fval() evaluates a polynomial in factorial form. The factorial polynomial coefficients: 1: 1 2: 2 3: 3 4: 4 5: 5 R8POLY(2.000000) = 11.000000 The correct value is 11. r8poly_n2p_test(): r8poly_n2p(): Newton => power sum; The power sum polynomial: = +4.000000 * x^3 +3.000000 * x^2 +2.000000 * x +1.000000 Newton polynomial coefficients: 49.000000 132.000000 51.000000 4.000000 Newton polynomial abscissas: 2.000000 4.000000 6.000000 8.000000 The recovered power sum polynomial: = +4.000000 * x^3 +3.000000 * x^2 +2.000000 * x +1.000000 r8poly_nval_test(): r8poly_nval() evaluates a Newton polynomial. Newton polynomial coefficients: 1.000000 2.000000 3.000000 4.000000 5.000000 Newton polynomial abscissas: 0.000000 1.000000 2.000000 3.000000 R8POLY (2.000000) = 11.000000 The correct value is 11. r8poly_nx_test(): r8poly_nx() replaces one abscissa in a Newton polynomial. Newton polynomial coefficients: 1: 1 2: 2 3: 3 Newton polynomial abscissas: 1: 1 2: 2 3: 3 Replace one abscissa by X = 0 Newton polynomial coefficients: 1: 5 2: -4 3: 3 Newton polynomial abscissas: 1: 0 2: 1 3: 2 r8poly_p2f_test(): r8poly_p2f(): power sum => factorial; The power sum polynomial: = +4.000000 * x^3 +3.000000 * x^2 +2.000000 * x +1.000000 The factorial polynomial coefficients: 1: 1 2: 9 3: 15 4: 4 The recovered power sum polynomial: = +4.000000 * x^3 +3.000000 * x^2 +2.000000 * x +1.000000 r8poly_p2n_test(): r8poly_p2n(): Power sum => Newton. The power sum polynomial: = +4.000000 * x^3 +3.000000 * x^2 +2.000000 * x +1.000000 Newton polynomial coefficients: 49.000000 132.000000 51.000000 4.000000 Newton polynomial abscissas: 2.000000 4.000000 6.000000 8.000000 The recovered power sum polynomial: = +4.000000 * x^3 +3.000000 * x^2 +2.000000 * x +1.000000 r8poly_p2t_test(): r8poly_p2t(): Power sum => Taylor. Taylor expansion point is X = 2.000000 The Taylor coefficients: 1.000000 2.000000 3.000000 4.000000 The power sum polynomial: = +4.000000 * x^3 -21.000000 * x^2 +38.000000 * x -23.000000 The recovered Taylor coefficients: 1.000000 2.000000 3.000000 4.000000 r8poly_print_test(): r8poly_print() prints an R8POLY. The polynomial: = +1.400000 * x^4 +3.300000 * x^3 +2.200000 * x^2 +5.100000 * x -2.000000 r8poly_pval_test(): r8poly_pval() evaluates a polynomial in power sum form. The polynomial to be evaluated: = +5.000000 * x^4 +4.000000 * x^3 +3.000000 * x^2 +2.000000 * x +1.000000 At X = 2.000000 Computed polynomial value is 129.000000 Correct value is 129. r8poly_t2p_test(): r8poly_t2p(): Taylor => Power sum; Taylor expansion point is X = 2.000000 The Taylor coefficients: 1.000000 2.000000 3.000000 4.000000 The power sum polynomial: = +4.000000 * x^3 -21.000000 * x^2 +38.000000 * x -23.000000 The recovered Taylor coefficients: 1.000000 2.000000 3.000000 4.000000 r8vec_backtrack_test(): r8vec_backtrack() uses backtracking, seeking a vector X of N values which satisfies some condition. In this demonstration, we have 8 values W(I). We seek all subsets that sum to 53.0. X(I) is 0.0 or 1.0 if the entry is skipped or used. 1 53: 15 22 16 2 53: 15 14 16 8 3 53: 22 14 9 8 Done! r8vec_frac_test(): r8vec_frac(): K-th smallest real vector entry; The real array to search: 1: 0.372255 2: 7.90953 3: 8.24746 4: 5.17404 5: 5.15357 6: 0.258728 7: 5.47162 8: 1.33565 9: 7.01569 10: 2.60774 Frac R8VEC_FRAC 1 0.258728 2 0.372255 3 1.335645 4 2.607742 5 5.153572 6 5.174043 7 5.471622 8 7.015686 9 7.909528 10 8.247458 r8vec_indicator1_test(): r8vec_indicator1() returns a 1-based indicator vector. The indicator1 vector: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 r8vec_mirror_next_test(): r8vec_mirror_next() generates all sign variations of a real vector. Next vector: 1: 1 2: 2 3: 3 Next vector: 1: -1 2: 2 3: 3 Next vector: 1: 1 2: -2 3: 3 Next vector: 1: -1 2: -2 3: 3 Next vector: 1: 1 2: 2 3: -3 Next vector: 1: -1 2: 2 3: -3 Next vector: 1: 1 2: -2 3: -3 Next vector: 1: -1 2: -2 3: -3 Done. Next vector: 1: 1 2: 0 3: 3 Next vector: 1: -1 2: 0 3: 3 Next vector: 1: 1 2: -0 3: -3 Next vector: 1: -1 2: -0 3: -3 Done. r8vec_print_test(): r8vec_print() prints an R8VEC. The R8VEC: 1: 123.456 2: 5e-06 3: -1e+06 4: 3.14159 rat_add_test(): rat_add() adds two rationals. A = 3/4 B = 10/7 C = A + B = 61/28 rat_div_test(): rat_div() divides two rationals. A = 3/4 B = 10/7 C = A / B = 21/40 rat_farey_test(): rat_farey() computes a row of the Farey fraction table. Row 1 Number of fractions: 2 0 1 1 1 Row 2 Number of fractions: 3 0 1 1 1 2 1 Row 3 Number of fractions: 5 0 1 1 2 1 1 3 2 3 1 Row 4 Number of fractions: 7 0 1 1 1 2 3 1 1 4 3 2 3 4 1 Row 5 Number of fractions: 11 0 1 1 1 2 1 3 2 3 4 1 1 5 4 3 5 2 5 3 4 5 1 Row 6 Number of fractions: 13 0 1 1 1 1 2 1 3 2 3 4 5 1 1 6 5 4 3 5 2 5 3 4 5 6 1 Row 7 Number of fractions: 19 0 1 1 1 1 2 1 2 3 1 4 3 2 5 3 4 5 6 1 1 7 6 5 4 7 3 5 7 2 7 5 3 7 4 5 6 7 1 rat_farey2_test(): rat_farey2() computes a row of the Farey fraction table. Row 1 0 1 1 1 Row 2 0 1 1 1 2 1 Row 3 0 1 1 2 1 1 3 2 3 1 Row 4 0 1 1 2 1 3 2 3 1 1 4 3 5 2 5 3 4 1 Row 5 0 1 1 2 1 3 2 3 1 4 3 5 2 5 3 4 1 1 5 4 7 3 8 5 7 2 7 5 8 3 7 4 5 1 rat_mul_test(): rat_mul() multiplies two rationals. A = 3/4 B = 10/7 C = A * B = 15/14 rat_normalize_test(): rat_normalize() normalizes a rational. A B A B normalized normalized 3 4 3 4 1 1000 1 1000 20 1 20 1 8 4 2 1 -10 7 -10 7 9 -15 -3 5 -11 -11 1 1 rat_sum_formula_test(): rat_sum_formula() computes the coefficients for the formulas for the sums of powers of integers. Power Sum Coefficients: 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 2 2 1 1 1 1 1 1 1 1 0 0 0 0 3 2 6 1 1 1 1 1 1 1 0 0 0 0 4 2 4 1 1 1 1 1 1 1 0 -1 0 0 5 2 3 1 30 1 1 1 1 5 0 -1 0 0 6 2 12 1 12 1 1 1 1 1 0 -1 0 1 7 2 2 1 6 1 42 rat_to_cfrac_test(): rat_to_cfrac() fraction => continued fraction, Regular fraction is 4096 / 15625 Continued fraction coefficients: 1: 0 2: 3 3: 1 4: 4 5: 2 6: 1 7: 1 8: 11 9: 13 The continued fraction convergents. The last row contains the value of the continued fraction, written as a common fraction. I, P(I), Q(I), P(I)/Q(I) 1 0 1 0.000000 2 1 3 0.333333 3 1 4 0.250000 4 5 19 0.263158 5 11 42 0.261905 6 16 61 0.262295 7 27 103 0.262136 8 313 1194 0.262144 9 4096 15625 0.262144 rat_to_dec_test(): rat_to_dec() converts fraction => decimal, In this test, choose the top and bottom of a rational at random, and compute the equivalent real number. Then convert to decimal, and the equivalent real. Then convert back to rational and the equivalent real. 9.581633 = 939 / 98 9.581633 = 958163265306122 * 10^-14 9.581633 = 479081632653061 / 50000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In rat_to_dec_test (line 39) In subset_test (line 333) In run (line 91)] 1.899614 = 492 / 259 1.899614 = 18996138996138996 * 10^-16 1.899614 = 4749034749034749 / 2500000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In rat_to_dec_test (line 39) In subset_test (line 333) In run (line 91)] 1.335196 = 717 / 537 1.335196 = 13351955307262576 * 10^-16 1.335196 = 834497206703911 / 625000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In rat_to_dec_test (line 39) In subset_test (line 333) In run (line 91)] -1.474104 = -740 / 502 -1.474104 = -14741035856573702 * 10^-16 -1.474104 = -7370517928286851 / 5000000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In rat_to_dec_test (line 39) In subset_test (line 333) In run (line 91)] -1.928962 = -353 / 183 -1.928962 = -19289617486338796 * 10^-16 -1.928962 = -4822404371584699 / 2500000000000000 1.416031 = 371 / 262 1.416031 = 1416030534351145 * 10^-15 1.416031 = 283206106870229 / 200000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In rat_to_dec_test (line 39) In subset_test (line 333) In run (line 91)] 1.353414 = 337 / 249 1.353414 = 13534136546184736 * 10^-16 1.353414 = 422941767068273 / 312500000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In rat_to_dec_test (line 39) In subset_test (line 333) In run (line 91)] -0.483450 = -482 / 997 -0.483450 = -4834503510531594 * 10^-16 -0.483450 = -2417251755265797 / 5000000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In rat_to_dec_test (line 39) In subset_test (line 333) In run (line 91)] -0.619554 = -583 / 941 -0.619554 = -6195536663124336 * 10^-16 -0.619554 = -387221041445271 / 625000000000000 [Warning: Inputs contain values larger than the largest consecutive flint. Result may be inaccurate.] [> In gcd (line 64) In dec_to_rat (line 45) In rat_to_dec_test (line 39) In subset_test (line 333) In run (line 91)] -0.180193 = -131 / 727 -0.180193 = -1801925722145805 * 10^-16 -0.180193 = -360385144429161 / 2000000000000000 rat_to_r8_test(): rat_to_r8() converts a rational to a real number. The maximum number of digits allowed is 4 R => A / B => R2 0.273307 2733 10000 0.2733 -2.11026 -21103 10000 -2.1103 6.92509 69251 10000 6.9251 4.62593 46259 10000 4.6259 5.14298 5143 1000 5.143 6.44749 2579 400 6.4475 1.48494 14849 10000 1.4849 2.88156 1801 625 2.8816 2.18898 2189 1000 2.189 0.0689901 69 1000 0.069 rat_to_s_test(): rat_to_s() converts a rational to a string. A B A/B 3 4 3/4 1 1000 1/1000 20 1 20/1 8 4 8/4 -10 7 -10/7 9 -15 9/-15 -11 -11 -11/-11 rat_width_test(): rat_width() determines the "width" of a rational. Top Bottom Width 1000 3 4 1000 40 4 1000 500 4 1000 6000 4 1000 70000 5 1 1 1 -1 200 3 -10 200 3 -100 200 4 -1000 200 5 1 -200 3 10 -200 3 100 -200 4 1000 -200 5 10000 -200 6 17 3000 4 4000000 4000000 7 ratmat_det_test(): ratmat_det(): determinant of a rational matrix. The 123/456/789 matrix: 1 2 3 1 1 1 4 5 6 1 1 1 7 8 9 1 1 1 Determinant of the 123/456/789 matrix = 0 / 1 The Hilbert matrix: 1 1 1 2 3 4 1 1 1 3 4 5 1 1 1 4 5 6 Determinant of the Hilbert matrix = 1 / 43200 The -1 2 -1 matrix: 2 -1 0 1 1 1 -1 2 -1 1 1 1 0 -1 2 1 1 1 Determinant of the -1,2,-1 matrix = 4 / 1 ratmat_print_test(): ratmat_print() prints a rational matrix. The Hilbert matrix: 1 1 1 2 3 4 1 1 1 3 4 5 1 1 1 4 5 6 1 1 1 5 6 7 regro_next_test(): regro_next() generates all restricted growth functions. 1 1 1 1 1 2 1 1 1 2 3 1 1 2 1 4 1 1 2 2 5 1 1 2 3 6 1 2 1 1 7 1 2 1 2 8 1 2 1 3 9 1 2 2 1 10 1 2 2 2 11 1 2 2 3 12 1 2 3 1 13 1 2 3 2 14 1 2 3 3 15 1 2 3 4 rfrac_to_cfrac(): rfrac_to_cfrac(): ratio to continued fration. Rational polynomial fraction coefficients: P: 1.000000 1.000000 2.000000 Q: 1.000000 3.000000 1.000000 1.000000 Continued fraction coefficients: 1: 1 2: 0.5 3: 1.33333 4: -0.5 5: -1.5 6: 2 Recovered rational polynomial: P: 1.000000 1.000000 2.000000 Q: 1.000000 3.000000 1.000000 1.000000 rfrac_to_jfrac_test(): rfrac_to_jfrac() converts a rational polynomial fraction to a J fraction. The original rational polynomial coefficients: 0.861993 0.389914 0.260180 0.396772 0.642726 0.867801 0.287260 0.408843 1.454402 0.558123 1.460696 1.244731 1.000000 The J fraction coefficients: 0.867801 0.630131 -0.928746 3.678614 -1.589153 0.419493 0.504093 0.696474 0.736411 -1.065256 -0.343974 0.716983 The recovered rational polynomial: 0.861993 0.389914 0.260180 0.396772 0.642726 0.867801 0.287260 0.408843 1.454402 0.558123 1.460696 1.244731 1.000000 schroeder_test(): schroeder() computes the Schroeder numbers. N S(N) 1 1 2 1 3 3 4 11 5 45 6 197 7 903 8 4279 9 20793 10 103049 sort_heap_external_test(): sort_heap_external() sorts objects externally. Unsorted array: 1: 5 2: 20 3: 13 4: 2 5: 13 6: 5 7: 16 8: 13 9: 7 10: 19 11: 13 12: 18 13: 14 14: 8 15: 10 16: 18 17: 14 18: 16 19: 15 20: 17 Sorted array: 1: 2 2: 5 3: 5 4: 7 5: 8 6: 10 7: 13 8: 13 9: 13 10: 13 11: 14 12: 14 13: 15 14: 16 15: 16 16: 17 17: 18 18: 18 19: 19 20: 20 subset_by_size_next_test(): subset_by_size_next() generates all subsets of an N set. 1 1 2 3 4 5 2 1 2 3 4 3 1 2 3 5 4 1 2 4 5 5 1 3 4 5 6 2 3 4 5 7 1 2 3 8 1 2 4 9 1 2 5 10 1 3 4 11 1 3 5 12 1 4 5 13 2 3 4 14 2 3 5 15 2 4 5 16 3 4 5 17 1 2 18 1 3 19 1 4 20 1 5 21 2 3 22 2 4 23 2 5 24 3 4 25 3 5 26 4 5 27 1 28 2 29 3 30 4 31 5 32 The empty set subset_gray_next_test(): subset_gray_next() generates all subsets of an N set. using the Gray code ordering: 0 0 1 0 1 means the subset contains 3 and 5. Gray code 1 0 0 0 0 0 2 1 0 0 0 0 3 1 1 0 0 0 4 0 1 0 0 0 5 0 1 1 0 0 6 1 1 1 0 0 7 1 0 1 0 0 8 0 0 1 0 0 9 0 0 1 1 0 10 1 0 1 1 0 11 1 1 1 1 0 12 0 1 1 1 0 13 0 1 0 1 0 14 1 1 0 1 0 15 1 0 0 1 0 16 0 0 0 1 0 17 0 0 0 1 1 18 1 0 0 1 1 19 1 1 0 1 1 20 0 1 0 1 1 21 0 1 1 1 1 22 1 1 1 1 1 23 1 0 1 1 1 24 0 0 1 1 1 25 0 0 1 0 1 26 1 0 1 0 1 27 1 1 1 0 1 28 0 1 1 0 1 29 0 1 0 0 1 30 1 1 0 0 1 31 1 0 0 0 1 32 0 0 0 0 1 subset_gray_rank_test(): subset_gray_rank() returns rank of a subset of an N set using the Gray code ordering. For N = 5 the subset is: 1 0 1 1 0 The rank is 10 subset_gray_unrank_test(): subset_gray_unrank() finds the subset of an N set of a given rank under the Gray code ordering. N is 5 Rank Subset 1 0 0 0 0 0 2 1 0 0 0 0 3 1 1 0 0 0 4 0 1 0 0 0 5 0 1 1 0 0 6 1 1 1 0 0 7 1 0 1 0 0 8 0 0 1 0 0 9 0 0 1 1 0 10 1 0 1 1 0 subset_lex_next_test(): subset_lex_next() generates all subsets of an N set. The user can impose a restriction on the maximum size of the subsets. Here, we require the subsets to be no larger than 3 1 1 2 1 2 3 1 2 4 1 2 5 1 3 1 3 4 1 3 5 1 4 1 4 5 1 5 2 2 3 2 3 4 2 3 5 2 4 2 4 5 2 5 3 3 4 3 4 5 3 5 4 4 5 5 The empty set. subset_random_test(): subset_random() picks a subset at random. The number of elements in the main set is 5 1 0 1 0 1 0 1 0 1 0 1 1 0 0 0 0 0 0 0 1 1 1 0 0 1 subcomp_next_test(): subcomp_next() generates subcompositions. Seek all subcompositions of N = 6 Into K = 3 parts. # Sum 1 0 0 0 0 2 1 1 0 0 3 1 0 1 0 4 1 0 0 1 5 2 2 0 0 6 2 1 1 0 7 2 0 2 0 8 2 1 0 1 9 2 0 1 1 10 2 0 0 2 11 3 3 0 0 12 3 2 1 0 13 3 1 2 0 14 3 0 3 0 15 3 2 0 1 16 3 1 1 1 17 3 0 2 1 18 3 1 0 2 19 3 0 1 2 20 3 0 0 3 21 4 4 0 0 22 4 3 1 0 23 4 2 2 0 24 4 1 3 0 25 4 0 4 0 26 4 3 0 1 27 4 2 1 1 28 4 1 2 1 29 4 0 3 1 30 4 2 0 2 31 4 1 1 2 32 4 0 2 2 33 4 1 0 3 34 4 0 1 3 35 4 0 0 4 36 5 5 0 0 37 5 4 1 0 38 5 3 2 0 39 5 2 3 0 40 5 1 4 0 41 5 0 5 0 42 5 4 0 1 43 5 3 1 1 44 5 2 2 1 45 5 1 3 1 46 5 0 4 1 47 5 3 0 2 48 5 2 1 2 49 5 1 2 2 50 5 0 3 2 51 5 2 0 3 52 5 1 1 3 53 5 0 2 3 54 5 1 0 4 55 5 0 1 4 56 5 0 0 5 57 6 6 0 0 58 6 5 1 0 59 6 4 2 0 60 6 3 3 0 61 6 2 4 0 62 6 1 5 0 63 6 0 6 0 64 6 5 0 1 65 6 4 1 1 66 6 3 2 1 67 6 2 3 1 68 6 1 4 1 69 6 0 5 1 70 6 4 0 2 71 6 3 1 2 72 6 2 2 2 73 6 1 3 2 74 6 0 4 2 75 6 3 0 3 76 6 2 1 3 77 6 1 2 3 78 6 0 3 3 79 6 2 0 4 80 6 1 1 4 81 6 0 2 4 82 6 1 0 5 83 6 0 1 5 84 6 0 0 6 subcompnz_next_test(): subcompnz_next() generates subcompositions using nonzero parts. Seek all subcompositions of N = 6 using K = 3 nonzero parts. # Sum 1 3 1 1 1 2 4 2 1 1 3 4 1 2 1 4 4 1 1 2 5 5 3 1 1 6 5 2 2 1 7 5 1 3 1 8 5 2 1 2 9 5 1 2 2 10 5 1 1 3 11 6 4 1 1 12 6 3 2 1 13 6 2 3 1 14 6 1 4 1 15 6 3 1 2 16 6 2 2 2 17 6 1 3 2 18 6 2 1 3 19 6 1 2 3 20 6 1 1 4 subcompnz2_next_test(): subcompnz2_next() generates subcompositions using nonzero parts. Seek all subcompositions of N using K = 3 nonzero parts for 5 <= N <= 7 # N 1 5 3 1 1 2 5 2 2 1 3 5 1 3 1 4 5 2 1 2 5 5 1 2 2 6 5 1 1 3 7 6 4 1 1 8 6 3 2 1 9 6 2 3 1 10 6 1 4 1 11 6 3 1 2 12 6 2 2 2 13 6 1 3 2 14 6 2 1 3 15 6 1 2 3 16 6 1 1 4 17 7 5 1 1 18 7 4 2 1 19 7 3 3 1 20 7 2 4 1 21 7 1 5 1 22 7 4 1 2 23 7 3 2 2 24 7 2 3 2 25 7 1 4 2 26 7 3 1 3 27 7 2 2 3 28 7 1 3 3 29 7 2 1 4 30 7 1 2 4 31 7 1 1 5 subtriangle_next_test(): subtriangle_next() generates the indices of subtriangles in a triangle whose edges were divided into N subedges. For this test, N = 4 Rank I1 J1 I2 J2 I3 J3 1 0 0 1 0 0 1 2 1 1 0 1 1 0 3 1 0 2 0 1 1 4 2 1 1 1 2 0 5 2 0 3 0 2 1 6 3 1 2 1 3 0 7 3 0 4 0 3 1 8 0 1 1 1 0 2 9 1 2 0 2 1 1 10 1 1 2 1 1 2 11 2 2 1 2 2 1 12 2 1 3 1 2 2 13 0 2 1 2 0 3 14 1 3 0 3 1 2 15 1 2 2 2 1 3 16 0 3 1 3 0 4 thue_binary_next_test(): thue_binary_next() returns the next Thue binary sequence. 1 0 2 01 4 0110 8 01101001 16 0110100110010110 32 01101001100101101001011001101001 64 0110100110010110100101100110100110010110011010010110100110010110 thue_ternary_next_test(): thue_ternary_next() returns the next Thue ternary sequence. 1 1 3 102 6 102120 12 102120102012 24 102120102012102120121020 48 102120102012102120121020102120102012102010212012 triang_test(): triang() relabels elements for a partial ordering, The input matrix: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 1 0 0 0 0 0 0 0 0 0 2: 0 1 0 1 0 1 0 1 0 0 3: 1 0 1 1 0 0 0 0 0 0 4: 0 0 0 1 0 0 0 0 0 0 5: 1 1 1 1 1 1 1 1 0 1 6: 0 0 0 1 0 1 0 1 0 0 7: 1 0 1 1 0 1 1 1 0 1 8: 0 0 0 1 0 0 0 1 0 0 9: 0 0 0 0 0 0 0 0 0 0 10: 1 0 1 1 0 0 0 1 0 1 The new ordering: 1 2 3 4 5 6 7 8 9 10 5 6 4 9 1 7 2 8 10 3 The reordered matrix: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 1 1 1 1 1 1 1 1 1 0 2: 0 1 1 1 1 0 1 1 1 0 3: 0 0 1 1 1 0 0 1 1 0 4: 0 0 0 1 1 0 0 0 1 0 5: 0 0 0 0 1 0 0 0 0 0 6: 0 0 0 0 0 1 1 1 1 0 7: 0 0 0 0 0 0 1 1 1 0 8: 0 0 0 0 0 0 0 1 1 0 9: 0 0 0 0 0 0 0 0 1 0 10: 0 0 0 0 0 0 0 0 0 0 tuple_next_test(): tuple_next() returns the next "tuple", that is, a vector of N integers, each between M1 and M2. M1 = 2 M2 = 4 N = 2 1 2 2 2 2 3 3 2 4 4 3 2 5 3 3 6 3 4 7 4 2 8 4 3 9 4 4 tuple_next_fast_test(): tuple_next_fast() returns the next "tuple", that is, a vector of N integers, each between 1 and M. M = 3 N = 2 0 1 1 1 1 2 2 1 3 3 2 1 4 2 2 5 2 3 6 3 1 7 3 2 8 3 3 tuple_next_ge_test(): tuple_next_ge() returns the next "tuple", that is, a vector of N integers, each between 1 and M, with the constraint that the entries be nondecreasing. M = 3 N = 3 1 1 1 1 2 1 1 2 3 1 1 3 4 1 2 2 5 1 2 3 6 1 3 3 7 2 2 2 8 2 2 3 9 2 3 3 10 3 3 3 tuple_next2_test(): tuple_next2() returns the next "tuple", that is, a vector of N integers. N = 3 The minimum tuple: 2 3 8 The maximum tuple: 4 3 5 1 2 3 8 2 2 3 7 3 2 3 6 4 2 3 5 5 3 3 8 6 3 3 7 7 3 3 6 8 3 3 5 9 4 3 8 10 4 3 7 11 4 3 6 12 4 3 5 ubvec_add_test() ubvec_add() adds unsigned binary vectors representing unsigned integers; I J K = I + J 16 38 Directly: 54 BVEC_ADD 54 32 57 Directly: 89 BVEC_ADD 89 56 92 Directly: 148 BVEC_ADD 148 45 6 Directly: 51 BVEC_ADD 51 53 80 Directly: 133 BVEC_ADD 133 8 57 Directly: 65 BVEC_ADD 65 15 72 Directly: 87 BVEC_ADD 87 42 56 Directly: 98 BVEC_ADD 98 74 87 Directly: 161 BVEC_ADD 161 72 91 Directly: 163 BVEC_ADD 163 ubvec_print_test(): ubvec_print() prints an unsigned binary vector. UBVEC: 0011101001 ubvec_to_ui4_test(): ubvec_to_ui4() converts an unsigned binary vector to an unsigned integer; UI4 --> UBVEC --> UI4 0 0000000000 0 1 1000000000 1 2 0100000000 2 3 1100000000 3 4 0010000000 4 5 1010000000 5 6 0110000000 6 7 1110000000 7 8 0001000000 8 9 1001000000 9 10 0101000000 10 ubvec_xor_test(): ubvec_xor() exclusive-ors unsigned binary vectors representing unsigned integers; I J K = I XOR J 72 21 93 63 48 15 58 85 111 91 16 75 22 22 0 99 50 81 2 59 57 46 73 103 18 87 69 51 95 108 ui4_to_ubvec_test(): ui4_to_ubvec() converts an unsigned integer to an unsigned binary vector; UI4 --> UBVEC --> UI4 0 0000000000 0 1 1000000000 1 2 0100000000 2 3 1100000000 3 4 0010000000 4 5 1010000000 5 6 0110000000 6 7 1110000000 7 8 0001000000 8 9 1001000000 9 10 0101000000 10 vec_colex_next_test(): vec_colex_next() generates all DIM_NUM-vectors in colex order in a given base BASE. The spatial dimension DIM_NUM = 3 The base BASE = 3 0 0 0 1 0 0 2 0 0 0 1 0 1 1 0 2 1 0 0 2 0 1 2 0 2 2 0 0 0 1 1 0 1 2 0 1 0 1 1 1 1 1 2 1 1 0 2 1 1 2 1 2 2 1 0 0 2 1 0 2 2 0 2 0 1 2 1 1 2 2 1 2 0 2 2 1 2 2 2 2 2 vec_colex_next2_test(): vec_colex_next2() generates all DIM_NUM-vectors in colex order in a given base BASE. The spatial dimension DIM_NUM = 3 The base vector: 2 1 3 0 0 0 1 0 0 0 0 1 1 0 1 0 0 2 1 0 2 vec_colex_next3_test(): vec_colex_next3() generates all DIM_NUM-vectors in colex order in a given base BASE. The spatial dimension DIM_NUM = 3 The base vector: 2 1 3 1 1 1 2 1 1 1 1 2 2 1 2 1 1 3 2 1 3 vec_gray_next_test(): vec_gray_next() generates product space elements. The number of components is 4 The number of elements is 16 Each component has its own number of degrees of freedom. Rank Change 2 2 1 4 1 1 0 0 0 0 2 4 0 0 0 1 3 4 0 0 0 2 4 4 0 0 0 3 5 2 0 1 0 3 6 4 0 1 0 2 7 4 0 1 0 1 8 4 0 1 0 0 9 1 1 1 0 0 10 4 1 1 0 1 11 4 1 1 0 2 12 4 1 1 0 3 13 2 1 0 0 3 14 4 1 0 0 2 15 4 1 0 0 1 16 4 1 0 0 0 vec_gray_rank_test(): vec_gray_rank() ranks product space elements. The number of components is 4 The number of elements is 16 Each component has its own number of degrees of freedom, which, for this example, are: VEC_GRAY_RANK reports the element 1 1 0 2 has rank 11 vec_gray_unrank_test(): vec_gray_unrank() unranks product space elements. The number of components is 4 The number of elements is 16 Each component has its own number of degrees of freedom, which, for this example, are: VEC_GRAY_UNRANK reports the element of rank 7 is: 0 1 0 1 vec_lex_next_test(): vec_lex_next() generates all DIM_NUM-vectors in lex order in a given base BASE. The spatial dimension DIM_NUM = 3 The base BASE = 3 0 0 0 0 0 1 0 0 2 0 1 0 0 1 1 0 1 2 0 2 0 0 2 1 0 2 2 1 0 0 1 0 1 1 0 2 1 1 0 1 1 1 1 1 2 1 2 0 1 2 1 1 2 2 2 0 0 2 0 1 2 0 2 2 1 0 2 1 1 2 1 2 2 2 0 2 2 1 2 2 2 vec_random_test(): vec_random() generates a random N-vector in a given base. Here, we use base 3 1 2 2 0 1 2 2 1 2 1 0 1 2 2 0 vector_constrained_next_test(): vector_constrained_next(): Consider vectors: X_MIN(1:N) <= X(1:N) <= X_MAX(1:N), Set P = Product X_MAX(1:N) Accept only vectors for which: sum ( (X(1:N)-1) * P / X_MAX(1:N) ) <= P X_MIN: 2 2 1 X_MAX: 4 5 3 Maximum allowed CONSTRAINT = P = 60 1 2 2 1 27 2 3 2 1 42 3 4 2 1 57 4 2 3 1 39 5 3 3 1 54 6 2 4 1 51 7 2 2 2 47 8 2 3 2 59 vector_constrained_next2_test(): vector_constrained_next2() Consider vectors: X_MIN(1:N) <= X(1:N) <= X_MAX(1:N), Set P = Product X_MAX(1:N) Accept only vectors for which: sum ( X(1:N) * P / X_MAX(1:N) ) <= P X_MIN: 1 1 X_MAX: 5 6 Maximum allowed CONSTRAINT = P = 30 1 1 1 11 2 2 1 17 3 3 1 23 4 4 1 29 5 1 2 16 6 2 2 22 7 3 2 28 8 1 3 21 9 2 3 27 10 1 4 26 X_MIN: 1 1 1 X_MAX: 5 6 4 Maximum allowed CONSTRAINT = P = 120 1 1 1 1 74 2 2 1 1 98 3 1 2 1 94 4 2 2 1 118 5 1 3 1 114 6 1 1 2 104 vector_constrained_next3_test(): vector_constrained_next3(): Consider vectors: X_MIN(1:N) <= X(1:N) <= X_MAX(1:N), Set CONSTRAINT = sum ( X(1:N) / X_MAX(1:N) ) Accept only vectors for which: CONSTRAINT <= 1 X_MIN: 1 1 X_MAX: 5 6 1 1 1 0.366667 2 2 1 0.566667 3 3 1 0.766667 4 4 1 0.966667 5 1 2 0.533333 6 2 2 0.733333 7 3 2 0.933333 8 1 3 0.700000 9 2 3 0.900000 10 1 4 0.866667 X_MIN: 1 1 1 X_MAX: 5 6 4 1 1 1 1 0.616667 2 2 1 1 0.816667 3 1 2 1 0.783333 4 2 2 1 0.983333 5 1 3 1 0.950000 6 1 1 2 0.866667 vector_constrained_next4_test(): vector_constrained_next4(): Consider vectors: X_MIN(1:N) <= X(1:N) <= X_MAX(1:N), Set TOTAL = sum ( ALPHA(1:N) * X(1:N) ) Accept only vectors for which: TOTAL <= Q ALPHA: 4.000000 3.000000 Q: 20.000000 X_MIN: 1 0 X_MAX: 2 6 1 4.000000 1 0 2 8.000000 2 0 3 7.000000 1 1 4 11.000000 2 1 5 10.000000 1 2 6 14.000000 2 2 7 13.000000 1 3 8 17.000000 2 3 9 16.000000 1 4 10 20.000000 2 4 11 19.000000 1 5 ALPHA: 4.000000 3.000000 5.000000 Q: 20.000000 X_MIN: 1 0 1 X_MAX: 2 6 4 1 9.000000 1 0 1 2 13.000000 2 0 1 3 12.000000 1 1 1 4 16.000000 2 1 1 5 15.000000 1 2 1 6 19.000000 2 2 1 7 18.000000 1 3 1 8 14.000000 1 0 2 9 18.000000 2 0 2 10 17.000000 1 1 2 11 20.000000 1 2 2 12 19.000000 1 0 3 vector_constrained_next5_test(): vector_constrained_next5(): Generate integer vectors X such that: SUM_MIN <= sum ( X(1:N) ) <= SUM_MAX, We require every X(I) to be at least 1. N = 3 SUM_MIN = 5 SUM_MAX = 7 # X(1) X(2) X(3) 1 3 1 1 2 2 2 1 3 2 1 2 4 1 3 1 5 1 2 2 6 1 1 3 7 4 1 1 8 3 2 1 9 3 1 2 10 2 3 1 11 2 2 2 12 2 1 3 13 1 4 1 14 1 3 2 15 1 2 3 16 1 1 4 17 5 1 1 18 4 2 1 19 4 1 2 20 3 3 1 21 3 2 2 22 3 1 3 23 2 4 1 24 2 3 2 25 2 2 3 26 2 1 4 27 1 5 1 28 1 4 2 29 1 3 3 30 1 2 4 31 1 1 5 vector_constrained_next6_test(): vector_constrained_next6(): Consider vectors: X_MIN(1:N) <= X(1:N) <= X_MAX(1:N), Set TOTAL = sum ( ALPHA(1:N) * X(1:N) ) Accept only vectors for which: Q_MIN <= TOTAL <= Q_MAX ALPHA: 4.000000 3.000000 Q_MIN: 16.000000 Q_MAX: 20.000000 X_MIN: 1 0 X_MAX: 2 6 1 16.000000 1 4 2 19.000000 1 5 3 17.000000 2 3 4 20.000000 2 4 ALPHA: 4.000000 3.000000 5.000000 Q_MIN: 16.000000 Q_MAX: 20.000000 X_MIN: 1 0 1 X_MAX: 2 6 4 1 19.000000 1 0 3 2 17.000000 1 1 2 3 20.000000 1 2 2 4 18.000000 1 3 1 5 18.000000 2 0 2 6 16.000000 2 1 1 7 19.000000 2 2 1 vector_constrained_next7_test(): vector_constrained_next7(): Consider vectors: 0 <= X(1:N) <= X_MAX(1:N), Set TOTAL = sum ( ALPHA(1:N) * X(1:N) ) Accept only vectors for which: Q_MIN <= TOTAL <= Q_MAX ALPHA: 4 3 Q_MIN: 16.000000 Q_MAX: 20.000000 X_MAX: 2 6 1 18.000000 0 6 2 19.000000 1 5 3 17.000000 2 3 4 20.000000 2 4 ALPHA: 4 3 5 Q_MIN: 16.000000 Q_MAX: 20.000000 X_MAX: 2 6 4 1 20.000000 0 0 4 2 18.000000 0 1 3 3 19.000000 0 3 2 4 17.000000 0 4 1 5 20.000000 0 5 1 6 18.000000 0 6 0 7 19.000000 1 0 3 8 17.000000 1 1 2 9 20.000000 1 2 2 10 18.000000 1 3 1 11 19.000000 1 5 0 12 18.000000 2 0 2 13 19.000000 2 2 1 14 17.000000 2 3 0 15 20.000000 2 4 0 vector_next_test(): vector_next(): Generate all vectors X such that: X_MIN(1:N) <= X(1:N) <= X_MAX(1:N), XMIN 1 4 1 1 4 2 2 4 3 1 5 4 2 5 5 1 6 6 2 6 XMAX 2 6 XMIN 1 4 3 1 1 4 3 2 2 4 3 3 1 5 3 4 2 5 3 5 1 6 3 6 2 6 3 7 1 4 4 8 2 4 4 9 1 5 4 10 2 5 4 11 1 6 4 12 2 6 4 XMAX 2 6 4 vector_sumlex_next_test(): vector_sumlex_next() generates integer vectors of dimension n. The vectors are listed in order by the sum of their entries. For a given sum, vectors are listed in lexicographic order. 0: (0,0,0,0) 1: (0,0,0,1) 2: (0,0,1,0) 3: (0,1,0,0) 4: (1,0,0,0) 5: (0,0,0,2) 6: (0,0,1,1) 7: (0,0,2,0) 8: (0,1,0,1) 9: (0,1,1,0) 10: (0,2,0,0) 11: (1,0,0,1) 12: (1,0,1,0) 13: (1,1,0,0) 14: (2,0,0,0) 15: (0,0,0,3) 16: (0,0,1,2) 17: (0,0,2,1) 18: (0,0,3,0) 19: (0,1,0,2) 20: (0,1,1,1) 21: (0,1,2,0) 22: (0,2,0,1) 23: (0,2,1,0) 24: (0,3,0,0) 25: (1,0,0,2) 26: (1,0,1,1) 27: (1,0,2,0) 28: (1,1,0,1) 29: (1,1,1,0) 30: (1,2,0,0) ytb_enum_test(): ytb_enum() counts Young tableau. N YTB(N) 0 0 1 1 2 2 3 4 4 10 5 26 6 76 7 232 8 764 9 2620 10 9496 ytb_next_test(): ytb_next() generates Young tableaus. 1 4 6 2 5 3 1 3 6 2 5 4 1 2 6 3 5 4 1 3 6 2 4 5 1 2 6 3 4 5 1 4 5 2 6 3 1 3 5 2 6 4 1 2 5 3 6 4 1 3 4 2 6 5 1 2 4 3 6 5 1 2 3 4 6 5 1 3 5 2 4 6 1 2 5 3 4 6 1 3 4 2 5 6 1 2 4 3 5 6 1 2 3 4 5 6 ytb_print_test(): ytb_print() prints a Young tableau. A Young tableau: 1 2 6 3 4 5 ytb_random_test(): ytb_random() generates a random Young tableau. 1 3 5 2 6 4 1 2 5 3 4 6 1 2 4 3 5 6 1 3 6 2 5 4 1 2 4 3 5 6 subset_test() Normal end of execution. 13-Dec-2023 14:46:51