17 September 2021 11:54:32.991 PM TRIANGLE_INTEGRALS_TEST: FORTRAN90 version. Test the TRIANGLE_INTEGRALS library. I4_TO_PASCAL_TEST I4_TO_PASCAL converts a linear index to Pascal triangle indices. K => I J 1 0 0 2 1 0 3 0 1 4 2 0 5 1 1 6 0 2 7 3 0 8 2 1 9 1 2 10 0 3 11 4 0 12 3 1 13 2 2 14 1 3 15 0 4 16 5 0 17 4 1 18 3 2 19 2 3 20 1 4 I4_TO_PASCAL_DEGREE_TEST I4_TO_PASCAL_DEGREE converts a linear index to the degree of the corresponding Pascal triangle indices. K => D 1 0 2 1 3 1 4 2 5 2 6 2 7 3 8 3 9 3 10 3 11 4 12 4 13 4 14 4 15 4 16 5 17 5 18 5 19 5 20 5 PASCAL_TO_I4_TEST PASCAL_TO_I4 converts Pascal triangle indices to a linear index. I J => K 0 0 1 1 0 2 0 1 3 2 0 4 1 1 5 0 2 6 3 0 7 2 1 8 1 2 9 0 3 10 4 0 11 3 1 12 2 2 13 1 3 14 0 4 15 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. TRINOMIAL_TEST TRINOMIAL evaluates the trinomial coefficient: T(I,J,K) = (I+J+K)! / I! / J! / K! I J K T(I,J,K) 0 0 0 1 1 0 0 1 2 0 0 1 3 0 0 1 4 0 0 1 0 1 0 1 1 1 0 2 2 1 0 3 3 1 0 4 4 1 0 5 0 2 0 1 1 2 0 3 2 2 0 6 3 2 0 10 4 2 0 15 0 3 0 1 1 3 0 4 2 3 0 10 3 3 0 20 4 3 0 35 0 4 0 1 1 4 0 5 2 4 0 15 3 4 0 35 4 4 0 70 0 0 1 1 1 0 1 2 2 0 1 3 3 0 1 4 4 0 1 5 0 1 1 2 1 1 1 6 2 1 1 12 3 1 1 20 4 1 1 30 0 2 1 3 1 2 1 12 2 2 1 30 3 2 1 60 4 2 1 105 0 3 1 4 1 3 1 20 2 3 1 60 3 3 1 140 4 3 1 280 0 4 1 5 1 4 1 30 2 4 1 105 3 4 1 280 4 4 1 630 0 0 2 1 1 0 2 3 2 0 2 6 3 0 2 10 4 0 2 15 0 1 2 3 1 1 2 12 2 1 2 30 3 1 2 60 4 1 2 105 0 2 2 6 1 2 2 30 2 2 2 90 3 2 2 210 4 2 2 420 0 3 2 10 1 3 2 60 2 3 2 210 3 3 2 560 4 3 2 1260 0 4 2 15 1 4 2 105 2 4 2 420 3 4 2 1260 4 4 2 3150 0 0 3 1 1 0 3 4 2 0 3 10 3 0 3 20 4 0 3 35 0 1 3 4 1 1 3 20 2 1 3 60 3 1 3 140 4 1 3 280 0 2 3 10 1 2 3 60 2 2 3 210 3 2 3 560 4 2 3 1260 0 3 3 20 1 3 3 140 2 3 3 560 3 3 3 1680 4 3 3 4200 0 4 3 35 1 4 3 280 2 4 3 1260 3 4 3 4200 4 4 3 11550 0 0 4 1 1 0 4 5 2 0 4 15 3 0 4 35 4 0 4 70 0 1 4 5 1 1 4 30 2 1 4 105 3 1 4 280 4 1 4 630 0 2 4 15 1 2 4 105 2 2 4 420 3 2 4 1260 4 2 4 3150 0 3 4 35 1 3 4 280 2 3 4 1260 3 3 4 4200 4 3 4 11550 0 4 4 70 1 4 4 630 2 4 4 3150 3 4 4 11550 4 4 4 34650 RS_TO_XY_MAP_TEST: RS_TO_XY_MAP determines the coefficients of the linear map from a the reference in RS coordinates to the physical triangle in XY coordinates: X = a + b * R + c * S Y = d + e * R + f * S XY triangle vertices: Col 1 2 3 Row 1: 2. 3. 0. 2: 0. 4. 3. Mapping coefficients are: X = 2.00000 + 1.00000 * R + -2.00000 * S Y = 0.00000 + 4.00000 * R + 3.00000 * S Apply map to RS triangle vertices. Recover XY vertices (2,0), (3,4) and (0,3). V(1) = ( 2.00000 , 0.00000 ) V(2) = ( 3.00000 , 4.00000 ) V(3) = ( 0.00000 , 3.00000 ) XY_TO_RS_MAP_TEST: XY_TO_RS_MAP determines the coefficients of the linear map from a general triangle in XY coordinates to the reference triangle in RS coordinates: R = a + b * X + c * Y S = d + e * X + f * Y XY triangle vertices: Col 1 2 3 Row 1: 2. 3. 0. 2: 0. 4. 3. Mapping coefficients are: R = -0.545455 + 0.272727 * X + 0.181818 * Y S = 0.727273 + -0.363636 * X + 0.909091E-01 * Y Apply map to XY triangle vertices. Recover RS vertices (0,0), (1,0) and (0,1). V(1) = ( 0.00000 , 0.00000 ) V(2) = ( 1.00000 , 0.111022E-15 ) V(3) = ( 0.00000 , 1.00000 ) POLY_PRINT_TEST: POLY_PRINT can print a D-degree polynomial in X and Y. P1(x,y) = 12.34 p1(x,y) = + 12.3400 P2(x,y) = 1 + 2 * x + 3 * Y p2(x,y) = + 1.00000 + 2.00000 x + 3.00000 y P3(x,y) = xy p3(x,y) = xy = + 1.00000 xy P4(x,y) = 1.0 - 2.1 * x + 3.2 * y - 4.3 * x^2 + 5.4 * xy - 6.5 * y^2 + 7.6 * x^3 - 8.7 * x^2y + 9.8 * xy^2 - 10.9 * y^3. p4(x,y) = + 1.00000 - 2.10000 x + 3.20000 y - 4.30000 x^ 2 + 5.40000 xy - 6.50000 y^ 2 + 7.60000 x^ 3 - 8.70000 x^ 2y + 9.80000 xy^ 2 - 10.9000 y^ 3 POLY_POWER_LINEAR_TEST: POLY_POWER_LINEAR computes the N-th power of a linear polynomial in X and Y. p1(x,y) = + 1.00000 + 2.00000 x + 3.00000 y p2(x,y) = p1(x,y)^n = + 1.00000 + 4.00000 x + 6.00000 y + 4.00000 x^ 2 + 12.0000 xy + 9.00000 y^ 2 Correct answer = + 1.00000 + 4.00000 x + 6.00000 y + 4.00000 x^ 2 + 12.0000 xy + 9.00000 y^ 2 p4(x,y) = + 2.00000 - 1.00000 x + 3.00000 y p5(x,y) = p4(x,y)^3 = + 8.00000 - 12.0000 x + 36.0000 y + 6.00000 x^ 2 - 36.0000 xy + 54.0000 y^ 2 - 1.00000 x^ 3 + 9.00000 x^ 2y - 27.0000 xy^ 2 + 27.0000 y^ 3 Correct answer = + 8.00000 - 12.0000 x + 36.0000 y + 6.00000 x^ 2 - 36.0000 xy + 54.0000 y^ 2 - 1.00000 x^ 3 + 9.00000 x^ 2y - 27.0000 xy^ 2 + 27.0000 y^ 3 POLY_POWER_TEST: POLY_POWER computes the N-th power of an X,Y polynomial. p1(x,y) = + 1.00000 + 2.00000 x + 3.00000 y p2(x,y) = p1(x,y)^2 = + 1.00000 + 4.00000 x + 6.00000 y + 4.00000 x^ 2 + 12.0000 xy + 9.00000 y^ 2 p3(x,y)=correct answer = + 1.00000 + 4.00000 x + 6.00000 y + 4.00000 x^ 2 + 12.0000 xy + 9.00000 y^ 2 p4(x,y) = + 1.00000 - 2.00000 x + 3.00000 y - 4.00000 x^ 2 + 5.00000 xy - 6.00000 y^ 2 p5(x,y) = p1(x,y)^3 = + 1.00000 - 6.00000 x + 9.00000 y - 21.0000 xy + 9.00000 y^ 2 + 40.0000 x^ 3 - 96.0000 x^ 2y + 108.000 xy^ 2 - 81.0000 y^ 3 + 84.0000 x^ 3y - 141.000 x^ 2y^ 2 + 171.000 xy^ 3 - 54.0000 y^ 4 - 96.0000 x^ 5 + 384.000 x^ 4y - 798.000 x^ 3y^ 2 + 1017.00 x^ 2y^ 3 - 756.000 xy^ 4 + 324.000 y^ 5 - 64.0000 x^ 6 + 240.000 x^ 5y - 588.000 x^ 4y^ 2 + 845.000 x^ 3y^ 3 - 882.000 x^ 2y^ 4 + 540.000 xy^ 5 - 216.000 y^ 6 p6(x,y)=correct answer = + 1.00000 - 6.00000 x + 9.00000 y - 21.0000 xy + 9.00000 y^ 2 + 40.0000 x^ 3 - 96.0000 x^ 2y + 108.000 xy^ 2 - 81.0000 y^ 3 + 84.0000 x^ 3y - 141.000 x^ 2y^ 2 + 171.000 xy^ 3 - 54.0000 y^ 4 - 96.0000 x^ 5 + 384.000 x^ 4y - 798.000 x^ 3y^ 2 + 1017.00 x^ 2y^ 3 - 756.000 xy^ 4 + 324.000 y^ 5 - 64.0000 x^ 6 + 240.000 x^ 5y - 588.000 x^ 4y^ 2 + 845.000 x^ 3y^ 3 - 882.000 x^ 2y^ 4 + 540.000 xy^ 5 - 216.000 y^ 6 POLY_PRODUCT_TEST: POLY_PRODUCT computes the product of two X,Y polynomials. p1(x,y) = + 1.00000 + 2.00000 x + 3.00000 y p2(x,y) = + 4.00000 + 5.00000 x p3(x,y) = p1(x,y) * p2(x,y) = + 4.00000 + 13.0000 x + 12.0000 y + 10.0000 x^ 2 + 15.0000 xy p4(x,y) = correct answer = + 4.00000 + 13.0000 x + 12.0000 y + 10.0000 x^ 2 + 15.0000 xy p5(x,y) = + 1.00000 - 2.00000 x + 3.00000 y - 4.00000 x^ 2 + 5.00000 xy - 6.00000 y^ 2 p6(x,y) = + 7.00000 + 3.00000 x^ 2 p7(x,y) = p5(x,y) * p6(x,y) = + 7.00000 - 14.0000 x + 21.0000 y - 25.0000 x^ 2 + 35.0000 xy - 42.0000 y^ 2 - 6.00000 x^ 3 + 9.00000 x^ 2y - 12.0000 x^ 4 + 15.0000 x^ 3y - 18.0000 x^ 2y^ 2 p8(x,y) = Correct answer = + 7.00000 - 14.0000 x + 21.0000 y - 25.0000 x^ 2 + 35.0000 xy - 42.0000 y^ 2 - 6.00000 x^ 3 + 9.00000 x^ 2y - 12.0000 x^ 4 + 15.0000 x^ 3y - 18.0000 x^ 2y^ 2 TRIANGLE01_MONOMIAL_INTEGRAL_TEST TRIANGLE01_MONOMIAL_INTEGRAL returns the integral Q of a monomial X^I Y^J over the interior of the unit triangle. I J Q(I,J) 0 0 0.500000 0 1 0.166667 1 0 0.166667 0 2 0.833333E-01 1 1 0.416667E-01 2 0 0.833333E-01 0 3 0.500000E-01 1 2 0.166667E-01 2 1 0.166667E-01 3 0 0.500000E-01 0 4 0.333333E-01 1 3 0.833333E-02 2 2 0.555556E-02 3 1 0.833333E-02 4 0 0.333333E-01 0 5 0.238095E-01 1 4 0.476190E-02 2 3 0.238095E-02 3 2 0.238095E-02 4 1 0.476190E-02 5 0 0.238095E-01 TRIANGLE01_POLY_INTEGRAL_TEST TRIANGLE01_POLY_INTEGRAL returns the integral Q of a polynomial P(X,Y) over the interior of the unit triangle. p(x,y) = + 1.00000 + 2.00000 x + 3.00000 y Q = 1.33333 Q (exact) = 1.33333 p(x,y) = + 1.00000 xy Q = 0.416667E-01 Q (exact) = 0.416667E-01 p(x,y) = + 1.00000 - 2.00000 x + 3.00000 y - 4.00000 x^ 2 + 5.00000 xy - 6.00000 y^ 2 Q = 0.416667E-01 Q (exact) = 0.416667E-01 TRIANGLE_AREA_TEST: TRIANGLE_AREA determines the (signed) area of a triangle. Triangle vertices are: (X1,Y1) = (0,0) (X2,Y2) = 2*(cos(angle),sin(angle)) (X3,Y3) = (0,1) where angle will sweep from 0 to 360 degrees. I Angle X2 Y2 Area (degrees) 0 0.0000 2.0000 0.0000 1.00000 1 15.0000 1.9319 0.5176 0.965926 2 30.0000 1.7321 1.0000 0.866025 3 45.0000 1.4142 1.4142 0.707107 4 60.0000 1.0000 1.7321 0.500000 5 75.0000 0.5176 1.9319 0.258819 6 90.0000 0.0000 2.0000 0.612323E-16 7 105.0000 -0.5176 1.9319 -0.258819 8 120.0000 -1.0000 1.7321 -0.500000 9 135.0000 -1.4142 1.4142 -0.707107 10 150.0000 -1.7321 1.0000 -0.866025 11 165.0000 -1.9319 0.5176 -0.965926 12 180.0000 -2.0000 0.0000 -1.00000 13 195.0000 -1.9319 -0.5176 -0.965926 14 210.0000 -1.7321 -1.0000 -0.866025 15 225.0000 -1.4142 -1.4142 -0.707107 16 240.0000 -1.0000 -1.7321 -0.500000 17 255.0000 -0.5176 -1.9319 -0.258819 18 270.0000 -0.0000 -2.0000 -0.183697E-15 19 285.0000 0.5176 -1.9319 0.258819 20 300.0000 1.0000 -1.7321 0.500000 21 315.0000 1.4142 -1.4142 0.707107 22 330.0000 1.7321 -1.0000 0.866025 23 345.0000 1.9319 -0.5176 0.965926 24 360.0000 2.0000 -0.0000 1.00000 TRIANGLE_XY_INTEGRAL_TEST TRIANGLE_XY_INTEGRAL determines Q, the integral of the monomial X*Y over a triangle (X1,Y1), (X2,Y2), (X3,Y3). (X1,Y1) = ( 0.00000 , 0.00000 ) (X2,Y2) = ( 1.00000 , 0.00000 ) (X3,Y3) = ( 1.00000 , 2.00000 ) Q = 0.500000 (Expecting answer 1/2. (X1,Y1) = ( 0.00000 , 0.00000 ) (X2,Y2) = ( 4.00000 , 0.00000 ) (X3,Y3) = ( 0.00000 , 1.00000 ) Q = 0.666667 (Expecting answer 2/3. TRIANGLE_MONOMIAL_INTEGRAL_TEST TRIANGLE_MONOMIAL_INTEGRAL returns the integral Q of a monomial X^I Y^J over the interior of a triangle. Triangle vertices: ( 0.00000 , 0.00000 ) ( 1.00000 , 0.00000 ) ( 0.00000 , 1.00000 ) Integrand = x^1 * y^0 Computed Q = 0.166667 Exact Q = 0.166667 Triangle vertices: ( 0.00000 , 0.00000 ) ( 1.00000 , 0.00000 ) ( 1.00000 , 2.00000 ) Integrand = x^1 * y^1 Computed Q = 0.500000 Exact Q = 0.500000 Triangle vertices: ( -3.00000 , 0.00000 ) ( 6.00000 , 0.00000 ) ( 0.00000 , 3.00000 ) Integrand = x^1 * y^0 Computed Q = 13.5000 Exact Q = 13.5000 Triangle vertices: ( 0.00000 , 0.00000 ) ( 4.00000 , 0.00000 ) ( 0.00000 , 1.00000 ) Integrand = x^1 * y^1 Computed Q = 0.666667 Exact Q = 0.666667 TRIANGLE_POLY_INTEGRAL_TEST TRIANGLE_POLY_INTEGRAL returns the integral Q of a polynomial over the interior of a triangle. Triangle vertices: ( 0.00000 , 0.00000 ) ( 1.00000 , 0.00000 ) ( 0.00000 , 1.00000 ) Integrand p1(x,y) = + 1.00000 x Computed Q = 0.166667 Exact Q = 0.166667 Triangle vertices: ( 0.00000 , 0.00000 ) ( 1.00000 , 0.00000 ) ( 1.00000 , 2.00000 ) Integrand p2(x,y) = + 1.00000 xy Computed Q = 0.500000 Exact Q = 0.500000 Triangle vertices: ( 0.00000 , 0.00000 ) ( 1.00000 , 0.00000 ) ( 1.00000 , 3.00000 ) Integrand p3(x,y) = + 2.00000 - 3.00000 x + 1.00000 xy Computed Q = 1.12500 Exact Q = 1.12500 Triangle vertices: ( 0.00000 , 3.00000 ) ( 1.00000 , 1.00000 ) ( 5.00000 , 3.00000 ) Integrand p4(x,y) = - 40.0000 y + 6.00000 x^ 2 Computed Q = -311.667 Exact Q = -311.667 TRIANGLE_INTEGRALS_TEST: Normal end of execution. 17 September 2021 11:54:32.991 PM