subpak_test 22-Mar-2019 19:53:05 subpak_test MATLAB version 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.076920 11.468512 11.772636 17.751697 8.281470 1.550576 1.998285 7.833761 -2.128565 -10.904626 -8.411751 -4.621440 -6.092735 -9.802855 -6.092735 -3.519670 -11.464828 3.366926 7.384728 9.650111 -11.014996 -1.268224 1.551374 5.014961 -2.480444 6.400643 10.085927 12.683828 7.471636 -12.520167 -11.377920 -6.236982 9.990367 -3.751003 -2.576004 2.532182 -10.190202 -12.224141 -10.190202 -5.940955 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 -405.477652 657.097310 674.522348 1017.097310 474.493297 88.841438 114.493297 448.841438 -121.957803 -624.789022 -481.957803 -264.789022 -349.087979 -561.662217 -349.087979 -201.662217 -656.886243 192.910626 423.113757 552.910626 -631.112790 -72.663897 88.887210 287.336103 -142.118955 366.729820 577.881045 726.729820 428.093214 -717.352746 -651.906786 -357.352746 572.405848 -214.916633 -147.594152 145.083367 -583.855560 -700.391676 -583.855560 -340.391676 SUBPAK_TEST03 ANGLE_TO_RGB converts an angle into an RGB color. ANGLE R G B 78.630587 0.601504 1.000000 0.000000 344.274328 1.000000 0.000000 0.208806 298.623324 0.964593 0.000000 1.000000 202.210359 0.000000 0.539396 1.000000 149.510549 0.000000 1.000000 0.406727 23.802745 1.000000 0.322067 0.000000 92.728005 0.372970 1.000000 0.000000 39.584446 1.000000 0.570120 0.000000 15.778439 1.000000 0.209527 0.000000 228.227656 0.000000 0.155331 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) 132.762745 7.000000 -4.000000 14.584602 224.426385 6.000000 -5.000000 35.149783 162.296062 4.000000 2.000000 45.642173 138.636669 4.000000 4.000000 36.047053 106.574350 6.000000 -3.000000 15.738120 109.259084 5.000000 3.000000 19.354181 160.195942 6.000000 1.000000 21.135091 219.593043 4.000000 0.000000 67.009201 234.625609 5.000000 -0.000000 45.821705 114.181713 4.000000 0.000000 34.842749 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 TEST10 GET_SEED gets a seed for the random number generator. These values are computed from the time and date. Values computed nearby in time will be near to each other, and should be passed through a random number generator a few times before use. I R(I) R2(I) R3(I) 1779268012 447693209 1744548222 1027734663 1779268090 449004155 155297527 892905184 1779268150 450012575 2071426938 1615145449 1779268168 450315101 713530479 758075705 1779268200 450852925 1162803859 1143270513 1779268263 451911766 1778875370 291010056 1779268267 451978994 761292719 339159407 1779268269 452012608 1326243217 1436975906 1779268280 452197485 138503662 2106257533 1779268287 452315134 2115830405 579906162 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.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 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.437417 0.092568 0.076778 0 0.298470 0.256395 0.812320 0 0.829740 0.210576 0.931456 0 0.456896 0.570112 0.104708 0 0.441630 0.626558 0.583298 0 0.119297 0.100406 0.726124 0 0.064628 0.368899 0.970407 0 0.786826 0.703985 0.854165 0 0.162687 0.895800 0.943592 0 0.670730 0.264251 0.330402 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.000000 2: 2.000000 3: 3.000000 4: 4.000000 The polynomial p(x) = - 10.000000 * x^3 + 35.000000 * x^2 - 50.000000 * x + 24.000000 TEST31 SORT_HEAP_EXTERNAL sorts objects externally. Unsorted array: 1: 5 2: 20 3: 17 4: 12 5: 9 6: 2 7: 6 8: 3 9: 1 10: 13 11: 2 12: 9 13: 9 14: 16 15: 16 16: 1 17: 18 18: 8 19: 2 20: 1 Sorted array: 1: 1 2: 1 3: 1 4: 2 5: 2 6: 2 7: 3 8: 5 9: 6 10: 8 11: 9 12: 9 13: 9 14: 12 15: 13 16: 16 17: 16 18: 17 19: 18 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. 22-Mar-2019 19:53:06 diary off