26 February 2022 12:34:55 PM I4LIB_TEST C version Test the I4LIB library. I4_ABS_TEST I4_ABS returns the absolute value of an I4. A B=I4_ABS(A) -57 57 92 92 66 66 12 12 -17 17 -87 87 -49 49 -78 78 -92 92 27 27 I4_AND_TEST I4_OR returns the bitwise AND of two I4's. I J I4_AND I&J 22 96 0 0 83 56 16 16 41 6 0 0 26 11 10 10 4 64 0 0 6 45 4 4 40 76 8 8 80 0 0 0 90 35 2 2 9 1 1 1 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) 22 5 96 7 83 7 56 6 41 6 6 3 26 5 11 4 4 3 64 7 I4_BIT_LO0_TEST I4_BIT_LO0 returns the location of the low 0 bit. I I4_BIT_LO0(I) 22 1 96 1 83 3 56 1 41 2 6 1 26 1 11 3 4 1 64 1 I4_BIT_LO1_TEST I4_BIT_LO1 returns the location of the low 1 bit. I I4_BIT_LO1(I) 22 2 96 6 83 1 56 4 41 1 6 2 26 2 11 1 4 3 64 7 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 1 1 0 2 1 3 0 4 0 5 1 6 1 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 Analyze the integer I4 = -31 Pos I4_BTEST(I4,POS) 0 1 1 0 2 0 3 0 4 0 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 I4_CEILING_TEST I4_CEILING evaluates the 'ceiling' of an R8. R8 I4_CEILING(R8) -56.3163 -56 91.2635 92 65.9018 66 12.3391 13 -16.9386 -16 -86.7763 -86 -48.4844 -48 -78.0086 -78 -91.2342 -91 26.7931 27 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 True 120 1000 999 True 1000 100 3 True 161700 100 10 False Not computable I4_CHOOSE_LOG_TEST I4_CHOOSE_LOG evaluates log(C(N,K)). N K log(CNK) exp(log(CNK)) CNK 0 0 0 1 1 1 0 0 1 1 1 1 0 1 1 2 0 0 1 1 2 1 0.693147 2 2 2 2 0 1 1 3 0 0 1 1 3 1 1.09861 3 3 3 2 1.09861 3 3 3 3 0 1 1 4 0 0 1 1 4 1 1.38629 4 4 4 2 1.79176 6 6 4 3 1.38629 4 4 4 4 0 1 1 I4_DIV_ROUNDED_TEST I4_DIV_ROUNDED performs rounded integer division. C0 = ( double ) ( a ) / ( double ) ( b ) C1 = I4_DIV_ROUNDED ( A, B ) C2 = r8_nint ( ( double ) ( a ) / ( double ) ( b ) ) C3 = A / B C4 = ( int ) ( ( double ) ( a ) / ( double ) ( b ) ) C1 and C2 should be equal; C3 and C4 should be equal. A B C0 C1 C2 C3 C4 -57 10 -5.7000 -6 -6 -5 -5 66 1 66.0000 66 66 66 66 -17 -9 1.8889 2 2 1 1 -49 -8 6.1250 6 6 6 6 -92 3 -30.6667 -31 -31 -30 -30 -88 -1 88.0000 88 88 88 88 -20 5 -4.0000 -4 -4 -4 -4 60 -10 -6.0000 -6 -6 -6 -6 80 -3 -26.6667 -27 -27 -26 -26 -81 -10 8.1000 8 8 8 8 72 7 10.2857 10 10 10 10 -76 -10 7.6000 8 8 7 7 -48 9 -5.3333 -5 -5 -5 -5 -78 -3 26.0000 26 26 26 26 65 -5 -13.0000 -13 -13 -13 -13 39 1 39.0000 39 39 39 39 73 -1 -73.0000 -73 -73 -73 -73 83 2 41.5000 41 42 41 41 -63 5 -12.6000 -13 -13 -12 -12 -21 -7 3.0000 3 3 3 3 I4_DIVP_TEST I4_DIVP(A,B) returns the smallest multiplier of J that is less than I A B C D -57 10 -4 -40 66 1 66 66 -17 -9 3 -27 -49 -8 7 -56 -92 3 -30 -90 -88 -1 90 -90 -20 5 -3 -15 60 -10 -4 40 80 -3 -25 75 -81 -10 9 -90 72 7 11 77 -76 -10 8 -80 -48 9 -4 -36 -78 -3 27 -81 65 -5 -11 55 39 1 39 39 73 -1 -71 71 83 2 42 84 -63 5 -11 -55 -21 -7 4 -28 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 the log of the factorial function. N lfact explfact exact 0 0 1 1 1 0 1 1 2 0.693147 2 2 3 1.79176 6 6 4 3.17805 24 24 5 4.78749 120 120 6 6.57925 720 720 7 8.52516 5040 5040 8 10.6046 40320 40320 9 12.8018 362880 362880 10 15.1044 3.6288e+06 3628800 11 17.5023 3.99168e+07 39916800 12 19.9872 4.79002e+08 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 an R8. R8 I4_FLOOR(R8) -56.3163 -57 91.2635 91 65.9018 65 12.3391 12 -16.9386 -17 -86.7763 -87 -48.4844 -49 -78.0086 -79 -91.2342 -92 26.7931 26 I4_GCD_TEST I4_GCD computes the greatest common divisor of two I4s 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 I4_HUGE_NORMALIZER_TEST I4_HUGE_NORMALIZER returns 1/(I4_HUGE+1). I4_HUGE() = 2147483647 I4_HUGE_NORMALIZER() = 4.656613e-10 I4_HUGE * I4_HUGE_NORMALIZER = 1.000000e+00 I4_IS_EVEN_TEST I4_IS_EVEN reports whether an I4 is even. I I4_IS_EVEN(I) -2 1 -1 0 0 1 1 0 2 1 3 0 4 1 5 0 6 1 7 0 8 1 9 0 10 1 11 0 12 1 13 0 14 1 15 0 16 1 17 0 18 1 19 0 20 1 21 0 22 1 23 0 24 1 25 0 I4_IS_ODD_TEST I4_IS_ODD reports whether an I4 is odd. I I4_IS_ODD(I) -2 0 -1 1 0 0 1 1 2 0 3 1 4 0 5 1 6 0 7 1 8 0 9 1 10 0 11 1 12 0 13 1 14 0 15 1 16 0 17 1 18 0 19 1 20 0 21 1 22 0 23 1 24 0 25 1 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 0 -3 0 -2 0 -1 0 0 0 1 1 2 1 3 0 4 1 5 0 6 0 7 0 8 1 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 1 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 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 0 98 0 99 0 100 1 101 0 102 0 103 0 I4_IS_PRIME_TEST I4_IS_PRIME reports whether an integer is prime. I I4_IS_PRIME(I) -2 0 -1 0 0 0 1 0 2 1 3 1 4 0 5 1 6 0 7 1 8 0 9 0 10 0 11 1 12 0 13 1 14 0 15 0 16 0 17 1 18 0 19 1 20 0 21 0 22 0 23 1 24 0 25 0 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 I_LOG_2 0 0 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: whole part of log base B, 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.000000 3 16 3.000000 2 16 4.000000 1 16 5.000000 1 16 6.000000 1 16 7.000000 1 16 8.000000 1 16 16.000000 0 16 32.000000 0 16 256.000000 0 I4_MANT_TEST I4_MANT decomposes an integer, Number to be decomposed is X = -314.159000 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) -57 92 92 66 12 66 -17 -87 -17 -49 -78 -49 -92 27 27 -88 -10 -10 -20 51 51 60 -100 60 80 -30 80 -81 -98 -81 I4_MIN_TEST I4_MIN returns the minimum of two I4's. A B C=I4_MIN(A,B) -57 92 -57 66 12 12 -17 -87 -87 -49 -78 -78 -92 27 -92 -88 -10 -88 -20 51 -20 60 -100 -100 80 -30 -30 -81 -98 -98 I4_MODDIV_TEST I4_MODDIV factors a number into a multiple and a remainder. Number Divisor Multiple Remainder 107 50 2 7 107 -50 -2 7 -107 50 -2 -7 -107 -50 2 -7 Repeat using C percent 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 remainder. Number Divisor Multiple Remainder 107 50 2 7 107 -50 -2 7 -107 50 -2 43 -107 -50 2 43 Repeat using C percent operator: 107 50 2 7 107 -50 -2 7 -107 50 -2 -7 -107 -50 2 -7 I4_NORMAL_AB_TEST I4_NORMAL_AB computes pseudonormal integers with mean MU and standard deviation SIGMA. The mean = 70.000000 The standard deviation = 10.000000 SEED = 123456789 1 87 2 64 3 82 4 83 5 53 6 48 7 70 8 77 9 67 10 92 I4_NOT_TEST I4_NOT returns the NOT of an I4 with respect to a maximum J. I J I4_NOT ~I + J + 1 22 255 233 233 96 255 159 159 83 255 172 172 56 255 199 199 41 255 214 214 6 255 249 249 26 255 229 229 11 255 244 244 4 255 251 251 64 255 191 191 I4_OR_TEST I4_OR returns the bitwise inclusive OR of two I4's. I J I4_OR I|J 22 96 118 118 83 56 123 123 41 6 47 47 26 11 27 27 4 64 68 68 6 45 47 47 40 76 108 108 80 0 80 80 90 35 123 123 9 1 9 9 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 two-way 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 I4s. 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 0 2 1 1 3 2 0 4 2 1 5 2 2 6 3 0 7 3 1 8 3 2 9 3 3 10 4 0 11 4 1 12 4 2 13 4 3 14 4 4 15 5 0 16 5 1 17 5 2 18 5 3 19 5 4 20 5 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 The initial seed is 123456789 1 -35 2 187 3 149 4 69 5 25 6 -81 7 -23 8 -67 9 -87 10 90 11 -82 12 35 13 20 14 127 15 139 16 -100 17 170 18 5 19 -72 20 -96 I4_WALSH_1D_TEST I4_WALSH_1D evaluates 1D Walsh functions: X W(+2) W(+1) W(0) W(-1) W(-2) W(-3) 0.0000 0 0 0 0 0 0 0.2500 0 0 0 0 1 0 0.5000 0 0 0 1 0 0 0.7500 0 0 0 1 1 0 1.0000 0 0 1 0 0 0 1.2500 0 0 1 0 1 0 1.5000 0 0 1 1 0 0 1.7500 0 0 1 1 1 0 2.0000 0 1 0 0 0 0 2.2500 0 1 0 0 1 0 2.5000 0 1 0 1 0 0 2.7500 0 1 0 1 1 0 3.0000 0 1 1 0 0 0 3.2500 0 1 1 0 1 0 3.5000 0 1 1 1 0 0 3.7500 0 1 1 1 1 0 4.0000 1 0 0 0 0 0 4.2500 1 0 0 0 1 0 4.5000 1 0 0 1 0 0 4.7500 1 0 0 1 1 0 5.0000 1 0 1 0 0 0 5.2500 1 0 1 0 1 0 5.5000 1 0 1 1 0 0 5.7500 1 0 1 1 1 0 6.0000 1 1 0 0 0 0 6.2500 1 1 0 0 1 0 6.5000 1 1 0 1 0 0 6.7500 1 1 0 1 1 0 7.0000 1 1 1 0 0 0 7.2500 1 1 1 0 1 0 7.5000 1 1 1 1 0 0 7.7500 1 1 1 1 1 0 8.0000 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 I4's. The operator ^ should generally be used instead. I J I4_XOR I^J 22 96 118 118 83 56 107 107 41 6 47 47 26 11 17 17 4 64 68 68 6 45 43 43 40 76 100 100 80 0 80 80 90 35 121 121 9 1 8 8 I4BLOCK_NEW_TEST: I4BLOCK_NEW dynamically creates a 3D array. I4BLOCK_DELETE deletes it. Array entries can be addressed using the notation "a[i][j][k]". Allocating memory for array A of size 2 by 3 by 2. Assigning values to A. Dynamically allocated matrix A: 0 1 10 11 20 21 100 101 110 111 120 121 I4BLOCK_PRINT_TEST I4BLOCK_PRINT prints an I4BLOCK. The 3D array: K = 0 J: 0 1 2 I: 0: 1 1 1 1: 2 4 8 2: 3 9 27 3: 4 16 64 K = 1 J: 0 1 2 I: 0: 2 2 2 1: 4 8 16 2: 6 18 54 3: 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: 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 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: 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 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 I4VEC as a table of columns. The original matrix: Col: 0 1 2 3 Row 0: 3 1 1 1 1: 10 3 5 9 2: 9 2 5 4 3: 6 1 8 1 4: 5 7 8 1 Ascending sorted: Col: 0 1 2 3 Row 0: 1 1 1 3 1: 3 5 9 10 2: 2 5 4 9 3: 1 8 1 6 4: 7 8 1 5 I4COL_SORT_D_TEST I4COL_SORT_D descending sorts an I4VEC as a table of columns. The original matrix: Col: 0 1 2 3 Row 0: 3 1 1 1 1: 10 3 5 9 2: 9 2 5 4 3: 6 1 8 1 4: 5 7 8 1 Descending sorted: Col: 0 1 2 3 Row 0: 3 1 1 1 1: 10 9 5 3 2: 9 4 5 2 3: 6 1 8 1 4: 5 1 8 7 I4COL_SORT2_A_TEST For a rectangular integer matrix: I4COL_SORT2_A sorts the elements of the columns. The matrix: Col: 0 1 2 3 Row 0: 4 5 8 1 1: 20 2 15 0 2: 17 0 16 18 3: 11 13 0 17 4: 8 1 18 2 5: 1 9 7 0 The element-sorted column matrix: Col: 0 1 2 3 Row 0: 1 0 0 0 1: 4 1 7 0 2: 8 2 8 1 3: 11 5 15 2 4: 17 9 16 17 5: 20 13 18 18 I4COL_SORTED_SINGLETON_COUNT_TEST I4COL_SORTED_SINGLETON_COUNT counts singletons in a sorted ICOL; Ascending sorted ICOL: Col: 0 1 2 3 4 5 6 7 8 9 Row 0: 0 0 0 1 1 1 1 2 2 3 1: 0 3 3 0 3 3 3 0 1 0 2: 3 1 3 0 0 1 3 1 0 0 Number of singletons = 10 Ascending sorted ICOL: Col: 0 1 2 3 4 5 6 7 8 9 Row 0: 0 0 1 2 2 2 2 2 3 3 1: 2 3 3 0 0 1 1 2 3 3 2: 1 1 2 1 3 0 3 3 0 1 Number of singletons = 10 I4COL_SORTED_UNIQUE_COUNT_TEST I4COL_SORTED_UNIQUE_COUNT counts the unique entries of a sorted ICOL; Ascending sorted ICOL: Col: 0 1 2 3 4 5 6 7 8 9 Row 0: 0 0 0 1 1 1 1 2 2 3 1: 0 3 3 0 3 3 3 0 1 0 2: 3 1 3 0 0 1 3 1 0 0 Number of unique entries = 10 Ascending sorted ICOL: Col: 0 1 2 3 4 5 6 7 8 9 Row 0: 0 0 1 2 2 2 2 2 3 3 1: 2 3 3 0 0 1 1 2 3 3 2: 1 1 2 1 3 0 3 3 0 1 Number of unique entries = 10 I4MAT_ELIM_TEST I4MAT_ELIM does exact Gauss elimination. The original matrix: Col: 0 1 2 3 4 Row 0: 1 2 3 4 5 1: 6 7 8 9 10 2: 11 12 13 14 15 3: 16 17 18 19 20 4: 21 22 23 24 25 The matrix returned by I4MAT_ELIM: Col: 0 1 2 3 4 Row 0: 5 1 3 4 2 1: 0 -4 -2 -1 -3 2: 0 0 0 0 0 3: 0 0 0 0 0 4: 0 0 0 0 0 The original matrix: Col: 0 1 2 3 4 Row 0: 40320 20160 13440 10080 8064 1: 20160 13440 10080 8064 6720 2: 13440 10080 8064 6720 5760 3: 10080 8064 6720 5760 5040 4: 8064 6720 5760 5040 4480 The matrix returned by I4MAT_ELIM: Col: 0 1 2 3 4 Row 0: 60 12 30 20 15 1: 0 -8 -10 -10 -9 2: 0 0 15 8 3 3: 0 0 0 -14 -9 4: 0 0 0 0 -1 The original matrix: Col: 0 1 2 3 4 Row 0: 1 2 3 4 5 1: 2 4 6 8 10 2: 3 6 9 12 15 3: 4 8 12 16 20 4: 5 10 15 20 25 The matrix returned by I4MAT_ELIM: Col: 0 1 2 3 4 Row 0: 5 2 3 4 1 1: 0 0 0 0 0 2: 0 0 0 0 0 3: 0 0 0 0 0 4: 0 0 0 0 0 I4MAT_INDICATOR_NEW_TEST I4MAT_INDICATOR_NEW returns an indicator I4MAT Indicator 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 I4MAT_L1_INVERSE_TEST I4MAT_L1_INVERSE inverts a unit lower triangular matrix. The original matrix: Col: 0 1 2 3 4 5 Row 0: 1 0 0 0 0 0 1: 2 1 0 0 0 0 2: 0 0 1 0 0 0 3: 5 0 3 1 0 0 4: 0 0 0 0 1 0 5: 75 0 0 6 4 1 The inverse matrix: Col: 0 1 2 3 4 5 Row 0: 1 0 0 0 0 0 1: 2 1 0 0 0 0 2: 0 0 1 0 0 0 3: 5 0 3 1 0 0 4: 0 0 0 0 1 0 5: 105 0 18 6 4 1 Product C = A * B: Col: 0 1 2 3 4 5 Row 0: 1 0 0 0 0 0 1: 4 1 0 0 0 0 2: 0 0 1 0 0 0 3: 10 0 6 1 0 0 4: 0 0 0 0 1 0 5: 210 0 36 12 8 1 I4MAT_MAX_TEST I4MAT_MAX returns the maximum of an I4MAT; Random I4MAT: Col: 0 1 2 3 4 5 6 Row 0: 2 0 0 0 9 10 7 1: 10 2 4 9 9 1 6 2: 9 1 4 3 1 3 9 3: 6 0 8 1 0 9 4 4: 4 6 8 0 2 2 10 Maximum entry = 10 I4MAT_MAX_INDEX_TEST I4MAT_MAX_INDEX locates the maximum in an I4MAT; Random array: Col: 0 1 2 3 4 5 6 Row 0: 2 0 0 0 9 10 7 1: 10 2 4 9 9 1 6 2: 9 1 4 3 1 3 9 3: 6 0 8 1 0 9 4 4: 4 6 8 0 2 2 10 Maximum I,J indices 2 1 I4MAT_MIN_TEST I4MAT_MIN returns the minimum of an I4MAT; Random I4MAT: Col: 0 1 2 3 4 5 6 Row 0: 2 0 0 0 9 10 7 1: 10 2 4 9 9 1 6 2: 9 1 4 3 1 3 9 3: 6 0 8 1 0 9 4 4: 4 6 8 0 2 2 10 Minimum entry = 0 I4MAT_MIN_INDEX_TEST I4MAT_MIN_INDEX locates the minimum in an I4MAT; Random array: Col: 0 1 2 3 4 5 6 Row 0: 2 0 0 0 9 10 7 1: 10 2 4 9 9 1 6 2: 9 1 4 3 1 3 9 3: 6 0 8 1 0 9 4 4: 4 6 8 0 2 2 10 Minimum I,J indices 1 2 I4MAT_PERM_UNIFORM_TEST I4MAT_PERM_UNIFORM applies a random permutation to an I4MAT. The original matrix: Col: 0 1 2 3 4 Row 0: 11 12 13 14 15 1: 21 22 23 24 25 2: 31 32 33 34 35 3: 41 42 43 44 45 4: 51 52 53 54 55 The permuted matrix: Col: 0 1 2 3 4 Row 0: 22 25 21 23 24 1: 52 55 51 53 54 2: 12 15 11 13 14 3: 32 35 31 33 34 4: 42 45 41 43 44 I4MAT_PRINT_TEST I4MAT_PRINT prints an I4MAT. 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 I4MAT_PRINT_SOME_TEST I4MAT_PRINT_SOME prints some of an I4MAT. The I4MAT, rows 1:3, cols 0:1: Col: -1 0 Row 0: 22044 11 1: 5 21 2: 4 31 I4MAT_PRODUCT_ELEMENTWISE_TEST I4MAT_PRODUCT_ELEMENTWISE computes the elementwise product of two I4MATs. A: Col: 0 1 2 Row 0: 1 2 3 1: 4 5 6 B: Col: 0 1 2 Row 0: 1 3 5 1: 2 4 6 Elementwise product = 86 I4MAT_RANK_TEST I4MAT_RANK computes the rank of an integer matrix. Matrix A1: Col: 0 1 2 Row 0: 1 2 3 1: 4 5 6 2: 7 8 9 The rank is 2 Matrix A2: Col: 0 1 2 Row 0: 1 2 3 1: 4 5 6 2: 7 8 0 The rank is 3 Matrix A3: Col: 0 1 2 Row 0: 1 2 3 1: 4 5 6 2: 7 8 0 3: 10 11 12 The rank is 3 Matrix A4: Col: 0 1 2 3 Row 0: 1 2 3 7 1: 4 5 6 8 2: 7 8 9 3 The rank is 3 Matrix A5: Col: 0 1 2 Row 0: 1 2 3 1: 4 5 6 2: 7 8 9 3: 10 11 12 4: 3 3 3 The rank is 2 Matrix A6: Col: 0 1 Row 0: 0 0 1: 0 0 2: 0 0 The rank is 0 I4MAT_REF_TEST I4MAT_REF computes the integer row echelon form (IREF) of a matrix. Input A: Col: 0 1 2 3 4 5 6 Row 0: 1 3 0 2 6 3 1 1: -2 -6 0 -2 -8 3 1 2: 3 9 0 0 6 6 2 3: -1 -3 0 1 0 9 3 Pseudo-determinant = 6 IREF form: Col: 0 1 2 3 4 5 6 Row 0: 1 3 0 2 6 3 1 1: 0 0 0 2 4 9 3 2: 0 0 0 0 0 3 1 3: 0 0 0 0 0 0 0 I4MAT_ROW_REDUCE_TEST I4MAT_ROW_REDUCE divides a common factor from row I of an I4MAT; Original matrix: Col: 0 1 2 Row 0: 12 88 9 1: 4 8 192 2: -12 88 94 3: 30 18 42 4: 0 4 8 After reducing a row: Col: 0 1 2 Row 0: 12 88 9 1: 4 8 192 2: -12 88 94 3: 30 18 42 4: 0 1 2 After reducing a row: Col: 0 1 2 Row 0: 12 88 9 1: 4 8 192 2: -12 88 94 3: 5 3 7 4: 0 1 2 After reducing a row: Col: 0 1 2 Row 0: 12 88 9 1: 4 8 192 2: -6 44 47 3: 5 3 7 4: 0 1 2 After reducing a row: Col: 0 1 2 Row 0: 12 88 9 1: 1 2 48 2: -6 44 47 3: 5 3 7 4: 0 1 2 After reducing a row: Col: 0 1 2 Row 0: 12 88 9 1: 1 2 48 2: -6 44 47 3: 5 3 7 4: 0 1 2 I4MAT_ROW_SWAP_TEST I4MAT_ROW_SWAP swaps two rows of an I4MAT. Input A: 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 Swap rows 1 and 4 Modified matrix: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 51 52 53 54 2: 31 32 33 34 3: 41 42 43 44 4: 21 22 23 24 I4MAT_RREF_TEST I4MAT_RREF computes the integer row reduced echelon form IRREF) of a matrix. Input A: Col: 0 1 2 3 4 5 6 Row 0: 1 3 0 2 6 3 1 1: -2 -6 0 -2 -8 3 1 2: 3 9 0 0 6 6 2 3: -1 -3 0 1 0 9 3 Pseudo-determinant = 6 IREF form: Col: 0 1 2 3 4 5 6 Row 0: 1 3 0 0 2 0 0 1: 0 0 0 1 2 0 0 2: 0 0 0 0 0 3 1 3: 0 0 0 0 0 0 0 I4MAT_TRANSPOSE_TEST I4MAT_TRANSPOSE transposes an I4MAT Original 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 Transposed matrix: Col: 0 1 2 3 4 Row 0: 11 21 31 41 51 1: 12 22 32 42 52 2: 13 23 33 43 53 3: 14 24 34 44 54 I4MAT_U_SOLVE_TEST I4MAT_U_SOLVE solves an upper triangular system. Input matrix A: Col: 0 1 2 3 Row 0: 1 2 4 7 1: 0 3 5 8 2: 0 0 6 9 3: 0 0 0 10 Right hand side b: 0: 45 1: 53 2: 54 3: 40 Solution x: 0: 1 1: 2 2: 3 3: 4 Norm of residual = 0 I4MAT_U1_INVERSE_TEST I4MAT_U1_INVERSE inverts a unit upper triangular matrix. The original matrix: Col: 0 1 2 3 4 5 Row 0: 1 2 0 5 0 75 1: 0 1 0 0 0 0 2: 0 0 1 3 0 0 3: 0 0 0 1 0 6 4: 0 0 0 0 1 4 5: 0 0 0 0 0 1 The inverse matrix: Col: 0 1 2 3 4 5 Row 0: 1 -2 0 -5 0 -45 1: 0 1 0 0 0 0 2: 0 0 1 -3 0 18 3: 0 0 0 1 0 -6 4: 0 0 0 0 1 -4 5: 0 0 0 0 0 1 Product C = A * B: Col: 0 1 2 3 4 5 Row 0: 1 0 0 0 0 0 1: 0 1 0 0 0 0 2: 0 0 1 0 0 0 3: 0 0 0 1 0 0 4: 0 0 0 0 1 0 5: 0 0 0 0 0 1 I4MAT_WIDTH_TEST I4MAT_WIDTH determines the printing width of an I4MAT. A1: Col: 0 1 2 Row 0: 11 12 13 1: 211 222 233 2: 3111 3222 3333 Printing width of A1 is 4 A2: Col: 0 1 2 Row 0: 10 42 77 1: 23 -1000 63 2: 45 63 90 Printing width of A2 is 5 I4RMAT_NEW_TEST: I4RMAT_NEW dynamically creates a 2D row-major array. I4RMAT_DELETE deletes it. Array entries can be addressed using the notation "a[i][j]". Allocating memory for array A of size 4 by 5. Assigning values to A. Dynamically allocated matrix A: 0 1 2 3 4 10 11 12 13 14 20 21 22 23 24 30 31 32 33 34 Dynamically allocated matrix B = A' * A: 1400 1460 1520 1580 1640 1460 1524 1588 1652 1716 1520 1588 1656 1724 1792 1580 1652 1724 1796 1868 1640 1716 1792 1868 1944 I4ROW_MAX_TEST I4ROW_MAX computes row maximums of an I4ROW; The matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Maximum: 1 4 2 8 3 12 I4ROW_MEAN_TEST I4ROW_MEAN computes row means of an I4ROW; The matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 The row means: 0: 2.5 1: 6.5 2: 10.5 I4ROW_MIN_TEST I4ROW_MIN computes row minimums of an I4ROW; The matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Minimum: 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: 0 1 2 3 Row 0: 2 0 9 7 1: 10 4 9 6 2: 9 4 1 9 3: 6 8 0 4 4: 4 8 2 10 5: 0 0 10 6 6: 2 9 1 2 7: 1 3 3 8 8: 0 1 9 4 9: 6 0 2 2 The row-sorted matrix: Col: 0 1 2 3 Row 0: 0 0 10 6 1: 0 1 9 4 2: 1 3 3 8 3: 2 0 9 7 4: 2 9 1 2 5: 4 8 2 10 6: 6 0 2 2 7: 6 8 0 4 8: 9 4 1 9 9: 10 4 9 6 I4ROW_SORT_D_TEST For a rectangular integer matrix: I4ROW_SORT_D sorts the rows; The original 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 The matrix, permuted by I4MAT_PERM2_UNIFORM: Col: 0 1 2 3 Row 0: 22 21 23 24 1: 62 61 63 64 2: 12 11 13 14 3: 52 51 53 54 4: 42 41 43 44 5: 32 31 33 34 The row-sorted matrix: Col: 0 1 2 3 Row 0: 62 61 63 64 1: 52 51 53 54 2: 42 41 43 44 3: 32 31 33 34 4: 22 21 23 24 5: 12 11 13 14 I4ROW_SORT2_D_TEST For a rectangular integer matrix: I4ROW_SORT2_D sorts the elements of the rows. The original 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 The matrix, permuted by I4MAT_PERM2_UNIFORM: Col: 0 1 2 3 Row 0: 22 21 23 24 1: 62 61 63 64 2: 12 11 13 14 3: 52 51 53 54 4: 42 41 43 44 5: 32 31 33 34 The element-sorted row-sorted matrix: Col: 0 1 2 3 Row 0: 24 23 22 21 1: 64 63 62 61 2: 14 13 12 11 3: 54 53 52 51 4: 44 43 42 41 5: 34 33 32 31 I4ROW_SUM_TEST I4ROW_SUM computes row sums; The matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 The rowsum: 0: 10 1: 26 2: 42 I4ROW_SWAP_TEST For an integer matrix of rows, I4ROW_SWAP swaps two rows; The matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Swap rows 1 and 3 The new matrix: Col: 0 1 2 3 Row 0: 9 10 11 12 1: 5 6 7 8 2: 1 2 3 4 I4ROW_VARIANCVE I4ROW_VARIANCE computes row variances of an I4ROW; The matrix: Col: 0 1 2 3 Row 0: 1 2 3 4 1: 5 6 7 8 2: 9 10 11 12 Row variances: 0: 1.66667 1: 1.66667 2: 1.66667 I4ROWS_TO_I4MAT_TEST I4ROWS_TO_I4MAT allows an I4MAT to be initialized by data stored ROW-WISE in a vector. The data vector: 0: 11 1: 12 2: 13 3: 14 4: 21 5: 22 6: 23 7: 24 8: 31 9: 32 10: 33 11: 34 The data copied into an array: Col: 0 1 2 3 Row 0: 11 12 13 14 1: 21 22 23 24 2: 31 32 33 34 I4VEC_ADD_NEW_TEST I4VEC_ADD_NEW adds two I4VEC's I A B C 0 -6 -9 -15 1 10 -1 9 2 7 -2 5 3 1 5 6 4 -2 6 4 5 -9 -10 -19 6 -5 8 3 7 -8 -3 -11 8 -10 -9 -19 9 3 -10 -7 I4VEC_AMAX_TEST I4VEC_AMAX: maximum absolute entry of an I4VEC; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Maximum absolute value: 10 I4VEC_AMAX_INDEX_TEST For an I4VEC: I4VEC_AMAX_INDEX: index of maximum absolute entry; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Maximum abs index: 2 I4VEC_AMIN_TEST I4VEC_AMIN: minimum absolute entry of an I4VEC; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Minimum absolute value: 1 I4VEC_AMIN_INDEX_TEST For an I4VEC: I4VEC_AMIN_INDEX: index minimum absolute entry; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Minimum abs index: 4 I4VEC_AMINZ_TEST For an I4VEC: I4VEC_AMINZ: minimum nonzero absolute entry; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Minimum abs nonzero: 1 I4VEC_AMINZ_INDEX_TEST For an I4VEC: I4VEC_AMINZ_INDEX: index of minimum nonzero absolute entry; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Minimum abs nonzero index: -1 I4VEC_APPEND_TEST I4VEC_APPEND appends a value to the end of an I4VEC; Initial array A: 0: 0 1: 1 2: 2 3: 3 4: 4 Array A after append: 0: 0 1: 1 2: 2 3: 3 4: 4 5: 17 I4VEC_APPEND_NEW_TEST I4VEC_APPEND_NEW appends a value to the end of an I4VEC; Vector after step 1 0: 1 Vector after step 2 0: 1 1: 2 Vector after step 3 0: 1 1: 2 2: 3 Vector after step 4 0: 1 1: 2 2: 3 3: 4 Vector after step 5 0: 1 1: 2 2: 3 3: 4 4: 5 I4VEC_ASCEND_SUB_TEST I4VEC_ASCEND_SUB computes a longest ascending subsequence of an I4VEC. Using initial random number seed = 123456789 The vector to be tested: 0: 3 1: 10 2: 9 3: 6 4: 5 5: 1 6: 3 7: 2 8: 1 9: 7 10: 1 11: 5 12: 5 13: 8 A longest ascending subsequence: 0: 1 1: 2 2: 5 3: 8 The vector to be tested: 0: 8 1: 1 2: 9 3: 4 4: 1 5: 1 6: 9 7: 9 8: 2 9: 1 10: 3 11: 10 12: 2 13: 4 A longest ascending subsequence: 0: 1 1: 2 2: 3 3: 4 The vector to be tested: 0: 9 1: 3 2: 7 3: 6 4: 9 5: 5 6: 10 7: 6 8: 2 9: 8 10: 4 11: 2 12: 6 13: 4 A longest ascending subsequence: 0: 3 1: 5 2: 6 3: 8 The vector to be tested: 0: 7 1: 4 2: 3 3: 8 4: 2 5: 3 6: 9 7: 9 8: 1 9: 8 10: 1 11: 8 12: 8 13: 4 A longest ascending subsequence: 0: 2 1: 3 2: 4 The vector to be tested: 0: 9 1: 8 2: 8 3: 5 4: 10 5: 6 6: 1 7: 6 8: 1 9: 4 10: 3 11: 9 12: 1 13: 1 A longest ascending subsequence: 0: 1 1: 3 2: 9 The vector to be tested: 0: 2 1: 2 2: 4 3: 2 4: 3 5: 3 6: 7 7: 9 8: 6 9: 3 10: 8 11: 8 12: 5 13: 9 A longest ascending subsequence: 0: 2 1: 3 2: 6 3: 8 4: 9 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: 0: 2 1: 4 2: 6 3: 8 4: 10 5: 10 6: 14 7: 16 8: 18 9: 20 Search for AVAL = -10 Left = -1 Right = 0 Search for AVAL = 2 Left = 0 Right = 0 Search for AVAL = 9 Left = 3 Right = 4 A[LEFT] = 6 A(RIGHT) = 8 Search for AVAL = 10 Left = 4 Right = 4 A[LEFT] = 8 A(RIGHT) = 8 Search for AVAL = 20 Left = 9 Right = 9 A[LEFT] = 18 A(RIGHT) = 18 Search for AVAL = 24 Left = 9 Right = -1 A[LEFT] = 18 I4VEC_CHOOSE_TEST: I4VEC_CHOOSE computes the generalized binomial coefficient. N: 8 5 1 9 8 K: 4 4 1 4 3 M V1 V2 0 1 1 1 70 70 2 350 350 3 350 350 4 44100 44100 5 2469600 2469600 I4VEC_CONCATENATE_TEST I4VEC_CONCATENATE concatenates two I4VECs. Array 1: 0: 91 1: 31 2: 71 3: 51 4: 31 Array 2: 0: 42 1: 22 2: 12 Array 3 = Array 1 + Array 2: 0: 91 1: 31 2: 71 3: 51 4: 31 5: 42 6: 22 7: 12 I4VEC_CUM_NEW I4VEC_CUM_NEW: cumulative sum of an I4VEC; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Cumulative sums: 0: -6 1: 4 2: 11 3: 12 4: 10 5: 1 6: -4 7: -12 8: -22 9: -19 I4VEC_CUM0_NEW_TEST I4VEC_CUM0_NEW: cumulative sum of an I4VEC, zero based; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 0-based Cumulative sums: 0: 0 1: -6 2: 4 3: 11 4: 12 5: 10 6: 1 7: -4 8: -12 9: -22 10: -19 I4VEC_DECREMENT_TEST I4VEC_DECREMENT decrements an I4VEC. The I4VEC: 0: -2 1: 10 2: 8 3: 3 The I4VEC after decrementing: 0: -3 1: 9 2: 7 3: 2 I4VEC_DIRECT_PRODUCT I4VEC_DIRECT_PRODUCT forms the entries of a direct product of a given number of I4VEC factors. J X(1) X(2) X(3) 0 1 50 800 1 2 50 800 2 3 50 800 3 4 50 800 4 1 60 800 5 2 60 800 6 3 60 800 7 4 60 800 8 1 70 800 9 2 70 800 10 3 70 800 11 4 70 800 12 1 50 900 13 2 50 900 14 3 50 900 15 4 50 900 16 1 60 900 17 2 60 900 18 3 60 900 19 4 60 900 20 1 70 900 21 2 70 900 22 3 70 900 23 4 70 900 I4VEC_DIRECT_PRODUCT2_TEST I4VEC_DIRECT_PRODUCT2 forms the entries of a direct product of a given number of I4VEC factors. J W(J) 0 418 1 627 2 1045 3 1463 4 494 5 741 6 1235 7 1729 8 646 9 969 10 1615 11 2261 12 462 13 693 14 1155 15 1617 16 546 17 819 18 1365 19 1911 20 714 21 1071 22 1785 23 2499 I4VEC_DISTANCES_TEST I4VEC_DISTANCES computes the pairwise distances between elements of an I4VEC. Locations: 0: 0 1: 3 2: 10 3: 20 4: 100 Distances: 0: 3 1: 10 2: 20 3: 100 4: 7 5: 17 6: 97 7: 10 8: 90 9: 80 I4VEC_DOT_PRODUCT_TEST I4VEC_DOT_PRODUCT computes the dot product of two I4VECs. The vector A: 0: 2 1: 10 2: 9 3: 6 4: 4 The vector B: 0: 0 1: 2 2: 1 3: 0 4: 6 The dot product is 53 I4VEC_FRAC_TEST I4VEC_FRAC: K-th smallest entry in an I4VEC. Using initial random number seed = 123456789 The array to search: 0: 5 1: 20 2: 17 3: 12 4: 9 5: 2 6: 6 7: 3 8: 1 9: 13 Fractile Value 1 1 6 9 I4VEC_HEAP_A_TEST I4VEC_HEAP_A turns an integer array into an ascending heap; Using random seed 123456789 Unheaped array: 0: 9 1: 39 2: 34 3: 23 4: 17 5: 3 6: 11 7: 5 8: 2 9: 26 10: 3 11: 18 12: 17 13: 31 14: 32 15: 1 16: 36 17: 15 18: 4 19: 1 20: 35 21: 34 22: 5 23: 1 24: 11 25: 37 26: 5 27: 15 28: 33 29: 11 Ascending heaped array: 0: 34 1: 39 2: 17 3: 23 4: 17 5: 9 6: 31 7: 5 8: 4 9: 26 10: 5 11: 18 12: 5 13: 15 14: 32 15: 1 16: 36 17: 15 18: 2 19: 1 20: 35 21: 34 22: 3 23: 1 24: 11 25: 37 26: 3 27: 11 28: 33 29: 11 I4VEC_HEAP_D_TEST I4VEC_HEAP_D turns an integer array into a descending heap; Using random seed 123456789 Unheaped array: 0: 9 1: 39 2: 34 3: 23 4: 17 5: 3 6: 11 7: 5 8: 2 9: 26 10: 3 11: 18 12: 17 13: 31 14: 32 15: 1 16: 36 17: 15 18: 4 19: 1 20: 35 21: 34 22: 5 23: 1 24: 11 25: 37 26: 5 27: 15 28: 33 29: 11 Descending heaped array: 0: 39 1: 36 2: 37 3: 23 4: 35 5: 34 6: 33 7: 9 8: 15 9: 26 10: 34 11: 18 12: 17 13: 31 14: 32 15: 1 16: 5 17: 2 18: 4 19: 1 20: 17 21: 3 22: 5 23: 1 24: 11 25: 3 26: 5 27: 15 28: 11 29: 11 I4VEC_HEAP_D_EXTRACT For a descending heap of integers, I4VEC_HEAP_D_EXTRACT extracts the maximum value; Inserting value 2 Current maximum value is 2 Inserting value 10 Current maximum value is 10 Inserting value 9 Current maximum value is 10 Inserting value 6 Current maximum value is 10 Inserting value 4 Current maximum value is 10 Inserting value 0 Current maximum value is 10 Inserting value 2 Current maximum value is 10 Inserting value 1 Current maximum value is 10 Inserting value 0 Current maximum value is 10 Inserting value 6 Current maximum value is 10 Current heap as a vector: 0: 10 1: 6 2: 9 3: 2 4: 6 5: 0 6: 2 7: 1 8: 0 9: 4 Now extract the maximum several times. Extracting maximum element = 10 Extracting maximum element = 0 Extracting maximum element = 0 Extracting maximum element = 1 Extracting maximum element = 2 Current heap as a vector: 0: 2 1: 9 2: 4 3: 6 4: 6 I4VEC_HEAP_D_INSERT_TEST For a descending heap of integers, I4VEC_HEAP_D_INSERT inserts a value into the heap. Inserting value 2 Current maximum value is 2 Inserting value 10 Current maximum value is 10 Inserting value 9 Current maximum value is 10 Inserting value 6 Current maximum value is 10 Inserting value 4 Current maximum value is 10 Inserting value 0 Current maximum value is 10 Inserting value 2 Current maximum value is 10 Inserting value 1 Current maximum value is 10 Inserting value 0 Current maximum value is 10 Inserting value 6 Current maximum value is 10 Current heap as a vector: 0: 10 1: 6 2: 9 3: 2 4: 6 5: 0 6: 2 7: 1 8: 0 9: 4 I4VEC_HEAP_D_MAX_TEST For a descending heap of integers, I4VEC_HEAP_D_MAX reports the maximum value. Inserting value 2 Current maximum value is 2 Inserting value 10 Current maximum value is 10 Inserting value 9 Current maximum value is 10 Inserting value 6 Current maximum value is 10 Inserting value 4 Current maximum value is 10 Inserting value 0 Current maximum value is 10 Inserting value 2 Current maximum value is 10 Inserting value 1 Current maximum value is 10 Inserting value 0 Current maximum value is 10 Inserting value 6 Current maximum value is 10 Current heap as a vector: 0: 10 1: 6 2: 9 3: 2 4: 6 5: 0 6: 2 7: 1 8: 0 9: 4 I4VEC_HISTOGRAM_TEST I4VEC_HISTOGRAM histograms an I4VEC. Histogram of data from 0 to 20 0 51 1 30 2 33 3 40 4 25 5 41 6 35 7 46 8 35 9 43 10 32 11 38 12 41 13 40 14 46 15 36 16 48 17 38 18 42 19 33 20 32 I4VEC_IDENTITY_ROW_NEW_TEST I4VEC_IDENTITY_ROW_NEW returns a row of the identity. -1: 0 0 0 0 0 0: 1 0 0 0 0 1: 0 1 0 0 0 2: 0 0 1 0 0 3: 0 0 0 1 0 4: 0 0 0 0 1 5: 0 0 0 0 0 I4VEC_INCREMENT_TEST I4VEC_INCREMENT increments an I4VEC. The I4VEC: 0: -2 1: 10 2: 8 3: 3 The I4VEC after incrementing: 0: -1 1: 11 2: 9 3: 4 I4VEC_INDEX_MAXn I4VEC_INDEX: first index of a given value in an I4VEC; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Index of first occurrence of -9 is 5 I4VEC_INDEX_DELETE_ALL_TEST I4VEC_INDEX_DELETE_ALL deletes all copies of a particular value. Generate some random values: 4 20 17 11 8 1 5 2 0 13 1 9 8 15 16 0 18 7 1 0 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 11 8 0 2 22 7 0 3 18 4 0 4 8 20 1 5 21 17 1 6 13 11 1 7 10 8 2 8 3 1 4 9 9 5 5 10 2 2 7 11 20 0 7 12 23 13 7 13 1 1 8 14 15 9 8 15 24 8 8 16 7 15 8 17 14 16 9 18 6 0 11 19 12 18 13 20 16 7 15 21 17 1 16 22 5 0 17 23 19 7 18 24 4 8 20 Call I4VEC_INDEX_DELETE_ALL to delete all values of 7: Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 10 8 0 2 20 4 0 3 17 20 0 4 7 17 1 5 19 11 1 6 12 8 1 7 9 1 2 8 2 5 4 9 8 2 5 10 1 0 8 11 14 13 8 12 21 1 8 13 6 9 8 14 13 8 9 15 5 15 11 16 11 16 13 17 15 0 15 18 16 18 16 19 4 1 17 20 18 0 18 21 3 8 20 I4VEC_INDEX_DELETE_DUPES_TEST I4VEC_INDEX_DELETE_DUPES deletes duplicates. Generate some random values: 4 20 17 11 8 1 5 2 0 13 1 9 8 15 16 0 18 7 1 0 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 11 8 0 2 22 7 0 3 18 4 0 4 8 20 1 5 21 17 1 6 13 11 1 7 10 8 2 8 3 1 4 9 9 5 5 10 2 2 7 11 20 0 7 12 23 13 7 13 1 1 8 14 15 9 8 15 24 8 8 16 7 15 8 17 14 16 9 18 6 0 11 19 12 18 13 20 16 7 15 21 17 1 16 22 5 0 17 23 19 7 18 24 4 8 20 Call I4VEC_INDEX_DELETE_DUPES to delete duplicates: Indexed list of unique entries: I INDX(I) X(I) 1 1 0 2 2 1 3 3 2 4 4 4 5 5 5 6 6 7 7 7 8 8 8 9 9 9 11 10 10 13 11 11 15 12 12 16 13 13 17 14 14 18 15 15 20 I4VEC_INDEX_DELETE_ONE_TEST I4VEC_INDEX_DELETE_ONE deletes one copies of a particular value. Generate some random values: 4 20 17 11 8 1 5 2 0 13 1 9 8 15 16 0 18 7 1 0 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 11 8 0 2 22 7 0 3 18 4 0 4 8 20 1 5 21 17 1 6 13 11 1 7 10 8 2 8 3 1 4 9 9 5 5 10 2 2 7 11 20 0 7 12 23 13 7 13 1 1 8 14 15 9 8 15 24 8 8 16 7 15 8 17 14 16 9 18 6 0 11 19 12 18 13 20 16 7 15 21 17 1 16 22 5 0 17 23 19 7 18 24 4 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: 4 20 17 11 8 1 5 2 0 13 1 9 8 15 16 0 18 7 1 0 Indexed list of entries: I INDX(I) X(I) X(INDX(I)) 1 11 8 0 2 22 7 0 3 18 4 0 4 8 20 1 5 21 17 1 6 13 11 1 7 10 8 2 8 3 1 4 9 9 5 5 10 2 2 7 11 20 0 7 12 23 13 7 13 1 1 8 14 15 9 8 15 24 8 8 16 7 15 8 17 14 16 9 18 6 0 11 19 12 18 13 20 16 7 15 21 17 1 16 22 5 0 17 23 19 7 18 24 4 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 9 4 0 2 6 20 1 3 8 17 2 4 1 11 4 5 7 8 5 6 15 1 7 7 5 5 8 8 11 2 9 9 4 0 11 10 10 13 13 11 12 9 15 12 13 15 16 13 3 16 17 14 14 18 18 15 2 7 20 I4VEC_INDEX_ORDER_TEST I4VEC_INDEX_ORDER sorts an index sorted array. Generate some random values: 4 20 17 11 8 1 5 2 0 13 1 9 8 15 16 0 18 7 1 0 Indexed list of unique entries: I INDX(I) X(I) X(INDX(I)) 0 9 4 0 1 6 20 1 2 8 17 2 3 1 11 4 4 7 8 5 5 15 1 7 6 5 5 8 7 11 2 9 8 4 0 11 9 10 13 13 10 12 9 15 11 13 15 16 12 3 16 17 13 14 18 18 14 2 7 20 Now call I4VEC_INDEX_ORDER to carry out the sorting: X: 0: 0 1: 1 2: 2 3: 4 4: 5 5: 7 6: 8 7: 9 8: 11 9: 13 10: 15 11: 16 12: 17 13: 18 14: 20 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 9 4 0 2 6 20 1 3 8 17 2 4 1 11 4 5 7 8 5 6 15 1 7 7 5 5 8 8 11 2 9 9 4 0 11 10 10 13 13 11 12 9 15 12 13 15 16 13 3 16 17 14 14 18 18 15 2 7 20 Results of search for given XVAL: XVAL Less Equal More 0 0 1 2 1 1 2 3 2 2 3 4 3 3 0 4 4 3 4 5 5 4 5 6 6 5 0 6 7 5 6 7 8 6 7 8 9 7 8 9 10 8 0 9 11 8 9 10 12 9 0 10 13 9 10 11 14 10 0 11 15 10 11 12 16 11 12 13 17 12 13 14 18 13 14 15 19 14 0 15 20 14 15 16 I4VEC_INDEXED_HEAP_D_TEST I4VEC_INDEXED_HEAP_D creates a descending heap from an indexed vector. The data vector: 0: 101 1: 102 2: 103 3: 104 4: 105 5: 106 6: 107 7: 108 8: 109 9: 110 10: 111 11: 112 12: 113 13: 114 14: 115 15: 116 16: 117 17: 118 18: 119 19: 120 The index vector: 0: 0 1: 10 2: 16 3: 4 4: 6 5: 12 6: 14 7: 2 8: 18 9: 8 A(INDX): 0 101 1 111 2 117 3 105 4 107 5 113 6 115 7 103 8 119 9 109 The data vector (should NOT change): 0: 101 1: 102 2: 103 3: 104 4: 105 5: 106 6: 107 7: 108 8: 109 9: 110 10: 111 11: 112 12: 113 13: 114 14: 115 15: 116 16: 117 17: 118 18: 119 19: 120 The index vector (may change): 0: 18 1: 10 2: 16 3: 4 4: 8 5: 12 6: 14 7: 2 8: 0 9: 6 A(INDX) is now a descending heap: 0 119 1 111 2 117 3 105 4 109 5 113 6 115 7 103 8 101 9 107 I4VEC_INDEXED_HEAP_D_EXTRACT_TEST I4VEC_INDEXED_HEAP_D_EXTRACT extracts the maximum value; This operation is used to model a priority queue. The data vector: 0: 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 The index vector: 0: 8 1: 1 2: 7 3: 13 4: 4 A(INDX): 0 9 1 2 2 8 3 14 4 5 The index vector after heaping: 0: 13 1: 8 2: 7 3: 1 4: 4 A(INDX) after heaping: 0 14 1 9 2 8 3 2 4 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: 0: 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 The index vector after insertions: 0: 19 1: 18 2: 13 3: 8 4: 14 5: 6 6: 7 7: 0 8: 1 9: 4 A(INDX) after insertions: 0 20 1 19 2 14 3 9 4 15 5 7 6 8 7 1 8 2 9 5 Now extract the maximum several times. Extracting maximum element A[19] = 20 Extracting maximum element A[18] = 19 Extracting maximum element A[14] = 15 Extracting maximum element A[13] = 14 Extracting maximum element A[8] = 9 The data vector after extractions: 0: 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 The index vector after extractions: 0: 7 1: 4 2: 6 3: 1 4: 0 A(INDX) after extractions: 0 8 1 5 2 7 3 2 4 1 I4VEC_INDEXED_HEAP_D_INSERT_TEST I4VEC_INDEXED_HEAP_D_INSERT inserts a value into the heap. This operation is needed to model a priority queue. The data vector: 0: 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 The index vector: 0: 8 1: 1 2: 7 3: 13 4: 4 A(INDX): 0 9 1 2 2 8 3 14 4 5 The index vector after heaping: 0: 13 1: 8 2: 7 3: 1 4: 4 A(INDX) after heaping: 0 14 1 9 2 8 3 2 4 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: 0: 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 The index vector after insertions: 0: 19 1: 18 2: 13 3: 8 4: 14 5: 6 6: 7 7: 0 8: 1 9: 4 A(INDX) after insertions: 0 20 1 19 2 14 3 9 4 15 5 7 6 8 7 1 8 2 9 5 I4VEC_INDEXED_HEAP_D_MAX_TEST I4VEC_INDEXED_HEAP_D_MAX reports the maximum value. This operation is needed to model a priority queue. The data vector: 0: 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 The index vector: 0: 8 1: 1 2: 7 3: 13 4: 4 A(INDX): 0 9 1 2 2 8 3 14 4 5 The index vector after heaping: 0: 13 1: 8 2: 7 3: 1 4: 4 A(INDX) after heaping: 0 14 1 9 2 8 3 2 4 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_NEW_TEST I4VEC_INDICATOR0_NEW returns an indicator vector. The indicator0 vector: 0: 0 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 I4VEC_INDICATOR1_NEW_TEST I4VEC_INDICATOR1_NEW returns an indicator vector. The indicator1 vector: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 I4VEC_INSERT_TEST I4VEC_INSERT inserts a value into a vector at a given location. Sorted array: 0: 2 1: 4 2: 6 3: 8 4: 10 5: 10 6: 14 7: 16 8: 18 9: 20 Try to insert value AVAL = -10 Sorted, augmented array: 0: -10 1: 2 2: 4 3: 6 4: 8 5: 10 6: 10 7: 14 8: 16 9: 18 10: 20 Try to insert value AVAL = 2 Sorted, augmented array: 0: -10 1: 2 2: 2 3: 4 4: 6 5: 8 6: 10 7: 10 8: 14 9: 16 10: 18 11: 20 Try to insert value AVAL = 9 Sorted, augmented array: 0: -10 1: 2 2: 2 3: 4 4: 6 5: 8 6: 9 7: 10 8: 10 9: 14 10: 16 11: 18 12: 20 Try to insert value AVAL = 10 Sorted, augmented array: 0: -10 1: 2 2: 2 3: 4 4: 6 5: 8 6: 9 7: 10 8: 10 9: 10 10: 14 11: 16 12: 18 13: 20 Try to insert value AVAL = 20 Sorted, augmented array: 0: -10 1: 2 2: 2 3: 4 4: 6 5: 8 6: 9 7: 10 8: 10 9: 10 10: 14 11: 16 12: 18 13: 20 14: 20 Try to insert value AVAL = 24 Sorted, augmented array: 0: -10 1: 2 2: 2 3: 4 4: 6 5: 8 6: 9 7: 10 8: 10 9: 10 10: 14 11: 16 12: 18 13: 20 14: 20 15: 24 I4VEC_IS_ASCENDING_TEST I4VEC_IS_ASCENDING determines if an I4VEC ascends. Test vector: 0: 1 1: 3 2: 2 3: 4 I4VEC_ASCENDS = 0 Test vector: 0: 2 1: 2 2: 2 3: 2 I4VEC_ASCENDS = 1 Test vector: 0: 1 1: 2 2: 2 3: 4 I4VEC_ASCENDS = 1 Test vector: 0: 1 1: 2 2: 3 3: 4 I4VEC_ASCENDS = 1 Test vector: 0: 4 1: 4 2: 3 3: 1 I4VEC_ASCENDS = 0 Test vector: 0: 9 1: 7 2: 3 3: 0 I4VEC_ASCENDS = 0 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: 0: 1 1: 3 2: 2 3: 4 I4VEC_IS_DESCENDING = 0 Test vector: 0: 2 1: 2 2: 2 3: 2 I4VEC_IS_DESCENDING = 1 Test vector: 0: 1 1: 2 2: 2 3: 4 I4VEC_IS_DESCENDING = 0 Test vector: 0: 1 1: 2 2: 3 3: 4 I4VEC_IS_DESCENDING = 0 Test vector: 0: 4 1: 4 2: 3 3: 1 I4VEC_IS_DESCENDING = 1 Test vector: 0: 9 1: 7 2: 3 3: 0 I4VEC_IS_DESCENDING = 1 i4VEC_IS_PAIRWISE_PRIME_TEST I4VEC_IS_PAIRWISE_PRIME determines if an I4VEC is pairwise prime. Pairwise Row Vector Prime? 1 3 2 4 0 2 2 2 2 0 5 7 12 29 1 1 13 1 11 1 1 4 9 16 0 6 35 13 77 0 I4VEC_MAX_TEST I4VEC_MAX produces the maximum entry in an I4VEC. Using random seed 123456789 The array: 0: 7 1: 29 2: 25 3: 17 4: 13 5: 2 6: 8 7: 4 8: 2 9: 20 Maximum 29 I4VEC_MAX_INDEX_TEST For an I4VEC: I4VEC_MAX_INDEX: a maximal index; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Maximum index: 1 I4VEC_MAX_INDEX_LAST_TEST For an I4VEC: I4VEC_MAX_INDEX_LAST: last maximal index; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Last maximum index: 1 I4VEC_MAX_LAST_TEST I4VEC_MAX_LAST identifies the largest element in an I4VEC, and moves it to the final entry. Input vector: 0: 7 1: 29 2: 25 3: 17 4: 13 5: 2 6: 8 7: 4 8: 2 9: 20 Maximum: = 29 Output vector: 0: 7 1: 25 2: 17 3: 13 4: 2 5: 8 6: 4 7: 2 8: 20 9: 29 I4VEC_MEAN_TEST For an I4VEC: I4VEC_MEAN: mean value; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Mean: -1.9 I4VEC_MEDIAN_TEST For an I4VEC: I4VEC_MEDIAN: median value; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Median: -5 I4VEC_MERGE_A_TEST For ascending order: I4VEC_MERGE_A merges two sorted I4VECs; Input vector A1: 0: 0 1: 0 2: 1 3: 2 4: 2 5: 4 6: 6 7: 6 8: 9 9: 10 Input vector A2: 0: 0 1: 0 2: 0 3: 1 4: 3 5: 4 6: 4 7: 8 8: 8 9: 9 Merged vector A3: 0: 0 1: 22044 2: 0 3: 0 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 I4VEC_MIN_TEST I4VEC_MIN produces the minimum entry in an I4VEC. Using random seed 123456789 The array: 0: 7 1: 29 2: 25 3: 17 4: 13 5: 2 6: 8 7: 4 8: 2 9: 20 Minimum 2 I4VEC_MIN_INDEX_TEST I4VEC_MIN_INDEX: a minimal index; Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Index of minimum value: 8 I4VEC_NONZERO_COUNT_TEST For an I4VEC: I4VEC_NONZERO_COUNT: number of nonzeroes; Input vector: 0: -1 1: 3 2: 2 3: 1 4: 0 5: -2 6: -1 7: -2 8: -2 9: 1 Number of nonzeroes : 9 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 2 2 1 0 -1 0 -1 -1 1 -1 2 2 1 -1 -1 -1 1 0 0 -1 0 0 2 2 -1 2 0 -1 -1 -1 2 2 -1 2 -1 -1 0 0 0 2 2 -1 -1 0 2 -1 0 2 0 2 2 -1 -1 2 -1 2 0 0 0 1 1 2 0 2 1 -1 2 0 -1 1 1 2 2 1 -1 2 -1 0 0 1 0 1 0 -1 1 -1 0 2 2 1 1 -1 1 -1 2 2 0 0 0 The value NZ counts the nonzeros, and the vector INDX indicates the original positions: Original vector: -1 1 -1 2 1 0 2 2 2 0 Number of nonzeros NZ = 8 Shifted vector: -1 1 -1 2 1 2 2 2 0 0 Index vector: 1 2 3 4 5 7 8 9 6 10 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 I4VEC. NVAL = 17 Partitioned: 0: 4 1: 4 2: 3 3: 3 4: 3 NVAL = -49 Partitioned: 0: -10 1: -10 2: -10 3: -10 4: -9 I4VEC_PART_QUICK_A_TEST I4VEC_PART_QUICK_A reorders an int vector as part of a quick sort. Using random seed 123456789 Before rearrangement: 0: 3 1: 16 2: 14 3: 9 4: 7 5: 1 6: 4 7: 1 8: 0 9: 10 10: 1 11: 7 12: 6 13: 12 14: 13 15: 0 Rearranged array Left = 5 Right = 7 0 0 1 1 2 0 3 1 4 1 5 3 6 4 7 7 8 10 9 9 10 7 11 6 12 12 13 13 14 14 15 16 I4VEC_PERMUTE_TEST I4VEC_PERMUTE reorders an I4VEC according to a given permutation. A[*], before rearrangement: 0: 2 1: 12 2: 10 3: 7 4: 5 5: 0 6: 3 7: 1 8: 0 9: 8 10: 0 11: 5 Permutation vector P[*]: 0: 4 1: 9 2: 1 3: 3 4: 11 5: 7 6: 6 7: 5 8: 0 9: 8 10: 10 11: 2 A[P[*]]: 0: 5 1: 8 2: 12 3: 7 4: 5 5: 1 6: 3 7: 0 8: 2 9: 0 10: 0 11: 10 I4VEC_PERMUTE_UNIFORM_TEST I4VEC_PERMUTE_UNIFORM randomly reorders an I4VEC. A, before rearrangement: 0: 101 1: 102 2: 103 3: 104 4: 105 5: 106 6: 107 7: 108 8: 109 9: 110 A, after random permutation: 0: 103 1: 110 2: 109 3: 107 4: 104 5: 106 6: 108 7: 105 8: 101 9: 102 I4VEC_PRINT_TEST I4VEC_PRINT prints an I4VEC Here is the I4VEC: 0: 91 1: 92 2: 93 3: 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: 0 1 2 Row 0: 12 88 9 1: 4 8 192 2: -12 88 94 3: 30 18 42 4: 0 4 8 Reduced matrix: Col: 0 1 2 Row 0: 12 88 9 1: 1 2 48 2: -6 44 47 3: 5 3 7 4: 0 1 2 I4VEC_REVERSE_TEST I4VEC_REVERSE reverses a list of integers. Original vector: 0: 6 1: 29 2: 25 3: 17 4: 12 5: 2 6: 7 7: 3 8: 1 9: 19 Reversed: 0: 19 1: 1 2: 3 3: 7 4: 2 5: 12 6: 17 7: 25 8: 29 9: 6 I4VEC_RUN_COUNT_TEST I4VEC_RUN_COUNT counts runs in an I4VEC Run Count Sequence 9 0 1 1 1 0 0 0 0 0 1 0 0 0 1 1 0 1 0 0 0 12 1 1 0 0 0 1 0 0 1 0 1 1 1 0 1 1 0 1 0 0 14 1 0 1 0 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 0 8 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 0 10 1 1 0 1 1 1 1 0 0 0 1 1 0 0 1 1 1 0 1 0 11 1 1 0 1 1 0 1 0 0 1 1 1 0 0 0 1 0 1 1 1 11 1 0 0 1 1 1 1 1 0 1 0 1 1 1 0 0 0 1 0 1 15 0 1 0 0 1 0 1 0 1 1 0 0 1 0 1 0 0 1 1 0 12 1 1 0 1 1 1 0 1 0 1 1 0 0 0 1 0 1 1 1 0 14 1 1 0 1 1 0 1 0 1 0 1 1 0 0 0 1 1 0 1 0 I4VEC_SEARCH_BINARY_A_TEST I4VEC_SEARCH_BINARY_A searches an ascending-sorted array for a value; Input vector A: 0: 0 1: 0 2: 0 3: 1 4: 1 5: 1 6: 2 7: 4 8: 5 9: 7 10: 8 11: 8 12: 9 13: 11 14: 13 15: 15 16: 16 17: 17 18: 18 19: 20 Search the array A for the value 4 SEARCH RESULT: The value occurs in index 7 I4VEC_SEARCH_BINARY_D_TEST I4VEC_SEARCH_BINARY_D searches a descending-sorted array for a value; Input vector A: 0: 0 1: 20 2: 11 3: 13 4: 0 5: 15 6: 2 7: 7 8: 8 9: 1 10: 0 11: 9 12: 5 13: 16 14: 1 15: 18 16: 1 17: 4 18: 8 19: 17 Search the array A for the value 4 SEARCH RESULT: The value does not occur in the array. I4VEC_SORT_BUBBLE_A_TEST I4VEC_SORT_BUBBLE_A sorts an I4VEC; Using random seed 123456789 Unsorted array: 0: 6 1: 29 2: 25 3: 17 4: 12 5: 2 6: 7 7: 3 8: 1 9: 19 10: 1 11: 13 12: 12 13: 23 14: 24 15: 0 16: 27 17: 10 18: 2 19: 0 20: 26 21: 26 22: 3 23: 0 24: 8 25: 28 26: 3 27: 10 28: 25 29: 8 Sorted array: 0: 0 1: 0 2: 0 3: 1 4: 1 5: 2 6: 2 7: 3 8: 3 9: 3 10: 6 11: 7 12: 8 13: 8 14: 10 15: 10 16: 12 17: 12 18: 13 19: 17 20: 19 21: 23 22: 24 23: 25 24: 25 25: 26 26: 26 27: 27 28: 28 29: 29 I4VEC_SORT_HEAP_A_TEST I4VEC_SORT_HEAP_A sorts an I4VEC; Using random seed 123456789 Unsorted array: 0: 6 1: 29 2: 25 3: 17 4: 12 5: 2 6: 7 7: 3 8: 1 9: 19 10: 1 11: 13 12: 12 13: 23 14: 24 15: 0 16: 27 17: 10 18: 2 19: 0 20: 26 21: 26 22: 3 23: 0 24: 8 25: 28 26: 3 27: 10 28: 25 29: 8 Sorted array: 0: 0 1: 0 2: 0 3: 1 4: 1 5: 2 6: 2 7: 3 8: 3 9: 3 10: 6 11: 7 12: 8 13: 8 14: 10 15: 10 16: 12 17: 12 18: 13 19: 17 20: 19 21: 23 22: 24 23: 25 24: 25 25: 26 26: 26 27: 27 28: 28 29: 29 I4VEC_SORT_HEAP_D_TEST I4VEC_SORT_HEAP_D descending sorts an I4VEC. Unsorted: 0: 13 1: 58 2: 50 3: 34 4: 25 5: 4 6: 15 7: 6 8: 2 9: 38 10: 3 11: 27 12: 24 13: 46 14: 48 15: 0 16: 54 17: 21 18: 5 19: 0 Descending sorted: 0: 0 1: 58 2: 34 3: 38 4: 0 5: 46 6: 6 7: 21 8: 25 9: 3 10: 2 11: 27 12: 15 13: 48 14: 4 15: 54 16: 5 17: 13 18: 24 19: 50 I4VEC_SORT_HEAP_INDEX_A_TEST I4VEC_SORT_HEAP_INDEX_A creates an ascending sort index for an I4VEC. Unsorted array A: 0: 13 1: 58 2: 50 3: 34 4: 25 5: 4 6: 15 7: 6 8: 2 9: 38 10: 3 11: 27 12: 24 13: 46 14: 48 15: 0 16: 54 17: 21 18: 5 19: 0 Sort vector INDX: 0: 15 1: 19 2: 8 3: 10 4: 5 5: 18 6: 7 7: 0 8: 6 9: 17 10: 12 11: 4 12: 11 13: 3 14: 9 15: 13 16: 14 17: 2 18: 16 19: 1 I INDX(I) A(INDX(I)) 0 15 0 1 19 0 2 8 2 3 10 3 4 5 4 5 18 5 6 7 6 7 0 13 8 6 15 9 17 21 10 12 24 11 4 25 12 11 27 13 3 34 14 9 38 15 13 46 16 14 48 17 2 50 18 16 54 19 1 58 I4VEC_SORT_HEAP_INDEX_D_TEST I4VEC_SORT_HEAP_INDEX_D creates a descending sort index for an I4VEC. Unsorted array: 0: 13 1: 58 2: 50 3: 34 4: 25 5: 4 6: 15 7: 6 8: 2 9: 38 10: 3 11: 27 12: 24 13: 46 14: 48 15: 0 16: 54 17: 21 18: 5 19: 0 Sort vector INDX: 0: 1 1: 16 2: 2 3: 14 4: 13 5: 9 6: 3 7: 11 8: 4 9: 12 10: 17 11: 6 12: 0 13: 7 14: 18 15: 5 16: 10 17: 8 18: 19 19: 15 I INDX(I) A(INDX(I)) 0 1 58 1 16 54 2 2 50 3 14 48 4 13 46 5 9 38 6 3 34 7 11 27 8 4 25 9 12 24 10 17 21 11 6 15 12 0 13 13 7 6 14 18 5 15 5 4 16 10 3 17 8 2 18 19 0 19 15 0 I4VEC_SORT_INSERT_A_TEST I4VEC_SORT_INSERT_A sorts an I4VEC; Using random seed 123456789 Unsorted array: 0: 6 1: 29 2: 25 3: 17 4: 12 5: 2 6: 7 7: 3 8: 1 9: 19 10: 1 11: 13 12: 12 13: 23 14: 24 15: 0 16: 27 17: 10 18: 2 19: 0 20: 26 21: 26 22: 3 23: 0 24: 8 25: 28 26: 3 27: 10 28: 25 29: 8 Sorted array: 0: 0 1: 0 2: 0 3: 1 4: 1 5: 2 6: 2 7: 3 8: 3 9: 3 10: 6 11: 7 12: 8 13: 8 14: 10 15: 10 16: 12 17: 12 18: 13 19: 17 20: 19 21: 23 22: 24 23: 25 24: 25 25: 26 26: 26 27: 27 28: 28 29: 29 I4VEC_SORT_QUICK_A_TEST I4VEC_SORT_QUICK_A sorts an I4VEC; Using random seed 123456789 Unsorted array: 0: 6 1: 29 2: 25 3: 17 4: 12 5: 2 6: 7 7: 3 8: 1 9: 19 10: 1 11: 13 12: 12 13: 23 14: 24 15: 0 16: 27 17: 10 18: 2 19: 0 20: 26 21: 26 22: 3 23: 0 24: 8 25: 28 26: 3 27: 10 28: 25 29: 8 Sorted array: 0: 0 1: 0 2: 0 3: 1 4: 1 5: 2 6: 2 7: 3 8: 3 9: 3 10: 6 11: 7 12: 8 13: 8 14: 10 15: 10 16: 12 17: 12 18: 13 19: 17 20: 19 21: 23 22: 24 23: 25 24: 25 25: 26 26: 26 27: 27 28: 28 29: 29 I4VEC_SORT_SHELL_A_TEST I4VEC_SORT_SHELL_A sorts an I4VEC; Using random seed 123456789 Unsorted array: 0: 6 1: 29 2: 25 3: 17 4: 12 5: 2 6: 7 7: 3 8: 1 9: 19 10: 1 11: 13 12: 12 13: 23 14: 24 15: 0 16: 27 17: 10 18: 2 19: 0 20: 26 21: 26 22: 3 23: 0 24: 8 25: 28 26: 3 27: 10 28: 25 29: 8 Sorted array: 0: 0 1: 0 2: 0 3: 1 4: 1 5: 2 6: 2 7: 3 8: 3 9: 3 10: 6 11: 7 12: 8 13: 8 14: 10 15: 10 16: 12 17: 12 18: 13 19: 17 20: 19 21: 23 22: 24 23: 25 24: 25 25: 26 26: 26 27: 27 28: 28 29: 29 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: 0: 11 1: 11 2: 11 3: 22 4: 22 5: 33 6: 33 7: 55 8: 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) 0 0 11 1 3 22 2 5 33 3 7 55 UNDX can be used to created XU, a copy of X containing only the unique elements, in sorted order. I UNDX XU(I) 0 0 11 1 3 22 2 5 33 3 7 55 XDNU can be used to match each element of X with one of the unique elements I XDNU X(I) XU(XDNU(I)) 0 0 11 11 1 0 11 11 2 0 11 11 3 1 22 22 4 1 22 22 5 2 33 33 6 2 33 33 7 3 55 55 8 3 55 55 I4VEC_SORTED_UNIQUE_COUNT_TEST I4VEC_SORTED_UNIQUE_COUNT counts unique entries in an I4VEC. Sorted array: 0: 0 1: 0 2: 0 3: 1 4: 1 5: 1 6: 2 7: 4 8: 5 9: 7 10: 8 11: 8 12: 9 13: 11 14: 13 15: 15 16: 16 17: 17 18: 18 19: 20 Number of unique entries is 15 I4VEC_SORTED_UNIQUE_HIST_TEST I4VEC_SORTED_UNIQUE_HIST stores the unique entries and their multiplicities. Using random seed 123456789 Unsorted array: 0: 6 1: 29 2: 25 3: 17 4: 12 5: 2 6: 7 7: 3 8: 1 9: 19 10: 1 11: 13 12: 12 13: 23 14: 24 15: 0 16: 27 17: 10 18: 2 19: 0 20: 26 21: 26 22: 3 23: 0 24: 8 25: 28 26: 3 27: 10 28: 25 29: 8 Sorted array: 0: 0 1: 0 2: 0 3: 1 4: 1 5: 2 6: 2 7: 3 8: 3 9: 3 10: 6 11: 7 12: 8 13: 8 14: 10 15: 10 16: 12 17: 12 18: 13 19: 17 20: 19 21: 23 22: 24 23: 25 24: 25 25: 26 26: 26 27: 27 28: 28 29: 29 I4VEC_SORTED_UNIQUE_HIST counts 19 unique entries. Value and Multiplicity 0: 0 3 1: 1 2 2: 2 2 3: 3 3 4: 6 1 5: 7 1 6: 8 2 7: 10 2 8: 12 2 9: 13 1 10: 17 1 11: 19 1 12: 23 1 13: 24 1 14: 25 2 15: 26 2 16: 27 1 17: 28 1 18: 29 1 I4VEC_SORTED_UNIQUE_TEST I4VEC_SORTED_UNIQUE finds unique entries in a sorted I4VEC. Input vector: 0: 0 1: 0 2: 0 3: 1 4: 1 5: 1 6: 2 7: 4 8: 5 9: 7 10: 8 11: 8 12: 9 13: 11 14: 13 15: 15 16: 16 17: 17 18: 18 19: 20 Unique entries: 0: 0 1: 1 2: 2 3: 4 4: 5 5: 7 6: 8 7: 9 8: 11 9: 13 10: 15 11: 16 12: 17 13: 18 14: 20 I4VEC_SUM_TEST I4VEC_SUM sums the entries of an I4VEC. The vector: 0: 2 1: 10 2: 9 3: 6 4: 4 The vector entries sum to 31 I4VEC_SUM_VEC_TEST I4VEC_SUM_VEC does a pairwise sum of two I4VEC's. A: 2 10 9 6 4 B: 0 2 1 0 6 C = A + B: 2 12 10 6 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: 0: 1 1: 2 2: 3 3: 4 4: 5 5: 6 6: 7 7: 8 8: 9 9: 10 10: 11 11: 12 Now call I4VEC_TRANSPOSE_PRINT with a short title: My array: 1 2 3 4 5 6 7 8 9 10 11 12 Now call I4VEC_TRANSPOSE_PRINT with no title: 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: 0: 33 1: 55 2: 11 3: 11 4: 55 5: 33 6: 22 7: 22 8: 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) 0 2 11 1 6 22 2 5 33 3 4 55 UNDX can be used to created XU, a copy of X containing only the unique elements, in sorted order. I UNDX XU(I) 0 2 11 1 6 22 2 5 33 3 4 55 XDNU can be used to match each element of X with one of the unique elements I XDNU X(I) XU(XDNU(I)) 0 2 33 33 1 3 55 55 2 0 11 11 3 0 11 11 4 3 55 55 5 2 33 33 6 1 22 22 7 1 22 22 8 0 11 11 I4VEC_UNIFORM_AB_NEW_TEST I4VEC_UNIFORM_AB_NEW computes pseudorandom values in an interval [A,B]. The lower endpoint A = -100 The upper endpoint B = 200 The initial seed is 123456789 The vector: 0: -35 1: 187 2: 149 3: 69 4: 25 5: -81 6: -23 7: -67 8: -87 9: 90 10: -82 11: 35 12: 20 13: 127 14: 139 15: -100 16: 170 17: 5 18: -72 19: -96 I4VEC_UNIQUE_COUNT_TEST I4VEC_UNIQUE_COUNT counts unique entries in an I4VEC. Array: 0: 4 1: 20 2: 17 3: 11 4: 8 5: 1 6: 5 7: 2 8: 0 9: 13 10: 1 11: 9 12: 8 13: 15 14: 16 15: 0 16: 18 17: 7 18: 1 19: 0 Number of unique entries is 15 I4VEC_UNIQUE_INDEX_TEST I4VEC_UNIQUE_INDEX, for each entry in an I4VEC indexes the unique elements. I A(I) UNIQUE 0 2 0 1 5 1 2 5 1 3 3 2 4 3 2 5 1 3 6 2 0 7 1 3 8 1 3 9 4 4 10 1 3 11 3 2 12 3 2 13 4 4 14 4 4 15 1 3 16 5 1 17 2 0 18 1 3 19 1 3 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: 0: 2 1: 5 2: 5 3: 3 4: 3 5: 1 6: 2 7: 1 8: 1 9: 4 10: 1 11: 3 12: 3 13: 4 14: 4 15: 1 16: 5 17: 2 18: 1 19: 1 20: 5 21: 5 22: 1 23: 1 24: 2 Indices of entries equal to given value: 0: 4 1: 5 2: 12 I4VEC_VARIANCE_TEST I4VEC_VARIANCE: variance of an I4VEC. Input vector: 0: -6 1: 10 2: 7 3: 1 4: -2 5: -9 6: -5 7: -8 8: -10 9: 3 Variance: 48.1 I4VEC_WIDTH_TEST I4VEC_WIDTH determines the printing width of an I4VEC. The I4VEC: 0: 0 1: 1 2: 2 3: 3 4: 9 5: 10 6: 11 7: 99 8: 101 9: -1 10: -2 11: -3 12: -9 Printing width is 3 I4VEC2_PRINT_TEST I4VEC2_PRINT prints a pair of I4VECs I, sum of I, sum of I^2 0: 0 0 1: 1 1 2: 3 5 3: 6 14 4: 10 30 5: 15 55 6: 21 91 7: 28 140 8: 36 204 9: 45 285 10: 55 385 I4VEC2_SORT_A_TEST For a pair of I4VECs: I4VEC2_SORT_A ascending sorts; The array: 0: 1 1 1: 3 2 2: 3 2 3: 2 3 4: 2 3 5: 1 1 6: 1 3 7: 1 2 8: 1 1 9: 2 1 After ascending sort: 0: 1 1 1: 1 1 2: 1 1 3: 1 2 4: 1 3 5: 2 1 6: 2 3 7: 2 3 8: 3 2 9: 3 2 I4VEC2_SORT_D_TEST For a pair of I4VECs: I4VEC2_SORT_D descending sorts; The array: 0: 1 1 1: 3 2 2: 3 2 3: 2 3 4: 2 3 5: 1 1 6: 1 3 7: 1 2 8: 1 1 9: 2 1 After descending sort: 0: 3 2 1: 3 2 2: 2 3 3: 2 3 4: 2 1 5: 1 3 6: 1 2 7: 1 1 8: 1 1 9: 1 1 I4VEC2_SORTED_UNIQUE_TEST For a sorted pair of I4VECs: I4VEC2_SORTED_UNIQUE counts unique entries. The array: 0: 1 1 1: 3 2 2: 1 1 3: 2 3 4: 3 2 5: 1 1 6: 1 3 7: 1 2 8: 1 1 9: 2 1 After ascending sort: 0: 1 1 1: 1 1 2: 1 1 3: 1 1 4: 1 2 5: 1 3 6: 2 1 7: 2 3 8: 3 2 9: 3 2 After UNIQ: 0: 1 1 1: 1 2 2: 1 3 3: 2 1 4: 2 3 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 - Warning! Permutation is missing value 0 PERM0_CHECK returns IERROR = 1 Permutation 2: 4 1 3 0 2 PERM0_CHECK returns IERROR = 0 Permutation 3: 0 2 1 3 2 PERM0_CHECK - Warning! Permutation is missing value 4 PERM0_CHECK returns IERROR = 1 PERM0_UNIFORM_TEST PERM0_UNIFORM randomly selects a permutation of 0, ..., N-1. 2 9 8 6 3 5 7 4 0 1 6 1 5 2 8 4 0 9 3 7 0 1 8 2 4 5 7 9 3 6 3 8 4 7 0 9 2 5 6 1 1 7 5 4 0 6 8 2 3 9 PERM1_CHECK_TEST PERM1_CHECK checks a permutation of 1, ..., N. Permutation 1: 5 2 3 4 1 PERM1_CHECK returns IERROR = 0 Permutation 2: 4 1 3 0 2 PERM1_CHECK - Fatal error! Permutation is missing value 5 PERM1_CHECK returns IERROR = 1 Permutation 3: 0 2 1 3 2 PERM1_CHECK - Fatal error! Permutation is missing value 4 PERM1_CHECK returns IERROR = 1 PERM1_UNIFORM_TEST PERM1_UNIFORM randomly selects a permutation of 1, ..., N. 3 10 9 7 4 6 8 5 1 2 7 2 6 3 9 5 1 10 4 8 1 2 9 3 5 6 8 10 4 7 4 9 5 8 1 10 3 6 7 2 2 8 6 5 1 7 9 3 4 10 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 0 0 0 1 0 1 1 1 2 2 0 3 2 1 4 2 2 5 3 0 6 3 1 7 3 2 8 3 3 9 4 0 10 4 1 11 4 2 12 4 3 13 4 4 14 TRIANGLE_UPPER_TO_I4_TEST TRIANGLE_UPPER_TO_I4 converts an upper triangular index to a linear one. I J ==> K 0 0 0 0 1 1 1 1 2 0 2 3 1 2 4 2 2 5 0 3 6 1 3 7 2 3 8 3 3 9 0 4 10 1 4 11 2 4 12 3 4 13 4 4 14 I4LIB_TEST Normal end of execution. 26 February 2022 12:34:55 PM