I4LIB
A Single Precision Integer Arithmetic Utility Library
I4LIB
is a C++ library which
includes a number of utility routines for "I4" or
single precision integer arithmetic.
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Languages:
I4LIB is available in
a C version and
a C++ version and
a FORTRAN77 version and
a FORTRAN90 version and
a MATLAB version and
a Python version.
Related Programs:
C4LIB,
a C++ library which
implements certain elementary functions for "C4" or
single precision complex variables;
C8LIB,
a C++ library which
implements certain elementary functions for "C8" or
double precision complex variables;
I8LIB,
a C++ library which
contains many utility routines, using "I8" or "double precision integer"
arithmetic.
R4LIB,
a C++ library which
contains many utility routines, using "R4" or
"single precision real" arithmetic.
R8LIB,
a C++ library which
contains many utility routines, using "R8" or
"double precision real" arithmetic.
SUBPAK,
a C++ library which
contains many utility routines;
Reference:
-
Milton Abramowitz, Irene Stegun,
Handbook of Mathematical Functions,
National Bureau of Standards, 1964,
ISBN: 0-486-61272-4,
LC: QA47.A34.
-
Thomas Cormen, Charles Leiserson, Ronald Rivest,
Introduction to Algorithms,
MIT Press, 2001,
ISBN: 0262032937,
LC: QA76.C662.
-
Albert Nijenhuis, Herbert Wilf,
Combinatorial Algorithms for Computers and Calculators,
Second Edition,
Academic Press, 1978,
ISBN: 0-12-519260-6,
LC: QA164.N54.
Source Code:
Examples and Tests:
List of Routines:
-
I4_ABS returns the absolute value of an I4.
-
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_CEILING rounds an R8 up to the next 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 an I4.
-
I4_EVEN returns TRUE if an I4 is even.
-
I4_FACTORIAL computes the factorial of N.
-
I4_FLOOR rounds an R8 down to the nearest I4.
-
I4_FRACTION computes a ratio and returns an integer result.
-
I4_GCD finds the greatest common divisor of two I4's.
-
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 an I4.
-
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 integer part of the logarithm base B of an I4.
-
I4_MANT computes the "mantissa" of an R4.
-
I4_MAX returns the maximum of two I4's.
-
I4_MIN returns the minimum of two I4's.
-
I4_MOD_INV calculates the inverse of B mod N.
-
I4_MODDIV breaks an I4 into a multiple of a divisor and remainder.
-
I4_MODP returns the nonnegative remainder of I4 division.
-
I4_MOP returns the I-th power of -1 as an I4 value.
-
I4_ODD returns TRUE if an I4 is odd.
-
I4_POWER returns the value of I^J.
-
I4_REVERSE_BYTES reverses the bytes in an I4.
-
I4_SIGN returns 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_BINARY produces the binary digits of an I4.
-
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_TO_L converts an I4 to a logical value.
-
I4_UNIFORM returns a scaled pseudorandom I4.
-
I4_UNSWAP3 unswaps three I4's.
-
I4_WALSH_1D evaluates the Walsh function of a real scalar argument.
-
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.
-
I43MAT_FLIP_COLS swaps the columns of an I43MAT.
-
I43MAT_FLIP_ROWS swaps the rows of an I43MAT.
-
I4BLOCK_DELETE frees memory associated with an I4BLOCK.
-
I4BLOCK_NEW allocates a new I4BLOCK.
-
I4COL_COMPARE compares columns I and J of an I4COL.
-
I4COL_FIND seeks a table column equal to an I4COL.
-
I4COL_FIND_ITEM searches an I4COL for a given value.
-
I4COL_FIND_PAIR_WRAP wrap searches an I4COL for a pair of items.
-
I4COL_FIRST_INDEX indexes the first occurrence of values in an I4COL.
-
I4COL_SORT_A ascending sorts the columns of an I4COL.
-
I4COL_SORT_D descending sorts the columns of an I4COL.
-
I4COL_SORT2_A ascending sorts the elements of each column of an I4COL.
-
I4COL_SORT2_D descending sorts the elements of each column of an I4COL.
-
I4COL_SORTED_SINGLETON_COUNT counts singletons in an I4COL.
-
I4COL_SORTED_UNIQUE keeps unique elements in a sorted I4COL.
-
I4COL_SORTED_UNIQUE_COUNT counts unique elements in an I4COL.
-
I4COL_SWAP swaps two columns of an I4COL.
-
I4COL_UNIQUE_INDEX indexes the unique occurrence of values in an I4COL.
-
I4I4_SORT_A ascending sorts a pair of I4's.
-
I4I4I4_SORT_A ascending sorts a triple of I4's.
-
I4INT_TO_R4INT maps an I4 interval to an R4 interval.
-
I4INT_TO_R8INT maps an I4 interval to an R8 interval.
-
I4LIST_PRINT prints an I4LIST.
-
I4MAT_BORDER_ADD adds a "border" to an I4MAT.
-
I4MAT_BORDER_CUT cuts the "border" of an I4MAT.
-
I4MAT_COPY copies one I4MAT to another.
-
I4MAT_COPY_NEW copies an I4MAT to a "new" I4MAT.
-
I4MAT_DELETE frees memory associated with an I4MAT.
-
I4MAT_ELIM carries out exact Gauss elimination on an I4MAT.
-
I4MAT_FLIP_COLS swaps the columns of an I4MAT.
-
I4MAT_FLIP_ROWS swaps the rows of an I4MAT.
-
I4MAT_HISTOGRAM computes a histogram of the elements of an I4MAT.
-
I4MAT_INDICATOR_NEW sets up an "indicator" I4MAT.
-
I4MAT_L1_INVERSE inverts a unit lower triangular I4MAT.
-
I4MAT_MAX returns the maximum of an I4MAT.
-
I4MAT_MAX_INDEX returns the location of the maximum of an I4MAT.
-
I4MAT_MIN returns the minimum of an I4MAT.
-
I4MAT_MIN_INDEX returns the location of the minimum of an I4MAT.
-
I4MAT_MM multiplies two I4MAT's.
-
I4MAT_NEW allocates a new I4MAT.
-
I4MAT_PERM_UNIFORM selects a random permutation of an I4MAT.
-
I4MAT_PERM2_UNIFORM selects a random permutation of an I4MAT.
-
I4MAT_PRINT prints an I4MAT.
-
I4MAT_PRINT_SOME prints some of an I4MAT.
-
I4MAT_RED divides out common factors in a row or column of an I4MAT.
-
I4MAT_TRANSPOSE_PRINT prints an I4MAT, transposed.
-
I4MAT_TRANSPOSE_PRINT_SOME prints some of an I4MAT, transposed.
-
I4MAT_U1_INVERSE inverts a unit upper triangular I4MAT.
-
I4MAT_UNIFORM_NEW returns a scaled pseudorandom I4MAT.
-
I4ROW_COMPARE compares two rows of a integer array.
-
I4ROW_FIND_ITEM searches the rows of an I4ROW for a given value.
-
I4ROW_MAX returns the maximums of an I4ROW.
-
I4ROW_MEAN returns the means of an I4ROW.
-
I4ROW_MIN returns the minimums of an I4ROW.
-
I4ROW_SORT_A ascending sorts the rows of an I4ROW.
-
I4ROW_SORT_D descending sorts the rows of an I4ROW.
-
I4ROW_SORT2_D descending sorts the elements of each row of an I4ROW.
-
I4ROW_SUM returns the sums of the rows of an I4ROW.
-
I4ROW_SWAP swaps two rows of an I4ROW.
-
I4ROW_VARIANCE returns the variances of an I4ROW.
-
I4VEC_ADD_NEW computes C = A + B for I4VEC's.
-
I4VEC_ALL_NONPOSITIVE: ( all ( A <= 0 ) ) for I4VEC's.
-
I4VEC_AMAX returns the largest magnitude in an I4VEC.
-
I4VEC_AMAX_INDEX returns the index of the maximum absolute value in an I4VEC.
-
I4VEC_AMIN returns the smallest magnitude in an I4VEC.
-
I4VEC_AMIN_INDEX returns the index of the minimum absolute value in an I4VEC.
-
I4VEC_AMINZ returns the smallest nonzero magnitude in an I4VEC.
-
I4VEC_AMINZ_INDEX returns the smallest nonzero magnitude in an I4VEC.
-
I4VEC_ANY_LT: ( any ( A < B ) ) for I4VEC's.
-
I4VEC_ANY_NEGATIVE: ( any A < 0 ) for I4VEC's.
-
I4VEC_ANY_NONZERO: ( any A nonzero ) for I4VEC's.
-
I4VEC_ASCEND_SUB computes the longest ascending subsequence in an I4VEC.
-
I4VEC_ASCENDS determines if an I4VEC is (weakly) ascending.
-
I4VEC_AXPY adds IA times the vector IX to the vector IY.
-
I4VEC_BRACKET searches a sorted I4VEC for successive brackets of a value.
-
I4VEC_COMPARE compares two I4VEC's.
-
I4VEC_COPY copies an I4VEC.
-
I4VEC_COPY_NEW copies an I4VEC to a "new" I4VEC.
-
I4VEC_CUM computes the cumulutive sum of the entries of an I4VEC.
-
I4VEC_CUM0 computes the cumulutive sum of the entries of an I4VEC.
-
I4VEC_DESCENDS determines if an I4VEC is (weakly) descending.
-
I4VEC_DIRECT_PRODUCT creates a direct product of I4VEC's.
-
I4VEC_DIRECT_PRODUCT2 creates a direct product of I4VEC's.
-
I4VEC_DOT_PRODUCT computes the dot product of two I4VEC's.
-
I4VEC_EVEN_ALL is TRUE if all entries of an I4VEC are even.
-
I4VEC_EVEN_ANY is TRUE if any entry of an I4VEC is even.
-
I4VEC_FIND finds the first occurrence of a value in an I4VEC.
-
I4VEC_FIRST_INDEX indexes the first occurrence of values in an I4VEC.
-
I4VEC_FRAC searches for the K-th smallest entry in an I4VEC.
-
I4VEC_GCD returns the greatest common divisor of an I4VEC.
-
I4VEC_HEAP_A reorders an I4VEC into a ascending heap.
-
I4VEC_HEAP_D reorders an I4VEC into a descending heap.
-
I4VEC_HEAP_D_EXTRACT extracts the maximum value from a descending heap.
-
I4VEC_HEAP_D_INSERT inserts a new value into a descending heap.
-
I4VEC_HEAP_D_MAX returns the maximum value in a descending heap of integers.
-
I4VEC_HISTOGRAM computes a histogram of the elements of an I4VEC.
-
I4VEC_INDEX locates a value in an I4VEC.
-
I4VEC_INDEX_DELETE_ALL deletes all occurrences of a value from an indexed sorted list.
-
I4VEC_INDEX_DELETE_DUPES deletes duplicates from an indexed sorted I4VEC.
-
I4VEC_INDEX_DELETE_ONE deletes one copy of an I4 from an indexed sorted I4VEC.
-
I4VEC_INDEX_INSERT inserts an I4 into an indexed sorted I4VEC.
-
I4VEC_INDEX_INSERT_UNIQUE inserts a unique I4 in an indexed sorted I4VEC.
-
I4VEC_INDEX_ORDER sorts an I4VEC using an index vector.
-
I4VEC_INDEX_SEARCH searches for an I4 in an indexed sorted I4VEC.
-
I4VEC_INDEX_SORT_UNIQUE creates a sort index for an I4VEC.
-
I4VEC_INDEXED_HEAP_D creates a descending heap from an indexed I4VEC.
-
I4VEC_INDEXED_HEAP_D_EXTRACT: extract from heap descending indexed I4VEC.
-
I4VEC_INDEXED_HEAP_D_INSERT: insert value into heap descending indexed I4VEC.
-
I4VEC_INDEXED_HEAP_D_MAX: maximum value in heap descending indexed I4VEC.
-
I4VEC_INDICATOR sets an I4VEC to the indicator vector.
-
I4VEC_INDICATOR_NEW sets an I4VEC to the indicator vector.
-
I4VEC_INSERT inserts a value into an I4VEC.
-
I4VEC_LCM returns the least common multiple of an I4VEC.
-
I4VEC_MAX returns the value of the maximum element in an I4VEC.
-
I4VEC_MAX_INDEX returns the index of the maximum value in an I4VEC.
-
I4VEC_MAX_INDEX_LAST: index of the last maximum value in an I4VEC.
-
I4VEC_MEAN returns the mean of an I4VEC.
-
I4VEC_MEDIAN returns the median of an unsorted I4VEC.
-
I4VEC_MERGE_A merges two ascending sorted I4VEC's.
-
I4VEC_MIN returns the value of the minimum element in an I4VEC.
-
I4VEC_MIN_INDEX returns the index of the minimum value in an I4VEC.
-
I4VEC_MIN_MV determines U(1:N) /\ V for vectors U and a single vector V.
-
I4VEC_NEGONE sets an I4VEC to -1.
-
I4VEC_NEGONE_NEW creates an I4VEC and sets it to -1.
-
I4VEC_NONZERO_COUNT counts the nonzero entries in an I4VEC.
-
I4VEC_NONZERO_FIRST left-shifts all nonzeros in an I4VEC.
-
I4VEC_ODD_ALL is TRUE if all entries of an I4VEC are odd.
-
I4VEC_ODD_ANY is TRUE if any entry of an I4VEC is odd.
-
I4VEC_ORDER_TYPE: is an I4VEC is (non)strictly ascending/descending?
-
I4VEC_PAIRWISE_PRIME checks whether an I4VEC is pairwise prime.
-
I4VEC_PART partitions an int NVAL into N nearly equal parts.
-
I4VEC_PART_QUICK_A reorders an I4VEC as part of a quick sort.
-
I4VEC_PERMUTE permutes an I4VEC in place.
-
I4VEC_PERMUTE_UNIFORM randomly permutes an I4VEC.
-
I4VEC_PRINT prints an I4VEC.
-
I4VEC_PRINT_PART prints "part" of an I4VEC.
-
I4VEC_PRINT_SOME prints "some" of an I4VEC.
-
I4VEC_PRODUCT multiplies the entries of an I4VEC.
-
I4VEC_RED divides out common factors in an I4VEC.
-
I4VEC_REVERSE reverses the elements of an I4VEC.
-
I4VEC_ROTATE rotates an I4VEC in place.
-
I4VEC_RUN_COUNT counts runs of equal values in an I4VEC.
-
I4VEC_SEARCH_BINARY_A searches an ascending sorted I4VEC for a value.
-
I4VEC_SEARCH_BINARY_D searches a descending sorted I4VEC for a value.
-
I4VEC_SORT_BUBBLE_A ascending sorts an I4VEC using bubble sort.
-
I4VEC_SORT_BUBBLE_D descending sorts an I4VEC using bubble sort.
-
I4VEC_SORT_HEAP_A ascending sorts an I4VEC using heap sort.
-
I4VEC_SORT_HEAP_D descending sorts an I4VEC using heap sort.
-
I4VEC_SORT_HEAP_INDEX_A does an indexed heap ascending sort of an I4VEC.
-
I4VEC_SORT_HEAP_INDEX_D does an indexed heap descending sort of an I4VEC.
-
I4VEC_SORT_INSERT_A uses an ascending insertion sort on an I4VEC.
-
I4VEC_SORT_INSERT_D uses a descending insertion sort on an I4VEC.
-
I4VEC_SORT_QUICK_A ascending sorts an I4VEC using quick sort.
-
I4VEC_SORT_SHELL_A ascending sorts an I4VEC using Shell's sort.
-
I4VEC_SORTED_UNDEX returns unique sorted indexes for a sorted I4VEC.
-
I4VEC_SORTED_UNIQUE finds the unique elements in a sorted I4VEC.
-
I4VEC_SORTED_UNIQUE_COUNT counts unique elements in a sorted I4VEC.
-
I4VEC_SORTED_UNIQUE_HIST histograms the unique elements of a sorted I4VEC.
-
I4VEC_SPLIT "splits" an unsorted I4VEC based on a splitting value.
-
I4VEC_STD returns the standard deviation of an I4VEC.
-
I4VEC_SUM sums the entries of an I4VEC.
-
I4VEC_SWAP swaps two I4VEC's.
-
I4VEC_TRANSPOSE_PRINT prints an I4VEC "transposed".
-
I4VEC_UNDEX returns unique sorted indexes for an I4VEC.
-
I4VEC_UNIFORM returns a scaled pseudorandom I4VEC.
-
I4VEC_UNIFORM_NEW returns a scaled pseudorandom I4VEC.
-
I4VEC_UNIQUE_COUNT counts the unique elements in an unsorted I4VEC.
-
I4VEC_UNIQUE_INDEX indexes the unique occurrence of values in an I4VEC.
-
I4VEC_VALUE_INDEX indexes I4VEC entries equal to a given value.
-
I4VEC_VALUE_NUM counts I4VEC entries equal to a given value.
-
I4VEC_VARIANCE returns the variance of an I4VEC.
-
I4VEC_WIDTH returns the "width" of an I4VEC.
-
I4VEC_ZERO zeroes an I4VEC.
-
I4VEC_ZERO_NEW creates and zeroes an I4VEC.
-
I4VEC2_COMPARE compares pairs of integers stored in two vectors.
-
I4VEC2_PRINT prints an I4VEC2.
-
I4VEC2_SORT_A ascending sorts an I4VEC2.
-
I4VEC2_SORT_D descending sorts an I4VEC2.
-
I4VEC2_SORTED_UNIQUE keeps the unique elements in an I4VEC2.
-
L_TO_I4 converts an L to an I4.
-
PERM_CHECK checks that a vector represents a permutation.
-
PERM_CYCLE analyzes a permutation.
-
PERM_UNIFORM_NEW selects a random permutation of N objects.
-
PRIME returns any of the first PRIME_MAX prime numbers.
-
R4_NINT returns the nearest integer to an R4.
-
R8_ABS returns the absolute value of an R8.
-
R8_NINT returns the nearest integer to an R8.
-
SORT_HEAP_EXTERNAL externally sorts a list of items into ascending order.
-
TIMESTAMP prints the current YMDHMS date as a time stamp.
You can go up one level to
the C++ source codes.
Last revised on 05 March 2012.