21 January 2020 11:07:20 AM
TRIANGLE_INTEGRALS_TEST:
C 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 matrix:
Col: 0 1 2 3
Row
0: 11 12 13 14
1: 21 22 23 24
2: 31 32 33 34
3: 41 42 43 44
4: 51 52 53 54
5: 61 62 63 64
R8MAT_PRINT_SOME_TEST
R8MAT_PRINT_SOME prints some of an R8MAT.
Rows 2:4, Cols 1:2:
Col: 0 1
Row
1: 21 22
2: 31 32
3: 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: 0 1 2
Row
0: 2 3 0
1: 0 4 3
Mapping coefficients are:
X = 2 + 1 * R + -2 * S
Y = 0 + 4 * R + 3 * S
Apply map to RS triangle vertices.
Recover XY vertices (2,0), (3,4) and (0,3).
V(0) = ( 2,0)
V(1) = ( 3,4)
V(2) = ( 0,3)
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: 0 1 2
Row
0: 2 3 0
1: 0 4 3
Mapping coefficients are:
R = -0.545455 + 0.272727 * X + 0.181818 * Y
S = 0.727273 + -0.363636 * X + 0.0909091 * Y
Apply map to XY triangle vertices.
Recover RS vertices (0,0), (1,0) and (0,1).
V[0] = (0,0)
V[1] = (1,1.11022e-16)
V[2] = (0,1)
POLY_PRINT_TEST:
POLY_PRINT can print a D-degree polynomial in X and Y.
P1(x,y) = 12.34
p1(x,y) =
+12.34
P2(x,y) = 1 + 2 * x + 3 * Y
p2(x,y) =
+1
+2 x
+3 y
P3(x,y) = xy
p3(x,y) = xy = 0
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
-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
POLY_POWER_LINEAR_TEST:
POLY_POWER_LINEAR computes the N-th power of
a linear polynomial in X and Y.
p1(x,y)