SUBPAK
A Utility Library
SUBPAK is a FORTRAN77 library
which contains many utility routines.
SUBPAK contains routines for
a variety of tasks, including the greatest common divisor of two
integers, searching, sorting, range, and unique elements of vectors,
determinants and inverses of small matrices, and all the primes
less than 10,000.
Various types of data can be handled. The routine names
are chosen to indicate the corresponding type:
-
C4, single precision complex
-
C8, double precision complex
-
CH, character
-
I4, integer
-
I8, "double precision" or "long" integer
-
R4, single precision real
-
R8, double precision real
-
S, character string
In some cases, the typical data object is a one dimension vector
or a two dimensional matrix of values. In these cases,
part of the name will include the key:
-
VEC, a vector of data;
-
MAT, a matrix of data;
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Related Programs:
SUBPAK is available in
a C version and
a C++ version and
a FORTRAN77 version and
a FORTRAN90 version and
a MATLAB version.
Reference:
-
Milton Abramowitz, Irene Stegun,
Handbook of Mathematical Functions,
National Bureau of Standards, 1964,
ISBN: 0-486-61272-4,
LC: QA47.A34.
-
Book Industry Study Group,
The Evolution in Product Identification:
Sunrise 2005 and the ISBN-13,
http://www.bisg.org/docs/The_Evolution_in_Product_ID.pdf
-
Paul Bratley, Bennett Fox, Harald Niederreiter,
Algorithm 738:
Programs to Generate Niederreiter's Low-Discrepancy Sequences,
ACM Transactions on Mathematical Software,
Volume 20, Number 4, 1994, pages 494-495.
-
Paul Bratley, Bennett Fox, Linus Schrage,
A Guide to Simulation,
Second Edition,
Springer, 1987,
ISBN: 0387964673,
LC: QA76.9.C65.B73.
-
Thomas Cormen, Charles Leiserson, Ronald Rivest,
Introduction to Algorithms,
MIT Press, 2001,
ISBN: 0262032937,
LC: QA76.C662.
-
Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart,
LINPACK User's Guide,
SIAM, 1979,
ISBN13: 978-0-898711-72-1,
LC: QA214.L56.
-
Bennett Fox,
Algorithm 647:
Implementation and Relative Efficiency of Quasirandom
Sequence Generators,
ACM Transactions on Mathematical Software,
Volume 12, Number 4, December 1986, pages 362-376.
-
John Halton,
On the efficiency of certain quasi-random sequences of points
in evaluating multi-dimensional integrals,
Numerische Mathematik,
Volume 2, Number 1, December 1960, pages 84-90.
-
John Halton, GB Smith,
Algorithm 247: Radical-Inverse Quasi-Random Point Sequence,
Communications of the ACM,
Volume 7, Number 12, December 1964, pages 701-702.
-
Ralph Hartley,
A More Symmetrical Fourier Analysis Applied to Transmission
Problems,
Proceedings of the Institute of Radio Engineers,
Volume 30, 1942, pages 144-150.
-
Donald Kreher, Douglas Simpson,
Combinatorial Algorithms,
CRC Press, 1998,
ISBN: 0-8493-3988-X,
LC: QA164.K73.
-
Peter Lewis, Allen Goodman, James Miller,
A Pseudo-Random Number Generator for the System/360,
IBM Systems Journal,
Volume 8, 1969, pages 136-143.
-
MIL-STD 1753,
Fortran, DoD Supplement to American National Standard X3.9-1978,
November, 1978,
../../papers/mil_std_1753.html
-
Albert Nijenhuis, Herbert Wilf,
Combinatorial Algorithms for Computers and Calculators,
Second Edition,
Academic Press, 1978,
ISBN: 0-12-519260-6,
LC: QA164.N54.
-
Branch Rickey,
Goodby to Some Old Baseball Ideas,
Life Magazine,
2 August 1954.
-
Alan Schwarz,
Looking Beyond the Batting Average,
The New York Times,
Sunday, 1 August 2004.
-
Helmut Spaeth,
Cluster Analysis Algorithms
for Data Reduction and Classification of Objects,
Ellis Horwood, 1980,
ISBN: 0470269464,
LC: QA278.S6813.
-
Pete Stewart,
Efficient Generation of Random Orthogonal Matrices With an Application
to Condition Estimators,
SIAM Journal on Numerical Analysis,
Volume 17, Number 3, June 1980, pages 403-409.
-
Daniel Zwillinger, editor,
CRC Standard Mathematical Tables and Formulae,
30th Edition,
CRC Press, 1996,
ISBN: 0-8493-2479-3,
LC: QA47.M315.
Source Code:
Examples and Tests:
List of Routines:
-
ANGLE_SHIFT shifts angle ALPHA to lie between BETA and BETA+2PI.
-
ANGLE_SHIFT_DEG shifts angle ALPHA to lie between BETA and BETA+360.
-
ANGLE_TO_RGB returns a color on the perimeter of the color hexagon.
-
ATAN4 computes the inverse tangent of the ratio Y / X.
-
AXIS_LIMITS returns "nice" axis limits for a plot.
-
BMI_ENGLISH computes the body mass index given English measurements.
-
BMI_METRIC computes the body mass index given metric measurements.
-
C4_ARGUMENT returns the argument of a C4.
-
C4_MAGNITUDE returns the magnitude of a C4.
-
C4VEC_PRINT_SOME prints some of a C4VEC.
-
C8_ARGUMENT returns the argument of a C8.
-
C8_CUBE_ROOT returns the principal cube root of a C8.
-
C8_I returns the C8 value of the imaginary unit, i.
-
C8_MAGNITUDE returns the magnitude of a C8.
-
C8_SWAP swaps two C8's.
-
C8_UNIFORM_01 returns a unit pseudorandom C8.
-
C8MAT_UNIFORM_01 returns a unit pseudorandom C8MAT.
-
C8VEC_UNIFORM_01 returns a unit pseudorandom C8VEC.
-
C8VEC_UNITY returns the N roots of unity.
-
CH_IS_DIGIT returns TRUE if a character is a decimal digit.
-
DEGREES_TO_RADIANS converts an angle measure from degrees to radians.
-
E_CONSTANT returns the value of E.
-
EULER_CONSTANT returns the value of the Euler-Mascheroni constant.
-
FAC_DIV divides two quantities represented as prime factors.
-
FEET_TO_METERS converts a measurement in feet to meters.
-
GET_SEED returns a seed for the random number generator.
-
GET_UNIT returns a free FORTRAN unit number.
-
I4_BIT_HI1 returns the position of the high 1 bit base 2 in an I4.
-
I4_BIT_LO0 returns the position of the low 0 bit base 2 in an I4.
-
I4_BIT_LO1 returns the position of the low 1 bit base 2 in an I4.
-
I4_BIT_REVERSE reverses the bits in an I4.
-
I4_CHARACTERISTIC gives the characteristic for an I4.
-
I4_CHOOSE computes the binomial coefficient C(N,K).
-
I4_DIV_ROUNDED computes the rounded result of I4 division.
-
I4_DIVP returns the smallest multiple of J greater than or equal to I.
-
I4_EVEN returns TRUE if an I4 is even.
-
I4_FACTORIAL computes the factorial of N.
-
I4_GCD finds the greatest common divisor of I and J.
-
I4_GCDB finds the greatest common divisor of the form K**N of two I4's.
-
I4_HUGE returns a "huge" I4.
-
I4_HUGE_NORMALIZER returns the "normalizer" for I4_HUGE.
-
I4_IS_POWER_OF_2 reports whether an I4 is a power of 2.
-
I4_IS_PRIME reports whether an I4 is prime.
-
I4_LCM computes the least common multiple of two I4's.
-
I4_LOG_10 returns the integer part of the logarithm base 10 of ABS(X).
-
I4_LOG_2 returns the integer part of the logarithm base 2 of an I4.
-
I4_LOG_I4 returns the logarithm of an I4 to an I4 base.
-
I4_LOG_R8 returns the logarithm of an I4 to an R8 base.
-
I4_MANT computes the "mantissa" of a double precision number.
-
I4_MODDIV breaks an I4 into a multiple of a divisor and remainder.
-
I4_MODP returns the nonnegative remainder of integer division.
-
I4_ODD returns TRUE if an I4 is odd.
-
I4_POWER returns the integer power of an I4.
-
I4_SIGN evaluates the sign of an I4.
-
I4_SWAP switches two I4's.
-
I4_SWAP3 swaps three I4's.
-
I4_TO_ANGLE maps I4's to points on a circle.
-
I4_TO_DIGITS_DECIMAL determines the last N decimal digits of an I4.
-
I4_TO_FAC converts an I4 into a product of prime factors.
-
I4_TO_HALTON computes one element of a leaped Halton subsequence.
-
I4_TO_ISBN converts an I4 to an ISBN digit.
-
I4_UNIFORM returns a scaled pseudorandom I4.
-
I4_UNSWAP3 unswaps three I4's.
-
I4_WALSH_1D evaluates the Walsh function.
-
I4_WIDTH returns the "width" of an I4.
-
I4_WRAP forces an I4 to lie between given limits by wrapping.
-
I4_XOR calculates the exclusive OR of two I4's.
-
I4MAT_INDICATOR sets up an "indicator" I4MAT.
-
I4MAT_PRINT prints an I4MAT.
-
I4MAT_PRINT_SOME prints some of an I4MAT.
-
I4MAT_TRANSPOSE_PRINT prints an I4MAT, transposed.
-
I4MAT_TRANSPOSE_PRINT_SOME prints some of the transpose of an I4MAT.
-
I4MAT_UNIFORM returns a scaled pseudorandom I4MAT.
-
I4VEC_ASCENDS determines if an I4VEC is (weakly) ascending.
-
I4VEC_AMAX returns the largest magnitude in an I4VEC.
-
I4VEC_COPY copies an I4VEC.
-
I4VEC_HEAP_D reorders an I4VEC into an descending heap.
-
I4VEC_INDEX returns the location of the first occurrence of a given value.
-
I4VEC_INDICATOR sets an I4VEC to the indicator vector.
-
I4VEC_MAX computes the maximum element of an I4VEC.
-
I4VEC_MIN computes the minimum element of an I4VEC.
-
I4VEC_PAIRWISE_PRIME checks whether an I4VEC's entries are pairwise prime.
-
I4VEC_PRINT prints an I4VEC.
-
I4VEC_PRINT_SOME prints "some" of an I4VEC.
-
I4VEC_PRODUCT returns the product of the entries of an I4VEC.
-
I4VEC_REVERSE reverses the elements of an I4VEC.
-
I4VEC_RUN_COUNT counts runs of equal values in an I4VEC.
-
I4VEC_SORT_BUBBLE_A ascending sorts an I4VEC using bubble sort.
-
I4VEC_SORT_HEAP_A ascending sorts an I4VEC using heap sort.
-
I4VEC_SORTED_UNIQUE finds the unique elements in a sorted I4VEC.
-
I4VEC_SUM returns the sum of the entries of an I4VEC.
-
I4VEC_UNIFORM returns a scaled pseudorandom I4VEC.
-
I4VEC_ZERO sets the entries of an I4VEC to 0.
-
I8_HUGE returns a "huge" I8.
-
INDEX_BOX2_NEXT_2D produces indices on the surface of a box in 2D.
-
INDEX_BOX2_NEXT_3D produces indices on the surface of a box in 3D.
-
POUNDS_TO_KILOGRAMS converts a measurement in pounds to kilograms.
-
PRIME returns any of the first PRIME_MAX prime numbers.
-
R4_EPSILON returns the R4 roundoff unit.
-
R4_HUGE returns a "huge" R4.
-
R4_UNIFORM_01 returns a unit pseudorandom R4.
-
R4MAT_MAX returns the maximum entry of an R4MAT.
-
R4MAT_MIN returns the minimum entry of an R4MAT.
-
R8_ABS returns the absolute value of an R8.
-
R8_CAS returns the "casine" of an R8 value.
-
R8_CEILING rounds an R8 "up" to the nearest integer.
-
R8_CHOOSE computes the binomial coefficient C(N,K) as an R8.
-
R8_CHOP chops an R8 to a given number of binary places.
-
R8_CUBE_ROOT returns the cube root of an R8.
-
R8_EPSILON returns the R8 roundoff unit.
-
R8_FACTORIAL computes the factorial of N.
-
R8_FLOOR rounds an R8 "down" (towards -infinity) to the next integer.
-
R8_FRACTION returns the fraction part of an R8.
-
R8_HUGE returns a "huge" R8.
-
R8_IN_01 is TRUE if an R8 is in the range [0,1].
-
R8_IS_INT determines if an R8 represents an integer value.
-
R8_LOG_2 returns the logarithm base 2 of an R8.
-
R8_LOG_10 returns the logarithm base 10 of an R8.
-
R8_NORMAL returns a scaled pseudonormal R8.
-
R8_NORMAL_01 returns a unit pseudonormal R8.
-
R8_PI returns the value of pi as an R8.
-
R8_POWER computes the P-th power of an R8.
-
R8_SWAP switches two R8's.
-
R8_TINY returns a very small but positive R8.
-
R8_UNIFORM returns a scaled pseudorandom R8.
-
R8_UNIFORM_01 returns a unit pseudorandom R8.
-
R8COL_MEAN returns the column means of an R8COL.
-
R8COL_PART_QUICK_A reorders the columns of an array as part of a quick sort.
-
R8COL_SORT_QUICK_A ascending sorts the columns of a table using quick sort.
-
R8COL_VARIANCE returns the variances of an R8COL.
-
R8MAT_DET_2D computes the determinant of a 2 by 2 matrix.
-
R8MAT_DET_3D computes the determinant of a 3 by 3 matrix.
-
R8MAT_HOUSE_AXH computes A*H where H is a compact Householder matrix.
-
R8MAT_IDENTITY stores the identity matrix in an R8MAT.
-
R8MAT_INDICATOR sets up an "indicator" R8MAT.
-
R8MAT_L_SOLVE solves a lower triangular linear system.
-
R8MAT_MAX returns the maximum entry of an R8MAT.
-
R8MAT_MIN returns the minimum entry of an R8MAT.
-
R8VEC_EQ is true if every pair of entries in two vectors is equal.
-
R8VEC_GT == ( A1 > A2 ) for double precision vectors.
-
R8VEC_HOUSE_COLUMN defines a Householder premultiplier that "packs" a column.
-
R8VEC_LT == ( A1 < A2 ) for double precision vectors.
-
R8MAT_INDICATOR sets up an "indicator" R8MAT.
-
R8MAT_MV multiplies a matrix times a vector.
-
R8MAT_ORTH_UNIFORM returns a random orthogonal R8MAT.
-
R8MAT_PRINT prints an R8MAT.
-
R8MAT_PRINT_SOME prints some of an R8MAT.
-
R8MAT_TRANSPOSE_IN_PLACE transposes a square matrix in place.
-
R8MAT_TRANSPOSE_PRINT prints an R8MAT, transposed.
-
R8MAT_TRANSPOSE_PRINT_SOME prints some of an R8MAT transposed.
-
R8MAT_UNIFORM returns a scaled pseudorandom R8MAT.
-
R8MAT_UNIFORM_01 returns a unit pseudorandom R8MAT.
-
R8VEC_DOT finds the dot product of a pair of R8VEC's.
-
R8VEC_EQ is true if every pair of entries in two vectors is equal.
-
R8VEC_GT == ( A1 > A2 ) for double precision vectors.
-
R8VEC_INDICATOR sets an R8VEC to the indicator vector.
-
R8VEC_LT == ( A1 < A2 ) for double precision vectors.
-
R8VEC_NORM_L2 returns the L2 norm of an R8VEC.
-
R8VEC_PRINT prints an R8VEC.
-
R8VEC_PRINT_SOME prints "some" of an R8VEC.
-
R8VEC_PRODUCT multiplies the entries of an R8VEC.
-
R8VEC_SUM sums the entries of an R8VEC.
-
R8VEC_SWAP swaps two R8VEC's.
-
R8VEC_UNIFORM returns a scaled pseudorandom R8VEC.
-
R8VEC_UNIFORM_01 returns a unit pseudorandom R8VEC.
-
R8VEC2_PRINT prints an R8VEC2.
-
S_LEN_TRIM returns the length of a string to the last nonblank.
-
SORT_HEAP_EXTERNAL externally sorts a list of items into ascending order.
-
TIMESTAMP prints out the current YMDHMS date as a timestamp.
-
TUPLE_NEXT2 computes the next element of an integer tuple space.
-
TVEC_EVEN computes evenly spaced angles between 0 and 2*PI.
-
TVEC_EVEN2 computes evenly spaced angles between 0 and 2*PI.
-
TVEC_EVEN3 computes evenly spaced angles between 0 and 2*PI.
-
TVEC_EVEN_BRACKET computes evenly spaced angles between THETA1 and THETA2.
-
TVEC_EVEN_BRACKET2 computes evenly spaced angles from THETA1 to THETA2.
-
TVEC_EVEN_BRACKET3 computes evenly spaced angles between THETA1 and THETA2.
-
UPC_CHECK_DIGIT returns the check digit of a UPC.
You can go up one level to
the FORTRAN77 source codes.
Last revised on 22 July 2008.