30 January 2011 11:28:50.978 AM BINS_PRB FORTRAN77 version Test the BINS library. TEST01 R8_TO_BIN_EVEN puts a number into a bin. BIN_TO_R8_EVEN returns the bin limits. The bins are equally spaced between A and B, with two extra bins, for things less than A, or greater than B. A = 10.0000 B = 20.0000 Total number of bins = 7 Using random seed = 1340724296 Generate some random values C and put them in bins. C Bin Bin_Min Bin_Max 8.05123 1 -0.100000E+31 10.0000 14.0847 4 14.0000 16.0000 17.8068 5 16.0000 18.0000 11.5006 2 10.0000 12.0000 12.6694 3 12.0000 14.0000 22.1369 7 20.0000 0.100000E+31 22.3214 7 20.0000 0.100000E+31 17.0377 5 16.0000 18.0000 15.3593 4 14.0000 16.0000 21.2970 7 20.0000 0.100000E+31 20.8569 7 20.0000 0.100000E+31 19.5752 6 18.0000 20.0000 18.0035 6 18.0000 20.0000 16.2225 5 16.0000 18.0000 8.12120 1 -0.100000E+31 10.0000 20.0052 7 20.0000 0.100000E+31 15.1669 4 14.0000 16.0000 12.3263 3 12.0000 14.0000 14.5061 4 14.0000 16.0000 20.6021 7 20.0000 0.100000E+31 10.9223 2 10.0000 12.0000 12.3730 3 12.0000 14.0000 20.8200 7 20.0000 0.100000E+31 13.5000 3 12.0000 14.0000 16.6342 5 16.0000 18.0000 13.5704 3 12.0000 14.0000 14.2647 4 14.0000 16.0000 13.5377 3 12.0000 14.0000 20.7573 7 20.0000 0.100000E+31 9.47848 1 -0.100000E+31 10.0000 TEST02 BIN_TO_R8_EVEN2 returns the bin limits. R8_TO_BIN_EVEN2 puts a number into a bin. The bins are equally spaced between A and B. A = 10.0000 B = 20.0000 Total number of bins = 5 Using random seed = 1341082568 Generate some random values C and put them in bins. C Bin Bin_Min Bin_Max 20.1108 5 18.0000 20.0000 18.6812 5 18.0000 20.0000 21.2567 5 18.0000 20.0000 19.0016 5 18.0000 20.0000 21.4247 5 18.0000 20.0000 21.3210 5 18.0000 20.0000 18.8525 5 18.0000 20.0000 20.3354 5 18.0000 20.0000 13.5880 2 12.0000 14.0000 10.6952 1 10.0000 12.0000 21.7015 5 18.0000 20.0000 9.71204 1 10.0000 12.0000 12.2507 2 12.0000 14.0000 19.5102 5 18.0000 20.0000 20.2249 5 18.0000 20.0000 16.2202 4 16.0000 18.0000 15.6489 3 14.0000 16.0000 12.9948 2 12.0000 14.0000 15.8865 3 14.0000 16.0000 16.1339 4 16.0000 18.0000 18.9479 5 18.0000 20.0000 18.8711 5 18.0000 20.0000 18.4168 5 18.0000 20.0000 18.6576 5 18.0000 20.0000 15.1972 3 14.0000 16.0000 10.9754 1 10.0000 12.0000 20.9448 5 18.0000 20.0000 11.3546 1 10.0000 12.0000 19.5809 5 18.0000 20.0000 8.82828 1 10.0000 12.0000 TEST03 BIN_TO_R82_EVEN returns the bin limits. R82_TO_BIN_EVEN puts a R82 number into a bin. The bins are equally spaced between A and B, with two extra bins, for things less than A, or greater than B. A(1) = 5.00000 B(1) = 15.0000 A(2) = 0.00000 B(2) = 20.0000 Total number of bins = 7 Generate some random values C and put them in bins. We list the X and Y components on separate lines. C Bin Bin_Min Bin_Max 19.1477 7 15.0000 0.100000E+31 14.3778 5 12.0000 16.0000 20.6757 7 15.0000 0.100000E+31 14.8691 5 12.0000 16.0000 20.8996 7 15.0000 0.100000E+31 18.4255 6 16.0000 20.0000 17.4699 7 15.0000 0.100000E+31 16.9142 6 16.0000 20.0000 10.4507 4 9.00000 11.0000 2.13268 2 0.00000 4.00000 21.2687 7 15.0000 0.100000E+31 0.625127 2 0.00000 4.00000 8.66760 3 7.00000 9.00000 15.6490 5 12.0000 16.0000 19.2998 7 15.0000 0.100000E+31 10.6044 4 8.00000 12.0000 13.1985 6 13.0000 15.0000 5.65872 3 4.00000 8.00000 13.5153 6 13.0000 15.0000 10.4719 4 8.00000 12.0000 17.5972 7 15.0000 0.100000E+31 14.6690 5 12.0000 16.0000 16.8891 7 15.0000 0.100000E+31 14.3416 5 12.0000 16.0000 12.5962 5 11.0000 13.0000 2.56232 2 0.00000 4.00000 20.2597 7 15.0000 0.100000E+31 3.14379 2 0.00000 4.00000 18.4413 7 15.0000 0.100000E+31 -0.729975 1 -0.100000E+31 0.00000 4.13927 1 -0.100000E+31 5.00000 6.87693 3 4.00000 8.00000 17.4487 7 15.0000 0.100000E+31 19.4345 6 16.0000 20.0000 3.76026 1 -0.100000E+31 5.00000 18.3318 6 16.0000 20.0000 7.76940 3 7.00000 9.00000 20.1228 7 20.0000 0.100000E+31 22.5201 7 15.0000 0.100000E+31 14.7079 5 12.0000 16.0000 4.93732 1 -0.100000E+31 5.00000 -1.42105 1 -0.100000E+31 0.00000 4.28018 1 -0.100000E+31 5.00000 16.3545 6 16.0000 20.0000 9.60387 4 9.00000 11.0000 10.9291 4 8.00000 12.0000 18.7850 7 15.0000 0.100000E+31 19.1095 6 16.0000 20.0000 13.9461 6 13.0000 15.0000 11.6862 4 8.00000 12.0000 4.45562 1 -0.100000E+31 5.00000 3.23596 2 0.00000 4.00000 5.45535 2 5.00000 7.00000 6.16165 3 4.00000 8.00000 3.81029 1 -0.100000E+31 5.00000 19.2448 6 16.0000 20.0000 10.7336 4 9.00000 11.0000 19.9022 6 16.0000 20.0000 18.9778 7 15.0000 0.100000E+31 19.0844 6 16.0000 20.0000 TEST04 R82VEC_BIN_EVEN constructs evenly spaced bins and assigns each element of a R82VEC to a bin. R82VEC_BINNED_REORDER can reorder the array to correspond to the bin ordering. R82VEC_BINNED_SORT_A can sort the individual bins after the array has been reordered. The bins are equally spaced between BIN_MIN and BIN_MAX, with two extra bins, for things less than BIN_MIN, or greater than BIN_MAX. Component 1 range: 10.0000 20.0000 Component 2 range: 5.00000 10.0000 Number of bins per row and column = 4 The data vector A to be binned: 1 20.1108 3.51267 2 18.6812 6.47358 3 21.2567 9.50190 4 19.0016 11.3874 5 21.4247 3.34212 6 21.3210 10.9559 7 18.8525 5.14623 8 20.3354 11.6567 9 13.5880 11.7841 10 10.6952 9.53786 11 21.7015 3.87179 12 9.71204 3.22655 13 12.2507 3.57608 14 19.5102 10.1822 15 20.2249 5.97174 16 16.2202 8.05921 17 15.6489 10.1032 18 12.9948 11.2602 19 15.8865 7.92577 20 16.1339 8.35549 21 18.9479 3.65503 22 18.8711 5.04885 23 18.4168 4.10491 24 18.6576 6.19369 25 15.1972 3.36463 26 10.9754 11.3132 27 20.9448 6.48013 28 11.3546 11.5704 29 19.5809 10.1900 30 8.82828 11.2504 The BIN_START array: Col 1 2 3 4 Row 1 12 -1 -1 30 2 13 -1 10 9 3 21 2 16 4 4 1 15 3 6 The BIN_LAST array: Col 1 2 3 4 Row 1 12 -1 -1 30 2 13 -1 10 9 3 21 2 16 4 4 1 15 3 6 The BIN_NEXT array: 1 5 2 7 3 0 4 14 5 11 6 8 7 22 8 0 9 18 10 0 11 0 12 0 13 0 14 17 15 27 16 19 17 29 18 26 19 20 20 0 21 23 22 24 23 25 24 0 25 0 26 28 27 0 28 0 29 0 30 0 Contents of bin number 1 1 1 12 9.71204 3.22655 Contents of bin number 1 2 Contents of bin number 1 3 Contents of bin number 1 4 1 30 8.82828 11.2504 Contents of bin number 2 1 1 13 12.2507 3.57608 Contents of bin number 2 2 Contents of bin number 2 3 1 10 10.6952 9.53786 Contents of bin number 2 4 1 9 13.5880 11.7841 2 18 12.9948 11.2602 3 26 10.9754 11.3132 4 28 11.3546 11.5704 Contents of bin number 3 1 1 21 18.9479 3.65503 2 23 18.4168 4.10491 3 25 15.1972 3.36463 Contents of bin number 3 2 1 2 18.6812 6.47358 2 7 18.8525 5.14623 3 22 18.8711 5.04885 4 24 18.6576 6.19369 Contents of bin number 3 3 1 16 16.2202 8.05921 2 19 15.8865 7.92577 3 20 16.1339 8.35549 Contents of bin number 3 4 1 4 19.0016 11.3874 2 14 19.5102 10.1822 3 17 15.6489 10.1032 4 29 19.5809 10.1900 Contents of bin number 4 1 1 1 20.1108 3.51267 2 5 21.4247 3.34212 3 11 21.7015 3.87179 Contents of bin number 4 2 1 15 20.2249 5.97174 2 27 20.9448 6.48013 Contents of bin number 4 3 1 3 21.2567 9.50190 Contents of bin number 4 4 1 6 21.3210 10.9559 2 8 20.3354 11.6567 Call R82VEC_BINNED_REORDER to reorder the array. The data vector, sorted by bins: 1 9.71204 3.22655 2 8.82828 11.2504 3 12.2507 3.57608 4 10.6952 9.53786 5 13.5880 11.7841 6 12.9948 11.2602 7 10.9754 11.3132 8 11.3546 11.5704 9 18.9479 3.65503 10 18.4168 4.10491 11 15.1972 3.36463 12 18.6812 6.47358 13 18.8525 5.14623 14 18.8711 5.04885 15 18.6576 6.19369 16 16.2202 8.05921 17 15.8865 7.92577 18 16.1339 8.35549 19 19.0016 11.3874 20 19.5102 10.1822 21 15.6489 10.1032 22 19.5809 10.1900 23 20.1108 3.51267 24 21.4247 3.34212 25 21.7015 3.87179 26 20.2249 5.97174 27 20.9448 6.48013 28 21.2567 9.50190 29 21.3210 10.9559 30 20.3354 11.6567 The BIN_START array: Col 1 2 3 4 Row 1 1 -1 -1 2 2 3 -1 4 5 3 9 12 16 19 4 23 26 28 29 The BIN_LAST array: Col 1 2 3 4 Row 1 1 -1 -1 2 2 3 -1 4 8 3 11 15 18 22 4 25 27 28 30 The BIN_NEXT array: 1 0 2 0 3 0 4 0 5 6 6 7 7 8 8 0 9 10 10 11 11 0 12 13 13 14 14 15 15 0 16 17 17 18 18 0 19 20 20 21 21 22 22 0 23 24 24 25 25 0 26 27 27 0 28 0 29 30 30 0 The data vector, with sorted bins: 1 9.71204 3.22655 2 8.82828 11.2504 3 12.2507 3.57608 4 10.6952 9.53786 5 10.9754 11.3132 6 11.3546 11.5704 7 12.9948 11.2602 8 13.5880 11.7841 9 15.1972 3.36463 10 18.4168 4.10491 11 18.9479 3.65503 12 18.6576 6.19369 13 18.6812 6.47358 14 18.8525 5.14623 15 18.8711 5.04885 16 15.8865 7.92577 17 16.1339 8.35549 18 16.2202 8.05921 19 15.6489 10.1032 20 19.0016 11.3874 21 19.5102 10.1822 22 19.5809 10.1900 23 20.1108 3.51267 24 21.4247 3.34212 25 21.7015 3.87179 26 20.2249 5.97174 27 20.9448 6.48013 28 21.2567 9.50190 29 20.3354 11.6567 30 21.3210 10.9559 TEST05 R82VEC_PART_QUICK_A reorders an R82VEC as part of a quick sort. Using initial random number seed = 123456789 Before rearrangment: 1 2.18418 2.40131 2 9.56318 2.75467 3 8.29509 2.79729 4 5.61695 2.00184 5 4.15307 2.89750 6 0.661187 2.35075 7 2.57578 2.09454 8 1.09957 2.01362 9 0.438290 2.85910 10 6.33966 2.84085 11 0.617272 2.12310 12 4.49539 2.00751 Rearranged array Left index = 4 Key index = 5 Right index = 6 Left half: 1 0.617272 2.12310 2 0.438290 2.85910 3 1.09957 2.01362 4 0.661187 2.35075 Key: 1 2.18418 2.40131 Right half: 1 2.57578 2.09454 2 4.15307 2.89750 3 5.61695 2.00184 4 6.33966 2.84085 5 8.29509 2.79729 6 4.49539 2.00751 7 9.56318 2.75467 TEST09 R8VEC_BIN computes bins for an R8VEC. The vector to be binned: 1 5.9476974 2 -0.49366219E-01 3 9.3019574 4 6.9979859 5 -1.8514497 6 -1.3158202 7 5.0106726 8 7.3738406 9 10.138650 10 3.2986608 11 2.5921752 12 10.688076 13 7.5007601 14 -1.7256631 15 6.7797186 16 8.7299799 17 0.77170276 18 3.0083308 19 -1.9842895 20 2.0458661 21 6.8710050 22 8.9812936 23 -0.39811970 24 10.802165 25 0.99227583 Number of bins is 5 Bin minimum is 0.00000 Bin maximum is 10.0000 Lower Limit Upper Limit Count 0.0000 0.0000 6 0.0000 2.0000 2 2.0000 4.0000 4 4.0000 6.0000 2 6.0000 8.0000 5 8.0000 10.0000 3 10.0000 3 TEST10 R8VEC_BIN_EVEN constructs evenly spaced bins and assigns each element of a DVEC to a bin. R8VEC_BINNED_REORDER can reorder the array to correspond to the bin ordering. R8VEC_BINNED_SORT_A can sort the array once it has been reordered. The bins are equally spaced between BIN_MIN and BIN_MAX, with two extra bins, for things less than BIN_MIN, or greater than BIN_MAX. BIN_MIN = 10.0000 BIN_MAX = 20.0000 Total number of bins = 7 The data vector A to be binned: 1 17.170420 2 10.250731 3 21.040720 4 18.382291 5 8.1714041 6 8.7894383 7 16.089238 8 18.815970 9 22.006135 10 14.113839 11 13.298664 12 22.640088 13 18.962415 14 8.3165425 15 18.130445 16 20.380746 17 11.198119 18 13.778843 19 8.0181275 20 12.668307 21 18.235775 22 20.670723 23 9.8483234 24 22.771729 25 11.452626 26 16.284406 27 14.004402 28 18.980344 29 9.6445943 30 18.695929 The BIN_START array: 1 5 2 2 3 11 4 10 5 1 6 4 7 3 The BIN_LAST array: 1 29 2 25 3 20 4 27 5 26 6 30 7 24 The BIN_NEXT array: 1 7 2 17 3 9 4 8 5 6 6 14 7 26 8 13 9 12 10 27 11 18 12 16 13 15 14 19 15 21 16 22 17 25 18 20 19 23 20 0 21 28 22 24 23 29 24 0 25 0 26 0 27 0 28 30 29 0 30 0 Contents of bin number 1 1 5 8.17140 2 6 8.78944 3 14 8.31654 4 19 8.01813 5 23 9.84832 6 29 9.64459 Contents of bin number 2 1 2 10.2507 2 17 11.1981 3 25 11.4526 Contents of bin number 3 1 11 13.2987 2 18 13.7788 3 20 12.6683 Contents of bin number 4 1 10 14.1138 2 27 14.0044 Contents of bin number 5 1 1 17.1704 2 7 16.0892 3 26 16.2844 Contents of bin number 6 1 4 18.3823 2 8 18.8160 3 13 18.9624 4 15 18.1304 5 21 18.2358 6 28 18.9803 7 30 18.6959 Contents of bin number 7 1 3 21.0407 2 9 22.0061 3 12 22.6401 4 16 20.3807 5 22 20.6707 6 24 22.7717 Call R8VEC_BINNED_REORDER to reorder the array. The data vector A: 1 8.1714041 2 8.7894383 3 8.3165425 4 8.0181275 5 9.8483234 6 9.6445943 7 10.250731 8 11.198119 9 11.452626 10 13.298664 11 13.778843 12 12.668307 13 14.113839 14 14.004402 15 17.170420 16 16.089238 17 16.284406 18 18.382291 19 18.815970 20 18.962415 21 18.130445 22 18.235775 23 18.980344 24 18.695929 25 21.040720 26 22.006135 27 22.640088 28 20.380746 29 20.670723 30 22.771729 The BIN_START array: 1 1 2 7 3 10 4 13 5 15 6 18 7 25 The BIN_LAST array: 1 6 2 9 3 12 4 14 5 17 6 24 7 30 The BIN_NEXT array: 1 2 2 3 3 4 4 5 5 6 6 0 7 8 8 9 9 0 10 11 11 12 12 0 13 14 14 0 15 16 16 17 17 0 18 19 19 20 20 21 21 22 22 23 23 24 24 0 25 26 26 27 27 28 28 29 29 30 30 0 The sorted data vector A: 1 8.0181275 2 8.1714041 3 8.3165425 4 8.7894383 5 9.6445943 6 9.8483234 7 10.250731 8 11.198119 9 11.452626 10 12.668307 11 13.298664 12 13.778843 13 14.004402 14 14.113839 15 16.089238 16 16.284406 17 17.170420 18 18.130445 19 18.235775 20 18.382291 21 18.695929 22 18.815970 23 18.962415 24 18.980344 25 20.380746 26 20.670723 27 21.040720 28 22.006135 29 22.640088 30 22.771729 BINS_PRB Normal end of execution. 30 January 2011 11:28:50.981 AM