9 September 2021 7:50:32.035 PM I4LIB_TEST FORTRAN90 version Test the I4LIB library. i4_abs_test(): i4_abs() returns the absolute value of an I4. A B=I4_ABS(A) -64 64 40 40 -68 68 27 27 48 48 -95 95 -31 31 68 68 -49 49 -91 91 i4_and_test(): i4_and() returns the bitwise AND of two integers. Compare with FORTRAN90 intrinsic IAND. I J I4_AND IAND 18 54 18 18 73 98 64 64 83 31 19 19 48 8 0 0 6 31 6 6 0 12 0 0 56 11 8 8 90 96 64 64 92 75 72 72 99 62 34 34 I4_BCLR_TEST I4_BCLR sets a given bit to 0. Working on I4 = 101 Pos I4_BCLR(I4,POS) 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(I4,POS) 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_BIT_HI1_TEST I4_BIT_HI1 returns the location of the high 1 bit. I I4_BIT_HI1(I) 31 5 21 5 9 4 1 1 100 7 43 6 58 6 37 6 2 2 1 1 I4_BIT_LO0_TEST I4_BIT_LO0 returns the location of the low 0 bit. I I4_BIT_LO0(I) 50 1 56 1 38 1 2 1 1 2 98 1 99 3 22 1 45 2 48 1 I4_BIT_LO1_TEST I4_BIT_LO1 returns the location of the low 1 bit. I I4_BIT_LO1(I) 19 1 25 1 54 2 73 1 88 4 60 3 19 1 50 2 94 2 26 2 I4_BIT_REVERSE_TEST I4_BIT_REVERSE bit reverses I with respect to 2^J I J I4_BIT_REVERSE(I,J) 0 0 0 0 1 0 1 1 1 0 2 0 1 2 2 2 2 1 3 2 3 0 3 0 1 3 4 2 3 2 3 3 6 4 3 1 5 3 5 6 3 3 7 3 7 0 4 0 1 4 8 2 4 4 3 4 12 4 4 2 5 4 10 6 4 6 7 4 14 8 4 1 9 4 9 10 4 5 11 4 13 12 4 3 13 4 11 14 4 7 15 4 15 I4_BSET_TEST I4_BSET sets a given bit to 1. Working on I4 = 101 Pos I4_BSET(I4,POS) 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(I4,POS) 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 T 1 F 2 T 3 F 4 F 5 T 6 T 7 F 8 F 9 F 10 F 11 F 12 F 13 F 14 F 15 F 16 F 17 F 18 F 19 F 20 F 21 F 22 F 23 F 24 F 25 F 26 F 27 F 28 F 29 F 30 F 31 F Analyze the integer I4 = -31 Pos I4_BTEST(I4,POS) 0 T 1 F 2 F 3 F 4 F 5 T 6 T 7 T 8 T 9 T 10 T 11 T 12 T 13 T 14 T 15 T 16 T 17 T 18 T 19 T 20 T 21 T 22 T 23 T 24 T 25 T 26 T 27 T 28 T 29 T 30 T 31 T I4_CEILING_TEST I4_CEILING evaluates the "ceiling" of an R8. R8 I4_CEILING(R8) -68.1911 -68 11.0391 12 54.1058 55 0.0426 1 -3.0100 -3 79.1614 80 35.3894 36 66.6018 67 88.5791 89 43.3776 44 I4_CHARACTERISTIC_TEST I4_CHARACTERISTIC computes the characteristic of an integer Q, which is Q if Q is prime; P, if Q = P^N for some prime P; 0, if Q is negative, 0, 1, or the product of more than 1 distinct prime. I I4_CHARACTERISTIC 1 0 2 2 3 3 4 2 5 5 6 0 7 7 8 2 9 3 10 0 11 11 12 0 13 13 14 0 15 0 16 2 17 17 18 0 19 19 20 0 21 0 22 0 23 23 24 0 25 5 26 0 27 3 28 0 29 29 30 0 31 31 32 2 33 0 34 0 35 0 36 0 37 37 38 0 39 0 40 0 41 41 42 0 43 43 44 0 45 0 46 0 47 47 48 0 49 7 50 0 I4_CHOOSE_TEST I4_CHOOSE evaluates C(N,K). N K CNK 0 0 1 1 0 1 1 1 1 2 0 1 2 1 2 2 2 1 3 0 1 3 1 3 3 2 3 3 3 1 4 0 1 4 1 4 4 2 6 4 3 4 4 4 1 I4_CHOOSE_CHECK_TEST I4_CHOOSE_CHECK checks whether C(N,K) can be computed with integer arithmetic or not. N K CHECK? I4_CHOOSE 10 3 T 120 1000 999 T 1000 100 3 T 161700 100 10 F Not computable I4_CHOOSE_LOG_TEST I4_CHOOSE_LOG evaluates log(C(N,K)). N K lcnk elcnk CNK 0 0 0.00000 1.00000 1 1 0 0.00000 1.00000 1 1 1 0.00000 1.00000 1 2 0 0.00000 1.00000 1 2 1 0.693147 2.00000 2 2 2 0.00000 1.00000 1 3 0 0.00000 1.00000 1 3 1 1.09861 3.00000 3 3 2 1.09861 3.00000 3 3 3 0.00000 1.00000 1 4 0 0.00000 1.00000 1 4 1 1.38629 4.00000 4 4 2 1.79176 6.00000 6 4 3 1.38629 4.00000 4 4 4 0.00000 1.00000 1 I4_DIV_ROUNDED_TEST I4_DIV_ROUNDED performs rounded integer division. C0 = real ( a ) / real ( b ) C1 = I4_DIV_ROUNDED ( A, B ) C2 = nint ( real ( a ) / real ( b ) ) C3 = A / B C4 = int ( real ( a ) / real ( b ) ) C1 and C2 should be equal; C3 and C4 should be equal. A B C0 C1 C2 C3 C4 43 4 10.750000 11 11 10 10 -49 7 -7.000000 -7 -7 -7 -7 70 1 70.000000 70 70 70 70 -52 -1 52.000000 52 52 52 52 -23 8 -2.875000 -3 -3 -2 -2 32 2 16.000000 16 16 16 16 -58 10 -5.800000 -6 -6 -5 -5 -81 10 -8.100000 -8 -8 -8 -8 8 -10 -0.800000 -1 -1 0 0 88 6 14.666667 15 15 14 14 61 -5 -12.200000 -12 -12 -12 -12 1 10 0.100000 0 0 0 0 55 -1 -55.000000 -55 -55 -55 -55 60 -3 -20.000000 -20 -20 -20 -20 -7 8 -0.875000 -1 -1 0 0 -62 -1 62.000000 62 62 62 62 18 10 1.800000 2 2 1 1 -85 -10 8.500000 8 9 8 8 99 -4 -24.750000 -25 -25 -24 -24 45 -3 -15.000000 -15 -15 -15 -15 I4_DIVP_TEST I4_DIVP(A,B) returns the smallest multiplier of J that is less than I A B C D 82 -7 -10 70 -35 -1 37 -37 88 7 13 91 -92 -9 11 -99 -42 8 -4 -32 17 1 17 17 -51 -5 11 -55 -23 3 -7 -21 78 10 8 80 -64 -9 8 -72 82 9 10 90 36 2 18 36 -44 -6 8 -48 -63 7 -8 -56 88 7 13 91 -8 -2 5 -10 -4 -9 1 -9 -87 -8 12 -96 -31 6 -4 -24 -96 9 -9 -81 I4_FACTORIAL_TEST: I4_FACTORIAL evaluates the factorial function: N Exact I4_FACTORIAL(N) 0 1 1 1 1 1 2 2 2 3 6 6 4 24 24 5 120 120 6 720 720 7 5040 5040 8 40320 40320 9 362880 362880 10 3628800 3628800 11 39916800 39916800 12 479001600 479001600 I4_FACTORIAL_LOG_TEST: I4_FACTORIAL_LOG evaluates log(N!): N lfact elfact fact 0 0.00000 1.00000 1 1 0.00000 1.00000 1 2 0.693147 2.00000 2 3 1.79176 6.00000 6 4 3.17805 24.0000 24 5 4.78749 120.000 120 6 6.57925 720.000 720 7 8.52516 5040.00 5040 8 10.6046 40320.0 40320 9 12.8018 362880. 362880 10 15.1044 0.362880E+07 3628800 11 17.5023 0.399168E+08 39916800 12 19.9872 0.479002E+09 479001600 I4_FACTORIAL2_TEST: I4_FACTORIAL2 evaluates the double factorial function: N Exact I4_FACTORIAL2(N) 0 1 1 1 1 1 2 2 2 3 3 3 4 8 8 5 15 15 6 48 48 7 105 105 8 384 384 9 945 945 10 3840 3840 11 10395 10395 12 46080 46080 13 135135 135135 14 645120 645120 15 2027025 2027025 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_FLOOR_TEST I4_FLOOR evaluates the "floor" of a real number. R8 I4_FLOOR(R8) 69.0438 69 -77.5209 -78 57.8563 57 72.7367 72 47.2176 47 -75.2288 -76 -76.4330 -77 -31.8275 -32 -98.5329 -99 -62.4598 -63 I4_GCD_TEST I4_GCD computes the greatest common factor, I J I4_GCD 36 30 6 49 -7 7 0 71 71 12 12 12 36 49 1 1 42 1 91 28 7 I4_HUGE_TEST I4_HUGE returns a huge integer. I4_HUGE() = 2147483647 HUGE(1) = 2147483647 I4_HUGE_NORMALIZER_TEST I4_HUGE_NORMALIZER returns 1/(I4_HUGE+1). I4_HUGE() = 2147483647 I4_HUGE_NORMALIZER() = 0.465661E-09 I4_HUGE * I4_HUGE_NORMALIZER = 1.00000 I4_IS_EVEN_TEST I4_IS_EVEN reports whether an I4 is even. I I4_IS_EVEN(I) -2 T -1 F 0 T 1 F 2 T 3 F 4 T 5 F 6 T 7 F 8 T 9 F 10 T 11 F 12 T 13 F 14 T 15 F 16 T 17 F 18 T 19 F 20 T 21 F 22 T 23 F 24 T 25 F I4_IS_ODD_TEST I4_IS_ODD reports whether an I4 is odd. I I4_IS_ODD(I) -2 F -1 T 0 F 1 T 2 F 3 T 4 F 5 T 6 F 7 T 8 F 9 T 10 F 11 T 12 F 13 T 14 F 15 T 16 F 17 T 18 F 19 T 20 F 21 T 22 F 23 T 24 F 25 T I4_IS_POWER_OF_2_TEST I4_IS_POWER_OF_2 reports whether an I4 is a power of 2. I I4_IS_POWER_OF_2(I) -4 F -3 F -2 F -1 F 0 F 1 T 2 T 3 F 4 T 5 F 6 F 7 F 8 T 9 F 10 F 11 F 12 F 13 F 14 F 15 F 16 T 17 F 18 F 19 F 20 F 21 F 22 F 23 F 24 F 25 F I4_IS_POWER_OF_10_TEST I4_IS_POWER_OF_10 reports whether an I4 is a power of 10. I I4_IS_POWER_OF_10(I) 97 F 98 F 99 F 100 T 101 F 102 F 103 F I4_IS_PRIME_TEST I4_IS_PRIME reports whether an I4 is prime. I I4_IS_PRIME(I) -2 F -1 F 0 F 1 F 2 T 3 T 4 F 5 T 6 F 7 T 8 F 9 F 10 F 11 T 12 F 13 T 14 F 15 F 16 F 17 T 18 F 19 T 20 F 21 F 22 F 23 T 24 F 25 F I4_LCM_TEST I4_LCM computes the least common multiple. I J I4_LCM 36 30 180 49 -7 49 0 71 0 12 12 12 36 49 1764 1 42 42 91 28 364 I4_LCM_12N_TEST I4_LCM_12N computes the least common multiple of integer 1 through N N I4_LCM_12N 1 1 2 2 3 6 4 12 5 60 6 60 7 420 8 420 9 1260 10 1260 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_LOG_2_TEST I4_LOG_2: whole part of log base 2. X I4_LOG_2 0 -2147483647 1 0 2 1 3 1 9 3 10 3 11 3 99 6 101 6 -1 0 -2 1 -3 1 -9 3 1000 9 1023 9 1024 10 1025 10 I4_LOG_I4_TEST I4_LOG_I4: logarithm of I4 base J4, I4 J4 I4_LOG_I4 0 2 0 1 2 0 2 2 1 3 2 1 4 2 2 5 2 2 6 2 2 7 2 2 8 2 3 9 2 3 10 2 3 0 3 0 1 3 0 2 3 0 3 3 1 4 3 1 5 3 1 6 3 1 7 3 1 8 3 1 9 3 2 10 3 2 0 4 0 1 4 0 2 4 0 3 4 0 4 4 1 5 4 1 6 4 1 7 4 1 8 4 1 9 4 1 10 4 1 0 5 0 1 5 0 2 5 0 3 5 0 4 5 0 5 5 1 6 5 1 7 5 1 8 5 1 9 5 1 10 5 1 I4_LOG_R8_TEST I4_LOG_R8: whole part of log base B, X B I4_LOG_R8 16 2.00000 3 16 3.00000 2 16 4.00000 1 16 5.00000 1 16 6.00000 1 16 7.00000 1 16 8.00000 1 16 16.0000 0 16 32.0000 0 16 256.000 0 I4_MANT_TEST I4_MANT decomposes an integer, Number to be decomposed is X = -314.159 I4_MANT: X = -1 * ( -1580547965/ 0) * 2 ^ 8 I4_MAX_TEST I4_MAX returns the maximum of two I4's. A B C=I4_MAX(A,B) 40 24 40 52 18 52 18 15 18 -82 -93 -82 -73 75 75 -90 -26 -26 87 47 87 -75 34 34 80 8 80 -4 -28 -4 I4_MIN_TEST I4_MIN returns the minimum of two I4's. A B C=I4_MIN(A,B) -24 -71 -71 -50 -65 -65 27 -46 -46 94 70 70 27 53 27 14 -80 -80 77 -70 -70 48 76 48 11 8 8 35 -25 -25 I4_MODDIV_TEST I4_MODDIV factors a number into a multiple M and remainder R. Number Divisor Multiple Remainder 107 50 2 7 107 -50 -2 7 -107 50 -2 -7 -107 -50 2 -7 Repeat using FORTRAN MOD: 107 50 2 7 107 -50 -2 7 -107 50 -2 -7 -107 -50 2 -7 I4_MODP_TEST I4_MODP factors a number into a multiple and a positive remainder. Number Divisor Multiple Remainder 107 50 2 7 107 -50 -2 7 -107 50 -3 43 -107 -50 3 43 Repeat using FORTRAN MOD: 107 50 2 7 107 -50 -2 7 -107 50 -2 -7 -107 -50 2 -7 I4_NORMAL_AB_TEST I4_NORMAL_AB computes integer pseudonormal values with mean MU and standard deviation SIGMA. MU = 70.0000 SIGMA = 10.0000 1 65 2 79 3 56 4 78 5 73 6 84 7 67 8 59 9 59 10 76 I4_NOT_TEST I4_NOT returns the NOT of an integer I with respect to a maximum integer J. Compare with FORTRAN90 intrinsic NOT. I J I4_NOT NOT + J + 1 92 255 163 163 68 255 187 187 69 255 186 186 62 255 193 193 31 255 224 224 60 255 195 195 91 255 164 164 97 255 158 158 1 255 254 254 76 255 179 179 I4_OR_TEST I4_OR returns the bitwise inclusive OR of two integers. Compare with FORTRAN90 intrinsic IOR. I J I4_OR IOR 65 51 115 115 35 42 43 43 89 56 121 121 23 2 23 23 71 27 95 95 30 44 62 62 32 65 97 97 40 96 104 104 5 2 7 7 51 56 59 59 I4_POWER_TEST I4_POWER computes I^J I J I4_POWER(I,J) 0 1 0 1 2 1 2 3 8 3 3 27 10 3 1000 -1 4 1 -2 5 -32 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 10 1 10 10 4000 1 4000 4000 10 2 110 110 18 3 6840 6840 4 4 840 840 98 3 970200 970200 1 7 5040 5040 I4_SIGN_TEST I4_SIGN returns the sign of an I4. I4 I4_SIGN(I4) -10 -1 -7 -1 0 1 5 1 9 1 I4_SIGN3_TEST I4_SIGN3 returns the three-way sign of an I4. I4 I4_SIGN3(I4) -10 -1 -7 -1 0 0 5 1 9 1 I4_SWAP_TEST I4_SWAP swaps two I4's. Before swapping: I = 1 J = 202 After swapping: I = 202 J = 1 I4_TO_HALTON_TEST I4_TO_HALTON computes a Halton sequence. The user specifies all data explicitly. In this test, we call I4_TO_HALTON repeatedly. We use distinct primes as bases. I R(0) R(1) R(2) 0 0.0000 0.0000 0.0000 1 0.5000 0.3333 0.2000 2 0.2500 0.6667 0.4000 3 0.7500 0.1111 0.6000 4 0.1250 0.4444 0.8000 5 0.6250 0.7778 0.0400 6 0.3750 0.2222 0.2400 7 0.8750 0.5556 0.4400 8 0.0625 0.8889 0.6400 9 0.5625 0.0370 0.8400 10 0.3125 0.3704 0.0800 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 I4_TO_TRIANGLE_LOWER_TEST I4_TO_TRIANGLE_LOWER converts a linear index to a lower triangular one. K => I J 0 0 0 1 1 1 2 2 1 3 2 2 4 3 1 5 3 2 6 3 3 7 4 1 8 4 2 9 4 3 10 4 4 11 5 1 12 5 2 13 5 3 14 5 4 15 5 5 16 6 1 17 6 2 18 6 3 19 6 4 20 6 5 i4_uniform_ab_test(): i4_uniform_ab() computes pseudorandom values in an interval [A,B]. The lower endpoint A = -100 The upper endpoint B = 200 1 -13 2 126 3 81 4 89 5 59 6 5 7 4 8 -52 9 -41 10 150 11 14 12 24 13 191 14 78 15 171 16 170 17 -30 18 30 19 175 20 150 I4_WALSH_1D_TEST I4_WALSH_1D evaluates 1D Walsh functions: X +2 +1 0 -1 -2 -3 0.000000 0 0 0 0 0 0 0.250000 0 0 0 0 1 0 0.500000 0 0 0 1 0 0 0.750000 0 0 0 1 1 0 1.000000 0 0 1 0 0 0 1.250000 0 0 1 0 1 0 1.500000 0 0 1 1 0 0 1.750000 0 0 1 1 1 0 2.000000 0 1 0 0 0 0 2.250000 0 1 0 0 1 0 2.500000 0 1 0 1 0 0 2.750000 0 1 0 1 1 0 3.000000 0 1 1 0 0 0 3.250000 0 1 1 0 1 0 3.500000 0 1 1 1 0 0 3.750000 0 1 1 1 1 0 4.000000 1 0 0 0 0 0 4.250000 1 0 0 0 1 0 4.500000 1 0 0 1 0 0 4.750000 1 0 0 1 1 0 5.000000 1 0 1 0 0 0 5.250000 1 0 1 0 1 0 5.500000 1 0 1 1 0 0 5.750000 1 0 1 1 1 0 6.000000 1 1 0 0 0 0 6.250000 1 1 0 0 1 0 6.500000 1 1 0 1 0 0 6.750000 1 1 0 1 1 0 7.000000 1 1 1 0 0 0 7.250000 1 1 1 0 1 0 7.500000 1 1 1 1 0 0 7.750000 1 1 1 1 1 0 8.000000 0 0 0 0 0 0 I4_WIDTH_TEST I4_WIDTH determines the printing "width" of an I4. I4 I4_WIDTH 0 1 1 1 2 1 3 1 9 1 10 2 11 2 99 2 101 3 -1 2 -2 2 -3 2 -9 2 I4_WRAP_TEST I4_WRAP forces an integer to lie within given limits. ILO = 4 IHI = 8 I I4_WRAP(I) -10 5 -9 6 -8 7 -7 8 -6 4 -5 5 -4 6 -3 7 -2 8 -1 4 0 5 1 6 2 7 3 8 4 4 5 5 6 6 7 7 8 8 9 4 10 5 11 6 12 7 13 8 14 4 15 5 16 6 17 7 18 8 19 4 20 5 I4_XOR_TEST I4_XOR returns the bitwise exclusive OR of two integers. Compare with FORTRAN90 intrinsic IEOR. I J I4_XOR IEOR 45 21 56 56 16 82 66 66 50 16 34 34 11 5 14 14 16 16 0 0 43 22 61 61 86 4 82 82 77 11 70 70 48 80 96 96 55 4 51 51 I4BLOCK_PRINT_TEST I4BLOCK_PRINT prints an I4BLOCK. The 3D array: K = 1 J: 1 2 3 I: 1: 1 1 1 2: 2 4 8 3: 3 9 27 4: 4 16 64 K = 2 J: 1 2 3 I: 1: 2 2 2 2: 4 8 16 3: 6 18 54 4: 8 32 128 I4COL_FIND_ITEM_TEST I4COL_FIND_ITEM finds the first occurrence of an item in an integer array of columns. The matrix of columns: 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 Item 34 occurs in row 3 and column 4 Item 12 occurs in row 1 and column 2 Item 90 occurs in row -1 and column -1 I4COL_FIND_PAIR_WRAP_TEST I4COL_FIND_PAIR_WRAP finds the first occurrence of a pair of item in an integer array of columns. Items in the array are ordered by column, and wraparound is allowed. The matrix of columns: 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 Item 22 followed by item 32 occurs in row 2 and column 2 Item 32 followed by item 22 occurs in row -1 and column -1 Item 22 followed by item 23 occurs in row -1 and column -1 Item 54 followed by item 14 occurs in row 5 and column 4 Item 54 followed by item 11 occurs in row -1 and column -1 I4COL_SORT_A_TEST I4COL_SORT_A ascending sorts an integer array as a table of columns. The original matrix: Col 1 2 3 4 Row 1: 10 7 8 1 2: 9 10 1 4 3: 2 10 2 9 4: 7 3 3 2 5: 1 3 5 4 Descending sorted: Col 1 2 3 4 Row 1: 1 7 8 10 2: 4 10 1 9 3: 9 10 2 2 4: 2 3 3 7 5: 4 3 5 1 I4COL_SORT_D_TEST I4COL_SORT_D descending sorts an integer array as a table of columns. The original matrix: Col 1 2 3 4 Row 1: 7 5 7 1 2: 4 3 4 5 3: 8 2 1 5 4: 6 3 2 8 5: 9 2 7 9 Descending sorted: Col 1 2 3 4 Row 1: 7 7 5 1 2: 4 4 3 5 3: 8 1 2 5 4: 6 2 3 8 5: 9 7 2 9 I4COL_SORT2_A_TEST For a rectangular integer matrix: I4COL_SORT2_D sorts the elements of the columns. The matrix: Col 1 2 3 4 Row 1: 8 7 3 7 2: 3 18 9 9 3: 5 4 4 3 4: 12 19 16 12 5: 2 15 0 0 6: 16 5 7 15 The element-sorted column matrix: Col 1 2 3 4 Row 1: 2 4 0 0 2: 3 5 3 3 3: 5 7 4 7 4: 8 15 7 9 5: 12 18 9 12 6: 16 19 16 15 I4COL_SORTED_SINGLETON_COUNT_TEST I4COL_SORTED_SINGLETON_COUNT counts singletons in a sorted I4COL; Ascending sorted ICOL: Col 1 2 3 4 5 6 7 8 9 10 Row 1: 0 0 0 1 1 1 2 3 3 3 2: 0 2 3 0 1 2 0 0 1 3 3: 1 2 3 2 2 3 2 0 3 2 Number of singletons = 10 Ascending sorted ICOL: Col 1 2 3 4 5 6 7 8 9 10 Row 1: 0 0 1 2 2 2 3 3 3 3 2: 1 2 2 0 1 2 0 1 2 3 3: 0 1 3 1 1 0 0 0 3 0 Number of singletons = 10 I4COL_SORTED_UNIQUE_COUNT_TEST I4COL_SORTED_UNIQUE_COUNT counts the unique entries of a sorted I4COL; Ascending sorted I4COL: Col 1 2 3 4 5 6 7 8 9 10 Row 1: 0 0 0 0 1 1 2 2 2 3 2: 0 0 0 2 0 2 2 3 3 3 3: 2 3 3 1 2 3 1 1 1 2 Number of unique entries = 8 Ascending sorted I4COL: Col 1 2 3 4 5 6 7 8 9 10 Row 1: 0 0 0 1 1 1 1 1 2 3 2: 2 3 3 0 0 1 2 3 3 2 3: 2 0 3 1 2 0 1 3 3 3 Number of unique entries = 10 I4MAT_ELIM_TEST I4MAT_ELIM does exact Gauss elimination. The original matrix: Col 1 2 3 4 5 Row 1: 1 2 3 4 5 2: 6 7 8 9 10 3: 11 12 13 14 15 4: 16 17 18 19 20 5: 21 22 23 24 25 The matrix returned by I4MAT_ELIM: Col 1 2 3 4 5 Row 1: 21 22 23 24 25 2: 0 -1 -2 -3 -4 3: 0 0 0 0 0 4: 0 0 0 0 0 5: 0 0 0 0 0 The original matrix: Col 1 2 3 4 5 Row 1: 40320 20160 13440 10080 8064 2: 20160 13440 10080 8064 6720 3: 13440 10080 8064 6720 5760 4: 10080 8064 6720 5760 5040 5: 8064 6720 5760 5040 4480 The matrix returned by I4MAT_ELIM: Col 1 2 3 4 5 Row 1: 60 30 20 15 12 2: 0 -840 -960 -945 -896 3: 0 0 80 135 168 4: 0 0 0 15 32 5: 0 0 0 0 1 The original matrix: Col 1 2 3 4 5 Row 1: 1 2 3 4 5 2: 2 4 6 8 10 3: 3 6 9 12 15 4: 4 8 12 16 20 5: 5 10 15 20 25 The matrix returned by I4MAT_ELIM: Col 1 2 3 4 5 Row 1: 1 2 3 4 5 2: 0 0 0 0 0 3: 0 0 0 0 0 4: 0 0 0 0 0 5: 0 0 0 0 0 I4MAT_INDICATOR_TEST I4MAT_INDICATOR returns an indicator matrix. The indicator matrix: Col 1 2 3 Row 1: 11 12 13 2: 21 22 23 3: 31 32 33 4: 41 42 43 5: 51 52 53 I4MAT_L1_INVERSE_TEST I4MAT_L1_INVERSE inverts a unit lower triangular matrix. The original matrix: Col 1 2 3 4 5 6 Row 1: 1 0 0 0 0 0 2: 2 1 0 0 0 0 3: 0 0 1 0 0 0 4: 5 0 3 1 0 0 5: 0 0 0 0 1 0 6: 75 0 0 6 4 1 The inverse matrix: Col 1 2 3 4 5 6 Row 1: 1 0 0 0 0 0 2: -2 1 0 0 0 0 3: 0 0 1 0 0 0 4: -5 0 -3 1 0 0 5: 0 0 0 0 1 0 6: -45 0 18 -6 -4 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_MAX_TEST I4MAT_MAX returns the maximum; Random array: Col 1 2 3 4 5 6 7 Row 1: 6 5 6 7 6 6 4 2: 8 10 4 7 2 8 9 3: 5 3 8 5 2 3 0 4: 9 2 10 4 8 4 2 5: 3 0 2 5 0 9 8 Maximum value is 10 I4MAT_MAX_INDEX_TEST I4MAT_MAX_INDEX locates the maximum; Random array: Col 1 2 3 4 5 6 7 Row 1: 0 9 8 0 3 2 8 2: 3 4 2 3 5 1 10 3: 5 8 3 7 9 0 7 4: 7 8 9 5 5 2 2 5: 2 1 2 8 9 5 5 Maximum I,J indices 2 7 I4MAT_MIN_TEST I4MAT_MIN returns the minimum; Random array: Col 1 2 3 4 5 6 7 Row 1: 0 8 0 9 10 9 5 2: 6 8 8 7 5 5 6 3: 0 10 2 9 10 9 5 4: 2 8 0 2 9 2 2 5: 10 1 7 9 9 6 0 Minimum value is 0 I4MAT_MIN_INDEX_TEST I4MAT_MIN_INDEX locates the minimum; Random array: Col 1 2 3 4 5 6 7 Row 1: 0 7 10 0 10 0 3 2: 9 10 7 9 1 3 5 3: 5 6 6 7 10 0 7 4: 3 10 10 6 9 7 10 5: 1 7 7 0 8 9 1 Minimum I,J indices 1 1 I4MAT_PERM_UNIFORM_TEST I4MAT_PERM_UNIFORM applies a random permutation to a square integer matrix. 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 The permuted matrix: Col 1 2 3 4 5 Row 1: 44 42 43 41 45 2: 24 22 23 21 25 3: 34 32 33 31 35 4: 14 12 13 11 15 5: 54 52 53 51 55 I4MAT_PRINT_TEST I4MAT_PRINT prints an I4MAT. The matrix: Col 1 2 3 Row 1: 11 12 13 2: 21 22 23 3: 31 32 33 4: 41 42 43 5: 51 52 53 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 I4MAT_PRODUCT_ELEMENTWISE_TEST I4MAT_PRODUCT_ELEMENTWISE computes the elementwise product of two I4MATs. A: Col 1 2 3 Row 1: 1 2 3 2: 4 5 6 B: Col 1 2 3 Row 1: 1 3 5 2: 2 4 6 Elementwise product = 86 I4MAT_RANK_TEST I4MAT_RANK computes the rank of an integer matrix. Matrix A1: Col 1 2 3 Row 1: 1 2 3 2: 4 5 6 3: 7 8 9 The rank is 2 Matrix A2: Col 1 2 3 Row 1: 1 2 3 2: 4 5 6 3: 7 8 0 The rank is 3 Matrix A3: Col 1 2 3 Row 1: 1 2 3 2: 4 5 6 3: 7 8 0 4: 10 11 12 The rank is 3 Matrix A4: Col 1 2 3 4 Row 1: 1 2 3 7 2: 4 5 6 8 3: 7 8 9 3 The rank is 3 Matrix A5: Col 1 2 3 Row 1: 1 2 3 2: 4 5 6 3: 7 8 9 4: 10 11 12 5: 3 3 3 The rank is 2 Matrix A6: Col 1 2 Row 1: 0 0 2: 0 0 3: 0 0 The rank is 0 I4MAT_REF_TEST I4MAT_REF computes the integer row echelon form (IREF) of an I4MAT. Input A: Col 1 2 3 4 5 6 7 Row 1: 1 3 0 2 6 3 1 2: -2 -6 0 -2 -8 3 1 3: 3 9 0 0 6 6 2 4: -1 -3 0 1 0 9 3 The pseudo-determinant = 6 IREF of A: Col 1 2 3 4 5 6 7 Row 1: 1 3 0 2 6 3 1 2: 0 0 0 2 4 9 3 3: 0 0 0 0 0 3 1 4: 0 0 0 0 0 0 0 I4MAT_ROW_REDUCE_TEST I4MAT_ROW_REDUCE divides out any common factors in the entries of a row of an I4MAT. Original matrix: Col 1 2 3 Row 1: 12 88 9 2: 4 8 192 3: -12 88 94 4: 30 18 42 5: 0 4 8 After reducing a row: Col 1 2 3 Row 1: 12 88 9 2: 4 8 192 3: -12 88 94 4: 30 18 42 5: 0 1 2 After reducing a row: Col 1 2 3 Row 1: 12 88 9 2: 4 8 192 3: -12 88 94 4: 5 3 7 5: 0 1 2 After reducing a row: Col 1 2 3 Row 1: 12 88 9 2: 4 8 192 3: -6 44 47 4: 5 3 7 5: 0 1 2 After reducing a row: Col 1 2 3 Row 1: 12 88 9 2: 1 2 48 3: -6 44 47 4: 5 3 7 5: 0 1 2 After reducing a row: Col 1 2 3 Row 1: 12 88 9 2: 1 2 48 3: -6 44 47 4: 5 3 7 5: 0 1 2 I4MAT_ROW_SWAP_TEST I4MAT_ROW_SWAP swaps two rows of an I4MAT. Input A: 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 Swap rows 2 and 5 Modified matrix: Col 1 2 3 4 Row 1: 11 12 13 14 2: 51 52 53 54 3: 31 32 33 34 4: 41 42 43 44 5: 21 22 23 24 I4MAT_RREF_TEST I4MAT_RREF computes the integer row reduced echelon form (IRREF) of an I4MAT. Input A: Col 1 2 3 4 5 6 7 Row 1: 1 3 0 2 6 3 1 2: -2 -6 0 -2 -8 3 1 3: 3 9 0 0 6 6 2 4: -1 -3 0 1 0 9 3 The pseudo-determinant = 6 IREF of A: Col 1 2 3 4 5 6 7 Row 1: 1 3 0 0 2 0 0 2: 0 0 0 1 2 0 0 3: 0 0 0 0 0 3 1 4: 0 0 0 0 0 0 0 I4MAT_RREF_SYSTEM_TEST FORTRAN90 version. I4MAT_RREF_SYSTEM computes the linear system associated with an integer reduced row echelon form of an I4MAT. Look at a "wide" matrix: Input A1: Col 1 2 3 4 5 6 7 Row 1: 1 3 0 2 6 3 1 2: -2 -6 0 -2 -8 3 1 3: 3 9 0 0 6 6 2 4: -1 -3 0 1 0 9 3 The pseudo-determinant = 6 A2, the IRREF of A1: Col 1 2 3 4 5 6 7 Row 1: 1 3 0 0 2 0 0 2: 0 0 0 1 2 0 0 3: 0 0 0 0 0 3 1 4: 0 0 0 0 0 0 0 B2, the right hand side: 1: 1 2: 1 3: 1 4: 0 The original system is CONSISTENT. A3, the augmented IRREF: Col 1 2 3 4 5 6 7 Row 1: 1 3 0 0 2 0 0 2: 0 1 0 0 0 0 0 3: 0 0 1 0 0 0 0 4: 0 0 0 1 2 0 0 5: 0 0 0 0 1 0 0 6: 0 0 0 0 0 3 1 7: 0 0 0 0 0 0 1 B3, the augmented RHS: 1: 1 2: 0 3: 0 4: 1 5: 0 6: 1 7: 0 Indices of degrees of freedom. 1: 2 2: 3 3: 5 4: 7 Look at a "tall" matrix: Input A1: Col 1 2 3 4 Row 1: 1 -2 3 -1 2: 3 -6 9 -3 3: 0 0 0 0 4: 2 -2 0 1 5: 6 -8 6 0 6: 3 3 6 9 7: 1 1 2 3 The pseudo-determinant = 32 A2, the IRREF of A1: Col 1 2 3 4 Row 1: 16 0 0 29 2: 0 16 0 21 3: 0 0 16 -1 4: 0 0 0 0 5: 0 0 0 0 6: 0 0 0 0 7: 0 0 0 0 B2, the right hand side: 1: 1 2: 1 3: 1 4: 1 5: 1 6: 1 7: 1 The original system is INCONSISTENT. A3, the augmented IRREF: Col 1 2 3 4 Row 1: 16 0 0 29 2: 0 16 0 21 3: 0 0 16 -1 4: 0 0 0 1 B3, the augmented RHS: 1: 1 2: 1 3: 1 4: 0 Indices of degrees of freedom. 1: 4 I4MAT_TRANSPOSE_TEST I4MAT_TRANSPOSE transposes a matrix. The matrix: Col 1 2 3 Row 1: 11 12 13 2: 21 22 23 3: 31 32 33 4: 41 42 43 5: 51 52 53 The transposed matrix: Col 1 2 3 4 5 Row 1: 11 21 31 41 51 2: 12 22 32 42 52 3: 13 23 33 43 53 I4MAT_U_SOLVE_TEST I4MAT_U_SOLVE solves an upper triangular system. Input matrix A: Col 1 2 3 4 Row 1: 1 2 4 7 2: 0 3 5 8 3: 0 0 6 9 4: 0 0 0 10 Right hand side b: 1: 45 2: 53 3: 54 4: 40 Computed solution x: 1: 1.0000000 2: 2.0000000 3: 3.0000000 4: 4.0000000 Norm of A*x-b = 0.00000 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_WIDTH_TEST I4MAT_WIDTH determines the printing "width" of an I4MAT. Matrix A1: Col 1 2 3 Row 1: 11 12 13 2: 211 222 233 3: 3111 3222 3333 Printing width of A1 = 4 Matrix A2: Col 1 2 3 Row 1: 10 42 77 2: 23 -1000 63 3: 45 63 90 Printing width of A2 = 5 I4ROW_MAX_TEST I4ROW_MAX computes row maximums; The matrix: Col 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 The row maximums: 1: 4 2: 8 3: 12 I4ROW_MEAN_TEST I4ROW_MEAN computes row means; The matrix: Col 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 The row means: 1: 2.5000000 2: 6.5000000 3: 10.500000 I4ROW_MIN_TEST I4ROW_MIN computes row minimums; The matrix: Col 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 The row minimums: 1: 1 2: 5 3: 9 I4ROW_SORT_A_TEST For a rectangular integer matrix: I4ROW_SORT_A sorts the rows; The original matrix: Col 1 2 3 4 Row 1: 6 8 7 8 2: 6 1 1 6 3: 5 1 1 9 4: 2 8 10 3 5: 9 3 3 7 6: 2 4 4 3 7: 8 10 2 2 8: 1 2 4 6 9: 8 4 2 10 10: 5 9 4 0 The row-sorted matrix: Col 1 2 3 4 Row 1: 1 2 4 6 2: 2 4 4 3 3: 2 8 10 3 4: 5 1 1 9 5: 5 9 4 0 6: 6 1 1 6 7: 6 8 7 8 8: 8 4 2 10 9: 8 10 2 2 10: 9 3 3 7 I4ROW_SORT_D_TEST For a rectangular integer matrix: I4ROW_SORT_D sorts the rows; The original matrix: 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 The matrix, permuted by I4MAT_PERM2_UNIFORM: Col 1 2 3 4 Row 1: 51 53 52 54 2: 41 43 42 44 3: 21 23 22 24 4: 31 33 32 34 5: 11 13 12 14 6: 61 63 62 64 The row-sorted matrix: Col 1 2 3 4 Row 1: 61 63 62 64 2: 51 53 52 54 3: 41 43 42 44 4: 31 33 32 34 5: 21 23 22 24 6: 11 13 12 14 I4ROW_SORT2_D_TEST For a rectangular integer matrix: I4ROW_SORT2_D sorts the elements of the rows. The original matrix: 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 The matrix, permuted by I4MAT_PERM2_UNIFORM: Col 1 2 3 4 Row 1: 12 11 14 13 2: 32 31 34 33 3: 62 61 64 63 4: 52 51 54 53 5: 22 21 24 23 6: 42 41 44 43 The element-sorted row-sorted matrix: Col 1 2 3 4 Row 1: 14 13 12 11 2: 34 33 32 31 3: 64 63 62 61 4: 54 53 52 51 5: 24 23 22 21 6: 44 43 42 41 I4ROW_SUM_TEST I4ROW_SUM computes row sums; The matrix: Col 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 The row sums: 1: 10 2: 26 3: 42 I4ROW_SWAP_TEST For an integer matrix of rows, I4ROW_SWAP swaps two rows; The matrix: Col 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 Swap rows 1 and 3 The new matrix: Col 1 2 3 4 Row 1: 9 10 11 12 2: 5 6 7 8 3: 1 2 3 4 I4ROW_VARIANCE_TEST I4ROW_VARIANCE computes row variances; The matrix: Col 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 Row variances: 1 1.6667 2 1.6667 3 1.6667 I4ROWS_TO_I4MAT_TEST I4ROWS_TO_I4MAT allows an I4MAT to be initialized by data stored ROW-WISE in a vector. The data vector: 1: 11 2: 12 3: 13 4: 14 5: 21 6: 22 7: 23 8: 24 9: 31 10: 32 11: 33 12: 34 The data copied into an array: Col 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 I4VEC_ADD_TEST I4VEC_ADD adds two I4VEC's I A B C 1 -4 -10 -14 2 9 8 17 3 3 8 11 4 3 -7 -4 5 -1 3 2 6 -2 -9 -11 7 4 -9 -5 8 4 4 8 9 -8 -5 -13 10 4 10 14 I4VEC_AMAX_TEST For an integer vector: I4VEC_AMAX: maximum absolute entry; Input vector: 1: -3 2: -1 3: -4 4: -7 5: 0 6: 2 7: 0 8: 4 9: -2 10: -3 Maximum absolute value: 7 I4VEC_AMAX_INDEX_TEST For an integer vector: I4VEC_AMAX_INDEX: index of maximum absolute entry; Input vector: 1: 10 2: -5 3: 10 4: 4 5: 6 6: -2 7: 9 8: -9 9: -4 10: 8 Maximum abs index: 1 I4VEC_AMIN_TEST For an integer vector: I4VEC_AMIN: minimum absolute entry; Input vector: 1: -3 2: 2 3: 0 4: -8 5: -2 6: -2 7: 4 8: -10 9: 3 10: -5 Minimum absolute value: 0 I4VEC_AMIN_INDEX_TEST For an integer vector: I4VEC_AMIN_INDEX: index minimum absolute entry; Input vector: 1: 6 2: 2 3: -1 4: 6 5: 10 6: -9 7: 0 8: 4 9: 4 10: 7 Minimum abs index: 7 I4VEC_AMINZ_TEST For an I4VEC: I4VEC_AMINZ: minimum nonzero absolute entry; Input vector: 1: 2 2: -3 3: 9 4: -9 5: -1 6: 3 7: -10 8: -7 9: -1 10: 5 Minimum abs nonzero: 1 I4VEC_AMINZ_INDEX_TEST For an I4VEC: I4VEC_AMINZ_INDEX: index of minimum nonzero absolute entry; Input vector: 1: 8 2: -2 3: 4 4: 10 5: -2 6: 6 7: 4 8: -2 9: 1 10: 7 Minimum abs nonzero index: 9 I4VEC_ASCEND_SUB_TEST I4VEC_ASCEND_SUB computes a longest ascending subsequence of an I4VEC. The vector to be tested: 1: 8 2: 3 3: 10 4: 4 5: 6 6: 4 7: 5 8: 6 9: 10 10: 9 11: 8 12: 1 13: 6 14: 1 A longest ascending subsequence: 1: 3 2: 4 3: 5 4: 6 5: 8 The vector to be tested: 1: 3 2: 1 3: 1 4: 9 5: 2 6: 2 7: 1 8: 9 9: 10 10: 5 11: 10 12: 5 13: 5 14: 1 A longest ascending subsequence: 1: 1 2: 2 3: 5 4: 10 The vector to be tested: 1: 1 2: 4 3: 5 4: 10 5: 5 6: 10 7: 9 8: 10 9: 10 10: 3 11: 7 12: 2 13: 7 14: 9 A longest ascending subsequence: 1: 1 2: 4 3: 5 4: 7 5: 9 The vector to be tested: 1: 2 2: 8 3: 7 4: 10 5: 9 6: 5 7: 9 8: 6 9: 10 10: 2 11: 3 12: 3 13: 3 14: 8 A longest ascending subsequence: 1: 2 2: 5 3: 6 4: 8 The vector to be tested: 1: 6 2: 4 3: 5 4: 9 5: 8 6: 10 7: 4 8: 1 9: 5 10: 5 11: 10 12: 9 13: 2 14: 8 A longest ascending subsequence: 1: 4 2: 5 3: 8 4: 9 The vector to be tested: 1: 7 2: 6 3: 4 4: 8 5: 2 6: 2 7: 8 8: 10 9: 2 10: 10 11: 9 12: 6 13: 10 14: 10 A longest ascending subsequence: 1: 2 2: 8 3: 9 4: 10 I4VEC_BINARY_NEXT_TEST I4VEC_BINARY_NEXT generates the next binary vector. 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 I4VEC_BRACKET_TEST I4VEC_BRACKET finds a pair of entries in a sorted I4VEC which bracket a value. Sorted array: 1: 2 2: 4 3: 6 4: 8 5: 10 6: 10 7: 14 8: 16 9: 18 10: 20 Search for AVAL = -10 Left = -1 Right = 1 A(RIGHT) = 2 Search for AVAL = 2 Left = 1 Right = 1 A(LEFT)= 2 A(RIGHT) = 2 Search for AVAL = 9 Left = 4 Right = 5 A(LEFT)= 8 A(RIGHT) = 10 Search for AVAL = 10 Left = 5 Right = 5 A(LEFT)= 10 A(RIGHT) = 10 Search for AVAL = 20 Left = 10 Right = 10 A(LEFT)= 20 A(RIGHT) = 20 Search for AVAL = 24 Left = 10 Right = -1 A(LEFT)= 20 I4VEC_CHOOSE_TEST: I4VEC_CHOOSE computes the generalized binomial coefficient. N: 8 12 8 5 7 K: 3 6 6 5 2 M V1 V2 0 1 1 1 56 56 2 51744 51744 3 1448832 1448832 4 1448832 1448832 5 30425472 30425472 I4VEC_CONCATENATE_TEST I4VEC_CONCATENATE concatenates two I4VECs Array 1: 1: 91 2: 31 3: 71 4: 51 5: 31 Array 2: 1: 42 2: 22 3: 12 Array 3 = Array 1 + Array 2: 1: 91 2: 31 3: 71 4: 51 5: 31 6: 42 7: 22 8: 12 I4VEC_CUM_TEST For an integer vector: I4VEC_CUM: cumulative sum; Input vector: 1: 3 2: -10 3: 0 4: 6 5: -7 6: -7 7: -8 8: 6 9: -7 10: -2 Cumulative sums: 1: 3 2: -7 3: -7 4: -1 5: -8 6: -15 7: -23 8: -17 9: -24 10: -26 I4VEC_CUM0_TEST For an integer vector: I4VEC_CUM0: cumulative sum, zero based; Input vector: 1: 5 2: 8 3: 2 4: 9 5: 7 6: 4 7: -8 8: 0 9: -4 10: 0 0-based Cumulative sums: 1: 0 2: 5 3: 13 4: 15 5: 24 6: 31 7: 35 8: 27 9: 27 10: 23 11: 23 I4VEC_DECREMENT_TEST I4VEC_DECREMENT decrements an I4VEC. The I4VEC: 1: 6 2: 7 3: -4 4: 6 The I4VEC after decrementing: 1: 5 2: 6 3: -5 4: 5 I4VEC_DIRECT_PRODUCT_TEST I4VEC_DIRECT_PRODUCT forms the entries of a direct product of a given number of I4VEC factors. J X(1) X(2) X(3) 1 1 50 800 2 2 50 800 3 3 50 800 4 4 50 800 5 1 60 800 6 2 60 800 7 3 60 800 8 4 60 800 9 1 70 800 10 2 70 800 11 3 70 800 12 4 70 800 13 1 50 900 14 2 50 900 15 3 50 900 16 4 50 900 17 1 60 900 18 2 60 900 19 3 60 900 20 4 60 900 21 1 70 900 22 2 70 900 23 3 70 900 24 4 70 900 I4VEC_DIRECT_PRODUCT2_TEST I4VEC_DIRECT_PRODUCT2 forms the entries of a direct product of a given number of I4VEC factors. Product W: 1: 418 2: 627 3: 1045 4: 1463 5: 494 6: 741 7: 1235 8: 1729 9: 646 10: 969 11: 1615 12: 2261 13: 462 14: 693 15: 1155 16: 1617 17: 546 18: 819 19: 1365 20: 1911 21: 714 22: 1071 23: 1785 24: 2499 I4VEC_DISTANCES_TEST I4VEC_DISTANCES computes the pairwise distances between elements of an I4VEC. Locations: 1: 0 2: 3 3: 10 4: 20 5: 100 Distances: 1: 3 2: 10 3: 20 4: 100 5: 7 6: 17 7: 97 8: 10 9: 90 10: 80 I4VEC_DOT_PRODUCT_TEST I4VEC_DOT_PRODUCT computes the dot product of two I4VECs. The vector A: 1: 7 2: 1 3: 5 4: 4 5: 2 The vector B: 1: 9 2: 0 3: 0 4: 9 5: 5 The dot product is 109 I4VEC_FRAC_TEST I4VEC_FRAC: K-th smallest entry in an I4VEC. The array to search: 1: 2 2: 15 3: 4 4: 20 5: 6 6: 11 7: 4 8: 2 9: 10 10: 7 Fractile Value 1 2 6 7 I4VEC_HEAP_A_TEST For an I4VEC, I4VEC_HEAP_A puts into ascending heap form. Unsorted array: 1: 5 2: 7 3: 1 4: 6 5: 7 6: 10 7: 2 8: 5 9: 0 10: 3 Ascending heap form: 1: 0 2: 3 3: 1 4: 5 5: 5 6: 10 7: 2 8: 7 9: 6 10: 7 I4VEC_HEAP_D_TEST For an I4VEC, I4VEC_HEAP_D puts into descending heap form. Unsorted array: 1: 9 2: 2 3: 6 4: 10 5: 1 6: 8 7: 0 8: 7 9: 8 10: 6 Descending heap form: 1: 10 2: 9 3: 8 4: 8 5: 6 6: 6 7: 0 8: 7 9: 2 10: 1 I4VEC_HEAP_D_EXTRACT_TEST For a descending heap of integers, I4VEC_HEAP_D_EXTRACT extracts the maximum value; Inserting value 4 Current maximum value is 4 Inserting value 2 Current maximum value is 4 Inserting value 8 Current maximum value is 8 Inserting value 0 Current maximum value is 8 Inserting value 8 Current maximum value is 8 Inserting value 7 Current maximum value is 8 Inserting value 1 Current maximum value is 8 Inserting value 3 Current maximum value is 8 Inserting value 9 Current maximum value is 9 Inserting value 5 Current maximum value is 9 Current heap as a vector: 1: 9 2: 8 3: 7 4: 8 5: 5 6: 4 7: 1 8: 0 9: 3 10: 2 Now extract the maximum several times. Extracting maximum element = 9 Extracting maximum element = 8 Extracting maximum element = 8 Extracting maximum element = 7 Extracting maximum element = 5 Current heap as a vector: 1: 4 2: 3 3: 2 4: 1 5: 0 I4VEC_HEAP_D_INSERT_TEST For a descending heap of integers, I4VEC_HEAP_D_INSERT inserts a value into the heap. Inserting value 6 Current maximum value is 6 Inserting value 7 Current maximum value is 7 Inserting value 7 Current maximum value is 7 Inserting value 6 Current maximum value is 7 Inserting value 6 Current maximum value is 7 Inserting value 0 Current maximum value is 7 Inserting value 3 Current maximum value is 7 Inserting value 0 Current maximum value is 7 Inserting value 2 Current maximum value is 7 Inserting value 8 Current maximum value is 8 Current heap as a vector: 1: 8 2: 7 3: 7 4: 6 5: 6 6: 0 7: 3 8: 0 9: 2 10: 6 I4VEC_HEAP_D_MAX_TEST For a descending heap of integers, I4VEC_HEAP_D_MAX reports the maximum value. Inserting value 7 Current maximum value is 7 Inserting value 8 Current maximum value is 8 Inserting value 3 Current maximum value is 8 Inserting value 4 Current maximum value is 8 Inserting value 4 Current maximum value is 8 Inserting value 9 Current maximum value is 9 Inserting value 9 Current maximum value is 9 Inserting value 8 Current maximum value is 9 Inserting value 6 Current maximum value is 9 Inserting value 7 Current maximum value is 9 I4VEC_HISTOGRAM_TEST I4VEC_HISTOGRAM histograms an I4VEC. Histogram of data from 0 to 20 0 42 1 30 2 44 3 43 4 37 5 36 6 41 7 37 8 37 9 42 10 38 11 42 12 33 13 31 14 50 15 46 16 37 17 35 18 32 19 41 20 25 I4VEC_IDENTITY_ROW_TEST I4VEC_IDENTITY_ROW returns a row of the identity matrix. 0: 0 0 0 0 0 1: 1 0 0 0 0 2: 0 1 0 0 0 3: 0 0 1 0 0 4: 0 0 0 1 0 5: 0 0 0 0 1 6: 0 0 0 0 0 I4VEC_INCREMENT_TEST I4VEC_INCREMENT increments an I4VEC. The I4VEC: 1: -5 2: -1 3: 6 4: -3 The I4VEC after incrementing: 1: -4 2: 0 3: 7 4: -2 I4VEC_INDEX_TEST For an I4VEC: I4VEC_INDEX: first index of given value; Input vector: 1: 4 2: -6 3: 6 4: -6 5: -9 6: -2 7: 10 8: 10 9: 9 10: 5 Index of first occurrence of -9 is 5 Index of first occurrence of -8 is -1 I4VEC_INDEX_DELETE_ALL For an index sorted array of integers. I4VEC_INDEX_DELETE_ALL deletes all copies of a particular value. 15 4 18 11 18 9 3 7 3 17 9 0 15 2 4 0 11 7 16 13 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 14 8 0 2 18 7 0 3 16 15 2 4 9 4 3 5 11 18 3 6 4 11 4 7 17 18 4 8 2 9 7 9 23 3 7 10 20 7 7 11 10 3 7 12 1 17 8 13 24 9 8 14 8 0 9 15 13 15 9 16 6 2 11 17 19 4 11 18 22 0 13 19 3 11 15 20 15 7 15 21 21 16 16 22 12 13 17 23 5 7 18 24 7 8 18 Call I4VEC_INDEX_DELETE_ALL to delete values of 7: Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 12 8 0 2 16 15 0 3 14 4 2 4 8 18 3 5 9 11 3 6 3 18 4 7 15 9 4 8 1 3 8 9 20 3 8 10 7 17 9 11 11 9 9 12 5 0 11 13 17 15 11 14 19 2 13 15 2 4 15 16 13 0 15 17 18 11 16 18 10 16 17 19 4 13 18 20 6 8 18 I4VEC_INDEX_DELETE_DUPES I4VEC_INDEX_DELETE_DUPES deletes duplicates. Generate some random values: 4 12 16 19 11 9 6 5 2 2 17 10 5 0 0 9 8 16 15 9 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 16 8 0 2 17 7 0 3 11 4 2 4 12 12 2 5 3 16 4 6 10 19 5 7 15 11 5 8 9 9 6 9 2 6 7 10 23 5 7 11 1 2 8 12 19 2 8 13 24 17 8 14 8 10 9 15 18 5 9 16 22 0 9 17 14 0 10 18 7 9 11 19 4 8 12 20 21 16 15 21 5 15 16 22 20 9 16 23 13 7 17 24 6 8 19 Call I4VEC_INDEX_DELETE_DUPES to delete duplicates: Indexed list of unique entries: I INDX(I) X(I) 1 1 0 2 2 2 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 10 10 10 11 11 11 12 12 12 15 13 13 16 14 14 17 15 15 19 I4VEC_INDEX_DELETE_ONE_TEST For an index sorted array of integers. I4VEC_INDEX_DELETE_ONE deletes one copies of a particular value. Generate some random values: 14 15 8 7 18 13 20 17 9 17 4 13 6 0 1 0 7 9 3 12 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 16 8 0 2 18 7 0 3 17 14 1 4 21 15 3 5 13 8 4 6 15 7 6 7 2 18 7 8 6 13 7 9 23 20 7 10 19 17 7 11 1 9 8 12 5 17 8 13 24 4 8 14 11 13 9 15 20 6 9 16 22 0 12 17 8 1 13 18 14 0 13 19 3 7 14 20 4 9 15 21 10 3 17 22 12 12 17 23 7 7 18 24 9 8 20 Call I4VEC_INDEX_DELETE_ONE to delete a value of 8: I4VEC_INDEX_INSERT_TEST I4VEC_INDEX_INSERT inserts values into an index sorted array of integers. Generate some random values: 2 19 12 17 9 11 0 11 20 15 14 3 5 5 18 16 2 5 18 11 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 9 8 0 2 3 7 2 3 19 2 2 4 14 19 3 5 15 12 5 6 20 17 5 7 16 9 5 8 2 11 7 9 23 0 7 10 1 11 8 11 24 20 8 12 7 15 9 13 8 14 11 14 22 3 11 15 10 5 11 16 5 5 12 17 13 18 14 18 12 16 15 19 18 2 16 20 6 5 17 21 17 18 18 22 21 11 18 23 4 7 19 24 11 8 20 I4VEC_INDEX_INSERT_UNIQUE_TEST I4VEC_INDEX_INSERT_UNIQUE inserts unique values into an index sorted array. Generate some random values: Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 6 14 0 2 8 15 1 3 4 10 2 4 9 2 3 5 10 13 6 6 3 0 10 7 13 19 11 8 5 1 13 9 1 3 14 10 2 6 15 11 11 16 16 12 12 17 17 13 7 11 19 I4VEC_INDEX_ORDER_TEST I4VEC_INDEX_ORDER sorts an index sorted array. Generate some random values: 9 14 16 6 11 17 15 0 6 3 14 16 14 3 8 16 0 11 19 10 Indexed list of unique entries: I INDX(I) X(I) X(INDX(I)) 1 8 9 0 2 9 14 3 3 4 16 6 4 10 6 8 5 1 11 9 6 12 17 10 7 5 15 11 8 2 0 14 9 7 3 15 10 3 8 16 11 6 19 17 12 11 10 19 Now call I4VEC_INDEX_ORDER to carry out the sorting: X: 1: 0 2: 3 3: 6 4: 8 5: 9 6: 10 7: 11 8: 14 9: 15 10: 16 11: 17 12: 19 I4VEC_INDEX_SEARCH_TEST I4VEC_INDEX_SEARCH searches for an entry with a given value. Generate some random values: Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 7 4 0 2 6 9 3 3 1 12 4 4 11 11 6 5 9 13 7 6 2 3 9 7 4 0 11 8 3 20 12 9 5 7 13 10 13 15 14 11 10 6 15 12 12 18 18 13 8 14 20 Results of search for given XVAL: XVAL Less Equal More 0 0 1 2 1 1 0 2 2 1 0 2 3 1 2 3 4 2 3 4 5 3 0 4 6 3 4 5 7 4 5 6 8 5 0 6 9 5 6 7 10 6 0 7 11 6 7 8 12 7 8 9 13 8 9 10 14 9 10 11 15 10 11 12 16 11 0 12 17 11 0 12 18 11 12 13 19 12 0 13 20 12 13 14 I4VEC_INDEXED_HEAP_D_TEST I4VEC_INDEXED_HEAP_D creates a descending heap from an indexed I4VEC. The data vector: 1: 101 2: 102 3: 103 4: 104 5: 105 6: 106 7: 107 8: 108 9: 109 10: 110 11: 111 12: 112 13: 113 14: 114 15: 115 16: 116 17: 117 18: 118 19: 119 20: 120 The index vector: 1: 1 2: 11 3: 17 4: 5 5: 7 6: 13 7: 15 8: 3 9: 19 10: 9 A(INDX): 1 101 2 111 3 117 4 105 5 107 6 113 7 115 8 103 9 119 10 109 The data vector (should NOT change): 1: 101 2: 102 3: 103 4: 104 5: 105 6: 106 7: 107 8: 108 9: 109 10: 110 11: 111 12: 112 13: 113 14: 114 15: 115 16: 116 17: 117 18: 118 19: 119 20: 120 The index vector (may change): 1: 19 2: 11 3: 17 4: 5 5: 9 6: 13 7: 15 8: 3 9: 1 10: 7 A(INDX) is now a descending heap: 1 119 2 111 3 117 4 105 5 109 6 113 7 115 8 103 9 101 10 107 I4VEC_INDEXED_HEAP_D_EXTRACT For an indexed I4VEC, I4VEC_INDEXED_HEAP_D_EXTRACT extracts the maximum value; The data vector: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 11: 11 12: 12 13: 13 14: 14 15: 15 16: 16 17: 17 18: 18 19: 19 20: 20 The index vector: 1: 9 2: 2 3: 8 4: 14 5: 5 A(INDX): 1 9 2 2 3 8 4 14 5 5 The index vector after heaping: 1: 14 2: 9 3: 8 4: 2 5: 5 A(INDX) after heaping: 1 14 2 9 3 8 4 2 5 5 Inserting value 7 Current maximum is 14 Inserting value 15 Current maximum is 15 Inserting value 1 Current maximum is 15 Inserting value 19 Current maximum is 19 Inserting value 20 Current maximum is 20 The data vector after insertions: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 11: 11 12: 12 13: 13 14: 14 15: 15 16: 16 17: 17 18: 18 19: 19 20: 20 The index vector after insertions: 1: 20 2: 19 3: 14 4: 9 5: 15 6: 7 7: 8 8: 1 9: 2 10: 5 A(INDX) after insertions: 1 20 2 19 3 14 4 9 5 15 6 7 7 8 8 1 9 2 10 5 Now extract the maximum several times. Extracting maximum element A( 20) = 20 Extracting maximum element A( 19) = 19 Extracting maximum element A( 15) = 15 Extracting maximum element A( 14) = 14 Extracting maximum element A( 9) = 9 The data vector after extractions: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 11: 11 12: 12 13: 13 14: 14 15: 15 16: 16 17: 17 18: 18 19: 19 20: 20 The index vector after extractions: 1: 8 2: 5 3: 7 4: 2 5: 1 A(INDX) after extractions: 1 8 2 5 3 7 4 2 5 1 I4VEC_INDEXED_HEAP_D_INSERT_TEST For an indexed I4VEC, I4VEC_INDEXED_HEAP_D_INSERT inserts a value into the heap. The data vector: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 11: 11 12: 12 13: 13 14: 14 15: 15 16: 16 17: 17 18: 18 19: 19 20: 20 The index vector: 1: 9 2: 2 3: 8 4: 14 5: 5 A(INDX): 1 9 2 2 3 8 4 14 5 5 The index vector after heaping: 1: 14 2: 9 3: 8 4: 2 5: 5 A(INDX) after heaping: 1 14 2 9 3 8 4 2 5 5 Inserting value 7 Inserting value 15 Inserting value 1 Inserting value 19 Inserting value 20 The data vector after insertions: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 11: 11 12: 12 13: 13 14: 14 15: 15 16: 16 17: 17 18: 18 19: 19 20: 20 The index vector after insertions: 1: 20 2: 19 3: 14 4: 9 5: 15 6: 7 7: 8 8: 1 9: 2 10: 5 A(INDX) after insertions: 1 20 2 19 3 14 4 9 5 15 6 7 7 8 8 1 9 2 10 5 I4VEC_INDEXED_HEAP_D_MAX_TEST For an indexed I4VEC, I4VEC_INDEXED_HEAP_D_MAX reports the maximum value. The data vector: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 11: 11 12: 12 13: 13 14: 14 15: 15 16: 16 17: 17 18: 18 19: 19 20: 20 The index vector: 1: 9 2: 2 3: 8 4: 14 5: 5 A(INDX): 1 9 2 2 3 8 4 14 5 5 The index vector after heaping: 1: 14 2: 9 3: 8 4: 2 5: 5 A(INDX) after heaping: 1 14 2 9 3 8 4 2 5 5 Inserting value 7 Current maximum is 14 Inserting value 15 Current maximum is 15 Inserting value 1 Current maximum is 15 Inserting value 19 Current maximum is 19 Inserting value 20 Current maximum is 20 I4VEC_INDICATOR0_TEST I4VEC_INDICATOR0 returns a 0-based 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 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 I4VEC_INSERT_TEST I4VEC_INSERT inserts a value into a vector. Sorted array: 1: 2 2: 4 3: 6 4: 8 5: 10 6: 10 7: 14 8: 16 9: 18 10: 20 Search for AVAL = -10 Left = -1 Right = 1 A(RIGHT) = 2 Sorted, augmented array: 1: -10 2: 2 3: 4 4: 6 5: 8 6: 10 7: 10 8: 14 9: 16 10: 18 11: 20 Search for AVAL = 2 Left = 2 Right = 2 A(LEFT)= 2 A(RIGHT) = 2 No insertion necessary. Search for AVAL = 9 Left = 5 Right = 6 A(LEFT)= 8 A(RIGHT) = 10 Sorted, augmented array: 1: -10 2: 2 3: 4 4: 6 5: 8 6: 9 7: 10 8: 10 9: 14 10: 16 11: 18 12: 20 Search for AVAL = 10 Left = 7 Right = 7 A(LEFT)= 10 A(RIGHT) = 10 No insertion necessary. Search for AVAL = 20 Left = 12 Right = 12 A(LEFT)= 20 A(RIGHT) = 20 No insertion necessary. Search for AVAL = 24 Left = 12 Right = -1 A(LEFT)= 20 Sorted, augmented array: 1: -10 2: 2 3: 4 4: 6 5: 8 6: 9 7: 10 8: 10 9: 14 10: 16 11: 18 12: 20 13: 24 I4VEC_IS_ASCENDING_TEST I4VEC_IS_ASCENDING determines if an I4VEC ascends. Test vector: 1: 1 2: 3 3: 2 4: 4 I4VEC_IS_ASCENDING = F Test vector: 1: 2 2: 2 3: 2 4: 2 I4VEC_IS_ASCENDING = T Test vector: 1: 1 2: 2 3: 2 4: 4 I4VEC_IS_ASCENDING = T Test vector: 1: 1 2: 2 3: 3 4: 4 I4VEC_IS_ASCENDING = T Test vector: 1: 4 2: 4 3: 3 4: 1 I4VEC_IS_ASCENDING = F Test vector: 1: 9 2: 7 3: 3 4: 0 I4VEC_IS_ASCENDING = F I4VEC_IS_BINARY_TEST I4VEC_IS_BINARY is TRUE if an I4VEC only contains 0 or 1 entries. X: 0 0 0 X is binary. X: 1 0 1 X is binary. X: 0 2 1 X is NOT binary. I4VEC_IS_DESCENDING_TEST I4VEC_IS_DESCENDING determines if an I4VEC descends. Test vector: 1: 1 2: 3 3: 2 4: 4 I4VEC_IS_DESCENDING = F Test vector: 1: 2 2: 2 3: 2 4: 2 I4VEC_IS_DESCENDING = T Test vector: 1: 1 2: 2 3: 2 4: 4 I4VEC_IS_DESCENDING = F Test vector: 1: 1 2: 2 3: 3 4: 4 I4VEC_IS_DESCENDING = F Test vector: 1: 4 2: 4 3: 3 4: 1 I4VEC_IS_DESCENDING = T Test vector: 1: 9 2: 7 3: 3 4: 0 I4VEC_IS_DESCENDING = T I4VEC_IS_PAIRWISE_PRIME_TEST I4VEC_IS_PAIRWISE_PRIME determines if an I4VEC is pairwise prime. Pairwise Row Vector Prime? 1 3 2 4 F 2 2 2 2 F 5 7 12 29 T 1 13 1 11 T 1 4 9 16 F 6 35 13 77 F I4VEC_MAX_TEST For an I4VEC: I4VEC_MAX: maximum entry; Input vector: 1: 16 2: 11 3: 25 4: 17 5: 21 6: 14 7: 27 8: 8 9: 8 10: 4 Maximum: 27 I4VEC_MAX_INDEX_TEST For an I4VEC: I4VEC_MAX_INDEX: a maximal index; Input vector: 1: 3 2: -5 3: 10 4: 0 5: -3 6: -7 7: 2 8: -10 9: -9 10: 8 Maximum index: 3 I4VEC_MAX_INDEX_LAST_TEST For an I4VEC: I4VEC_MAX_INDEX_LAST: last maximal index; Input vector: 1: -4 2: -10 3: -10 4: 1 5: -5 6: -10 7: -9 8: -9 9: -9 10: 4 Last maximum index: 10 I4VEC_MAX_LAST_TEST I4VEC_MAX_LAST identifies the largest element in an I4VEC, and moves it to the final entry. Input vector: 1: 23 2: 17 3: 12 4: 5 5: 14 6: 26 7: 19 8: 23 9: 22 10: 13 Maximum: 26 Output vector: 1: 23 2: 17 3: 12 4: 5 5: 14 6: 19 7: 23 8: 22 9: 13 10: 26 I4VEC_MEAN_TEST For an I4VEC: I4VEC_MEAN: mean value; Input vector: 1: 9 2: -3 3: 7 4: -6 5: -7 6: -9 7: -3 8: 2 9: 5 10: -9 Mean: -1.40000 I4VEC_MEDIAN_TEST For an I4VEC: I4VEC_MEDIAN: median value; Input vector: 1: -3 2: -1 3: 1 4: -1 5: 8 6: -5 7: -8 8: -5 9: -8 10: -1 Median: -3 I4VEC_MERGE_A_TEST I4VEC_MERGE_A merges two ascending-sorted I4VECs; Input vector A1: 1: 2 2: 3 3: 4 4: 5 5: 5 6: 7 7: 9 8: 9 9: 10 10: 10 Input vector A2: 1: 0 2: 2 3: 3 4: 4 5: 4 6: 6 7: 7 8: 8 9: 10 10: 10 Merged vector A3: 1: 0 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 I4VEC_MIN_TEST For an I4VEC: I4VEC_MIN: minimum entry; Input vector: 1: 17 2: 25 3: 3 4: 19 5: 17 6: 6 7: 12 8: 16 9: 9 10: 26 Minimum: 3 I4VEC_MIN_INDEX_TEST For an I4VEC: I4VEC_MIN_INDEX: a minimal index; Input vector: 1: -10 2: 3 3: -9 4: 5 5: 7 6: 1 7: 9 8: -5 9: 1 10: -9 Minimum index: 1 I4VEC_NONZERO_COUNT_TEST For an I4VEC: I4VEC_NONZERO_COUNT: number of nonzeroes; Input vector: 1: 1 2: 2 3: 1 4: -1 5: 0 6: 2 7: -2 8: 3 9: -3 10: 0 11: 2 12: 2 13: 2 14: 1 15: 2 Number of nonzeroes : 13 I4VEC_NONZERO_FIRST_TEST For an I4VEC: I4VEC_NONZERO_FIRST left shifts the nonzero entries of an I4VEC so they appear first. ----------Before-------------- ----------After--------------- 1 1 0 1 0 -1 0 0 -1 1 1 1 1 -1 -1 1 0 0 0 0 1 -1 1 1 -1 -1 -1 0 -1 -1 1 -1 1 1 -1 -1 -1 -1 -1 0 1 2 -1 1 2 2 -1 0 2 1 1 2 -1 1 2 2 -1 2 1 0 2 2 2 1 -1 -1 2 2 0 2 2 2 2 1 -1 -1 2 2 2 0 -1 0 0 1 0 1 0 2 1 -1 -1 1 1 2 1 -1 0 0 0 0 The value NZ counts the nonzeros, and the vector INDX indicates the original positions: Original vector: 0 1 -1 -1 1 2 2 0 2 -1 Number of nonzeros NZ = 8 Shifted vector: 1 -1 -1 1 2 2 2 -1 0 0 Index vector: 2 3 4 5 6 7 9 10 1 8 I4VEC_ORDER_TYPE_TEST I4VEC_ORDER_TYPE classifies an I4VEC as -1: no order 0: all equal; 1: ascending; 2: strictly ascending; 3: descending; 4: strictly descending. The following vector has order type -1 1 1 2 3 3 2 4 4 The following vector has order type 0 1 2 2 2 3 2 4 2 The following vector has order type 1 1 1 2 2 3 2 4 4 The following vector has order type 2 1 1 2 2 3 3 4 4 The following vector has order type 3 1 4 2 4 3 3 4 1 The following vector has order type 4 1 9 2 7 3 3 4 0 I4VEC_PART_TEST I4VEC_PART partitions an integer. NVAL = 17 Partitioned: 1: 4 2: 4 3: 3 4: 3 5: 3 NVAL = -49 Partitioned: 1: -10 2: -10 3: -10 4: -10 5: -9 I4VEC_PART_QUICK_A_TEST I4VEC_PART_QUICK_A reorders an I4VEC as part of a quick sort. Before rearrangement: 1: 12 2: 9 3: 2 4: 12 5: 3 6: 11 7: 3 8: 1 9: 7 10: 9 11: 11 12: 1 Rearranged array Left index = 10 Key index = 11 Right index = 13 Left half: 1: 2 2: 9 3: 3 4: 11 5: 3 6: 1 7: 7 8: 9 9: 11 10: 1 Key: 1: 12 Right half: 1: 12 I4VEC_PERMUTE_TEST I4VEC_PERMUTE reorders an I4VEC according to a given permutation. A, before rearrangement: 1: 9 2: 1 3: 4 4: 11 5: 4 6: 4 7: 7 8: 0 9: 7 10: 4 11: 2 12: 12 Permutation vector P: 1: 7 2: 10 3: 11 4: 1 5: 9 6: 8 7: 6 8: 4 9: 5 10: 12 11: 3 12: 2 A, after rearrangement: 1: 7 2: 4 3: 2 4: 9 5: 7 6: 0 7: 4 8: 11 9: 4 10: 12 11: 4 12: 1 I4VEC_PERMUTE_UNIFORM_TEST I4VEC_PERMUTE_UNIFORM randomly reorders an I4VEC. A, before permutation: 1: 101 2: 102 3: 103 4: 104 5: 105 6: 106 7: 107 8: 108 9: 109 10: 110 A, after random permutation: 1: 103 2: 104 3: 105 4: 106 5: 109 6: 101 7: 110 8: 102 9: 108 10: 107 I4VEC_PRINT_TEST I4VEC_PRINT prints an I4VEC The I4VEC: 1: 91 2: 92 3: 93 4: 94 I4VEC_RED_TEST I4VEC_RED divides out any common factors in the entries of an I4VEC. Apply I4VEC_RED to each row of this matrix: Col 1 2 3 Row 1: 12 88 9 2: 4 8 192 3: -12 88 94 4: 30 18 42 5: 0 4 8 Reduced matrix: Col 1 2 3 Row 1: 12 88 9 2: 1 2 48 3: -6 44 47 4: 5 3 7 5: 0 1 2 I4VEC_REVERSE_TEST I4VEC_REVERSE reverses an I4VEC. Original vector: 1: 7 2: 14 3: 2 4: 12 5: 29 6: 12 7: 11 8: 1 9: 15 10: 1 Reversed: 1: 1 2: 15 3: 1 4: 11 5: 12 6: 29 7: 12 8: 2 9: 14 10: 7 Re-reversed array using a(1:n) = a(n:1:-1): 1: 7 2: 14 3: 2 4: 12 5: 29 6: 12 7: 11 8: 1 9: 15 10: 1 I4VEC_RUN_COUNT_TEST I4VEC_RUN_COUNT counts runs in an I4VEC Run Count Sequence 11 0 1 1 1 0 0 1 1 0 1 1 1 1 1 0 0 1 0 1 0 13 1 0 0 1 1 0 0 1 0 0 0 1 0 1 0 1 1 0 1 1 9 0 0 0 0 1 0 0 1 0 1 1 0 0 1 1 1 0 0 0 0 11 1 1 1 0 1 0 0 1 1 1 0 1 1 0 0 0 0 1 0 1 15 0 1 0 1 1 0 1 0 0 0 0 1 0 1 0 1 0 0 1 0 7 0 0 1 0 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 12 0 1 0 0 1 0 1 1 0 1 1 1 0 0 0 1 1 1 0 1 11 0 1 0 0 0 1 0 1 0 0 0 0 0 0 1 0 1 1 0 0 8 1 0 0 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 9 1 1 1 0 1 0 1 0 0 1 1 1 1 1 0 1 1 1 1 1 I4VEC_SEARCH_BINARY_A_TEST For ascending order: I4VEC_SEARCH_BINARY_A searches an I4VEC for a value; Input vector A: 1: 1 2: 1 3: 1 4: 2 5: 2 6: 3 7: 5 8: 5 9: 6 10: 6 11: 8 12: 8 13: 10 14: 12 15: 13 16: 13 17: 16 18: 16 19: 19 20: 20 Search the array A for the value 13 SEARCH RESULT: The value occurs in index 15 I4VEC_SORT_BUBBLE_A_TEST For an I4VEC, I4VEC_SORT_BUBBLE_A ascending sorts, Unsorted: 1: 36 2: 0 3: 23 4: 39 5: 9 6: 53 7: 6 8: 24 9: 9 10: 17 11: 39 12: 31 13: 35 14: 21 15: 38 16: 28 17: 26 18: 45 19: 57 20: 11 Ascending sorted: 1: 0 2: 6 3: 9 4: 9 5: 11 6: 17 7: 21 8: 23 9: 24 10: 26 11: 28 12: 31 13: 35 14: 36 15: 38 16: 39 17: 39 18: 45 19: 53 20: 57 I4VEC_SORT_HEAP_A_TEST I4VEC_SORT_HEAP_A ascending sorts an I4VEC, Unsorted: 1: 31 2: 3 3: 8 4: 10 5: 4 6: 32 7: 20 8: 8 9: 34 10: 59 11: 0 12: 27 13: 23 14: 18 15: 35 16: 16 17: 31 18: 29 19: 55 20: 53 Ascending sorted: 1: 0 2: 3 3: 4 4: 8 5: 8 6: 10 7: 16 8: 18 9: 20 10: 23 11: 27 12: 29 13: 31 14: 31 15: 32 16: 34 17: 35 18: 53 19: 55 20: 59 I4VEC_SORT_HEAP_D_TEST I4VEC_SORT_HEAP_D descending sorts an I4VEC. Unsorted: 1: 36 2: 20 3: 43 4: 35 5: 8 6: 32 7: 21 8: 35 9: 40 10: 49 11: 49 12: 39 13: 7 14: 26 15: 54 16: 16 17: 13 18: 20 19: 27 20: 6 Descending sorted: 1: 54 2: 49 3: 49 4: 43 5: 40 6: 39 7: 36 8: 35 9: 35 10: 32 11: 27 12: 26 13: 21 14: 20 15: 20 16: 16 17: 13 18: 8 19: 7 20: 6 I4VEC_SORT_HEAP_INDEX_A_TEST I4VEC_SORT_HEAP_INDEX_A creates an ascending sort index for an I4VEC. Unsorted array A: 1: 47 2: 38 3: 57 4: 35 5: 56 6: 9 7: 41 8: 23 9: 33 10: 58 11: 2 12: 30 13: 60 14: 33 15: 22 16: 60 17: 15 18: 52 19: 25 20: 22 Index vector INDX: 1: 11 2: 6 3: 17 4: 20 5: 15 6: 8 7: 19 8: 12 9: 9 10: 14 11: 4 12: 2 13: 7 14: 1 15: 18 16: 5 17: 3 18: 10 19: 13 20: 16 I, INDX(I), A(INDX(I)) 1 11 2 2 6 9 3 17 15 4 20 22 5 15 22 6 8 23 7 19 25 8 12 30 9 9 33 10 14 33 11 4 35 12 2 38 13 7 41 14 1 47 15 18 52 16 5 56 17 3 57 18 10 58 19 13 60 20 16 60 I4VEC_SORT_HEAP_INDEX_D_TEST I4VEC_SORT_HEAP_INDEX_D creates a descending sort index for an I4VEC. Unsorted array: 1: 2 2: 9 3: 28 4: 38 5: 8 6: 40 7: 2 8: 51 9: 26 10: 10 11: 22 12: 39 13: 50 14: 51 15: 46 16: 7 17: 16 18: 12 19: 48 20: 46 Index vector INDX: 1: 8 2: 14 3: 13 4: 19 5: 20 6: 15 7: 6 8: 12 9: 4 10: 3 11: 9 12: 11 13: 17 14: 18 15: 10 16: 2 17: 5 18: 16 19: 7 20: 1 Now use the index array to carry out the permutation implicitly. I, INDX(I), A(INDX(I)) 1 8 51 2 14 51 3 13 50 4 19 48 5 20 46 6 15 46 7 6 40 8 12 39 9 4 38 10 3 28 11 9 26 12 11 22 13 17 16 14 18 12 15 10 10 16 2 9 17 5 8 18 16 7 19 7 2 20 1 2 I4VEC_SORT_INSERT_A_TEST I4VEC_SORT_INSERT_A sorts an I4VEC. Unsorted array: 1: 1 2: 7 3: 0 4: 0 5: 6 6: 1 7: 0 8: 6 9: 9 10: 8 Sorted array: 1: 0 2: 0 3: 0 4: 1 5: 1 6: 6 7: 6 8: 7 9: 8 10: 9 I4VEC_SORT_QUICK_A_TEST I4VEC_SORT_QUICK_A quicksorts an I4VEC. Unsorted array: 1: 35 2: 56 3: 8 4: 46 5: 46 6: 44 7: 37 8: 57 9: 53 10: 39 11: 44 12: 30 13: 47 14: 45 15: 59 16: 38 17: 27 18: 4 19: 44 20: 57 Sorted array: 1: 35 2: 56 3: 56 4: 56 5: 56 6: 56 7: 56 8: 56 9: 56 10: 56 11: 56 12: 56 13: 56 14: 56 15: 56 16: 56 17: 56 18: 56 19: 56 20: 56 I4VEC_SORT_SHELL_A_TEST I4VEC_SORT_SHELL_A Shell sorts an I4VEC. Unsorted array: 1: 28 2: 30 3: 35 4: 59 5: 39 6: 48 7: 11 8: 56 9: 19 10: 6 11: 59 12: 41 13: 10 14: 23 15: 0 16: 19 17: 29 18: 19 19: 19 20: 56 Sorted array: 1: 0 2: 6 3: 10 4: 11 5: 19 6: 19 7: 19 8: 19 9: 23 10: 28 11: 29 12: 30 13: 35 14: 39 15: 41 16: 48 17: 56 18: 56 19: 59 20: 59 I4VEC_SORTED_UNDEX_TEST I4VEC_SORTED_UNDEX produces index vectors which create a sorted list of the unique elements of a sorted I4VEC, and a map from the original vector to the (implicit) vector of sorted unique elements. The vector X: 1: 11 2: 11 3: 11 4: 22 5: 22 6: 33 7: 33 8: 55 9: 55 Number of unique entries in X is 4 UNDX can be used to list the unique elements of X in sorted order. I UNDX X(UNDX) 1 1 11 2 4 22 3 6 33 4 8 55 UNDX can be used to created XU, a copy of X containing only the unique elements, in sorted order. I UNDX XU(I) 1 1 11 2 4 22 3 6 33 4 8 55 XDNU can be used to match each element of X with one of the unique elements I XDNU X(I) XU(XDNU(I)) 1 1 11 11 2 1 11 11 3 1 11 11 4 2 22 22 5 2 22 22 6 3 33 33 7 3 33 33 8 4 55 55 9 4 55 55 I4VEC_SORTED_UNIQUE_TEST I4VEC_SORTED_UNIQUE finds unique entries in a sorted array. Input vector: 1: 1 2: 2 3: 2 4: 2 5: 2 6: 4 7: 5 8: 5 9: 7 10: 11 11: 11 12: 13 13: 14 14: 15 15: 16 16: 16 17: 18 18: 18 19: 18 20: 19 Unique entries: 1: 1 2: 2 3: 4 4: 5 5: 7 6: 11 7: 13 8: 14 9: 15 10: 16 11: 18 12: 19 I4VEC_SORTED_UNIQUE_COUNT_TEST I4VEC_SORTED_UNIQUE_COUNT counts unique entries in a sorted I4VEC. Input vector: 1: 3 2: 3 3: 4 4: 5 5: 5 6: 5 7: 7 8: 8 9: 9 10: 9 11: 9 12: 10 13: 11 14: 11 15: 13 16: 14 17: 15 18: 15 19: 16 20: 17 Number of unique entries is 13 I4VEC_SORTED_UNIQUE_HIST_TEST For an I4VEC, I4VEC_SORTED_UNIQUE_HIST makes a histogram of unique entries. Unsorted: 1: 52 2: 39 3: 54 4: 33 5: 27 6: 30 7: 6 8: 3 9: 2 10: 25 11: 57 12: 9 13: 18 14: 34 15: 46 16: 3 17: 25 18: 31 19: 9 20: 29 Ascending sorted: 1: 2 2: 3 3: 3 4: 6 5: 9 6: 9 7: 18 8: 25 9: 25 10: 27 11: 29 12: 30 13: 31 14: 33 15: 34 16: 39 17: 46 18: 52 19: 54 20: 57 I4VEC_UNIQ3 counts 17 unique entries. Value and Multiplicity 1: 2 1 2: 3 2 3: 6 1 4: 9 2 5: 18 1 6: 25 2 7: 27 1 8: 29 1 9: 30 1 10: 31 1 11: 33 1 12: 34 1 13: 39 1 14: 46 1 15: 52 1 16: 54 1 17: 57 1 I4VEC_SUM_TEST I4VEC_SUM sums the entries of an I4VEC. The vector: 1: 3 2: 4 3: 3 4: 1 5: 10 The vector entries sum to 21 I4VEC_SUM_VEC_TEST I4VEC_SUM_VEC does a pairwise sum of two I4VEC's. A: 8 1 1 0 3 B: 3 1 2 2 7 C = A + B: 11 2 3 2 10 I4VEC_TRANSPOSE_PRINT_TEST I4VEC_TRANSPOSE_PRINT prints an I4VEC with 5 entries to a row, and an optional 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 Call I4VEC_TRANSPOSE_PRINT with a short title: My array: 1 2 3 4 5 6 7 8 9 10 11 12 I4VEC_UNDEX_TEST I4VEC_UNDEX produces index vectors which create a sorted list of the unique elements of an (unsorted) I4VEC, and a map from the original vector to the (implicit) vector of sorted unique elements. The vector X: 1: 33 2: 55 3: 11 4: 11 5: 55 6: 33 7: 22 8: 22 9: 11 Number of unique entries in X is 4 UNDX can be used to list the unique elements of X in sorted order. I UNDX X(UNDX) 1 3 11 2 7 22 3 6 33 4 5 55 UNDX can be used to created XU, a copy of X containing only the unique elements, in sorted order. I UNDX XU(I) 1 3 11 2 7 22 3 6 33 4 5 55 XDNU can be used to match each element of X with one of the unique elements I XDNU X(I) XU(XDNU(I)) 1 3 33 33 2 4 55 55 3 1 11 11 4 1 11 11 5 4 55 55 6 3 33 33 7 2 22 22 8 2 22 22 9 1 11 11 I4VEC_UNIFORM_AB_TEST I4VEC_UNIFORM_AB computes pseudorandom values in an interval [A,B]. The lower endpoint A = -100 The upper endpoint B = 200 The random vector: 1: -82 2: 7 3: 157 4: 48 5: -16 6: 131 7: 135 8: 32 9: 76 10: -53 11: 96 12: 12 13: -26 14: -44 15: -32 16: 44 17: -37 18: 140 19: 98 20: 69 I4VEC_UNIQUE_COUNT_TEST I4VEC_UNIQUE_COUNT counts unique entries in an I4VEC. Input vector: 1: 2 2: 14 3: 4 4: 11 5: 11 6: 19 7: 2 8: 0 9: 13 10: 3 11: 5 12: 4 13: 15 14: 10 15: 16 16: 17 17: 9 18: 11 19: 0 20: 16 Number of unique entries is 14 I4VEC_UNIQUE_INDEX_TEST I4VEC_UNIQUE_INDEX, for each entry in an I4VEC indexes the unique elements. I A(I) UNIQUE 1 4 1 2 1 2 3 1 2 4 1 2 5 5 3 6 2 4 7 2 4 8 4 1 9 4 1 10 5 3 11 2 4 12 2 4 13 5 3 14 3 5 15 3 5 16 1 2 17 5 3 18 5 3 19 1 2 20 4 1 I4VEC_VALUE_INDEX_TEST I4VEC_VALUE_INDEX indexes entries equal to a given value. The desired value is 3 Maximum number of indices to find is 3 Input vector A: 1: 3 2: 2 3: 3 4: 2 5: 2 6: 5 7: 3 8: 2 9: 2 10: 1 11: 5 12: 2 13: 3 14: 5 15: 4 16: 2 17: 3 18: 1 19: 3 20: 4 21: 5 22: 3 23: 4 24: 4 25: 4 Indices of entries equal to given value: 1: 1 2: 3 3: 7 I4VEC_VARIANCE_TEST I4VEC_VARIANCE computes the variance of an I4VEC. Input vector: 1: 2 2: 8 3: 1 4: 10 5: 0 6: 7 7: 7 8: -1 9: 9 10: -10 Variance: 37.7889 I4VEC_WIDTH_TEST I4VEC_WIDTH determines the printing "width" of an I4VEC. The I4VEC: 1: 0 2: 1 3: 2 4: 3 5: 9 6: 10 7: 11 8: 99 9: 101 10: -1 11: -2 12: -3 13: -9 The printing width is 3 I4VEC2_PRINT_TEST I4VEC2_PRINT prints a pair of I4VECs I, sum of I, sum of I^2: 1: 0 0 2: 1 1 3: 3 5 4: 6 14 5: 10 30 6: 15 55 7: 21 91 8: 28 140 9: 36 204 10: 45 285 11: 55 385 I4VEC2_SORT_A_TEST For a pair of I4VECs: I4VEC2_SORT_A ascending sorts; The array: 1: 3 3 2: 3 1 3: 3 3 4: 2 2 5: 3 1 6: 3 1 7: 3 1 8: 2 3 9: 3 3 10: 3 2 After ascending sort: 1: 2 2 2: 2 3 3: 3 1 4: 3 1 5: 3 1 6: 3 1 7: 3 2 8: 3 3 9: 3 3 10: 3 3 I4VEC2_SORT_D_TEST For a pair of I4VECs: I4VEC2_SORT_D descending sorts; The array: 1: 1 3 2: 1 2 3: 1 3 4: 3 3 5: 1 2 6: 1 1 7: 3 3 8: 1 3 9: 1 3 10: 1 1 After descending sort: 1: 3 3 2: 3 3 3: 1 3 4: 1 3 5: 1 3 6: 1 3 7: 1 2 8: 1 2 9: 1 1 10: 1 1 I4VEC2_SORTED_UNIQUE_TEST For a pair of I4VECs: I4VEC2_SORTED_UNIQUE counts unique entries. The array: 1: 1 2 2: 2 1 3: 1 2 4: 2 1 5: 2 1 6: 2 2 7: 1 2 8: 1 3 9: 1 2 10: 3 2 After ascending sort: 1: 1 2 2: 1 2 3: 1 2 4: 1 2 5: 1 3 6: 2 1 7: 2 1 8: 2 1 9: 2 2 10: 3 2 After UNIQ: 1: 1 2 2: 1 3 3: 2 1 4: 2 2 5: 3 2 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 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 PERM0_CHECK_TEST PERM0_CHECK checks a permutation of 0,...,N-1. Permutation 1: 5 2 3 4 1 PERM0_CHECK - Fatal error! Permutation is missing value 0 Permutation 2: 4 1 3 0 2 Permutation 3: 0 2 1 3 2 PERM0_CHECK - Fatal error! Permutation is missing value 4 PERM0_UNIFORM_TEST PERM0_UNIFORM randomly selects a permutation of 0,...,N-1. 9 6 8 2 4 3 5 0 1 7 7 5 9 3 6 2 4 8 0 1 7 1 2 8 3 4 5 0 9 6 9 7 3 0 5 6 4 8 2 1 7 5 2 0 8 9 3 6 4 1 PERM1_CHECK_TEST PERM1_CHECK checks a permutation of 1,...,N. Permutation 1: 5 2 3 4 1 Permutation 2: 4 1 3 0 2 PERM1_CHECK - Fatal error! Permutation is missing value 5 Permutation 3: 0 2 1 3 2 PERM1_CHECK - Fatal error! Permutation is missing value 4 PERM1_UNIFORM_TEST PERM1_UNIFORM randomly selects a permutation of 1,...,N. 3 9 4 1 7 2 10 6 8 5 3 1 10 5 9 8 6 7 2 4 3 1 6 5 9 7 2 10 4 8 1 3 6 5 4 8 9 10 2 7 6 5 9 2 1 4 3 10 7 8 PERMUTATION_SYMBOL_TEST PERMUTATION_SYMBOL evaluates the Levi-Civita permutation symbol. Input vector: 1 2 3 4 5 Levi-Civita permutation symbol = 1 Input vector: 4 2 3 1 5 Levi-Civita permutation symbol = -1 Input vector: 1 2 3 4 2 Levi-Civita permutation symbol = 0 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 TRIANGLE_LOWER_TO_I4_TEST TRIANGLE_LOWER_TO_I4 converts a lower triangular index to a linear one. I, J ==> K 1 1 1 2 1 2 2 2 3 3 1 4 3 2 5 3 3 6 4 1 7 4 2 8 4 3 9 4 4 10 i4lib_test(): Normal end of execution. 9 September 2021 7:50:32.040 PM