Wed Oct 8 08:03:04 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 1 1 9 2 3 3 5 4 11 5 12 6 8 7 10 8 12 9 1 10 5 11 6 Permutation vector P[*]: 0 0 1 6 2 5 3 10 4 7 5 4 6 9 7 1 8 8 9 3 10 2 11 11 A[P[*]]: 0 1 1 8 2 12 3 5 4 10 5 11 6 1 7 9 8 12 9 5 10 3 11 6 i4vec_sort_heap_index_a_test() i4vec_sort_heap_index_a() creates an ascending sort index for an I4VEC. Unsorted array A: 0 25 1 3 2 19 3 58 4 38 5 50 6 17 7 10 8 11 9 20 10 5 11 25 12 16 13 42 14 7 15 16 16 5 17 29 18 33 19 59 Sort vector INDX: 0 1 1 16 2 10 3 14 4 7 5 8 6 12 7 15 8 6 9 2 10 9 11 11 12 0 13 17 14 18 15 4 16 13 17 5 18 3 19 19 I INDX(I) A(INDX(I)) 0 1 3 1 16 5 2 10 5 3 14 7 4 7 10 5 8 11 6 12 16 7 15 16 8 6 17 9 2 19 10 9 20 11 11 25 12 0 25 13 17 29 14 18 33 15 4 38 16 13 42 17 5 50 18 3 58 19 19 59 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 7 9 1 4 0 3 2 8 6 0 7 9 2 8 4 5 1 3 6 9 7 0 3 2 6 8 5 4 1 1 4 7 6 5 2 8 3 9 0 7 4 1 9 6 2 3 8 0 5 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. 26: 4 = 1 + 0 + 3 27: 4 = 1 + 1 + 2 39: 5 = 0 + 3 + 2 37: 5 = 0 + 1 + 4 48: 5 = 2 + 1 + 2 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 52 52 2 57 57 3 22 22 4 50 50 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 3 0 3 3 3 0 4 2 3 0 5 1 3 0 6 0 3 1 0 5 3 1 1 4 2 1 3 2 2 1 4 1 2 1 5 0 2 2 0 4 2 2 1 3 2 2 2 2 0 2 3 2 0 2 4 1 0 2 5 0 0 3 0 4 0 3 1 3 0 3 2 2 3 0 1 2 3 0 2 1 3 0 3 0 3 1 0 2 3 1 1 1 3 1 2 0 2 3 0 1 2 3 1 0 2 4 0 0 3 0 0 3 3 0 1 2 3 0 2 1 2 3 2 1 2 3 3 0 2 4 0 2 2 4 1 1 2 4 2 0 2 5 0 1 2 1 3 2 2 1 4 1 2 1 5 0 2 2 0 4 2 2 1 3 2 2 2 2 3 0 1 2 3 0 2 1 3 0 3 0 3 1 0 2 3 1 1 1 3 1 2 0 1 2 2 0 1 3 0 1 1 3 1 0 1 4 0 0 2 0 0 3 2 0 1 2 0 3 0 3 0 3 1 2 0 3 2 1 0 3 3 0 0 4 0 2 0 4 1 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 19 2 1 0 30 2 0 2 21 0 0 4 32 2 2 0 23 0 2 2 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 10 2 0 0 24 0 3 1 6 0 1 1 24 0 3 1 27 1 1 2 mono_value_test() mono_value() evaluates a monomial. Let M = 3 N = 6 M(X) = x^(1,5,0) M(1,2,3) = 32 M(-2,4,1) = -2048 M(X) = x^(1,3,2) M(1,2,3) = 72 M(-2,4,1) = -128 M(X) = x^(3,0,2) M(1,2,3) = 9 M(-2,4,1) = -8 M(X) = x^(2,1,0) M(1,2,3) = 2 M(-2,4,1) = 16 M(X) = x^(3,2,1) M(1,2,3) = 12 M(-2,4,1) = -128 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.630253 -0.486726 0.762747 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.762747 0.762747 3 0 1 0 -0.486726 -0.486726 4 1 0 0 -0.630253 -0.630253 5 0 0 2 0.372674 0.372674 6 0 1 1 -0.371249 -0.371249 7 0 2 0 -0.144646 -0.144646 8 1 0 1 -0.480723 -0.480723 9 1 1 0 0.306761 0.306761 10 2 0 0 0.0958284 0.0958284 11 0 0 3 -0.0347386 -0.0347386 12 0 1 2 -0.18139 -0.18139 13 0 2 1 -0.110328 -0.110328 14 0 3 0 0.441823 0.441823 15 1 0 2 -0.234879 -0.234879 16 1 1 1 0.233981 0.233981 17 1 2 0 0.0911637 0.0911637 18 2 0 1 0.0730928 0.0730928 19 2 1 0 -0.0466422 -0.0466422 20 3 0 0 0.319508 0.319508 legendre_product_polynomial_test(): Normal end of execution. Wed Oct 8 08:03:04 2025