I4LIB
A Single Precision Integer Arithmetic Utility Library
I4LIB
is a Python library which
contains many 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 FORTRAN90 version and
a MATLAB version and
a Python version.
Related Data and Programs:
C4LIB,
a Python library which
contains many utility routines, using "C4" or
"single precision complex" arithmetic.
C8LIB,
a Python library which
contains many utility routines, using "C8" or
"double precision complex" arithmetic.
R4LIB,
a Python library which
contains many utility routines
using single precision real (R4) arithmetic.
R8LIB,
a Python library which
contains many utility routines
using double precision real (R8) arithmetic.
UNIFORM,
a Python library which
contains uniform random number generators (RNG's) for
several arithmetic types.
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:
-
gamma_log_values.py,
returns selected values of the logarithm of the gamma function.
-
i4_abs.py,
returns the absolute value of an I4.
-
i4_and.py,
returns the AND of two I4's.
-
i4_bclr.py,
sets a given bit of an I4 to 0.
-
i4_bit_hi1.py,
returns the position of the high 1 bit base 2 in an I4.
-
i4_bit_lo0.py,
returns the position of the low 0 bit base 2 in an I4.
-
i4_bit_lo1.py,
returns the position of the low 1 bit base 2 in an I4.
-
i4_bit_reverse.py,
reverses the bits in an I4.
-
i4_bset.py,
sets a given bit of an I4 to 1.
-
i4_btest.py,
is true if bit POS of I is a 1.
-
i4_ceiling.py,
rounds an R8 up to an I4.
-
i4_characteristic.py,
computes the characteristic of an I4.
-
i4_choose.py,
computes the binomial coefficient C(N,K) as an I4.
-
i4_choose_check.py,
determines whether the binomial coefficient C(N,K) can
be computed as an I4.
-
i4_choose_log.py,
computes the logarithm of the binomial coefficient C(N,K) as an I4.
-
i4_division.py,
returns the result of division of one I4 by another.
-
i4_divp.py,
returns the smallest multiple of J greater than or equal to I.
-
i4_factorial.py,
evaluates the factorial function as an I4.
-
i4_factorial_log.py,
evaluates the logarithm of the factorial function as an I4.
-
i4_factorial_values.py,
returns selected values of the factorial function.
-
i4_factorial2.py,
evaluates the double factorial function as an I4.
-
i4_fall.py,
evaluates the falling factorial function.
-
i4_fall_values.py,
returns selected values of the falling factorial function.
-
i4_floor.py,
rounds an R8 down to an I4.
-
i4_fraction.py,
computes a ratio and returns an I4 result.
-
i4_gcd.py,
returns the greatest common divisor of two I4's;
-
i4_gcdb.py,
returns the greatest common divisor of the form K^N of two I4's.
-
i4_huge.py,
returns a huge I4;
-
i4_huge_normalizer.py,
returns the normalizer for i4_huge();
-
i4_is_even.py,
is true if an I4 is even.
-
i4_is_odd.py,
is true if an I4 is odd.
-
i4_is_power_of_2.py,
is true if an I4 is a power of 2.
-
i4_is_power_of_10.py,
is true if an I4 is a power of 10.
-
i4_is_prime.py,
is true if I4 is prime.
-
i4_lcm.py,
returns the lowest common multiple of two I4's;
-
i4_lcm_12n.py,
returns the lowest common multiple of 1 through N;
-
i4_log_2.py,
returns the integer part of the logarithm base 2 of ABS(X);
-
i4_log_10.py,
returns the integer part of the logarithm base 10 of ABS(X);
-
i4_log_i4.py,
returns the integer part of the logarithm of ABS(X) to an I4 base.
-
i4_log_r8.py,
returns the integer part of the logarithm of ABS(X) to an R8 base.
-
i4_mant.py,
returns the mantissa of an R8.
-
i4_max.py,
returns the maximum of two I4's.
-
i4_min.py,
returns the minimum of two I4's.
-
i4_mod_inv.py,
calculates the inverse of B mod N.
-
i4_moddiv.py,
breaks a number into a multiple of a divisor and remainder.
-
i4_modp.py,
returns the nonnegative remainder of I4 division.
-
i4_mop.py,
returns the I-th power of -1 as an I4.
-
i4_not.py,
returns the NOT of an I4 with respect to a value J.
-
i4_or.py,
returns the inclusive OR of two I4's.
-
i4_power.py,
returns I to the power J.
-
i4_rise.py,
evaluates the rising factorial function as an I4.
-
i4_rise_values.py,
returns selected values of the rising factorial function.
-
i4_sign.py,
returns the sign of an I4 as an I4.
-
i4_sign3.py,
returns the three-way sign of an I4 as an I4.
-
i4_swap.py,
swaps two I4's.
-
i4_swap3.py,
swaps three I4's.
-
i4_to_angle.py,
maps integers to points on a circle.
-
i4_to_halton.py,
computes an element of a multidimensional Halton sequence.
-
i4_to_isbn.py,
converts an I4 to an ISBN digit.
-
i4_to_l4.py,
converts an I4 to an L4.
-
i4_to_pascal.py,
converts an I4 to a pair of indices in Pascal's triangle;
-
i4_to_pascal_degree.py,
converts an I4 to the degree (sum) of the corresponding pair
of indices in Pascal's triangle;
-
i4_to_triangle_lower.py,
converts an I4 to a pair of indices in a lower triangle;
-
i4_to_triangle_upper.py,
converts an I4 to a pair of indices in an upper triangle;
-
i4_uniform_ab.py,
returns a scaled uniform I4 between A and B.
-
i4_unswap3.py,
unswaps three I4's.
-
i4_walsh_1d.py,
evaluates the Walsh function.
-
i4_width.py,
returns the "width" of an I4.
-
i4_wrap.py,
forces an I4 to lie between given limits by wrapping.
-
i4_xor.py,
returns the exclusive OR of two I4's.
-
i4mat_flip_cols.py,
reverses the order of the columns of an I4MAT.
-
i4mat_flip_rows.py,
reverses the order of the rows of an I4MAT.
-
i4mat_indicator.py,
returns an indicator I4MAT.
-
i4mat_is_binary.py,
is true if the I4MAT has only 0 and 1 entries.
-
i4mat_is_integer.py,
is TRUE if all entries of an I4MAT are actually integers;
-
i4mat_max.py,
returns the maximum entry in an I4MAT.
-
i4mat_min.py,
returns the minimum entry in an I4MAT.
-
i4mat_mm.py,
returns the product of two I4MAT's.
-
i4mat_print.py,
prints an I4MAT.
-
i4mat_print_some.py,
prints some of an I4MAT.
-
i4mat_product_elementwise.py,
computes the elementwise product of two I4MAT's.
-
i4mat_ref.py,
returns the integer row echelon form (IREF) of an I4MAT.
-
i4mat_row_reduce.py,
divides a common factor from a row of an I4MAT.
-
i4mat_row_swap.py,
swaps two rows of an I4MAT.
-
i4mat_rref.m,
returns the integer reduced row echelon form (IRREF) of an I4MAT.
-
i4mat_rref_solve_binary.py,
seeks binary solutions (if any) of an integer row reduced echelon form
(IRREF) linear system.
-
i4mat_rref_solve_binary_nz.py,
seeks binary solutions (if any) of an integer row reduced echelon form
(IRREF) linear system, but only consider solutions with exactly NZ nonzeros.
-
i4mat_sum.py,
returns the sum of the entries in an I4MAT.
-
i4mat_transpose.py,
transposes an I4MAT.
-
i4mat_transpose_print.py,
prints an I4MAT, transposed.
-
i4mat_transpose_print_some.py,
prints some of an I4MAT, transposed.
-
i4mat_u_solve.py,
solves an upper triangular linear system involving only integer values.
-
i4mat_u1_inverse.py,
returns the inverse of a unit upper triangular I4MAT.
-
i4mat_uniform_ab.py,
returns an I4MAT whose entries are uniformly random between A and B.
-
i4mat_width.py,
returns the printing width of an I4MAT.
-
i4row_max.py,
returns the row maximums of an I4ROW.
-
i4row_mean.py,
returns the row means of an I4ROW.
-
i4row_min.py,
returns the minimums of an I4ROW.
-
i4row_variance.py,
returns the variances of an I4ROW.
-
i4rows_to_i4mat.py,
copies data from a rowwise vector to a columnwise doubly indexed array.
-
i4vec_add.py,
adds two I4VEC's.
-
i4vec_amax.py,
returns the largest of the magnitudes of the entries of an I4VEC.
-
i4vec_amin.py,
returns the smallest of the magnitudes of the entries of an I4VEC.
-
i4vec_binary_next.py,
returns the next binary vector as an I4VEC.
-
i4vec_choose.py,
evaluates the generalized binomial coefficient.
-
i4vec_concatenate.py,
concatenates two I4VEC's.
-
i4vec_copy.py,
copies an I4VEC.
-
i4vec_decrement.py,
decrements an I4VEC.
-
i4vec_dot_product.py,
computes the dot product of two I4VEC's.
-
i4vec_frac.py,
searches for the K-th smallest entry in an I4VEC.
-
i4vec_heap_d.py,
sets an I4VEC to a descending heap;
-
i4vec_identity_row.py,
returns a row of the identity matrix as an I4VEC.
-
i4vec_increment.py,
increments an I4VEC.
-
i4vec_index.py,
returns the location of the first occurrence of a given value in an I4VEC.
-
i4vec_indicator0.py,
returns an indicator vector as an I4VEC.
-
i4vec_indicator1.py,
returns an indicator vector as an I4VEC.
-
i4vec_is_ascending.py,
is true if the I4VEC is ascending.
-
i4vec_is_binary.py,
is true if the I4VEC has only 0 and 1 entries.
-
i4vec_is_descending.py,
is true if the I4VEC is descending.
-
i4vec_is_distinct.py,
is true if the entries of an I4VEC are distinct.
-
i4vec_is_equal.py,
is true if two I4VEC's are equal.
-
i4vec_is_even_all.py,
is true if the entries of an I4VEC are all even.
-
i4vec_is_even_any.py,
is true if any entry of an I4VEC is even.
-
i4vec_is_lt_any.py,
is true if any entry of an I4VEC X is less than the corresponding
entry of an I4VEC Y.
-
i4vec_is_negative_any.py,
is true if any entry of an I4VEC is negative.
-
i4vec_is_nonpositive_all.py,
is true if the entries of an I4VEC are all nonpositive.
-
i4vec_is_odd_all.py,
is true if the entries of an I4VEC are all odd.
-
i4vec_is_odd_any.py,
is true if any entry of an I4VEC is odd.
-
i4vec_is_one.py,
is true if the entries of an I4VEC are all 1.
-
i4vec_is_pairwise_prime.py,
is true if the elements of an I4VEC are pairwise prime.
-
i4vec_is_zero.py,
is true if the entries of an I4VEC are all 0.
-
i4vec_max.py,
returns the maximum entry in an I4VEC.
-
i4vec_max_index_last.py,
returns the index of the last maximal element of an I4VEC.
-
i4vec_mean.py,
returns the mean of an I4VEC.
-
i4vec_mean_i4.py,
returns the I4 mean of an I4VEC.
-
i4vec_min.py,
returns the minimum entry in an I4VEC.
-
i4vec_permute.py,
applies a 0-based permutation to an I4VEC.
-
i4vec_permute_uniform.py,
randomly permutes an I4VEC.
-
i4vec_print.py,
prints an I4VEC.
-
i4vec_print_mask.py,
prints the masked elements of an I4VEC.
-
i4vec_product.py,
computes the product of the entries of an I4VEC.
-
i4vec_red.py,
divides out common factors in an I4VEC;
-
i4vec_reverse.py,
reverses the order of the entries of an I4VEC.
-
i4vec_run_count.py,
counts the number of runs in an I4VEC.
-
i4vec_search_binary_a.py,
searches the ascending sorted I4VEC for a value.
-
i4vec_search_binary_d.py,
searches the descending sorted I4VEC for a value.
-
i4vec_sort_bubble_a.py,
ascending sorts an I4VEC using bubble sort;
-
i4vec_sort_heap_a.py,
ascending sorts an I4VEC using heap sort;
-
i4vec_sort_heap_index_a.py,
returns an index vector to ascending sort an I4VEC.
-
i4vec_sort_heap_index_d.py,
returns an index vector to descending sort an I4VEC.
-
i4vec_sort_insert_a.py,
ascending sorts an I4VEC using insertion sort;
-
i4vec_sort_insert_d.py,
descending sorts an I4VEC using insertion sort;
-
i4vec_sorted_unique.py,
returns the unique elements in a sorted I4VEC;
-
i4vec_sorted_unique_count.py,
counts the number of unique elements in a sorted I4VEC;
-
i4vec_sorted_unique_hist.py,
creates a histogram of the unique elements in a sorted I4VEC;
-
i4vec_sum.py,
sums the entries of an I4VEC.
-
i4vec_sum_vec.py,
returns the pairwise sum of two I4VEC's.
-
i4vec_transpose_print.py,
prints an I4VEC "transposed", that is, 5 entries to a line.
-
i4vec_uniform_ab.py,
returns an I4VEC whose entries are uniformly random between A and B.
-
i4vec_unique_count.py,
counts the unique elements in an I4VEC.
-
i4vec_variance.py,
returns the variance of an I4VEC.
-
i4vec_width.py,
returns the printing width of an I4VEC.
-
i4vec2_print.py,
prints a pair of I4VECs.
-
ksub_next4.py,
selects the next subset of size K from a set of size N.
-
l4_to_i4.py,
converts an L4 to an I4.
-
pascal_to_i4.py,
converts a pair of indices in Pascal's triangle to a linear index;
-
perm0_check.py,
checks a permutation of (0,...,N-1).
-
perm0_uniform.py,
randomly selects a permutation of (0,...,N-1).
-
perm1_check.py,
checks a permutation of (1,...,N).
-
perm1_uniform.py,
randomly selects a permutation of (1,...,N).
-
permutation_symbol.py,
evaluates the Levi-Civita permutation symbol.
-
prime.py,
returns a prime number from a stored table.
-
r8_gamma_log.py,
computes the logarithm of the gamma function;
-
r8_uniform_ab.py,
returns a random R8 between given limits;
-
r8vec_print.py,
prints an R8VEC.
-
timestamp.py,
prints the current YMDHMS date as a timestamp;
-
triangle_lower_to_i4.py,
converts a pair of indices in a lower triangle to an I4.
-
triangle_upper_to_i4.py,
converts a pair of indices in an upper triangle to an I4.
Examples and Tests:
You can go up one level to
the Python source codes.
Last revised on 17 September 2018.