Tue May 20 21:48:17 2025 legendre_product_polynomial_test(): python version: 3.10.12 numpy version: 1.26.4 Test legendre_product_polynomial(). i4vec_permute_test(): i4vec_permute() reorders an I4VEC according to a given permutation. A[*], before rearrangement: 0 2 1 2 2 3 3 7 4 4 5 11 6 10 7 2 8 0 9 0 10 11 11 6 Permutation vector P[*]: 0 8 1 10 2 0 3 3 4 6 5 7 6 4 7 11 8 5 9 2 10 9 11 1 A[P[*]]: 0 0 1 11 2 2 3 7 4 10 5 2 6 4 7 6 8 11 9 3 10 0 11 2 i4vec_sort_heap_index_a_test() i4vec_sort_heap_index_a() creates an ascending sort index for an I4VEC. Unsorted array A: 0 50 1 4 2 16 3 37 4 48 5 33 6 49 7 9 8 10 9 43 10 43 11 43 12 35 13 41 14 14 15 41 16 5 17 51 18 51 19 22 Sort vector INDX: 0 1 1 16 2 7 3 8 4 14 5 2 6 19 7 5 8 12 9 3 10 13 11 15 12 11 13 10 14 9 15 4 16 6 17 0 18 18 19 17 I INDX(I) A(INDX(I)) 0 1 4 1 16 5 2 7 9 3 8 10 4 14 14 5 2 16 6 19 22 7 5 33 8 12 35 9 3 37 10 13 41 11 15 41 12 11 43 13 10 43 14 9 43 15 4 48 16 6 49 17 0 50 18 18 51 19 17 51 r8vec_permute_test(): r8vec_permute() permutes an R8VEC. Original array X[]: 0: 1.1 1: 2.2 2: 3.3 3: 4.4 4: 5.5 Permutation vector P[]: 0 1 1 3 2 4 3 0 4 2 Permuted array X[P[*]]: 0: 2.2 1: 4.4 2: 5.5 3: 1.1 4: 3.3 perm0_uniform_test() perm0_uniform() randomly selects a permutation of 0,...,N-1. 5 4 2 6 0 3 9 7 1 8 6 5 1 4 3 0 7 2 9 8 1 2 0 7 9 8 3 5 4 6 7 3 8 2 4 0 9 1 6 5 8 3 2 7 0 9 5 4 6 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_grlex_test(): A COMP is a composition of an integer N into K parts. Each part is nonnegative. The order matters. comp_next_grlex determines the next COMP in graded lexicographic (grlex) order. 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(): A COMP is a composition of an integer N into K parts. Each part is nonnegative. The order matters. comp_random_grlex selects a random COMP in graded lexicographic (grlex) order between indices RANK1 and RANK2. 29: 4 = 1 + 3 + 0 47: 5 = 2 + 0 + 3 21: 4 = 0 + 0 + 4 44: 5 = 1 + 2 + 2 52: 5 = 3 + 1 + 1 comp_rank_grlex_test(): A COMP is a composition of an integer N into K parts. Each part is nonnegative. The order matters. comp_rank_grlex determines the rank of a COMP from its parts. Actual Inferred Test Rank Rank 0 58 58 1 53 53 2 35 35 3 34 34 4 32 32 comp_unrank_grlex_test(): A COMP is a composition of an integer N into K parts. Each part is nonnegative. The order matters. comp_unrank_grlex determines the parts of a COMP from its rank. 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 mono_next_grlex_test(): mono_next_grlex() computes the next monomial in M variables in grlex order. Let M = 4 0 1 1 1 0 1 2 0 0 2 0 1 0 2 1 0 0 3 0 0 1 0 0 2 3 0 3 3 3 0 4 2 3 0 5 1 3 0 6 0 3 1 0 5 3 1 1 4 1 3 3 0 1 4 0 2 1 4 1 1 1 4 2 0 1 5 0 1 1 5 1 0 1 3 2 3 1 3 3 2 1 3 4 1 1 3 5 0 1 4 0 4 1 4 1 3 3 0 1 0 3 1 0 0 4 0 0 0 0 0 0 5 0 0 1 4 0 0 2 3 2 1 2 0 2 2 0 1 2 2 1 0 2 3 0 0 3 0 0 2 3 0 1 1 1 1 2 0 1 2 0 1 1 2 1 0 1 3 0 0 2 0 0 2 2 0 1 1 2 1 1 3 2 1 2 2 2 1 3 1 2 1 4 0 2 2 0 3 2 2 1 2 0 0 3 0 0 1 0 2 0 1 1 1 0 1 2 0 0 2 0 1 0 2 1 0 3 1 2 2 3 1 3 1 3 1 4 0 3 2 0 3 3 2 1 2 3 2 2 1 mono_print_test(): mono_print() can print out a monomial. Monomial [5]: x^5 Monomial [-5]: x^(-5) Monomial [2,1,0,3]: x^(2,1,0,3) Monomial [17,-3,199]: x^(17,-3,199) mono_rank_grlex_test(): mono_rank_grlex() returns the rank of a monomial in the sequence of all monomials in M dimensions, in grlex order. Print a monomial sequence with ranks assigned. Let M = 3 N = 4 1 0 0 0 2 0 0 1 3 0 1 0 4 1 0 0 5 0 0 2 6 0 1 1 7 0 2 0 8 1 0 1 9 1 1 0 10 2 0 0 11 0 0 3 12 0 1 2 13 0 2 1 14 0 3 0 15 1 0 2 16 1 1 1 17 1 2 0 18 2 0 1 19 2 1 0 20 3 0 0 21 0 0 4 22 0 1 3 23 0 2 2 24 0 3 1 25 0 4 0 26 1 0 3 27 1 1 2 28 1 2 1 29 1 3 0 30 2 0 2 31 2 1 1 32 2 2 0 33 3 0 1 34 3 1 0 35 4 0 0 Now, given a monomial, retrieve its rank in the sequence: 1 0 0 0 4 1 0 0 2 0 0 1 7 0 2 0 15 1 0 2 24 0 3 1 77 3 2 1 158 5 2 1 mono_unrank_grlex(): mono_unrank_grlex() is given a rank, and returns the corresponding monomial in the sequence of all monomials in M dimensions in grlex order. For reference, print a monomial sequence with ranks. Let M = 3 N = 4 1 0 0 0 2 0 0 1 3 0 1 0 4 1 0 0 5 0 0 2 6 0 1 1 7 0 2 0 8 1 0 1 9 1 1 0 10 2 0 0 11 0 0 3 12 0 1 2 13 0 2 1 14 0 3 0 15 1 0 2 16 1 1 1 17 1 2 0 18 2 0 1 19 2 1 0 20 3 0 0 21 0 0 4 22 0 1 3 23 0 2 2 24 0 3 1 25 0 4 0 26 1 0 3 27 1 1 2 28 1 2 1 29 1 3 0 30 2 0 2 31 2 1 1 32 2 2 0 33 3 0 1 34 3 1 0 35 4 0 0 Now choose random ranks between 1 and 35 20 3 0 0 10 2 0 0 19 2 1 0 27 1 1 2 11 0 0 3 mono_upto_enum_test(): mono_upto_enum() can enumerate the number of monomials in M variables, of total degree between 0 and N. N: 0 1 2 3 4 5 6 7 8 M +--------------------------------------------------------------- 1 | 1 2 3 4 5 6 7 8 9 2 | 1 3 6 10 15 21 28 36 45 3 | 1 4 10 20 35 56 84 120 165 4 | 1 5 15 35 70 126 210 330 495 5 | 1 6 21 56 126 252 462 792 1287 6 | 1 7 28 84 210 462 924 1716 3003 7 | 1 8 36 120 330 792 1716 3432 6435 8 | 1 9 45 165 495 1287 3003 6435 12870 mono_upto_next_grlex_test() mono_upto_next_grlex() can list the monomials in M variables, of total degree up to N, in grlex order, one at a time. We start the process with (0,0,...,0,0). The process ends with (N,0,...,0,0) Let M = 3 N = 4 1 0 0 0 2 0 0 1 3 0 1 0 4 1 0 0 5 0 0 2 6 0 1 1 7 0 2 0 8 1 0 1 9 1 1 0 10 2 0 0 11 0 0 3 12 0 1 2 13 0 2 1 14 0 3 0 15 1 0 2 16 1 1 1 17 1 2 0 18 2 0 1 19 2 1 0 20 3 0 0 21 0 0 4 22 0 1 3 23 0 2 2 24 0 3 1 25 0 4 0 26 1 0 3 27 1 1 2 28 1 2 1 29 1 3 0 30 2 0 2 31 2 1 1 32 2 2 0 33 3 0 1 34 3 1 0 35 4 0 0 mono_upto_random_test(): mono_upto_random() selects at random a monomial in M dimensions of total degree no greater than N. Let M = 3 N = 4 13 0 2 1 15 1 0 2 12 0 1 2 10 2 0 0 15 1 0 2 mono_value_test() mono_value() evaluates a monomial. Let M = 3 N = 6 M(X) = x^(2,1,1) M(1,2,3) = 6 M(-2,4,1) = 16 M(X) = x^(3,2,0) M(1,2,3) = 4 M(-2,4,1) = -128 M(X) = x^(0,0,6) M(1,2,3) = 729 M(-2,4,1) = 1 M(X) = x^(0,4,0) M(1,2,3) = 16 M(-2,4,1) = 256 M(X) = x^(3,0,0) M(1,2,3) = 1 M(-2,4,1) = -8 polynomial_compress_test() polynomial_compress() compresses a polynomial. Uncompressed polynomial = + 7.0 * x^(0,0,0) - 5.0 * x^(0,0,1) + 5.0 * x^(0,0,1) + 9.0 * x^(1,0,0) + 11.0 * x^(0,0,2) + 3.0 * x^(0,0,2) + 6.0 * x^(0,0,2) + 0.0 * x^(0,1,2) - 13.0 * x^(3,0,1) + 1e-20 * x^(4,0,0). Compressed polynomial = + 7.0 * x^(0,0,0) + 9.0 * x^(1,0,0) + 20.0 * x^(0,0,2) - 13.0 * x^(3,0,1). polynomial_print_test() polynomial_print() prints a polynomial. P1(X) = + 7.0 * x^(0,0,0) - 5.0 * x^(0,0,1) + 9.0 * x^(1,0,0) + 11.0 * x^(0,0,2) + 0.0 * x^(0,1,2) - 13.0 * x^(3,0,1). polynomial_sort_test(): polynomial_sort() sorts a polynomial by exponent index. Unsorted polynomial: + 0.0 * x^(0,1,2) + 9.0 * x^(1,0,0) - 5.0 * x^(0,0,1) - 13.0 * x^(3,0,1) + 7.0 * x^(0,0,0) + 11.0 * x^(0,0,2). Sorted polynomial: + 7.0 * x^(0,0,0) - 5.0 * x^(0,0,1) + 9.0 * x^(1,0,0) + 11.0 * x^(0,0,2) + 0.0 * x^(0,1,2) - 13.0 * x^(3,0,1). polynomial_value_test(): polynomial_value() evaluates a polynomial. P(X) = + 7.0 * x^(0,0,0) - 5.0 * x^(0,0,1) + 9.0 * x^(1,0,0) + 11.0 * x^(0,0,2) + 0.0 * x^(0,1,2) - 13.0 * x^(3,0,1). P(1.000000,2.000000,3.000000) = 61 P(-2.000000,4.000000,1.000000) = 99 lp_coefficients_test(): lp_coefficients(): coefficients of Legendre polynomial P(n,x). P(0,x) = + 1.0 * x^(0). P(1,x) = + 1.0 * x^(1). P(2,x) = - 0.5 * x^(0) + 1.5 * x^(2). P(3,x) = - 1.5 * x^(1) + 2.5 * x^(3). P(4,x) = + 0.375 * x^(0) - 3.75 * x^(2) + 4.375 * x^(4). P(5,x) = + 1.875 * x^(1) - 8.75 * x^(3) + 7.875 * x^(5). P(6,x) = - 0.3125 * x^(0) + 6.5625 * x^(2) - 19.6875 * x^(4) + 14.4375 * x^(6). P(7,x) = - 2.1875 * x^(1) + 19.6875 * x^(3) - 43.3125 * x^(5) + 26.8125 * x^(7). P(8,x) = + 0.2734375 * x^(0) - 9.84375 * x^(2) + 54.140625 * x^(4) - 93.84375 * x^(6) + 50.2734375 * x^(8). P(9,x) = + 2.4609375 * x^(1) - 36.09375 * x^(3) + 140.765625 * x^(5) - 201.09375 * x^(7) + 94.9609375 * x^(9). P(10,x) = - 0.24609375 * x^(0) + 13.53515625 * x^(2) - 117.3046875 * x^(4) + 351.9140625 * x^(6) - 427.32421875 * x^(8) + 180.42578125 * x^(10). lp_value_test(): lp_value() evaluates a Legendre polynomial. Tabulated Computed O X L(O,X) L(O,X) Error 0 0.25000000 1 1 0 1 0.25000000 0.25 0.25 0 2 0.25000000 -0.40625 -0.40625 0 3 0.25000000 -0.3359375 -0.3359375 0 4 0.25000000 0.15771484375 0.15771484375 0 5 0.25000000 0.3397216796875 0.3397216796875 0 6 0.25000000 0.0242767333984375 0.0242767333984375 0 7 0.25000000 -0.2799186706542969 -0.2799186706542969 0 8 0.25000000 -0.1524540185928345 -0.1524540185928345 -2.8e-17 9 0.25000000 0.1768244206905365 0.1768244206905365 0 10 0.25000000 0.2212002165615559 0.2212002165615559 2.8e-17 3 0.00000000 0 -0 0 3 0.10000000 -0.1475 -0.1475 0 3 0.20000000 -0.28 -0.28 0 3 0.30000000 -0.3825 -0.3825 0 3 0.40000000 -0.44 -0.4399999999999999 -5.6e-17 3 0.50000000 -0.4375 -0.4375 0 3 0.60000000 -0.36 -0.36 5.6e-17 3 0.70000000 -0.1925 -0.1925000000000001 1.1e-16 3 0.80000000 0.08 0.08000000000000022 -2.2e-16 3 0.90000000 0.4725 0.4725000000000001 -1.1e-16 3 1.00000000 1 1 0 lp_values_test(): lp_values() stores values of the Legendre polynomial P(o,x). Tabulated O X L(O,X) 0 0.25000000 1 1 0.25000000 0.25 2 0.25000000 -0.40625 3 0.25000000 -0.3359375 4 0.25000000 0.15771484375 5 0.25000000 0.3397216796875 6 0.25000000 0.0242767333984375 7 0.25000000 -0.2799186706542969 8 0.25000000 -0.1524540185928345 9 0.25000000 0.1768244206905365 10 0.25000000 0.2212002165615559 3 0.00000000 0 3 0.10000000 -0.1475 3 0.20000000 -0.28 3 0.30000000 -0.3825 3 0.40000000 -0.44 3 0.50000000 -0.4375 3 0.60000000 -0.36 3 0.70000000 -0.1925 3 0.80000000 0.08 3 0.90000000 0.4725 3 1.00000000 1 lpp_to_polynomial_test(): lpp_to_polynomial() is given a Legendre product polynomial and determines its polynomial representation. Using spatial dimension M = 2 LPP #1 = L(0,X)*L(0,Y) = + 1.0 * x^(0,0). LPP #2 = L(0,X)*L(1,Y) = + 1.0 * x^(0,1). LPP #3 = L(1,X)*L(0,Y) = + 1.0 * x^(1,0). LPP #4 = L(0,X)*L(2,Y) = - 0.5 * x^(0,0) + 1.5 * x^(0,2). LPP #5 = L(1,X)*L(1,Y) = + 1.0 * x^(1,1). LPP #6 = L(2,X)*L(0,Y) = - 0.5 * x^(0,0) + 1.5 * x^(2,0). LPP #7 = L(0,X)*L(3,Y) = - 1.5 * x^(0,1) + 2.5 * x^(0,3). LPP #8 = L(1,X)*L(2,Y) = - 0.5 * x^(1,0) + 1.5 * x^(1,2). LPP #9 = L(2,X)*L(1,Y) = - 0.5 * x^(0,1) + 1.5 * x^(2,1). LPP #10 = L(3,X)*L(0,Y) = - 1.5 * x^(1,0) + 2.5 * x^(3,0). LPP #11 = L(0,X)*L(4,Y) = + 0.375 * x^(0,0) - 3.75 * x^(0,2) + 4.375 * x^(0,4). lpp_value_test(): lpp_value() evaluates a Legendre product polynomial. Evaluate at X = 0.748741 -0.608181 0.112467 Rank I1 I2 I3: L(I1,X1)*L(I2,X2)*L(I3,X3) P(X1,X2,X3) 1 0 0 0 1 1 2 0 0 1 0.112467 0.112467 3 0 1 0 -0.608181 -0.608181 4 1 0 0 0.748741 0.748741 5 0 0 2 -0.481027 -0.481027 6 0 1 1 -0.0684002 -0.0684002 7 0 2 0 0.0548258 0.0548258 8 1 0 1 0.0842086 0.0842086 9 1 1 0 -0.45537 -0.45537 10 2 0 0 0.340919 0.340919 11 0 0 3 -0.165144 -0.165144 12 0 1 2 0.292551 0.292551 13 0 2 1 0.00616609 0.00616609 14 0 3 0 0.349881 0.349881 15 1 0 2 -0.360164 -0.360164 16 1 1 1 -0.051214 -0.051214 17 1 2 0 0.0410503 0.0410503 18 2 0 1 0.0383421 0.0383421 19 2 1 0 -0.20734 -0.20734 20 3 0 0 -0.0737278 -0.0737278 legendre_product_polynomial_test(): Normal end of execution. Tue May 20 21:48:17 2025