30-Jul-2021 15:31:24 subpak_test(): MATLAB/Octave version 9.9.0.1467703 (R2020b) Test subpak() ANGLES_SHIFT_TEST ANGLE_SHIFT shifts an angle by multiples of 2 Pi until it lies between BETA and BETA+2Pi. ALPHA BETA GAMMA BETA+2Pi 7.909869 10.198664 14.193054 16.481849 -9.374844 10.389268 15.757897 16.672454 3.326551 -10.114913 -9.239820 -3.831728 -5.566947 1.178261 6.999424 7.461446 11.498401 11.683923 17.781586 17.967109 -8.605122 11.827287 16.527619 18.110472 11.489859 -0.367550 5.206673 5.915635 7.546871 -9.000378 -5.019499 -2.717193 -1.966353 10.448573 10.600017 16.731759 7.343971 11.548304 13.627157 17.831490 ANGLE_SHIFT_DEG_TEST ANGLE_SHIFT_DEG shifts an angle by multiples of 360 until it lies between BETA and BETA+360. ALPHA BETA GAMMA BETA+360 224.266607 -668.575183 -495.733393 -308.575183 502.746200 624.950277 862.746200 984.950277 257.378623 371.145788 617.378623 731.145788 350.110754 -155.193092 -9.889246 204.806908 223.888162 -473.491170 -136.111838 -113.491170 296.706367 -674.160701 -423.293633 -314.160701 -321.230902 -653.513197 -321.230902 -293.513197 -580.130235 465.779273 499.869765 825.779273 280.553217 -263.376749 -79.446783 96.623251 648.319750 -670.397644 -431.680250 -310.397644 SUBPAK_TEST03 ANGLE_TO_RGB converts an angle into an RGB color. ANGLE R G B 157.947969 0.000000 1.000000 0.542074 137.361045 0.000000 1.000000 0.231250 275.586044 0.502719 0.000000 1.000000 286.271964 0.692535 0.000000 1.000000 67.274138 0.825639 1.000000 0.000000 176.315182 0.000000 1.000000 0.907903 160.411032 0.000000 1.000000 0.584547 232.672684 0.000000 0.096210 1.000000 255.371339 0.203970 0.000000 1.000000 271.687206 0.440331 0.000000 1.000000 TEST04 AXIS_LIMITS adjusts plot limits to "nicer" values. Input XMIN = 67.300000 Input XMAX = 114.700000 Input NDIVS = 6 Output PXMIN = 60.000000 Output PXMAX = 120.000000 Output PXDIV = 10.000000 Output NTICKS = 5 Input XMIN = -26.000000 Input XMAX = 26.000000 Input NDIVS = 10 Output PXMIN = -50.000000 Output PXMAX = 50.000000 Output PXDIV = 10.000000 Output NTICKS = 5 SUBPAK_TEST05 AXIS_LIMITS computes "nice" limits for a graph that must include a given range. All tests use NDIVS = 5 XMIN XMAX PXMIN PXMAX PXDIV NTICKS 1.000000 9.000000 0.000000 10.000000 2.000000 4 1.003000 4.125000 1.000000 6.000000 1.000000 5 101.250000 193.750000 100.000000 200.000000 20.000000 4 2000.125000 2000.250000 2000.120000 2000.320000 0.040000 4 -7.000000 12.000000 -20.000000 30.000000 10.000000 5 TEST06 BAR_CHECK checks digits for a barcode; BAR_CODE computes the barcode for a string of 11 digits; BAR_DIGIT_CODE_LEFT returns the left digit code. BAR_DIGIT_CODE_RIGHT returns the right digit code. The check digit is 5 The left and right digit codes: 0 0001101 1110010 1 0011001 1100110 2 0010011 1101100 3 0111101 1000010 4 0100011 1011100 5 0110001 1001110 6 0101111 1010000 7 0111011 1000100 8 0110111 1001000 9 0001011 1110100 Bar code: 000000000 101 0001101 0011001 0010011 0111101 0100011 0110001 01010 1010000 1000100 1001000 1110100 1110010 1001110 101 000000000 TEST07 BMI_ENGLISH computes the Body Mass Index given body measurements in English Units. Weight Height BMI (LB) (FT IN) 141.403762 6.000000 -2.000000 20.289120 198.264701 4.000000 5.000000 49.624026 117.849652 5.000000 4.000000 20.228640 243.961594 5.000000 -1.000000 49.273768 187.790163 5.000000 -5.000000 43.646135 212.690059 5.000000 -4.000000 47.683648 175.893558 6.000000 -1.000000 24.531922 233.635488 7.000000 -4.000000 25.665940 182.082329 4.000000 5.000000 45.573711 122.394101 5.000000 -4.000000 27.439915 TEST08 For products of prime factors: FAC_DIV computes a quotient; FAC_MUL multiplies; FAC_LCM computes the LCM; FAC_GCD computes the GCD; I4_TO_FAC converts an integer; FAC_TO_I4 converts to an integer. FAC_TO_RAT converts to a ratio. Representation of I1 = 720 Prime Power 2 4 3 2 5 1 Representation of I2 = 42 Prime Power 2 1 3 1 7 1 LCM of I1, I2: Prime Power 2 4 3 2 5 1 7 1 GCD of I1, I2: Prime Power 2 1 3 1 Product of I1, I2: Prime Power 2 5 3 3 5 1 7 1 Quotient of I2 / I1: Prime Power 2 -3 3 -1 5 -1 7 1 Quotient as a rational: 7 / 120 TEST09 GAUSS_SUM evaluates a function which is the sum of Gaussian functions. Number of component Gaussians = 3 Center Amplitude Width X Y 1 2.000000 3.000000 10.000000 1.000000 2 5.000000 8.000000 5.000000 2.000000 3 7.000000 5.000000 -3.000000 4.000000 X Y Gauss_Sum(X,Y) 0.000000 0.000000 -0.029388 0.000000 1.000000 -0.048263 0.000000 2.000000 -0.012567 0.000000 3.000000 0.073900 0.000000 4.000000 -0.064255 0.000000 5.000000 -0.135940 0.000000 6.000000 -0.128237 0.000000 7.000000 -0.101758 0.000000 8.000000 -0.070295 0.000000 9.000000 -0.044101 0.000000 10.000000 -0.025860 1.000000 0.000000 -0.065825 1.000000 1.000000 -0.048943 1.000000 2.000000 1.173200 1.000000 3.000000 3.432716 1.000000 4.000000 1.057990 1.000000 5.000000 -0.239166 1.000000 6.000000 -0.262896 1.000000 7.000000 -0.174933 1.000000 8.000000 -0.088586 1.000000 9.000000 -0.045001 1.000000 10.000000 -0.032589 2.000000 0.000000 -0.130577 2.000000 1.000000 -0.048176 2.000000 2.000000 3.320561 2.000000 3.000000 9.511281 2.000000 4.000000 3.097712 2.000000 5.000000 -0.390133 2.000000 6.000000 -0.395630 2.000000 7.000000 -0.079310 2.000000 8.000000 0.168697 2.000000 9.000000 0.179090 2.000000 10.000000 0.062060 3.000000 0.000000 -0.230881 3.000000 1.000000 -0.338618 3.000000 2.000000 0.724746 3.000000 3.000000 2.822831 3.000000 4.000000 0.350270 3.000000 5.000000 -0.842388 3.000000 6.000000 -0.359642 3.000000 7.000000 0.573010 3.000000 8.000000 1.210563 3.000000 9.000000 1.026518 3.000000 10.000000 0.445341 4.000000 0.000000 -0.358276 4.000000 1.000000 -0.625461 4.000000 2.000000 -0.906097 4.000000 3.000000 -1.140568 4.000000 4.000000 -1.467084 4.000000 5.000000 -1.295569 4.000000 6.000000 -0.173238 4.000000 7.000000 1.701411 4.000000 8.000000 2.920047 4.000000 9.000000 2.403819 4.000000 10.000000 1.074225 5.000000 0.000000 -0.489736 5.000000 1.000000 -0.859468 5.000000 2.000000 -1.330171 5.000000 3.000000 -1.808706 5.000000 4.000000 -2.102815 5.000000 5.000000 -1.809384 5.000000 6.000000 -0.355450 5.000000 7.000000 2.074412 5.000000 8.000000 3.668758 5.000000 9.000000 3.034490 5.000000 10.000000 1.349661 6.000000 0.000000 -0.590735 6.000000 1.000000 -1.036754 6.000000 2.000000 -1.605303 6.000000 3.000000 -2.187329 6.000000 4.000000 -2.576169 6.000000 5.000000 -2.407814 6.000000 6.000000 -1.214967 6.000000 7.000000 0.837806 6.000000 8.000000 2.288220 6.000000 9.000000 1.995881 6.000000 10.000000 0.841789 7.000000 0.000000 -0.628834 7.000000 1.000000 -1.103630 7.000000 2.000000 -1.709121 7.000000 3.000000 -2.332851 7.000000 4.000000 -2.784549 7.000000 5.000000 -2.806129 7.000000 6.000000 -2.141563 7.000000 7.000000 -0.903878 7.000000 8.000000 0.130049 7.000000 9.000000 0.328886 7.000000 10.000000 0.047842 8.000000 0.000000 -0.590735 8.000000 1.000000 -1.036770 8.000000 2.000000 -1.605719 8.000000 3.000000 -2.193830 8.000000 4.000000 -2.637838 8.000000 5.000000 -2.762694 8.000000 6.000000 -2.453620 8.000000 7.000000 -1.784422 8.000000 8.000000 -1.078788 8.000000 9.000000 -0.626347 8.000000 10.000000 -0.396864 9.000000 0.000000 -0.489737 9.000000 1.000000 -0.859514 9.000000 2.000000 -1.331231 9.000000 3.000000 -1.819415 9.000000 4.000000 -2.193170 9.000000 5.000000 -2.326750 9.000000 6.000000 -2.161157 9.000000 7.000000 -1.748271 9.000000 8.000000 -1.239664 9.000000 9.000000 -0.788193 9.000000 10.000000 -0.456047 10.000000 0.000000 -0.358299 10.000000 1.000000 -0.628834 10.000000 2.000000 -0.973956 10.000000 3.000000 -1.331223 10.000000 4.000000 -1.605607 10.000000 5.000000 -1.708331 10.000000 6.000000 -1.602233 10.000000 7.000000 -1.323725 10.000000 8.000000 -0.964305 10.000000 9.000000 -0.621317 10.000000 10.000000 -0.354748 TEST11 GRID1 computes a 1D grid between two DIM_NUM dimensional points X1 and X2. Here, we will use 11 steps going from 1.000000 0.000000 20.000000 -5.000000 1.000000 to 1.000000 10.000000 0.000000 5.000000 2.000000 The grid matrix: Row: 1 2 3 4 5 Col 1: 1 0 20 -5 1 2: 1 1 18 -4 1.1 3: 1 2 16 -3 1.2 4: 1 3 14 -2 1.3 5: 1 4 12 -1 1.4 6: 1 5 10 0 1.5 7: 1 6 8 1 1.6 8: 1 7 6 2 1.7 9: 1 8 4 3 1.8 10: 1 9 2 4 1.9 11: 1 10 0 5 2 TEST12 GRID1N computes a 1D grid between two DIM_NUM dimensional points X1 and X2, one point at a time. Here, we will use 11 steps going from 1.000000 0.000000 20.000000 -5.000000 1.000000 to 1.000000 10.000000 0.000000 5.000000 2.000000 1 1.000000 0.000000 20.000000 -5.000000 1.000000 2 1.000000 1.000000 18.000000 -4.000000 1.100000 3 1.000000 2.000000 16.000000 -3.000000 1.200000 4 1.000000 3.000000 14.000000 -2.000000 1.300000 5 1.000000 4.000000 12.000000 -1.000000 1.400000 6 1.000000 5.000000 10.000000 0.000000 1.500000 7 1.000000 6.000000 8.000000 1.000000 1.600000 8 1.000000 7.000000 6.000000 2.000000 1.700000 9 1.000000 8.000000 4.000000 3.000000 1.800000 10 1.000000 9.000000 2.000000 4.000000 1.900000 11 1.000000 10.000000 0.000000 5.000000 2.000000 TEST13 GRID2 computes a 1 D grid between two DIM_NUM dimensional points X1 and X2, computing X1 and X2 at user specified times. Here, we will use 20 steps and on step 3 we will compute 1.000000 0.000000 20.000000 -5.000000 1.000000 and on step 13 we will compute 1.000000 10.000000 0.000000 5.000000 2.000000 The grid matrix: Col: 1 2 3 4 5 Row 1 : 1 1 1 1 1 2 : -2 -1 0 1 2 3 : 24 22 20 18 16 4 : -7 -6 -5 -4 -3 5 : 0.8 0.9 1 1.1 1.2 Col: 6 7 8 9 10 Row 1 : 1 1 1 1 1 2 : 3 4 5 6 7 3 : 14 12 10 8 6 4 : -2 -1 0 1 2 5 : 1.3 1.4 1.5 1.6 1.7 Col: 11 12 13 14 15 Row 1 : 1 1 1 1 1 2 : 8 9 10 11 12 3 : 4 2 0 -2 -4 4 : 3 4 5 6 7 5 : 1.8 1.9 2 2.1 2.2 Col: 16 17 18 19 20 Row 1 : 1 1 1 1 1 2 : 13 14 15 16 17 3 : -6 -8 -10 -12 -14 4 : 8 9 10 11 12 5 : 2.3 2.4 2.5 2.6 2.7 TEST14 GRID2N computes points from a 1D grid between two DIM_NUM dimensional points X1 and X2, one at a time, with X1 and X2 having user specified J coordinates. Here, on step 3 we would compute 1.000000 0.000000 20.000000 -5.000000 1.000000 and on step 13 we would compute 1.000000 10.000000 0.000000 5.000000 2.000000 1 1.000000 -2.000000 24.000000 -7.000000 0.800000 2 1.000000 -1.000000 22.000000 -6.000000 0.900000 3 1.000000 0.000000 20.000000 -5.000000 1.000000 4 1.000000 1.000000 18.000000 -4.000000 1.100000 5 1.000000 2.000000 16.000000 -3.000000 1.200000 6 1.000000 3.000000 14.000000 -2.000000 1.300000 7 1.000000 4.000000 12.000000 -1.000000 1.400000 8 1.000000 5.000000 10.000000 0.000000 1.500000 9 1.000000 6.000000 8.000000 1.000000 1.600000 10 1.000000 7.000000 6.000000 2.000000 1.700000 11 1.000000 8.000000 4.000000 3.000000 1.800000 12 1.000000 9.000000 2.000000 4.000000 1.900000 13 1.000000 10.000000 0.000000 5.000000 2.000000 14 1.000000 11.000000 -2.000000 6.000000 2.100000 15 1.000000 12.000000 -4.000000 7.000000 2.200000 16 1.000000 13.000000 -6.000000 8.000000 2.300000 17 1.000000 14.000000 -8.000000 9.000000 2.400000 18 1.000000 15.000000 -10.000000 10.000000 2.500000 19 1.000000 16.000000 -12.000000 11.000000 2.600000 20 1.000000 17.000000 -14.000000 12.000000 2.700000 TEST15 GRID3 computes a 2D grid in the plane containing the DIM_NUM-dimensional points X1, X2 and X3. Here, we will use 3 steps going from 1.000000 0.000000 20.000000 -5.000000 1.000000 to 1.000000 10.000000 0.000000 5.000000 2.000000 and 6 steps 1.000000 5.000000 0.000000 0.000000 3.000000 1 1 1.000000 0.000000 20.000000 -5.000000 1.000000 1 2 1.000000 1.000000 16.000000 -4.000000 1.400000 1 3 1.000000 2.000000 12.000000 -3.000000 1.800000 1 4 1.000000 3.000000 8.000000 -2.000000 2.200000 1 5 1.000000 4.000000 4.000000 -1.000000 2.600000 1 6 1.000000 5.000000 0.000000 0.000000 3.000000 2 1 1.000000 5.000000 10.000000 0.000000 1.500000 2 2 1.000000 6.000000 6.000000 1.000000 1.900000 2 3 1.000000 7.000000 2.000000 2.000000 2.300000 2 4 1.000000 8.000000 -2.000000 3.000000 2.700000 2 5 1.000000 9.000000 -6.000000 4.000000 3.100000 2 6 1.000000 10.000000 -10.000000 5.000000 3.500000 3 1 1.000000 10.000000 0.000000 5.000000 2.000000 3 2 1.000000 11.000000 -4.000000 6.000000 2.400000 3 3 1.000000 12.000000 -8.000000 7.000000 2.800000 3 4 1.000000 13.000000 -12.000000 8.000000 3.200000 3 5 1.000000 14.000000 -16.000000 9.000000 3.600000 3 6 1.000000 15.000000 -20.000000 10.000000 4.000000 TEST16 GRID3N computes a point from a 2D grid in the plane containing the DIM_NUM-dimensional points X1, X2 and X3. Here, we will use 3 steps from 1.000000 0.000000 20.000000 -5.000000 1.000000 to 1.000000 10.000000 0.000000 5.000000 2.000000 and 6 steps to 1.000000 5.000000 0.000000 0.000000 3.000000 1 1 1.000000 0.000000 20.000000 -5.000000 1.000000 1 2 1.000000 1.000000 16.000000 -4.000000 1.400000 1 3 1.000000 2.000000 12.000000 -3.000000 1.800000 1 4 1.000000 3.000000 8.000000 -2.000000 2.200000 1 5 1.000000 4.000000 4.000000 -1.000000 2.600000 1 6 1.000000 5.000000 0.000000 0.000000 3.000000 2 1 1.000000 5.000000 10.000000 0.000000 1.500000 2 2 1.000000 6.000000 6.000000 1.000000 1.900000 2 3 1.000000 7.000000 2.000000 2.000000 2.300000 2 4 1.000000 8.000000 -2.000000 3.000000 2.700000 2 5 1.000000 9.000000 -6.000000 4.000000 3.100000 2 6 1.000000 10.000000 -10.000000 5.000000 3.500000 3 1 1.000000 10.000000 0.000000 5.000000 2.000000 3 2 1.000000 11.000000 -4.000000 6.000000 2.400000 3 3 1.000000 12.000000 -8.000000 7.000000 2.800000 3 4 1.000000 13.000000 -12.000000 8.000000 3.200000 3 5 1.000000 14.000000 -16.000000 9.000000 3.600000 3 6 1.000000 15.000000 -20.000000 10.000000 4.000000 TEST17 GRID4 computes a 2D planar grid containing the DIM_NUM-dimensional points X1, X2 and X3. We compute the points on the following steps: X1 on step (2, 3) X2 on step (5, 3) X3 on step (2, 9) We will use 6 steps in the J direction and 10 steps in the K direction. The points X1, X2 and X3 are: 1.000000 0.000000 20.000000 -5.000000 1.000000 1.000000 10.000000 0.000000 5.000000 2.000000 1.000000 5.000000 0.000000 0.000000 3.000000 1 1 1.000000 -5.000000 33.333333 -10.000000 -0.000000 1 2 1.000000 -4.166667 30.000000 -9.166667 0.333333 1 3 1.000000 -3.333333 26.666667 -8.333333 0.666667 1 4 1.000000 -2.500000 23.333333 -7.500000 1.000000 1 5 1.000000 -1.666667 20.000000 -6.666667 1.333333 1 6 1.000000 -0.833333 16.666667 -5.833333 1.666667 1 7 1.000000 0.000000 13.333333 -5.000000 2.000000 1 8 1.000000 0.833333 10.000000 -4.166667 2.333333 1 9 1.000000 1.666667 6.666667 -3.333333 2.666667 1 10 1.000000 2.500000 3.333333 -2.500000 3.000000 2 1 1.000000 -1.666667 26.666667 -6.666667 0.333333 2 2 1.000000 -0.833333 23.333333 -5.833333 0.666667 2 3 1.000000 0.000000 20.000000 -5.000000 1.000000 2 4 1.000000 0.833333 16.666667 -4.166667 1.333333 2 5 1.000000 1.666667 13.333333 -3.333333 1.666667 2 6 1.000000 2.500000 10.000000 -2.500000 2.000000 2 7 1.000000 3.333333 6.666667 -1.666667 2.333333 2 8 1.000000 4.166667 3.333333 -0.833333 2.666667 2 9 1.000000 5.000000 0.000000 0.000000 3.000000 2 10 1.000000 5.833333 -3.333333 0.833333 3.333333 3 1 1.000000 1.666667 20.000000 -3.333333 0.666667 3 2 1.000000 2.500000 16.666667 -2.500000 1.000000 3 3 1.000000 3.333333 13.333333 -1.666667 1.333333 3 4 1.000000 4.166667 10.000000 -0.833333 1.666667 3 5 1.000000 5.000000 6.666667 -0.000000 2.000000 3 6 1.000000 5.833333 3.333333 0.833333 2.333333 3 7 1.000000 6.666667 0.000000 1.666667 2.666667 3 8 1.000000 7.500000 -3.333333 2.500000 3.000000 3 9 1.000000 8.333333 -6.666667 3.333333 3.333333 3 10 1.000000 9.166667 -10.000000 4.166667 3.666667 4 1 1.000000 5.000000 13.333333 -0.000000 1.000000 4 2 1.000000 5.833333 10.000000 0.833333 1.333333 4 3 1.000000 6.666667 6.666667 1.666667 1.666667 4 4 1.000000 7.500000 3.333333 2.500000 2.000000 4 5 1.000000 8.333333 0.000000 3.333333 2.333333 4 6 1.000000 9.166667 -3.333333 4.166667 2.666667 4 7 1.000000 10.000000 -6.666667 5.000000 3.000000 4 8 1.000000 10.833333 -10.000000 5.833333 3.333333 4 9 1.000000 11.666667 -13.333333 6.666667 3.666667 4 10 1.000000 12.500000 -16.666667 7.500000 4.000000 5 1 1.000000 8.333333 6.666667 3.333333 1.333333 5 2 1.000000 9.166667 3.333333 4.166667 1.666667 5 3 1.000000 10.000000 0.000000 5.000000 2.000000 5 4 1.000000 10.833333 -3.333333 5.833333 2.333333 5 5 1.000000 11.666667 -6.666667 6.666667 2.666667 5 6 1.000000 12.500000 -10.000000 7.500000 3.000000 5 7 1.000000 13.333333 -13.333333 8.333333 3.333333 5 8 1.000000 14.166667 -16.666667 9.166667 3.666667 5 9 1.000000 15.000000 -20.000000 10.000000 4.000000 5 10 1.000000 15.833333 -23.333333 10.833333 4.333333 6 1 1.000000 11.666667 0.000000 6.666667 1.666667 6 2 1.000000 12.500000 -3.333333 7.500000 2.000000 6 3 1.000000 13.333333 -6.666667 8.333333 2.333333 6 4 1.000000 14.166667 -10.000000 9.166667 2.666667 6 5 1.000000 15.000000 -13.333333 10.000000 3.000000 6 6 1.000000 15.833333 -16.666667 10.833333 3.333333 6 7 1.000000 16.666667 -20.000000 11.666667 3.666667 6 8 1.000000 17.500000 -23.333333 12.500000 4.000000 6 9 1.000000 18.333333 -26.666667 13.333333 4.333333 6 10 1.000000 19.166667 -30.000000 14.166667 4.666667 TEST18 GRID4N computes, one at a time, points on a 2D grid in the plane containing the DIM_NUM-dimensional points X1, X2 and X3. We wish to compute the points on the following steps: X1 on step (2, 3) X2 on step (5, 3) X3 on step (2, 9) We will use 6 steps in the J direction and 10 steps in the K direction. The points X1, X2 and X3 are: 1.000000 0.000000 20.000000 -5.000000 1.000000 1.000000 10.000000 0.000000 5.000000 2.000000 1.000000 5.000000 0.000000 0.000000 3.000000 1 1 1.000000 -5.000000 33.333333 -10.000000 -0.000000 1 2 1.000000 -4.166667 30.000000 -9.166667 0.333333 1 3 1.000000 -3.333333 26.666667 -8.333333 0.666667 1 4 1.000000 -2.500000 23.333333 -7.500000 1.000000 1 5 1.000000 -1.666667 20.000000 -6.666667 1.333333 1 6 1.000000 -0.833333 16.666667 -5.833333 1.666667 1 7 1.000000 0.000000 13.333333 -5.000000 2.000000 1 8 1.000000 0.833333 10.000000 -4.166667 2.333333 1 9 1.000000 1.666667 6.666667 -3.333333 2.666667 1 10 1.000000 2.500000 3.333333 -2.500000 3.000000 2 1 1.000000 -1.666667 26.666667 -6.666667 0.333333 2 2 1.000000 -0.833333 23.333333 -5.833333 0.666667 2 3 1.000000 0.000000 20.000000 -5.000000 1.000000 2 4 1.000000 0.833333 16.666667 -4.166667 1.333333 2 5 1.000000 1.666667 13.333333 -3.333333 1.666667 2 6 1.000000 2.500000 10.000000 -2.500000 2.000000 2 7 1.000000 3.333333 6.666667 -1.666667 2.333333 2 8 1.000000 4.166667 3.333333 -0.833333 2.666667 2 9 1.000000 5.000000 0.000000 0.000000 3.000000 2 10 1.000000 5.833333 -3.333333 0.833333 3.333333 3 1 1.000000 1.666667 20.000000 -3.333333 0.666667 3 2 1.000000 2.500000 16.666667 -2.500000 1.000000 3 3 1.000000 3.333333 13.333333 -1.666667 1.333333 3 4 1.000000 4.166667 10.000000 -0.833333 1.666667 3 5 1.000000 5.000000 6.666667 -0.000000 2.000000 3 6 1.000000 5.833333 3.333333 0.833333 2.333333 3 7 1.000000 6.666667 0.000000 1.666667 2.666667 3 8 1.000000 7.500000 -3.333333 2.500000 3.000000 3 9 1.000000 8.333333 -6.666667 3.333333 3.333333 3 10 1.000000 9.166667 -10.000000 4.166667 3.666667 4 1 1.000000 5.000000 13.333333 -0.000000 1.000000 4 2 1.000000 5.833333 10.000000 0.833333 1.333333 4 3 1.000000 6.666667 6.666667 1.666667 1.666667 4 4 1.000000 7.500000 3.333333 2.500000 2.000000 4 5 1.000000 8.333333 0.000000 3.333333 2.333333 4 6 1.000000 9.166667 -3.333333 4.166667 2.666667 4 7 1.000000 10.000000 -6.666667 5.000000 3.000000 4 8 1.000000 10.833333 -10.000000 5.833333 3.333333 4 9 1.000000 11.666667 -13.333333 6.666667 3.666667 4 10 1.000000 12.500000 -16.666667 7.500000 4.000000 5 1 1.000000 8.333333 6.666667 3.333333 1.333333 5 2 1.000000 9.166667 3.333333 4.166667 1.666667 5 3 1.000000 10.000000 0.000000 5.000000 2.000000 5 4 1.000000 10.833333 -3.333333 5.833333 2.333333 5 5 1.000000 11.666667 -6.666667 6.666667 2.666667 5 6 1.000000 12.500000 -10.000000 7.500000 3.000000 5 7 1.000000 13.333333 -13.333333 8.333333 3.333333 5 8 1.000000 14.166667 -16.666667 9.166667 3.666667 5 9 1.000000 15.000000 -20.000000 10.000000 4.000000 5 10 1.000000 15.833333 -23.333333 10.833333 4.333333 6 1 1.000000 11.666667 0.000000 6.666667 1.666667 6 2 1.000000 12.500000 -3.333333 7.500000 2.000000 6 3 1.000000 13.333333 -6.666667 8.333333 2.333333 6 4 1.000000 14.166667 -10.000000 9.166667 2.666667 6 5 1.000000 15.000000 -13.333333 10.000000 3.000000 6 6 1.000000 15.833333 -16.666667 10.833333 3.333333 6 7 1.000000 16.666667 -20.000000 11.666667 3.666667 6 8 1.000000 17.500000 -23.333333 12.500000 4.000000 6 9 1.000000 18.333333 -26.666667 13.333333 4.333333 6 10 1.000000 19.166667 -30.000000 14.166667 4.666667 subpak_test19 INDEX1_COL column indexes a 1D array, INDEX1_ROW row indexes a 1D array, and there are several more versions of these functions. By COLS: Imin I Imax Xmin Index 1 3 5 INDEX1_COL 0 2 INDEXN_COL 0 2 1 3 5 1 2 4 INDEX2_COL 0 7 INDEXN_COL 0 7 1 3 5 1 2 4 1 1 3 INDEX3_COL 0 7 INDEXN_COL 0 7 1 3 5 1 2 4 1 1 3 1 2 2 INDEX4_COL 0 67 INDEXN_COL 0 67 By ROWS: Imin I Imax Xmin Index 1 3 5 INDEX1_ROW 0 2 INDEXN_ROW 0 2 1 3 5 1 2 4 INDEX2_ROW 0 9 INDEXN_ROW 0 9 1 3 5 1 2 4 1 1 3 INDEX3_ROW 0 27 INDEXN_ROW 0 27 1 3 5 1 2 4 1 1 3 1 2 2 INDEX4_ROW 0 55 INDEXN_ROW 0 55 TEST22 LCM_12N computes the least common multiple of the integers 1 through N. N LCM_12N ( N ) 1 1 2 2 3 6 4 12 5 60 6 60 7 420 8 420 9 1260 10 1260 11 13860 12 13860 TEST24 PERM_INVERSE inverts a permutation in place; The original permutation: 1 2 3 4 5 6 7 4 3 5 1 7 6 2 The inverted permutation: 1 2 3 4 5 6 7 4 7 2 1 3 6 5 TEST25 PRIME_GE returns the smallest prime number greater than or equal to N. N P 1 2 2 2 3 3 4 5 5 5 6 7 7 7 8 11 9 11 10 11 11 11 12 13 13 13 14 17 15 17 16 17 17 17 18 19 19 19 20 23 TEST26 RANDOM_INITIALIZE can make up a seed for the MATLAB random number generator RAND, or use a single SEED value from the user. Calling RANDOM_INITIALIZE with a zero input value of SEED tells the routine to make up a seed. And, at least for calls a few milliseconds apart, the output SEED should be different. In any case, if RAND is restarted by calling RANDOM_INITIALIZE with a nonzero input SEED, then the random number sequence should repeat. Call RANDOM_INITIALIZE 10 times, with a zero input SEED. Also, get the first three real random values. SEED Random 1, 2, 3 0 0.956616 0.411646 0.609278 0 0.239067 0.935189 0.219902 0 0.399627 0.517367 0.352024 0 0.396952 0.253431 0.991799 0 0.009399 0.251490 0.852543 0 0.394888 0.917203 0.872617 0 0.887681 0.924152 0.520439 0 0.325709 0.059678 0.280342 0 0.648565 0.239312 0.338382 0 0.311439 0.745560 0.065535 Now call RANDOM_INITIALIZE with SEED = 5, 95, 5, 95. We promise the random numbers will repeat the second time. SEED Random 1, 2, 3 5 0.221993 0.870732 0.206719 95 0.228803 0.190688 0.886360 5 0.221993 0.870732 0.206719 95 0.228803 0.190688 0.886360 TEST27 RAND(M,N) is a MATLAB routine which returns an M by N array of pseudorandom values. Using initial random number seed = 123456789 Test #1: Call 5 times, 1 value each time. 1 0.534906 2 0.377497 3 0.684082 4 0.921795 5 0.307508 Test #2: Restore the random number seed. Call 5 times, 1 value each time. The results should be identical. 1 0.534906 2 0.377497 3 0.684082 4 0.921795 5 0.307508 Test #3: Restore the random number seed. Call 1 time for 5 values. The results should be identical. 1 0.534906 2 0.377497 3 0.684082 4 0.921795 5 0.307508 Test #4: Restore the random number seed. Call for 2, 1, and 2 values. The results should be identical. 1 0.534906 2 0.377497 1 0.684082 1 0.921795 2 0.307508 Test #5: Number of samples was 1000 Minimum value was 0.000090 Maximum value was 0.999361 Average value was 0.494394 Variance was 0.082373 Expected average 0.500000 Expected variance 0.083333 TEST28 RAND('STATE',J) sets the random seed to its Jth value. RAND(M,N) is a MATLAB routine which returns an M by N array of pseudorandom values between 0 and 1. Set RAND to its seed state number 123456789 Number of values computed was N = 1000 Average value was 0.494728 Variance was 0.082312 TEST29 RAT_FACTOR factors a rational value. Rational value is 1638 / 12 Prime representation: I, FACTOR(I), POWER(I) 1 2 -1 2 3 1 3 7 1 4 13 1 TEST30 ROOTS_TO_R8POLY computes the coefficients of a polynomial from its roots. R8POLY_PRINT prints a polynomial. Roots: 1: 1 2: 2 3: 3 4: 4 The polynomial = +1.000000 * x^4 -10.000000 * x^3 +35.000000 * x^2 -50.000000 * x +24.000000 TEST31 SORT_HEAP_EXTERNAL sorts objects externally. Unsorted array: 1: 12 2: 4 3: 11 4: 19 5: 6 6: 6 7: 15 8: 11 9: 4 10: 19 11: 17 12: 1 13: 15 14: 20 15: 4 16: 11 17: 18 18: 6 19: 17 20: 12 Sorted array: 1: 1 2: 4 3: 4 4: 4 5: 6 6: 6 7: 6 8: 11 9: 11 10: 11 11: 12 12: 12 13: 15 14: 15 15: 17 16: 17 17: 18 18: 19 19: 19 20: 20 TEST32 For evenly spaced angles between 0 and 2*PI: TVEC_EVEN TVEC_EVEN2 TVEC_EVEN3 TVEC_EVEN NT = 4 0.000000 1.570796 3.141593 4.712389 TVEC_EVEN2 NT = 4 0.785398 2.356194 3.926991 5.497787 TVEC_EVEN3 NT = 4 0.000000 2.094395 4.188790 6.283185 TEST33 For evenly spaced angles between THETA1 and THETA2: TVEC_EVEN_BRACKET TVEC_EVEN_BRACKET2. TVEC_EVEN_BRACKET3. TVEC_EVEN_BRACKET NT = 4 THETA1 = 30.000000 THETA2 = 90.000000 30.000000 50.000000 70.000000 90.000000 TVEC_EVEN_BRACKET2 NT = 5 THETA1 = 30.000000 THETA2 = 90.000000 40.000000 50.000000 60.000000 70.000000 80.000000 TVEC_EVEN_BRACKET3 NT = 3 THETA1 = 30.000000 THETA2 = 90.000000 40.000000 60.000000 80.000000 subpak_test(): Normal end of execution. 30-Jul-2021 15:31:24