23-Jun-2024 21:37:13 i4lib_test MATLAB/Octave version 6.4.0 Test i4lib. 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_AND returns the bitwise AND of two integers. MATLAB provides a BITAND operator. I J I4_AND BITAND 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 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 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 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 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 1 120 1000 999 1 1000 100 3 1 161700 100 10 0 Not computable I4_CHOOSE_LOG_TEST I4_CHOOSE_LOG evaluates log(C(N,K)). N K lcnk elcnk 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 = int ( a / b ) C1 = I4_DIV_ROUNDED ( A, B ) C2 = nint ( a / b ) A B C0 C1 C2 -57 10 -6 -6 -6 66 1 66 66 66 -17 -9 1 2 2 -49 -8 6 6 6 -92 3 -31 -31 -31 -88 -1 88 88 88 -20 5 -4 -4 -4 60 -10 -6 -6 -6 80 -3 -27 -27 -27 -81 -10 8 8 8 72 7 10 10 10 -76 -10 7 8 8 -48 9 -6 -5 -5 -78 -3 26 26 26 65 -5 -13 -13 -13 39 1 39 39 39 73 -1 -73 -73 -73 83 2 41 41 42 -63 5 -13 -13 -13 -21 -7 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 -5 -50 66 1 66 66 -17 -9 3 -27 -49 -8 7 -56 -92 3 -30 -90 -88 -1 90 -90 -20 5 -4 -20 60 -10 -5 50 80 -3 -26 78 -81 -10 9 -90 72 7 11 77 -76 -10 8 -80 -48 9 -5 -45 -78 -3 27 -81 65 -5 -12 60 39 1 39 39 73 -1 -71 71 83 2 42 84 -63 5 -12 -60 -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(N!). N lfact elfact fact 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 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 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_integer_test i4_is_integer is TRUE if i4 stores an integer value. Example 1: Obviously integer: a = 6 A is an integer value. Example 2: Obviously NOT integer: a = 6.5000 A is NOT an integer value. Example 3: Not Integer, Not obvious: a = 6.0000 A is NOT an integer value. Example 4: Not Integer, Not obvious: a = 3.0000e+08 A is NOT an integer value. 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 I4_LOG_2 0 -Inf 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: logarith 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.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 * ( 2763371787763843 / 2251799813685248 ) * 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 -3 -43 -107 50 -3 43 -107 -50 2 -7 Repeat using MOD: 107 50 2 7 107 -50 -3 -43 -107 50 -3 43 -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 -3 43 -107 -50 3 43 Repeat using MOD: 107 50 2 7 107 -50 -3 -43 -107 50 -3 43 -107 -50 2 -7 I4_NOT_TEST I4_NOT returns the bitwise NOT of an integer I with respect to some maximum value J. MATLAB provides a BITCMP operator. I I4_NOT(255) BITCMP(uint8) 55 200 200 244 11 11 212 43 43 143 112 112 106 149 149 16 239 239 65 190 190 28 227 227 11 244 244 162 93 93 I4_OR_TEST I4_OR returns the bitwise inclusive OR of two integers. MATLAB provides a BITOR operator. I J I4_OR BITOR 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_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 I4_SIGN_TEST I4_SIGN returns the sign of a number. 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 a number. I4 I4_SIGN3(I4) -10 -1 -7 -1 0 0 5 1 9 1 I4_SWAP_TEST I4_SWAP swaps two integers. 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.000000 0.000000 0.000000 1 0.500000 0.333333 0.200000 2 0.250000 0.666667 0.400000 3 0.750000 0.111111 0.600000 4 0.125000 0.444444 0.800000 5 0.625000 0.777778 0.040000 6 0.375000 0.222222 0.240000 7 0.875000 0.555556 0.440000 8 0.062500 0.888889 0.640000 9 0.562500 0.037037 0.840000 10 0.312500 0.370370 0.080000 I4_TO_L4_TEST I4_TO_L4 converts an I4 to an L4. I4 L4 -5 1 -4 1 -3 1 -2 1 -1 1 0 0 1 1 2 1 3 1 4 1 5 1 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 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_TO_TRIANGLE_UPPER_TEST I4_TO_TRIANGLE_UPPER converts a linear index to an upper triangular one. K => I J 1 1 1 2 1 2 3 2 2 4 1 3 5 2 3 6 3 3 7 1 4 8 2 4 9 3 4 10 4 4 11 1 5 12 2 5 13 3 5 14 4 5 15 5 5 16 1 6 17 2 6 18 3 6 19 4 6 20 5 6 I4_UNIFORM_AB_TEST I4_UNIFORM_AB computes pseudorandom values in an interval [A,B]. The lower endpoint A = -100.000000 The upper endpoint B = 200.000000 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.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_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. MATLAB provides a BITXOR operator which should be used instead! I J I4_XOR BITXOR 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_PRINT_TEST I4BLOCK_PRINT prints an I4BLOCK. The 3D array: K = 1 J: 1 2 3 1: 1 1 1 2: 2 4 8 3: 3 9 27 4: 4 16 64 K = 2 J: 1 2 3 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: 3 1 1 1 2: 10 3 5 9 3: 9 2 5 4 4: 6 1 8 1 5: 5 7 8 1 Ascending sorted: Col: 1 2 3 4 Row 1: 1 1 1 3 2: 3 5 9 10 3: 2 5 4 9 4: 1 8 1 6 5: 7 8 1 5 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: 3 1 1 1 2: 10 3 5 9 3: 9 2 5 4 4: 6 1 8 1 5: 5 7 8 1 Descending sorted: Col: 1 2 3 4 Row 1: 3 1 1 1 2: 10 9 5 3 3: 9 4 5 2 4: 6 1 8 1 5: 5 1 8 7 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: 4 5 8 1 2: 20 2 15 0 3: 17 0 16 18 4: 11 13 0 17 5: 8 1 18 2 6: 1 9 7 0 The element-sorted column matrix: Col: 1 2 3 4 Row 1: 1 0 0 0 2: 4 1 7 0 3: 8 2 8 1 4: 11 5 15 2 5: 17 9 16 17 6: 20 13 18 18 I4COL_SORTED_SINGLETON_COUNT_TEST I4COL_SORTED_SINGLETON_COUNT counts singletons in a sorted I4COL; Ascending sorted I4COL: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 0 0 0 1 1 1 1 2 2 3 2: 0 3 3 0 3 3 3 0 1 0 3: 3 1 3 0 0 1 3 1 0 0 Number of singletons = 10 Ascending sorted I4COL: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 0 0 1 2 2 2 2 2 3 3 2: 2 3 3 0 0 1 1 2 3 3 3: 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 I4COL; Ascending sorted I4COL: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 0 0 0 1 1 1 1 2 2 3 2: 0 3 3 0 3 3 3 0 1 0 3: 3 1 3 0 0 1 3 1 0 0 Number of unique entries = 10 Ascending sorted I4COL: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 0 0 1 2 2 2 2 2 3 3 2: 2 3 3 0 0 1 1 2 3 3 3: 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: 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; Indicator 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 I4MAT_IS_BINARY_TEST I4MAT_IS_BINARY is TRUE if an I4MAT only contains 0 or 1 entries. Matrix: Col: 1 2 3 Row 1: 0 1 0 2: 1 0 1 X is binary Matrix: Col: 1 2 3 Row 1: 1 1 1 2: 1 1 1 X is binary Matrix: Col: 1 2 3 Row 1: 0 1 0 2: 1 2 1 X is binary i4mat_is_integer_test i4mat_is_integer is TRUE if every entry of an I4MAT is an integer. Example 1: Obviously integer: a = 1 2 3 4 5 6 A is an integer matrix. Example 2: Obviously NOT integer: a = 1.0000 2.0000 3.0000 4.0000 5.0000 6.5000 A is NOT an integer matrix. Example 3: Not Integer, Not obvious: a = 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 A is NOT an integer matrix. Example 4: Not Integer, Not obvious: a = 1.0000e+00 2.0000e+00 3.0000e+08 4.0000e+00 5.0000e+00 6.0000e+00 A is NOT an integer matrix. i4mat_is_ternary_test i4mat_is_ternary is TRUE if an I4MAT only contains -1, 0, and +1 entries. Matrix: Col: 1 2 3 Row 1: 0 -1 0 2: 1 0 1 X is ternary Matrix: Col: 1 2 3 Row 1: 1 1 1 2: 1 1 1 X is ternary Matrix: Col: 1 2 3 Row 1: 0 1 0 2: -1 2 -1 X is NOT ternary. 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: 2 0 0 0 9 10 7 2: 10 2 4 9 9 1 6 3: 9 1 4 3 1 3 9 4: 6 0 8 1 0 9 4 5: 4 6 8 0 2 2 10 Maximum entry = 10 I4MAT_MAX_INDEX_TEST I4MAT_MAX_INDEX locates the maximum; Random array: Col: 1 2 3 4 5 6 7 Row 1: 2 0 0 0 9 10 7 2: 10 2 4 9 9 1 6 3: 9 1 4 3 1 3 9 4: 6 0 8 1 0 9 4 5: 4 6 8 0 2 2 10 Maximum I,J indices = 2 1 I4MAT_MIN_TEST I4MAT_MIN returns the minimum; Random array: Col: 1 2 3 4 5 6 7 Row 1: 2 0 0 0 9 10 7 2: 10 2 4 9 9 1 6 3: 9 1 4 3 1 3 9 4: 6 0 8 1 0 9 4 5: 4 6 8 0 2 2 10 Minimum entry = 0 I4MAT_MIN_INDEX_TEST I4MAT_MIN_INDEX locates the minimum; Random array: Col: 1 2 3 4 5 6 7 Row 1: 2 0 0 0 9 10 7 2: 10 2 4 9 9 1 6 3: 9 1 4 3 1 3 9 4: 6 0 8 1 0 9 4 5: 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 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: 22 25 21 23 24 2: 52 55 51 53 54 3: 12 15 11 13 14 4: 32 35 31 33 34 5: 42 45 41 43 44 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_PRINT_TEST I4MAT_PRINT prints an I4MAT. The I4MAT: 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 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_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 0 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 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 99 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 99 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 99 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: -12 99 94 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: -12 99 94 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: -12 99 94 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 reduced row echelon form 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 IRREF form: 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_SOLVE_BINARY_TEST: I4MAT_RREF_SOLVE_BINARY seeks binary solutions of an Integer Row-Reduced Echelon Form (IRREF) system A*x=b when A and b contain integer values. The IRREF matrix A: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 1 0 0 0 0 0 1 0 -1 0 2: 0 1 0 0 0 0 0 0 1 0 3: 0 0 1 0 0 0 1 0 -1 0 4: 0 0 0 1 0 0 0 0 1 1 5: 0 0 0 0 1 0 0 0 0 1 6: 0 0 0 0 0 1 -1 0 1 0 7: 0 0 0 0 0 0 0 1 0 -1 8: 0 0 0 0 0 0 0 0 0 0 9: 0 0 0 0 0 0 0 0 0 0 The right hand side b: 1: 0 2: 1 3: 0 4: 1 5: 1 6: 1 7: 0 8: 0 9: 0 Binary solution vectors x: Col: 1 2 3 4 Row 1: 0 0 1 0 2: 1 1 0 0 3: 0 0 1 0 4: 1 0 0 0 5: 1 0 1 1 6: 1 1 0 1 7: 0 0 0 1 8: 0 1 0 0 9: 0 0 1 1 10: 0 1 0 0 I4MAT_RREF_SOLVE_BINARY_NZ_TEST: I4MAT_RREF_SOLVE_BINARY_NZ seeks binary solutions of an Integer Row-Reduced Echelon Form (IRREF) system A*x=b which have exactly NZ nonzeros. The IRREF matrix A: Col: 1 2 3 4 5 6 7 8 9 10 Row 1: 1 0 0 0 0 0 1 0 -1 0 2: 0 1 0 0 0 0 0 0 1 0 3: 0 0 1 0 0 0 1 0 -1 0 4: 0 0 0 1 0 0 0 0 1 1 5: 0 0 0 0 1 0 0 0 0 1 6: 0 0 0 0 0 1 -1 0 1 0 7: 0 0 0 0 0 0 0 1 0 -1 8: 0 0 0 0 0 0 0 0 0 0 9: 0 0 0 0 0 0 0 0 0 0 The right hand side b: 1: 0 2: 1 3: 0 4: 1 5: 1 6: 1 7: 0 8: 0 9: 0 Only consider binary solutions with exactly 4 nonzeros. Binary solution vectors x: Col: 1 2 3 4 Row 1: 0 1 0 0 2: 1 0 1 0 3: 0 1 0 0 4: 1 0 0 0 5: 1 1 0 1 6: 1 0 1 1 7: 0 0 0 1 8: 0 0 1 0 9: 0 1 0 1 10: 0 0 1 0 I4MAT_U_SOLVE_TEST I4MAT_U_SOLVE solves an upper triangular system A*x=b, where A and b contain only integer values. 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 Integer solution x: 1: 1 2: 2 3: 3 4: 4 Norm of A*x-b = 0 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. A1: Col: 1 2 3 Row 1: 11 211 3111 2: 12 222 3222 3: 13 233 3333 The printing width of A1 is 4 A2: Col: 1 2 3 Row 1: 10 23 45 2: 42 -1000 63 3: 77 63 90 The printing width of A2 is 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 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 Sum, mean: 1 10 2.500000 2 26 6.500000 3 42 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 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: 2 0 9 7 2: 10 4 9 6 3: 9 4 1 9 4: 6 8 0 4 5: 4 8 2 10 6: 0 0 10 6 7: 2 9 1 2 8: 1 3 3 8 9: 0 1 9 4 10: 6 0 2 2 The row-sorted matrix: Col: 1 2 3 4 Row 1: 0 0 10 6 2: 0 1 9 4 3: 1 3 3 8 4: 2 0 9 7 5: 2 9 1 2 6: 4 8 2 10 7: 6 0 2 2 8: 6 8 0 4 9: 9 4 1 9 10: 10 4 9 6 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: 22 21 23 24 2: 62 61 63 64 3: 12 11 13 14 4: 52 51 53 54 5: 42 41 43 44 6: 32 31 33 34 The row-sorted matrix: Col: 1 2 3 4 Row 1: 62 61 63 64 2: 52 51 53 54 3: 42 41 43 44 4: 32 31 33 34 5: 22 21 23 24 6: 12 11 13 14 The element-sorted row-sorted matrix: Col: 1 2 3 4 Row 1: 64 63 62 61 2: 54 53 52 51 3: 44 43 42 41 4: 34 33 32 31 5: 24 23 22 21 6: 14 13 12 11 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: 22 21 23 24 2: 62 61 63 64 3: 12 11 13 14 4: 52 51 53 54 5: 42 41 43 44 6: 32 31 33 34 The row-sorted matrix: Col: 1 2 3 4 Row 1: 62 61 63 64 2: 52 51 53 54 3: 42 41 43 44 4: 32 31 33 34 5: 22 21 23 24 6: 12 11 13 14 The element-sorted row-sorted matrix: Col: 1 2 3 4 Row 1: 64 63 62 61 2: 54 53 52 51 3: 44 43 42 41 4: 34 33 32 31 5: 24 23 22 21 6: 14 13 12 11 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 Sum, mean: 1 10 2.500000 2 26 6.500000 3 42 10.500000 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.666667 2 1.666667 3 1.666667 m = 3 n = 4 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 -6 -9 -15 2 10 -1 9 3 7 -2 5 4 1 5 6 5 -2 6 4 6 -9 -10 -19 7 -5 8 3 8 -8 -3 -11 9 -10 -9 -19 10 3 -10 -7 I4VEC_AMAX_TEST For an integer vector: I4VEC_AMAX: maximum absolute entry; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Maximum absolute value: 10.000000 I4VEC_AMAX_INDEX_TEST For an integer vector: I4VEC_AMAX_INDEX: index of maximum absolute entry; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Maximum abs index: 2 I4VEC_AMIN_TEST For an integer vector: I4VEC_AMIN: minimum absolute entry; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Minimum absolute value: 1.000000 I4VEC_AMIN_INDEX_TEST For an integer vector: I4VEC_AMIN_INDEX: index minimum absolute entry; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Minimum abs index: 1 I4VEC_AMINZ_TEST For an integer vector: I4VEC_AMINZ: minimum nonzero absolute entry; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Minimum abs nonzero: 1.000000 I4VEC_AMINZ_INDEX_TEST For an integer vector: I4VEC_AMINZ_INDEX: index of minimum nonzero absolute entry; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Minimum abs nonzero index: 4 I4VEC_ASCEND_SUB_TEST I4VEC_ASCEND_SUB computes a longest ascending subsequence of an integer vector. Using initial random number seed = 123456789 The vector to be tested: 1: 3 2: 10 3: 9 4: 6 5: 5 6: 1 7: 3 8: 2 9: 1 10: 7 11: 1 12: 5 13: 5 14: 8 A longest ascending subsequence: 1: 1 2: 2 3: 5 4: 8 The vector to be tested: 1: 8 2: 1 3: 9 4: 4 5: 1 6: 1 7: 9 8: 9 9: 2 10: 1 11: 3 12: 10 13: 2 14: 4 A longest ascending subsequence: 1: 1 2: 2 3: 3 4: 4 The vector to be tested: 1: 9 2: 3 3: 7 4: 6 5: 9 6: 5 7: 10 8: 6 9: 2 10: 8 11: 4 12: 2 13: 6 14: 4 A longest ascending subsequence: 1: 3 2: 5 3: 6 4: 8 The vector to be tested: 1: 7 2: 4 3: 3 4: 8 5: 2 6: 3 7: 9 8: 9 9: 1 10: 8 11: 1 12: 8 13: 8 14: 4 A longest ascending subsequence: 1: 2 2: 3 3: 4 The vector to be tested: 1: 9 2: 8 3: 8 4: 5 5: 10 6: 6 7: 1 8: 6 9: 1 10: 4 11: 3 12: 9 13: 1 14: 1 A longest ascending subsequence: 1: 1 2: 3 3: 9 The vector to be tested: 1: 2 2: 2 3: 4 4: 2 5: 3 6: 3 7: 7 8: 9 9: 6 10: 3 11: 8 12: 8 13: 5 14: 9 A longest ascending subsequence: 1: 2 2: 3 3: 6 4: 8 5: 9 I4VEC_BINARY_NEXT_TEST I4VEC_BINARY_NEXT generates the next binary vector. 000 001 010 011 100 101 110 111 I4VEC_BRACKET_TEST I4VEC_BRACKET finds a pair of entries in a sorted integer array 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 = 2 A(LEFT) = 2 A(RIGHT) = 4 Sorted, augmented array: 1: 2 2: -10 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 = 3 A(LEFT) = -10 A(RIGHT) = 4 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 10 8: 10 9: 14 10: 16 11: 18 12: 20 Search for AVAL = 9 Left = 6 Right = 7 A(LEFT) = 8 A(RIGHT) = 10 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 14 11: 16 12: 18 13: 20 Search for AVAL = 10 Left = 9 Right = 10 A(LEFT) = 10 A(RIGHT) = 14 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 10 11: 14 12: 16 13: 18 14: 20 Search for AVAL = 20 Left = 13 Right = 14 A(LEFT) = 18 A(RIGHT) = 20 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 10 11: 14 12: 16 13: 18 14: 20 15: 20 Search for AVAL = 24 Left = 14 Right = 15 A(LEFT) = 20 A(RIGHT) = 20 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 10 11: 14 12: 16 13: 18 14: 20 15: 24 16: 20 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_compare_test: i4vec_compare compares the order of two i4vec's. V1 and V2: 1: 1 0 2: 2 5 3: 3 10 compare = 1 V1 and V2: 1: 1 1 2: 2 2 3: 3 3 compare = 0 V1 and V2: 1: 1 1 2: 2 3 3: 3 0 compare = -1 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: 2 2: 10 3: 9 4: 6 5: 4 6: 0 7: 2 8: 1 9: 0 10: 6 Cumulative sums: 1: 2 2: 12 3: 21 4: 27 5: 31 6: 31 7: 33 8: 34 9: 34 10: 40 I4VEC_CUM0_TEST For an integer vector: I4VEC_CUM0: cumulative sum (zero based); Input vector: 1: 2 2: 10 3: 9 4: 6 5: 4 6: 0 7: 2 8: 1 9: 0 10: 6 0-based cumulative sums: 1: 0 2: 2 3: 12 4: 21 5: 27 6: 31 7: 31 8: 33 9: 34 10: 34 11: 40 I4VEC_DECREMENT_TEST I4VEC_DECREMENT decrements an I4VEC. The I4VEC: 1: -2 2: 10 3: 8 4: 3 The I4VEC after decrementing: 1: -3 2: 9 3: 7 4: 2 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. J W(J) 1 40000 2 80000 3 120000 4 160000 5 48000 6 96000 7 144000 8 192000 9 56000 10 112000 11 168000 12 224000 13 45000 14 90000 15 135000 16 180000 17 54000 18 108000 19 162000 20 216000 21 63000 22 126000 23 189000 24 252000 I4VEC_DOT_PRODUCT_TEST I4VEC_DOT_PRODUCT computes the dot product of two I4VECs. The vector A: 1: 2 2: 10 3: 9 4: 6 5: 4 The vector B: 1: 0 2: 2 3: 1 4: 0 5: 6 The dot product is 53 I4VEC_FRAC_TEST I4VEC_FRAC: K-th smallest integer vector entry. Using initial random number seed = 123456789 The array to search: 1: 5 2: 20 3: 17 4: 12 5: 9 6: 2 7: 6 8: 3 9: 1 10: 13 Fractile Value 1 1 6 9 i4vec_gcd_test i4vec_gcd computes the greatest common divisor of the entries in an I4VEC. The I4VEC: 1: 120120 2: 90090 3: 750750 4: 330330 GCD = 30030 I4VEC_HEAP_A_TEST For an integer vector, I4VEC_HEAP_A puts into ascending heap form. Unsorted array: 1: 2 2: 10 3: 9 4: 6 5: 4 6: 0 7: 2 8: 1 9: 0 10: 6 Ascending heap form: 1: 0 2: 1 3: 0 4: 2 5: 4 6: 9 7: 2 8: 10 9: 6 10: 6 I4VEC_HEAP_D_TEST For an integer vector, I4VEC_HEAP_D puts into descending heap form. Unsorted array: 1: 2 2: 10 3: 9 4: 6 5: 4 6: 0 7: 2 8: 1 9: 0 10: 6 Descending heap form: 1: 10 2: 6 3: 9 4: 2 5: 6 6: 0 7: 2 8: 1 9: 0 10: 4 I4VEC_HEAP_D_EXTRACT_TEST 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: 1: 10 2: 6 3: 9 4: 2 5: 6 6: 0 7: 2 8: 1 9: 0 10: 4 Now extract the maximum several times. Extracting maximum element = 10 Extracting maximum element = 9 Extracting maximum element = 6 Extracting maximum element = 6 Extracting maximum element = 4 Current heap as a vector: 1: 2 2: 2 3: 1 4: 0 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 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: 1: 10 2: 6 3: 9 4: 2 5: 6 6: 0 7: 2 8: 1 9: 0 10: 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: 1: 10 2: 6 3: 9 4: 2 5: 6 6: 0 7: 2 8: 1 9: 0 10: 4 I4VEC_HISTOGRAM_TEST I4VEC_HISTOGRAM histograms an integer vector. 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_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: -2 2: 10 3: 8 4: 3 The I4VEC after incrementing: 1: -1 2: 11 3: 9 4: 4 I4VEC_INDEX_TEST For an integer vector: I4VEC_INDEX: first index of given value; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Index of first occurrence of -2 is 5 Index of first occurrence of -1 is -1 I4VEC_INDEX_DELETE_ALL_TEST I4VEC_INDEX_DELETE_ALL deletes all copies of a particular value. 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 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. 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: Call I4VEC_INDEX_DELETE_ALL to delete 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 6 1 8 13 13 9 9 14 5 8 11 15 11 15 13 16 15 16 15 17 16 0 16 18 4 18 17 19 18 1 18 20 3 0 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 8 7 7 9 8 8 11 9 9 13 10 10 15 11 11 16 12 12 17 13 13 18 14 14 20 I4VEC_INDEX_DELETE_ONE_TEST I4VEC_INDEX_DELETE_ONE deletes one copies of a particular value. 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: 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 7 8 8 16 14 15 9 17 6 16 11 18 12 0 13 19 16 18 15 20 17 7 16 21 5 1 17 22 19 0 18 23 4 7 20 I4VEC_INDEX_INSERT_TEST I4VEC_INDEX_INSERT inserts values into an index sorted array of integers. 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: 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)) 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)) 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 Now call I4VEC_INDEX_ORDER to carry out the sorting: X: 1: 0 2: 1 3: 2 4: 4 5: 5 6: 7 7: 8 8: 9 9: 11 10: 13 11: 15 12: 16 13: 17 14: 18 15: 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: 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_TEST 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 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 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 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_INDICATOR0_TEST I4VEC_INDICATOR0 returns an 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 an 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 = 2 A(LEFT) = 2 A(RIGHT) = 4 Sorted, augmented array: 1: 2 2: -10 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 = 3 A(LEFT) = -10 A(RIGHT) = 4 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 10 8: 10 9: 14 10: 16 11: 18 12: 20 Search for AVAL = 9 Left = 6 Right = 7 A(LEFT) = 8 A(RIGHT) = 10 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 14 11: 16 12: 18 13: 20 Search for AVAL = 10 Left = 9 Right = 10 A(LEFT) = 10 A(RIGHT) = 14 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 10 11: 14 12: 16 13: 18 14: 20 Search for AVAL = 20 Left = 13 Right = 14 A(LEFT) = 18 A(RIGHT) = 20 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 10 11: 14 12: 16 13: 18 14: 20 15: 20 Search for AVAL = 24 Left = 14 Right = 15 A(LEFT) = 20 A(RIGHT) = 20 Sorted, augmented array: 1: 2 2: -10 3: 2 4: 4 5: 6 6: 8 7: 9 8: 10 9: 10 10: 10 11: 14 12: 16 13: 18 14: 20 15: 24 16: 20 I4VEC_IS_ASCENDING_TEST I4VEC_IS_ASCENDING determines if an integer vector ascends. Test vector: 1: 1 2: 3 3: 2 4: 4 I4VEC_IS_ASCENDING = 0 Test vector: 1: 2 2: 2 3: 2 4: 2 I4VEC_IS_ASCENDING = 1 Test vector: 1: 1 2: 2 3: 2 4: 4 I4VEC_IS_ASCENDING = 1 Test vector: 1: 1 2: 2 3: 3 4: 4 I4VEC_IS_ASCENDING = 1 Test vector: 1: 4 2: 4 3: 3 4: 1 I4VEC_IS_ASCENDING = 0 Test vector: 1: 9 2: 7 3: 3 4: 0 I4VEC_IS_ASCENDING = 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 integer vector descends. Test vector: 1: 1 2: 3 3: 2 4: 4 I4VEC_IS_DESCENDING = 0 Test vector: 1: 2 2: 2 3: 2 4: 2 I4VEC_IS_DESCENDING = 1 Test vector: 1: 1 2: 2 3: 2 4: 4 I4VEC_IS_DESCENDING = 0 Test vector: 1: 1 2: 2 3: 3 4: 4 I4VEC_IS_DESCENDING = 0 Test vector: 1: 4 2: 4 3: 3 4: 1 I4VEC_IS_DESCENDING = 1 Test vector: 1: 9 2: 7 3: 3 4: 0 I4VEC_IS_DESCENDING = 1 i4vec_is_integer_test i4vec_is_integer is TRUE if every entry of an I4VEC is an integer. Example 1: Obviously integer: a = 1 2 3 A is an integer vector. Example 2: Obviously NOT integer: a = 4.0000 5.0000 6.5000 A is NOT an integer vector. Example 3: Not Integer, Not obvious: a = 1.0000 2.0000 3.0000 A is NOT an integer vector. Example 4: Not Integer, Not obvious: a = 1.0000e+00 2.0000e+00 3.0000e+08 A is NOT an integer vector. I4VEC_IS_PAIRWISE_PRIME_TEST I4VEC_IS_PAIRWISE_PRIME determines if a vector of integers 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_LCM_TEST I4VEC_LCM computes the least common multiple of the entries in an I4VEC. The I4VEC: 1: 120120 2: 90090 3: 750750 4: 330330 LCM = 99099000 I4VEC_MAX_TEST For an integer vector: I4VEC_MAX: maximum entry; Input vector: 1: 7 2: 29 3: 25 4: 17 5: 13 6: 2 7: 8 8: 4 9: 2 10: 20 Maximum: 29 I4VEC_MAX_INDEX_TEST For an integer vector: I4VEC_MAX_INDEX: a maximal index; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Maximum index: 2 I4VEC_MAX_INDEX_LAST_TEST For an integer vector: I4VEC_MAX_INDEX_LAST: last maximal index; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Last maximum index: 2 I4VEC_MAX_LAST_TEST I4VEC_MAX_LAST identifies the largest element in an I4VEC, and moves it to the final entry. Input vector: 1: 7 2: 29 3: 25 4: 17 5: 13 6: 2 7: 8 8: 4 9: 2 10: 20 Maximum: 29 Output vector: 1: 7 2: 25 3: 17 4: 13 5: 2 6: 8 7: 4 8: 2 9: 20 10: 29 I4VEC_MEAN_TEST For an I4VEC: I4VEC_MEAN: mean value; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Mean: -1.900000 I4VEC_MEDIAN_TEST For an I4VEC: I4VEC_MEDIAN: median value; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Median: -5 I4VEC_MERGE_A_TEST For ascending order: I4VEC_MERGE_A merges two sorted integer arrays; Input vector A1: 1: 0 2: 0 3: 1 4: 2 5: 2 6: 4 7: 6 8: 6 9: 9 10: 10 Input vector A2: 1: 0 2: 0 3: 0 4: 1 5: 3 6: 4 7: 4 8: 8 9: 8 10: 9 Merged vector A3: 1: 0 2: 1 3: 2 4: 3 5: 4 6: 6 7: 8 8: 9 9: 10 I4VEC_MIN_TEST I4VEC_MIN: minimum entry of an I4VEC. Input vector: 1: 7 2: 29 3: 25 4: 17 5: 13 6: 2 7: 8 8: 4 9: 2 10: 20 Minimum: 2 I4VEC_MIN_INDEX_TEST For an integer vector: I4VEC_MIN_INDEX: a minimal index; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Minimum index: 9 I4VEC_NONZERO_COUNT_TEST For an integer vector: I4VEC_NONZERO_COUNT: number of nonzeroes; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Number of nonzeroes: 10 I4VEC_NONZERO_FIRST_TEST For an integer vector: 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 integer vector 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 integer vector as part of a quick sort. Using initial random number seed = 123456789 Before rearrangement: 1: 2 2: 12 3: 10 4: 7 5: 5 6: 0 7: 3 8: 1 9: 0 10: 8 11: 0 12: 5 Rearranged array Left index = 4 Key index = 5 Right index = 6 Left half: 1: 0 2: 0 3: 1 4: 0 Key: 1: 2 Right half: 1: 3 2: 5 3: 7 4: 8 5: 10 6: 5 7: 12 I4VEC_PERMUTE_TEST I4VEC_PERMUTE reorders an integer vector according to a given permutation. Using initial random number seed = 123456789 A, before rearrangement: 1: 2 2: 12 3: 10 4: 7 5: 5 6: 0 7: 3 8: 1 9: 0 10: 8 11: 0 12: 5 Permutation vector P: 1: 5 2: 10 3: 2 4: 4 5: 12 6: 8 7: 7 8: 6 9: 1 10: 9 11: 11 12: 3 A, after rearrangement: 1: 5 2: 8 3: 12 4: 7 5: 5 6: 1 7: 3 8: 0 9: 2 10: 0 11: 0 12: 10 I4VEC_PERMUTE_UNIFORM_TEST I4VEC_PERMUTE_UNIFORM randomly reorders an I4VEC. A, before rearrangement: 1: 101 2: 102 3: 103 4: 104 5: 105 6: 106 7: 107 8: 108 9: 109 10: 110 11: 111 12: 112 A, after rearrangement: 1: 103 2: 112 3: 111 4: 109 5: 108 6: 106 7: 105 8: 107 9: 104 10: 101 11: 110 12: 102 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 a list of integers. Original vector: 1: 6 2: 29 3: 25 4: 17 5: 12 6: 2 7: 7 8: 3 9: 1 10: 19 Reversed: 1: 19 2: 1 3: 3 4: 7 5: 2 6: 12 7: 17 8: 25 9: 29 10: 6 i4vec_rotate_test i4vec_rotate() rotates an I4VEC by M positions. The vector: 1 2 3 4 5 6 7 8 9 10 M = -3: 8 9 10 1 2 3 4 5 6 7 M = -2: 9 10 1 2 3 4 5 6 7 8 M = -1: 10 1 2 3 4 5 6 7 8 9 M = 0: 1 2 3 4 5 6 7 8 9 10 M = 1: 2 3 4 5 6 7 8 9 10 1 M = 2: 3 4 5 6 7 8 9 10 1 2 M = 3: 4 5 6 7 8 9 10 1 2 3 M = 4: 5 6 7 8 9 10 1 2 3 4 M = 5: 6 7 8 9 10 1 2 3 4 5 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 vector. Ascending sorted array: 1: 0 2: 1 3: 1 4: 2 5: 3 6: 4 7: 5 8: 6 9: 7 10: 8 Now search for an instance of the value 5 The value occurs at index = 7 I4VEC_SEARCH_BINARY_D_TEST I4VEC_SEARCH_BINARY_D searches a descending sorted vector. Descending sorted array: 1: 8 2: 7 3: 6 4: 5 5: 4 6: 3 7: 2 8: 1 9: 1 10: 0 Now search for an instance of the value 5 The value occurs at index = 4 i4vec_shift_circular_test(): i4vec_shift_circular() circularly shifts a vector by K positions. The vector: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 Using a circular shift of K = 3 Shifted vector: 1: 8 2: 9 3: 10 4: 1 5: 2 6: 3 7: 4 8: 5 9: 6 10: 7 I4VEC_SORT_BUBBLE_A_TEST For a vector of integers, I4VEC_SORT_BUBBLE_A ascending sorts, Unsorted: 1: 13 2: 58 3: 50 4: 34 5: 25 6: 4 7: 15 8: 6 9: 2 10: 38 11: 3 12: 27 13: 24 14: 46 15: 48 16: 0 17: 54 18: 21 19: 5 20: 0 Ascending sorted: 1: 0 2: 0 3: 2 4: 3 5: 4 6: 5 7: 6 8: 13 9: 15 10: 21 11: 24 12: 25 13: 27 14: 34 15: 38 16: 46 17: 48 18: 50 19: 54 20: 58 I4VEC_SORT_HEAP_A_TEST For a vector of integers, I4VEC_SORT_HEAP_A ascending sorts, Unsorted: 1: 13 2: 58 3: 50 4: 34 5: 25 6: 4 7: 15 8: 6 9: 2 10: 38 11: 3 12: 27 13: 24 14: 46 15: 48 16: 0 17: 54 18: 21 19: 5 20: 0 Ascending sorted: 1: 0 2: 0 3: 2 4: 3 5: 4 6: 5 7: 6 8: 13 9: 15 10: 21 11: 24 12: 25 13: 27 14: 34 15: 38 16: 46 17: 48 18: 50 19: 54 20: 58 I4VEC_SORT_HEAP_D_TEST For a vector of integers, I4VEC_SORT_HEAP_D descending sorts. Unsorted: 1: 13 2: 58 3: 50 4: 34 5: 25 6: 4 7: 15 8: 6 9: 2 10: 38 11: 3 12: 27 13: 24 14: 46 15: 48 16: 0 17: 54 18: 21 19: 5 20: 0 Descending sorted: 1: 58 2: 54 3: 50 4: 48 5: 46 6: 38 7: 34 8: 27 9: 25 10: 24 11: 21 12: 15 13: 13 14: 6 15: 5 16: 4 17: 3 18: 2 19: 0 20: 0 I4vEC_SORT_HEAP_INDEX_A_TEST I4VEC_SORT_HEAP_INDEX_A creates an ascending sort index for an I4VEC. Unsorted array: 1: 13 2: 58 3: 50 4: 34 5: 25 6: 4 7: 15 8: 6 9: 2 10: 38 11: 3 12: 27 13: 24 14: 46 15: 48 16: 0 17: 54 18: 21 19: 5 20: 0 Sort vector INDX: 1: 16 2: 20 3: 9 4: 11 5: 6 6: 19 7: 8 8: 1 9: 7 10: 18 11: 13 12: 5 13: 12 14: 4 15: 10 16: 14 17: 15 18: 3 19: 17 20: 2 I, INDX(I), A(INDX(I)) 1 16 0 2 20 0 3 9 2 4 11 3 5 6 4 6 19 5 7 8 6 8 1 13 9 7 15 10 18 21 11 13 24 12 5 25 13 12 27 14 4 34 15 10 38 16 14 46 17 15 48 18 3 50 19 17 54 20 2 58 I4VEC_SORT_HEAP_INDEX_D_TEST I4VEC_SORT_HEAP_INDEX_D creates a descending sort index for an integer array. Unsorted array: 1: 13 2: 58 3: 50 4: 34 5: 25 6: 4 7: 15 8: 6 9: 2 10: 38 11: 3 12: 27 13: 24 14: 46 15: 48 16: 0 17: 54 18: 21 19: 5 20: 0 Sort vector INDX: 1: 2 2: 17 3: 3 4: 15 5: 14 6: 10 7: 4 8: 12 9: 5 10: 13 11: 18 12: 7 13: 1 14: 8 15: 19 16: 6 17: 11 18: 9 19: 20 20: 16 I, INDX(I), A(INDX(I)) 1 2 58 2 17 54 3 3 50 4 15 48 5 14 46 6 10 38 7 4 34 8 12 27 9 5 25 10 13 24 11 18 21 12 7 15 13 1 13 14 8 6 15 19 5 16 6 4 17 11 3 18 9 2 19 20 0 20 16 0 I4VEC_SORT_INSERT_A_TEST I4VEC_SORT_INSERT_A sorts an integer array. Unsorted array: 1: 2 2: 10 3: 9 4: 6 5: 4 6: 0 7: 2 8: 1 9: 0 10: 6 Sorted array: 1: 0 2: 0 3: 1 4: 2 5: 2 6: 4 7: 6 8: 6 9: 9 10: 10 I4VEC_SORT_INSERT_D_TEST I4VEC_SORT_INSERT_D descending sorts an I4VEC. Unsorted array: 1: 2 2: 10 3: 9 4: 6 5: 4 6: 0 7: 2 8: 1 9: 0 10: 6 Descending sorted array: 1: 10 2: 9 3: 6 4: 6 5: 4 6: 2 7: 2 8: 1 9: 0 10: 0 I4VEC_SORT_QUICK_A_TEST I4VEC_SORT_QUICK_A sorts an integer vector using quick sort. Unsorted array: 1: 13 2: 58 3: 50 4: 34 5: 25 6: 4 7: 15 8: 6 9: 2 10: 38 11: 3 12: 27 13: 24 14: 46 15: 48 16: 0 17: 54 18: 21 19: 5 20: 0 Sorted array: 1: 0 2: 0 3: 2 4: 3 5: 4 6: 5 7: 6 8: 13 9: 15 10: 21 11: 24 12: 25 13: 27 14: 34 15: 38 16: 46 17: 48 18: 50 19: 54 20: 58 I4VEC_SORT_SHELL_A_TEST I4VEC_SORT_SHELL_A sorts an integer vector using Shell's sort. Unsorted array: 1: 13 2: 58 3: 50 4: 34 5: 25 6: 4 7: 15 8: 6 9: 2 10: 38 11: 3 12: 27 13: 24 14: 46 15: 48 16: 0 17: 54 18: 21 19: 5 20: 0 Sorted array: 1: 0 2: 0 3: 2 4: 3 5: 4 6: 5 7: 6 8: 13 9: 15 10: 21 11: 24 12: 25 13: 27 14: 34 15: 38 16: 46 17: 48 18: 50 19: 54 20: 58 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: 0 2: 0 3: 0 4: 1 5: 1 6: 1 7: 2 8: 4 9: 5 10: 7 11: 8 12: 8 13: 9 14: 11 15: 13 16: 15 17: 16 18: 17 19: 18 20: 20 Unique entries: 1: 0 2: 1 3: 2 4: 4 5: 5 6: 7 7: 8 8: 9 9: 11 10: 13 11: 15 12: 16 13: 17 14: 18 15: 20 I4VEC_SORTED_UNIQUE_COUNT_TEST I4VEC_SORTED_UNIQUE_COUNT counts unique entries in a sorted I4VEC. Input vector: 1: 0 2: 0 3: 0 4: 1 5: 1 6: 1 7: 2 8: 4 9: 5 10: 7 11: 8 12: 8 13: 9 14: 11 15: 13 16: 15 17: 16 18: 17 19: 18 20: 20 Number of unique entries is 15 I4VEC_SORTED_UNIQUE_HIST_TEST I4VEC_SORTED_UNIQUE_HIST_TEST is given a sorted array of integers, and returns the number of unique values, the unique values, and their frequency. The sorted vector: 1: 0 2: 0 3: 0 4: 0 5: 0 6: 0 7: 0 8: 0 9: 0 10: 0 11: 0 12: 0 13: 3 14: 3 15: 4 16: 4 17: 6 18: 6 19: 8 20: 8 21: 9 22: 9 23: 10 24: 15 25: 18 26: 18 27: 18 28: 20 29: 20 30: 24 31: 24 32: 24 33: 24 34: 27 35: 28 36: 32 37: 36 38: 36 39: 36 40: 40 41: 42 42: 48 43: 54 44: 54 45: 54 46: 56 47: 63 48: 70 49: 70 50: 100 Unique values and frequencies: 1: 0 12 2: 3 2 3: 4 2 4: 6 2 5: 8 2 6: 9 2 7: 10 1 8: 15 1 9: 18 3 10: 20 2 11: 24 4 12: 27 1 13: 28 1 14: 32 1 15: 36 3 16: 40 1 17: 42 1 18: 48 1 19: 54 3 20: 56 1 21: 63 1 22: 70 2 23: 100 1 I4VEC_SUM_TEST I4VEC_SUM sums the entries of an I4VEC. The vector: 1: 2 2: 10 3: 9 4: 6 5: 4 The vector entries sum to 31 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 a 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 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.000000 The upper endpoint B = 200.000000 The initial seed is 123456789 The random vector: 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 I4VEC_UNIQUE_COUNT_TEST I4VEC_UNIQUE_COUNT counts unique entries in an I4VEC. Input vector: 1: 4 2: 20 3: 17 4: 11 5: 8 6: 1 7: 5 8: 2 9: 0 10: 13 11: 1 12: 9 13: 8 14: 15 15: 16 16: 0 17: 18 18: 7 19: 1 20: 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 1 2 1 2 5 2 3 5 2 4 3 3 5 3 3 6 1 4 7 2 1 8 1 4 9 1 4 10 4 5 11 1 4 12 3 3 13 3 3 14 4 5 15 4 5 16 1 4 17 5 2 18 2 1 19 1 4 20 1 4 I4VEC_VALUE_INDEX_TEST I4VEC_VALUE_INDEX indexes entries equal to a given value. The desired value is The maximum number of indices to find is 3 Input vector A: 1: 2 2: 5 3: 5 4: 3 5: 3 6: 1 7: 2 8: 1 9: 1 10: 4 11: 1 12: 3 13: 3 14: 4 15: 4 16: 1 17: 5 18: 2 19: 1 20: 1 21: 5 22: 5 23: 1 24: 1 25: 2 Indices of entries equal to given value: 1: 4 2: 5 3: 12 I4VEC_VARIANCE_TEST For an integer vector: I4VEC_VARIANCE: variance. Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Variance: 48.100000 I4VEC_WIDTH_TEST I4VEC_WIDTH determines the printing "width" of an I4VEC. The vector 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 i4vec_wrap_test i4vec_wrap() wraps an I4VEC into [LO,HI]. The vector: -2 4 7 2 9 5 Wrap interval is [2,5] Wrapped vector: 2 4 3 2 5 5 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 integer vectors: I4VEC2_SORT_A ascending sorts; The array: 1: 1 1 2: 3 2 3: 1 1 4: 2 3 5: 3 2 6: 1 1 7: 1 3 8: 1 2 9: 1 1 10: 2 1 After ascending sort: 1: 1 1 2: 1 1 3: 1 1 4: 1 1 5: 1 2 6: 1 3 7: 2 1 8: 2 3 9: 3 2 10: 3 2 I4VEC2_SORT_D_TEST For a pair of integer vectors: I4VEC2_SORT_D descending sorts; The array: 1: 1 1 2: 3 2 3: 1 1 4: 2 3 5: 3 2 6: 1 1 7: 1 3 8: 1 2 9: 1 1 10: 2 1 After descending sort: 1: 3 2 2: 3 2 3: 2 3 4: 2 1 5: 1 3 6: 1 2 7: 1 1 8: 1 1 9: 1 1 10: 1 1 I4VEC2_SORTED_UNIQUE_TEST For a pair of integer vectors: I4VEC2_SORTED_UNIQUE counts unique entries. The array: 1: 1 1 2: 3 2 3: 1 1 4: 2 3 5: 3 2 6: 1 1 7: 1 3 8: 1 2 9: 1 1 10: 2 1 After ascending sort: 1: 1 1 2: 1 1 3: 1 1 4: 1 1 5: 1 2 6: 1 3 7: 2 1 8: 2 3 9: 3 2 10: 3 2 After descending sort: 1: 3 2 2: 3 2 3: 2 3 4: 2 1 5: 1 3 6: 1 2 7: 1 1 8: 1 1 9: 1 1 10: 1 1 Unique entries 1: 3 2 2: 2 3 3: 2 1 4: 1 3 5: 1 2 6: 1 1 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 L4_TO_I4_TEST L4_TO_I4 converts an L4 to an I4. L4 I4 0 0 1 1 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 the value 0. Permutation 2: 4 1 3 0 2 Permutation 3: 0 2 1 3 2 PERM0_CHECK - Warning! Permutation is missing the value 4. 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 Permutation 2: 4 1 3 0 2 PERM1_CHECK - Warning! Permutation is missing the value 5. Permutation 3: 0 2 1 3 2 PERM1_CHECK - Warning! Permutation is missing the value 4. 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 R8VEC_IS_INTEGER_TEST R8VEC_IS_INTEGER is TRUE if every entry of an R8VEC is an integer. Example 1: Obviously integer: a = 1 2 3 4 5 6 A is an integer vector. Example 2: Obviously NOT integer: a = 1.0000 2.0000 3.0000 4.0000 5.0000 6.5000 A is NOT an integer vector. Example 3: Not Integer, Not obvious: a = 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 A is NOT an integer vector. Example 4: Not Integer, Not obvious: a = 1.0000e+00 2.0000e+00 3.0000e+08 4.0000e+00 5.0000e+00 6.0000e+00 A is NOT an integer vector. R8VEC_PRINT_TEST R8VEC_PRINT prints an R8VEC. The R8VEC: 1: 123.456 2: 5e-06 3: -1e+06 4: 3.14159 TRIANGLE_LOWER_TO_I4_TEST TRIANGLE_LOWER_TO_I4 converts a lower triangular index to a linear one. I, J => K i = 1 1 1 1 i = 2 2 1 2 i = 3 3 1 4 i = 4 4 1 7 TRIANGLE_UPPER_TO_I4_TEST TRIANGLE_UPPER_TO_I4 converts an upper triangular index to a linear one. I, J => K 1 1 1 1 2 2 1 3 4 1 4 7 2 2 3 2 3 5 2 4 8 3 3 6 3 4 9 4 4 10 i4lib_test Normal end of execution. 23-Jun-2024 21:37:14