22 March 2017 9:13:43.861 PM I4LIB_PRB FORTRAN77 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_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_CEILING_TEST I4_CEILING returns 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 T 120 1000 999 T 1000 100 3 T 161700 100 10 F Not computable I4_DIV_ROUNDED_TEST I4_DIV_ROUNDED performs rounded integer division. C0 = real ( a ) / real ( b ) C1 = I4_DIV_ROUNDED ( A, B ) C2 = nint ( real ( a ) / real ( b ) ) C3 = A / B C4 = int ( real ( a ) / real ( b ) ) C1 and C2 should be equal; C3 and C4 should be equal. A B C0 C1 C2 C3 C4 -57 10 -5.700000 -6 -6 -5 -5 66 1 66.000000 66 66 66 66 -17 -9 1.888889 2 2 1 1 -49 -8 6.125000 6 6 6 6 -92 3 -30.666667 -31 -31 -30 -30 -88 -1 88.000000 88 88 88 88 -20 5 -4.000000 -4 -4 -4 -4 60 -10 -6.000000 -6 -6 -6 -6 80 -3 -26.666667 -27 -27 -26 -26 -81 -10 8.100000 8 8 8 8 72 7 10.285714 10 10 10 10 -76 -10 7.600000 8 8 7 7 -48 9 -5.333333 -5 -5 -5 -5 -78 -3 26.000000 26 26 26 26 65 -5 -13.000000 -13 -13 -13 -13 39 1 39.000000 39 39 39 39 73 -1 -73.000000 -73 -73 -73 -73 83 2 41.500000 41 42 41 41 -63 5 -12.600000 -13 -13 -12 -12 -21 -7 3.000000 3 3 3 3 I4_DIVISION_TEST I4_DIVISION performs integer division. C0 = real ( a ) / real ( b ) C1 = I4_DIVISION ( A, B ) C2 = nint ( real ( a ) / real ( b ) ) C3 = A / B C4 = int ( real ( a ) / real ( b ) ) C1 and C3 and C4 should be equal. C2 may differ; A B C0 C1 C2 C3 C4 -57 10 -5.700000 -5 -6 -5 -5 66 1 66.000000 66 66 66 66 -17 -9 1.888889 1 2 1 1 -49 -8 6.125000 6 6 6 6 -92 3 -30.666667 -30 -31 -30 -30 -88 -1 88.000000 88 88 88 88 -20 5 -4.000000 -4 -4 -4 -4 60 -10 -6.000000 -6 -6 -6 -6 80 -3 -26.666667 -26 -27 -26 -26 -81 -10 8.100000 8 8 8 8 72 7 10.285714 10 10 10 10 -76 -10 7.600000 7 8 7 7 -48 9 -5.333333 -5 -5 -5 -5 -78 -3 26.000000 26 26 26 26 65 -5 -13.000000 -13 -13 -13 -13 39 1 39.000000 39 39 39 39 73 -1 -73.000000 -73 -73 -73 -73 83 2 41.500000 41 42 41 41 -63 5 -12.600000 -12 -13 -12 -12 -21 -7 3.000000 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_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 returns 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_GCDB_TEST I4_GCDB computes the greatest common factor of the form K^N I J K I4_GCD 288 2880 2 32 288 2880 3 9 288 2880 4 16 288 2880 5 1 I4_HUGE_TEST I4_HUGE returns a huge integer. I4_HUGE() = 2147483647 I4_HUGE_NORMALIZE_TEST I4_HUGE_NORMALIZER returns 1/(I4_HUGE+1). I4_HUGE() = 2147483647 I4_HUGE_NORMALIZER() = 0.465661E-09 I4_HUGE * I4_HUGE_NORMALIZER = 1.00000 I4_IS_EVEN_TEST I4_IS_EVEN reports whether an I4 is even. I I4_IS_EVEN(I) -2 T -1 F 0 T 1 F 2 T 3 F 4 T 5 F 6 T 7 F 8 T 9 F 10 T 11 F 12 T 13 F 14 T 15 F 16 T 17 F 18 T 19 F 20 T 21 F 22 T 23 F 24 T 25 F I4_IS_ODD_TEST I4_IS_ODD reports whether an I4 is odd. I I4_IS_ODD(I) -2 F -1 T 0 F 1 T 2 F 3 T 4 F 5 T 6 F 7 T 8 F 9 T 10 F 11 T 12 F 13 T 14 F 15 T 16 F 17 T 18 F 19 T 20 F 21 T 22 F 23 T 24 F 25 T I4_IS_POWER_OF_2_TEST I4_IS_ODD reports whether an I4 is a power of 2. I I4_IS_POWER_OF_2(I) -4 F -3 F -2 F -1 F 0 F 1 T 2 T 3 F 4 T 5 F 6 F 7 F 8 T 9 F 10 F 11 F 12 F 13 F 14 F 15 F 16 T 17 F 18 F 19 F 20 F 21 F 22 F 23 F 24 F 25 F I4_IS_PRIME_TEST I4_IS_PRIME reports whether an integer is prime. I I4_IS_PRIME(I) -2 F -1 F 0 F 1 F 2 T 3 T 4 F 5 T 6 F 7 T 8 F 9 F 10 F 11 T 12 F 13 T 14 F 15 F 16 F 17 T 18 F 19 T 20 F 21 F 22 F 23 T 24 F 25 F I4_LCM_TEST I4_LCM computes the least common multiple. I J I4_LCM 36 30 180 49 -7 49 0 71 0 12 12 12 36 49 1764 1 42 42 91 28 364 I4_LOG_10_TEST I4_LOG_10: whole part of log base 10, X, I4_LOG_10 0 0 1 0 2 0 3 0 9 0 10 1 11 1 99 1 101 2 -1 0 -2 0 -3 0 -9 0 I4_LOG_2_TEST I4_LOG_2: whole part of log base 2. X I4_LOG_2 0 -2147483647 1 0 2 1 3 1 9 3 10 3 11 3 99 6 101 6 -1 0 -2 1 -3 1 -9 3 1000 9 1023 9 1024 10 1025 10 I4_LOG_I4_TEST I4_LOG_I4: logarithm of I4 base J4, I4 J4 I4_LOG_I4 0 2 0 1 2 0 2 2 1 3 2 1 4 2 2 5 2 2 6 2 2 7 2 2 8 2 3 9 2 3 10 2 3 0 3 0 1 3 0 2 3 0 3 3 1 4 3 1 5 3 1 6 3 1 7 3 1 8 3 1 9 3 2 10 3 2 0 4 0 1 4 0 2 4 0 3 4 0 4 4 1 5 4 1 6 4 1 7 4 1 8 4 1 9 4 1 10 4 1 0 5 0 1 5 0 2 5 0 3 5 0 4 5 0 5 5 1 6 5 1 7 5 1 8 5 1 9 5 1 10 5 1 I4_LOG_R8_TEST I4_LOG_R8: whole part of log base B, X, B, I4_LOG_R8 16 2.00000 3 16 3.00000 2 16 4.00000 1 16 5.00000 1 16 6.00000 1 16 7.00000 1 16 8.00000 1 16 16.0000 0 16 32.0000 0 16 256.000 0 I4_MANT_TEST I4_MANT decomposes an integer, Number to be decomposed is X = -314.159 I4_MANT: X = -1 * ( -1580547965/ 0) * 2 ^ 8 I4_MAX_TEST I4_MAX returns the maximum of two I4's. A B C=I4_MAX(A,B) -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_MOD_INV_TEST I4_MOD_INV finds the inverse of B mod N, that is, Y such that ( B * Y ) mod N = 1. B N Y B*YmodN 1 17 1 1 2 17 9 1 3 17 6 1 4 17 13 1 5 17 7 1 6 17 3 1 7 17 5 1 8 17 15 1 9 17 2 1 10 17 12 1 11 17 14 1 12 17 10 1 13 17 4 1 14 17 11 1 15 17 8 1 16 17 16 1 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 FORTRAN MOD: 107 50 2 7 107 -50 -2 7 -107 50 -2 -7 -107 -50 2 -7 I4_MODP_TEST I4_MODP factors an I4 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 FORTRAN MOD: 107 50 2 7 107 -50 -2 7 -107 50 -2 -7 -107 -50 2 -7 I4_MOP_TEST I4_MOP computes a minus-one-power (-1)^I. I4 I4_MOP(I4) -563164 1 912636 1 659019 -1 123391 -1 -169386 1 -867763 -1 -484845 -1 -780087 -1 -912342 1 267932 1 I4_POWER_TEST I4_POWER computes I^J I J I4_POWER(I,J) 0 1 0 1 2 1 2 3 8 3 3 27 10 3 1000 -1 4 1 -2 5 -32 I4_RISE_TEST: I4_RISE evaluates the rising factorial function: M N Exact I4_RISE(M,N) 5 0 1 1 5 1 5 5 5 2 30 30 5 3 210 210 5 4 1680 1680 5 5 15120 15120 5 6 151200 151200 50 0 1 1 10 1 10 10 4000 1 4000 4000 10 2 110 110 18 3 6840 6840 4 4 840 840 98 3 970200 970200 1 7 5040 5040 I4_SIGN_TEST I4_SIGN returns the sign of an I4. I4 I4_SIGN(I4) -10 -1 -7 -1 0 1 5 1 9 1 I4_SIGN3_TEST I4_SIGN3 returns the three-way sign of a number. I4 I4_SIGN3(I4) -10 -1 -7 -1 0 0 5 1 9 1 I4_SWAP_TEST I4_SWAP swaps two I4's. Before swapping: I = 1 J = 202 After swapping: I = 202 J = 1 I4_TO_HALTON_TEST I4_TO_HALTON computes a Halton sequence. The user specifies all data explicitly. In this test, we call I4_TO_HALTON repeatedly. We use distinct primes as bases. I R(0) R(1) R(2) 0 0.0000 0.0000 0.0000 1 0.5000 0.3333 0.2000 2 0.2500 0.6667 0.4000 3 0.7500 0.1111 0.6000 4 0.1250 0.4444 0.8000 5 0.6250 0.7778 0.0400 6 0.3750 0.2222 0.2400 7 0.8750 0.5556 0.4400 8 0.0625 0.8889 0.6400 9 0.5625 0.0370 0.8400 10 0.3125 0.3704 0.0800 I4_TO_ISBN_TEST I4_TO_ISBN converts an I4 digit to an ISBN symbol. I4 S 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 X 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 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_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.000000 0 0 0 0 0 0 0.250000 0 0 0 0 1 0 0.500000 0 0 0 1 0 0 0.750000 0 0 0 1 1 0 1.000000 0 0 1 0 0 0 1.250000 0 0 1 0 1 0 1.500000 0 0 1 1 0 0 1.750000 0 0 1 1 1 0 2.000000 0 1 0 0 0 0 2.250000 0 1 0 0 1 0 2.500000 0 1 0 1 0 0 2.750000 0 1 0 1 1 0 3.000000 0 1 1 0 0 0 3.250000 0 1 1 0 1 0 3.500000 0 1 1 1 0 0 3.750000 0 1 1 1 1 0 4.000000 1 0 0 0 0 0 4.250000 1 0 0 0 1 0 4.500000 1 0 0 1 0 0 4.750000 1 0 0 1 1 0 5.000000 1 0 1 0 0 0 5.250000 1 0 1 0 1 0 5.500000 1 0 1 1 0 0 5.750000 1 0 1 1 1 0 6.000000 1 1 0 0 0 0 6.250000 1 1 0 0 1 0 6.500000 1 1 0 1 0 0 6.750000 1 1 0 1 1 0 7.000000 1 1 1 0 0 0 7.250000 1 1 1 0 1 0 7.500000 1 1 1 1 0 0 7.750000 1 1 1 1 1 0 8.000000 0 0 0 0 0 0 I4_WIDTH_TEST I4_WIDTH determines the printing "width" of an I4. I4 I4_WIDTH 0 1 1 1 2 1 3 1 9 1 10 2 11 2 99 2 101 3 -1 2 -2 2 -3 2 -9 2 I4_WRAP_TEST I4_WRAP forces an integer to lie within given limits. ILO = 4 IHI = 8 I I4_WRAP(I) -10 5 -9 6 -8 7 -7 8 -6 4 -5 5 -4 6 -3 7 -2 8 -1 4 0 5 1 6 2 7 3 8 4 4 5 5 6 6 7 7 8 8 9 4 10 5 11 6 12 7 13 8 14 4 15 5 16 6 17 7 18 8 19 4 20 5 I4_XOR_TEST I4_XOR returns the bitwise exclusive OR of two integers. Compare with FORTRAN90 intrinsic IEOR. I J I4_XOR IEOR 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 I: 1: 1 1 1 2: 2 4 8 3: 3 9 27 4: 4 16 64 K = 2 J: 1 2 3 I: 1: 2 2 2 2: 4 8 16 3: 6 18 54 4: 8 32 128 I4COL_FIND_ITEM_TEST I4COL_FIND_ITEM finds the first occurrence of an item in an integer array of columns. The matrix of columns: Col 1 2 3 4 Row 1: 11 12 13 14 2: 21 22 23 24 3: 31 32 33 34 4: 41 42 43 44 5: 51 52 53 54 Item 34 occurs in row 3 and column 4 Item 12 occurs in row 1 and column 2 Item 90 occurs in row -1 and column -1 I4COL_FIND_PAIR_SWAP_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 TEST27 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 ICOL: 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 ICOL: 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, as returned by I4MAT_RED: (Factors are displayed in an extra row and column. 1 2 3 4 1 1 6 7 8 9 2 1 11 12 13 14 3 1 16 17 18 19 4 1 21 22 23 24 5 1 1 1 1 1 5 The matrix returned by I4MAT_ELIM: Col 1 2 3 4 5 Row 1: 1 11 23 2 5 2: 0 -10 -40 -5 -16 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, as returned by I4MAT_RED: (Factors are displayed in an extra row and column. 60 30 140 210 504 2 30 20 105 168 420 1 20 15 84 140 360 1 15 12 70 120 315 1 12 10 60 105 280 1 672 672 96 48 16 The matrix returned by I4MAT_ELIM: Col 1 2 3 4 5 Row 1: 1 3 7 14 63 2: 0 -2 -8 -21 -112 3: 0 0 2 9 63 4: 0 0 0 1 12 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, as returned by I4MAT_RED: (Factors are displayed in an extra row and column. 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 5 5 5 5 5 5 1 2 3 4 5 The matrix returned by I4MAT_ELIM: Col 1 2 3 4 5 Row 1: 1 1 1 1 1 2: 0 0 0 0 0 3: 0 0 0 0 0 4: 0 0 0 0 0 5: 0 0 0 0 0 I4MAT_INDICATOR_TEST I4MAT_INDICATOR returns an indicator matrix. The indicator matrix: Col 1 2 3 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_L1_INVERSE_TEST I4MAT_L1_INVERSE inverts a unit lower triangular I4MAT. 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 of an I4MAT. 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 value = 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 value = 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_RED_TEST I4MAT_RED divides common factors in a matrix; 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, as returned by I4MAT_RED: (Factors are displayed in an extra row and column. 1 2 3 4 1 1 6 7 8 9 2 1 11 12 13 14 3 1 16 17 18 19 4 1 21 22 23 24 5 1 1 1 1 1 5 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, as returned by I4MAT_RED: (Factors are displayed in an extra row and column. 60 30 140 210 504 2 30 20 105 168 420 1 20 15 84 140 360 1 15 12 70 120 315 1 12 10 60 105 280 1 672 672 96 48 16 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, as returned by I4MAT_RED: (Factors are displayed in an extra row and column. 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 5 5 5 5 5 5 1 2 3 4 5 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 I4ROW_MAX_TEST I4ROW_MAX computes row maximums; The matrix: Col 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 The row maximums: 1: 4 2: 8 3: 12 I4ROW_MEAN_TEST I4ROW_MEAN computes row means; The matrix: Col 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 The row means: 1: 2.5000000 2: 6.5000000 3: 10.500000 I4ROW_MIN_TEST I4ROW_MIN computes row minimums; The matrix: Col 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 The row minimums: 1: 1 2: 5 3: 9 I4ROW_SORT_A_TEST For a rectangular integer matrix: I4ROW_SORT_A sorts the rows; The original matrix: Col 1 2 3 4 Row 1: 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 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 element-sorted row-sorted matrix: Col 1 2 3 4 Row 1: 24 23 22 21 2: 64 63 62 61 3: 14 13 12 11 4: 54 53 52 51 5: 44 43 42 41 6: 34 33 32 31 I4ROW_SUM_TEST I4ROW_SUM computes row sums; The matrix: Col 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 The row sums: 1: 10 2: 26 3: 42 I4ROW_SWAP_TEST For an integer matrix of rows, I4ROW_SWAP swaps two rows; The matrix: Col 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 Swap rows 1 and 3 The new matrix: Col 1 2 3 4 Row 1: 9 10 11 12 2: 5 6 7 8 3: 1 2 3 4 I4ROW_VARIANCE_TEST I4ROW_VARIANCE computes row variances; The matrix: Col 1 2 3 4 Row 1: 1 2 3 4 2: 5 6 7 8 3: 9 10 11 12 Row variances: 1 1.6667 2 1.6667 3 1.6667 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 I4VEC: 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 I4VEC_AMAX_INDEX_TEST For an I4VEC: 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 I4VEC: 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 I4VEC_AMIN_INDEX_TEST For an I4VEC: 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_INDEX_TEST For an I4VEC: 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_AMINZ_INDEX_TEST For an I4VEC: 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 I4VEC_ASCEND_SUB computes a longest ascending subsequence of an I4VEC. 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_ASCENDS_TEST I4VEC_ASCENDS determines if an I4VEC ascends. Test vector: 1: 1 2: 3 3: 2 4: 4 I4VEC_ASCENDS = F Test vector: 1: 2 2: 2 3: 2 4: 2 I4VEC_ASCENDS = T Test vector: 1: 1 2: 2 3: 2 4: 4 I4VEC_ASCENDS = T Test vector: 1: 1 2: 2 3: 3 4: 4 I4VEC_ASCENDS = T Test vector: 1: 4 2: 4 3: 3 4: 1 I4VEC_ASCENDS = F Test vector: 1: 9 2: 7 3: 3 4: 0 I4VEC_ASCENDS = F I4VEC_BRACKET_TEST I4VEC_BRACKET finds a pair of entries in a sorted I4VEC which bracket a value. Sorted array: 1: 2 2: 4 3: 6 4: 8 5: 10 6: 10 7: 14 8: 16 9: 18 10: 20 Search for AVAL = -10 Left = -1 Right = 1 A(RIGHT) = 2 Search for AVAL = 2 Left = 1 Right = 1 A(LEFT)= 2 A(RIGHT) = 2 Search for AVAL = 9 Left = 4 Right = 5 A(LEFT)= 8 A(RIGHT) = 10 Search for AVAL = 10 Left = 5 Right = 5 A(LEFT)= 10 A(RIGHT) = 10 Search for AVAL = 20 Left = 10 Right = 10 A(LEFT)= 20 A(RIGHT) = 20 Search for AVAL = 24 Left = 10 Right = -1 A(LEFT)= 20 I4VEC_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 I4VEC: I4VEC_CUM: cumulative sum; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 Cumulative sums: 1: -6 2: 4 3: 11 4: 12 5: 10 6: 1 7: -4 8: -12 9: -22 10: -19 I4VEC_CUM0_TEST For an I4VEC: I4VEC_CUM0: cumulative sum, zero based; Input vector: 1: -6 2: 10 3: 7 4: 1 5: -2 6: -9 7: -5 8: -8 9: -10 10: 3 0-based Cumulative sums: 1: 0 2: -6 3: 4 4: 11 5: 12 6: 10 7: 1 8: -4 9: -12 10: -22 11: -19 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_DESCENDS_TEST I4VEC_DESCENDS determines if an I4VEC descends. Test vector: 1: 1 2: 3 3: 2 4: 4 I4VEC_DESCENDS = F Test vector: 1: 2 2: 2 3: 2 4: 2 I4VEC_DESCENDS = T Test vector: 1: 1 2: 2 3: 2 4: 4 I4VEC_DESCENDS = F Test vector: 1: 1 2: 2 3: 3 4: 4 I4VEC_DESCENDS = F Test vector: 1: 4 2: 4 3: 3 4: 1 I4VEC_DESCENDS = T Test vector: 1: 9 2: 7 3: 3 4: 0 I4VEC_DESCENDS = T I4VEC_DIRECT_PRODUCT_TEST I4VEC_DIRECT_PRODUCT forms the entries of a direct product of a given number of I4VEC factors. J X(1) X(2) X(3) 1 1 50 800 2 2 50 800 3 3 50 800 4 4 50 800 5 1 60 800 6 2 60 800 7 3 60 800 8 4 60 800 9 1 70 800 10 2 70 800 11 3 70 800 12 4 70 800 13 1 50 900 14 2 50 900 15 3 50 900 16 4 50 900 17 1 60 900 18 2 60 900 19 3 60 900 20 4 60 900 21 1 70 900 22 2 70 900 23 3 70 900 24 4 70 900 I4VEC_DIRECT_PRODUCT2_TEST I4VEC_DIRECT_PRODUCT2 forms the entries of a direct product of a given number of I4VEC factors. Product W: 1: 418 2: 627 3: 1045 4: 1463 5: 494 6: 741 7: 1235 8: 1729 9: 646 10: 969 11: 1615 12: 2261 13: 462 14: 693 15: 1155 16: 1617 17: 546 18: 819 19: 1365 20: 1911 21: 714 22: 1071 23: 1785 24: 2499 I4VEC_FRAC_TEST I4VEC_FRAC: K-th smallest entry. Using initial random number seed = 2261 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_HEAP_A_TEST For an I4VEC, I4VEC_HEAP_A: ascending heap form. Using initial random number seed = 3 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 I4VEC, I4VEC_HEAP_D: descending heap form. Using initial random number seed = 1361431000 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_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_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 I4VEC: 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 0 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_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: 1 2: 11 3: 17 4: 5 5: 9 6: 13 7: 15 8: 3 9: 19 10: 9 A(INDX) is now a descending heap: 1 101 2 111 3 117 4 105 5 109 6 113 7 115 8 103 9 119 10 109 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: 9 2: 14 3: 8 4: 14 5: 5 A(INDX) after heaping: 1 9 2 14 3 8 4 14 5 5 Inserting value 7 Current maximum is 9 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: 9 4: 14 5: 15 6: 7 7: 8 8: 1 9: 14 10: 5 A(INDX) after insertions: 1 20 2 19 3 9 4 14 5 15 6 7 7 8 8 1 9 14 10 5 Now extract the maximum several times. Extracting maximum element A( 20) = 20 Extracting maximum element A( 5) = 5 Extracting maximum element A( 14) = 14 Extracting maximum element A( 1) = 1 Extracting maximum element A( 8) = 8 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: 7 2: 19 3: 9 4: 14 5: 15 A(INDX) after extractions: 1 7 2 19 3 9 4 14 5 15 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: 9 2: 14 3: 8 4: 14 5: 5 A(INDX) after heaping: 1 9 2 14 3 8 4 14 5 5 Inserting value 7 Inserting value 15 Inserting value 1 Inserting value 19 Inserting value 20 The data vector after insertions: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 11: 11 12: 12 13: 13 14: 14 15: 15 16: 16 17: 17 18: 18 19: 19 20: 20 The index vector after insertions: 1: 20 2: 19 3: 9 4: 14 5: 15 6: 7 7: 8 8: 1 9: 14 10: 5 A(INDX) after insertions: 1 20 2 19 3 9 4 14 5 15 6 7 7 8 8 1 9 14 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: 9 2: 14 3: 8 4: 14 5: 5 A(INDX) after heaping: 1 9 2 14 3 8 4 14 5 5 Inserting value 7 Current maximum is 9 Inserting value 15 Current maximum is 15 Inserting value 1 Current maximum is 15 Inserting value 19 Current maximum is 19 Inserting value 20 Current maximum is 20 I4VEC_INDICATOR0_TEST I4VEC_INDICATOR0 returns 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_INSERT_TEST I4VEC_INSERT inserts a value into a vector. We use these two routines to bracket a value, and then insert it. Sorted array: 1: 2 2: 4 3: 6 4: 8 5: 10 6: 10 7: 14 8: 16 9: 18 10: 20 Search for AVAL = -10 Left = -1 Right = 1 A(RIGHT) = 2 Sorted, augmented array: 1: -10 2: 2 3: 4 4: 6 5: 8 6: 10 7: 10 8: 14 9: 16 10: 18 11: 20 Search for AVAL = 2 Left = 2 Right = 2 A(LEFT)= 2 A(RIGHT) = 2 No insertion necessary. Search for AVAL = 9 Left = 5 Right = 6 A(LEFT)= 8 A(RIGHT) = 10 Sorted, augmented array: 1: -10 2: 2 3: 4 4: 6 5: 8 6: 9 7: 10 8: 10 9: 14 10: 16 11: 18 12: 20 Search for AVAL = 10 Left = 7 Right = 7 A(LEFT)= 10 A(RIGHT) = 10 No insertion necessary. Search for AVAL = 20 Left = 12 Right = 12 A(LEFT)= 20 A(RIGHT) = 20 No insertion necessary. Search for AVAL = 24 Left = 12 Right = -1 A(LEFT)= 20 Sorted, augmented array: 1: -10 2: 2 3: 4 4: 6 5: 8 6: 9 7: 10 8: 10 9: 14 10: 16 11: 18 12: 20 13: 24 I4VEC_MAX_TEST For an I4VEC: 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 I4VEC: 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 I4VEC: 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_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.90000 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 I4VEC_MERGE_A merges two ascending-sorted I4VECs; 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 For an I4VEC: I4VEC_MIN: minimum entry; 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 For an I4VEC: 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 I4VEC: I4VEC_NONZERO_COUNT: number of nonzeroes; Input vector: 1: -2 2: 4 3: 3 4: 1 5: 0 6: -3 7: -1 8: -3 9: -3 10: 2 11: -3 12: 0 13: 0 14: 3 15: 3 Number of nonzeroes : 12 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_PAIRWISE_PRIME_TEST I4VEC_PAIRWISE_PRIME determines if an I4VEC is pairwise prime. Pairwise Row Vector Prime? 1 3 2 4 F 2 2 2 2 F 5 7 12 29 T 1 13 1 11 T 1 4 9 16 F 6 35 13 77 F I4VEC_PART_TEST I4VEC_PART partitions an integer. NVAL = 17 Partitioned: 1: 4 2: 4 3: 3 4: 3 5: 3 NVAL = -49 Partitioned: 1: -10 2: -10 3: -10 4: -10 5: -9 I4VEC_PART_QUICK_A_TEST I4VEC_PART_QUICK_A reorders an I4VEC as part of a quick sort. Using initial random number seed = 2 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 = 0 Key index = 1 Right index = 2 Left half: Key: 1: 2 Right half: 1: 12 2: 12 3: 12 4: 12 5: 12 6: 12 7: 12 8: 12 9: 12 10: 12 11: 12 I4VEC_PERMUTE_TEST I4VEC_PERMUTE reorders an I4VEC according to a given permutation. Using initial random number seed = 9 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_PRINT_TEST I4VEC_PRINT prints an I4VEC The I4VEC: 1: 91 2: 92 3: 93 4: 94 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 Re-reversed array using a(1:n) = a(n:1:-1): 1: 6 2: 29 3: 25 4: 17 5: 12 6: 2 7: 7 8: 3 9: 1 10: 19 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 For ascending order: I4VEC_SEARCH_BINARY_A searchs an I4VEC for a value; Input vector A: 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 Search the array A for the value 4 SEARCH RESULT: The value occurs in index 8 I4VEC_SORT_BUBBLE_A_TEST For an I4VEC, 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 I4VEC_SORT_HEAP_A ascending sorts an I4VEC, 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 I4VEC_SORT_HEAP_D descending sorts an I4VEC. 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 Now use the index array to carry out the permutation implicitly. 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 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: 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 Now use the index array to carry out the permutation implicitly. 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_QUICK_A_TEST I4VEC_SORT_QUICK_A sorts an I4VEC 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: 13 2: 58 3: 58 4: 58 5: 58 6: 58 7: 58 8: 58 9: 58 10: 58 11: 58 12: 58 13: 58 14: 58 15: 58 16: 58 17: 58 18: 58 19: 58 20: 58 I4VEC_SORT_SHELL_A_TEST I4VEC_SORT_SHELL_A sorts an I4VEC 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_UNIQUE_HIST_TEST For an I4VEC, I4VEC_SORTED_UNIQUE_HIST makes a histogram of unique entries. 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_UNIQ3 counts 19 unique entries. Value and Multiplicity 1: 0 2 2: 2 1 3: 3 1 4: 4 1 5: 5 1 6: 6 1 7: 13 1 8: 15 1 9: 21 1 10: 24 1 11: 25 1 12: 27 1 13: 34 1 14: 38 1 15: 46 1 16: 48 1 17: 50 1 18: 54 1 19: 58 1 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_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 I4VEC_TRANSPOSE_PRINT_TEST I4VEC_TRANSPOSE_PRINT prints an I4VEC with 5 entries to a row, and an optional title. Output from I4VEC_PRINT: 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 7: 7 8: 8 9: 9 10: 10 11: 11 12: 12 Call I4VEC_TRANSPOSE_PRINT with a short title: My array: 1 2 3 4 5 6 7 8 9 10 11 12 I4VEC_UNDEX_TEST I4VEC_UNDEX produces index vectors which create a sorted list of the unique elements of an (unsorted) I4VEC, and a map from the original vector to the (implicit) vector of sorted unique elements. The vector X: 1: 33 2: 55 3: 11 4: 11 5: 55 6: 33 7: 22 8: 22 9: 11 Number of unique entries in X is 4 UNDX can be used to list the unique elements of X in sorted order. I UNDX X(UNDX) 1 3 11 2 7 22 3 6 33 4 5 55 UNDX can be used to created XU, a copy of X containing only the unique elements, in sorted order. I UNDX XU(I) 1 3 11 2 7 22 3 6 33 4 5 55 XDNU can be used to match each element of X with one of the unique elements I XDNU X(I) XU(XDNU(I)) 1 3 33 33 2 4 55 55 3 1 11 11 4 1 11 11 5 4 55 55 6 3 33 33 7 2 22 22 8 2 22 22 9 1 11 11 I4VEC_UNIFORM_AB_TEST I4VEC_UNIFORM_AB computes pseudorandom values in an interval [A,B]. The lower endpoint A = -100 The upper endpoint B = 200 The 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_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 3 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 I4VEC: 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.1000 I4VEC2_SORT_A_TEST For a pair of I4VECs: 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 I4VECs: 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 I4VECs: 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 UNIQ: 1: 1 1 2: 1 2 3: 1 3 4: 2 1 5: 2 3 6: 3 2 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 PERM_UNIFORM_TEST PERM_UNIFORM randomly selects a permutation. 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 PRIME_TEST PRIME returns primes from a table. Number of primes stored is 1600 I Prime(I) 1 2 2 3 3 5 4 7 5 11 6 13 7 17 8 19 9 23 10 29 1590 13411 1591 13417 1592 13421 1593 13441 1594 13451 1595 13457 1596 13463 1597 13469 1598 13477 1599 13487 1600 13499 TRIANGLE_LOWER_TO_I4_TEST TRIANGLE_LOWER_TO_I4 converts a lower triangular index to a linear one. I, J => K 1 1 1 2 1 2 2 2 3 3 1 4 3 2 5 3 3 6 4 1 7 4 2 8 4 3 9 4 4 10 I4LIB_PRB Normal end of execution. 22 March 2017 9:13:43.866 PM