I4LIB
A Single Precision Integer Arithmetic Utility Library
I4LIB,
a MATLAB library which
contains many utility routines for "I4" or "single precision integer"
arithmetic.
Licensing:
The computer code and data files 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 Programs:
C4LIB,
a MATLAB library which
implements certain elementary functions for
single precision complex (C4) variables.
C8LIB,
a MATLAB library which
implements certain elementary functions for "C8"
or double precision complex variables;
i4lib,
a MATLAB library which
contains many utility routines, using single precision integer (I4)
arithmetic.
i4lib_test
L4LIB,
a MATLAB library which
contains many utility routines, using one byte logical (L4)
variables.
QUATERNIONS,
a MATLAB library which
carries out some simple arithmetic operations for quaternions.
R8LIB,
a MATLAB library which
contains many utility routines, using "R8" or
"double precision real" arithmetic.
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:
-
get_seed.m,
returns a random seed for the random number generator.
-
i4_abs.m,
returns the absolute value of an I4;
-
i4_and.m,
returns the AND of two I4's;
-
i4_bclr.m,
sets a given bit of an I4 to 0.
-
i4_bit_hi1.m,
returns the location of the highest 1 bit in an I4;
-
i4_bit_lo0.m,
returns the location of the lowest 0 bit in an I4;
-
i4_bit_lo1.m,
returns the location of the lowest 1 bit in an I4;
-
i4_bit_reverse.m,
reverses the bits of an I4.
-
i4_bset.m,
sets a given bit of an I4 to 1.
-
i4_btest.m,
is true if bit POS of I is a 1.
-
i4_btest_test.m
-
i4_ceiling.m,
rounds an R8 up to the nearest I4;
-
i4_characteristic.m,
gives the characteristic for an I4;
-
i4_choose.m,
computes the binomial coefficient C(N,K) as an I4;
-
i4_choose_check.m,
checks whether the binomial coefficient C(N,K) can be computed
without overflow;
-
i4_choose_log.m,
computes the logarithm of the binomial coefficient C(N,K);
-
i4_div_rounded.m,
computes the rounded result of I4 division.
-
i4_division.m,
computes the rounded result of I4 division.
-
i4_divp.m,
returns the smallest multiple of J greater than or equal to an I4;
-
i4_factorial.m,
computes the factorial of an I4;
-
i4_factorial_log.m,
computes the logarithm of N!;
-
i4_factorial2.m,
computes the double factorial as an I4;
-
i4_factorial2_values.m,
returns selected values of the double factorial function..
-
i4_fall.m,
computes a falling factorial as an I4.
-
i4_fall_values.m,
returns selected values of the falling factorial function..
-
i4_floor.m,
computes the "floor" of an I4.
-
i4_fraction.m,
computes a ratio and returns an I4 result.
-
i4_gcd.m,
returns the greatest common divisor of two I4's;
-
i4_gcdb.m,
returns the greatest common divisor of the form K^N of two I4's;
-
i4_huge.m,
returns a huge I4;
-
i4_huge_normalizer.m,
returns the "normalizer" for I4_HUGE.
-
i4_is_even.m,
is true if an I4 is even;
-
i4_is_odd.m,
is true if an I4 is odd;
-
i4_is_power_of_2.m,
is true if an I4 is a power of 2;
-
i4_is_power_of_10.m,
is true if an I4 is a power of 10;
-
i4_is_prime.m,
is true if an I4 is prime number;
-
i4_lcm.m,
returns the least common multiple of two I4's;
-
i4_lcm_12n.m,
returns the least common multiple of the integer from 1 to N;
-
i4_log_2.m,
returns the integer part of the logarithm base 2 of an I4;
-
i4_log_10.m,
returns the integer part of the logarithm base 10 of an I4;
-
i4_log_i4.m,
logarithm of an I4 to an I4 base;
-
i4_log_r8.m,
logarithm of an I4 to an R8 base;
-
i4_mant.m,
returns the mantissa of a real number as an I4;
-
i4_max.m,
returns the maximum of two I4's;
-
i4_min.m,
returns the minimum of two I4's;
-
i4_mod_inv.m,
computes the inverse of an I4 modulo another I4.
-
i4_moddiv.m,
breaks an I4 into a multiple of a divisor and a remainder;
-
i4_modp.m,
returns the nonnegative remainder of I4 division;
-
i4_not.m,
returns the NOT of an I4 with respect to a maximum value;
-
i4_or.m,
returns the OR of two I4's;
-
i4_power.m,
returns the value of the J-th power of an I4;
-
i4_rise.m,
computes a rising factorial as an I4;
-
i4_rise_values.m,
returns selected values of the rising factorial function;
-
i4_sign.m,
returns the sign of an I4.
-
i4_sign3.m,
returns the three-way sign of an I4.
-
i4_swap.m,
swaps two I4's.
-
i4_swap3.m,
swaps three I4's;
-
i4_to_angle.m,
maps I4's to points on a circle;
-
i4_to_digits_binary.m,
determines the last N binary digits of an I4;
-
i4_to_digits_decimal.m,
determines the last N decimal digits of an I4;
-
i4_to_fac.m,
converts an I4 into a product of prime factors;
-
i4_to_halton.m,
converts an I4 to the I-th Halton number;
-
i4_to_isbn.m,
converts an I4 to its ISBN representation;
-
i4_to_l4.m,
converts an I4 to an L4;
-
i4_to_pascal.m,
converts an I4 to a pair of indices in Pascal's triangle;
-
i4_to_pascal_degree.m,
converts an I4 to the degree (sum) of the corresponding pair
of indices in Pascal's triangle;
-
i4_to_triangle_lower.m,
converts an I4 to a pair of indices in a lower triangle;
-
i4_to_triangle_upper.m,
converts an I4 to a pair of indices in an upper triangle;
-
i4_uniform_ab.m,
returns a pseudorandom I4 between A and B;
-
i4_unswap3.m,
unswaps three I4's;
-
i4_walsh_1d.m,
evaluates the Walsh function;
-
i4_width.m,
returns the printing "width" of an I4;
-
i4_wrap.m,
forces an I4 to lie between given limits;
-
i4_xor.m,
returns the exclusive OR of two I4's;
-
i4block_print.m,
prints an I4BLOCK;
-
i4col_compare.m,
compares two columns of an I4COL;
-
i4col_find.m,
searches an I4COL for a given column vector;
-
i4col_find_item.m,
searches an I4COL for a given scalar value;
-
i4col_find_pair_wrap.m,
wrap-searches an I4COL for a pair of values;
-
i4col_first_index.m,
indexes the first occurrence of values in an I4COL.
-
i4col_sort_a.m,
ascending sorts the columns of an I4COL;
-
i4col_sort_d.m,
descending sorts the columns of an I4COL;
-
i4col_sort2_a.m,
ascending sorts the elements of each column of an I4COL;
-
i4col_sorted_singleton_count.m,
counts the number of singletons in a sorted I4COL;
-
i4col_sorted_unique.m,
returns the unique elements in a sorted I4COL;
-
i4col_sorted_unique_count.m,
counts the number of unique elements in a sorted I4COL;
-
i4col_swap.m,
swaps two columns of an I4COL;
-
i4i4_sort_a.m,
ascending sorts a pair of integers;
-
i4i4i4_sort_a.m,
ascending sorts a triple of integers;
-
i4int_to_r8int.m,
maps an I4 interval to an R8 interval;
-
i4list_print.m,
prints an I4LIST.
-
i4mat_border_add.m,
adds a "border" to an I4MAT.
-
i4mat_border_cut.m,
cuts the "border" of an I4MAT.
-
i4mat_elim.m,
performs exact Gauss elimination on an I4MAT;
-
i4mat_flip_cols.m,
flips the columns in an I4MAT;
-
i4mat_flip_rows.m,
flips the rows in an I4MAT;
-
i4mat_histogram.m,
returns a histogram of the entries of an I4MAT;
-
i4mat_indicator.m,
returns the indicator matrix as an I4MAT.
-
i4mat_is_binary.m,
is true if an I4MAT has only 0 and 1 entries;
-
i4mat_is_integer.m,
is TRUE if all entries of an I4MAT are actually integers;
-
i4mat_l1_inverse.m,
returns the inverse of a unit lower triangular I4MAT;
-
i4mat_max.m,
returns the maximum element in an I4MAT.
-
i4mat_max_index.m,
returns the location of the maximum element of an I4MAT;
-
i4mat_min.m,
returns the minimum element in an I4MAT.
-
i4mat_min_index.m,
returns the location of the minimum element of an I4MAT;
-
i4mat_perm.m,
applies a permutation to the rows and columns of an I4MAT;
-
i4mat_perm_uniform.m,
selects a random permutation of an I4MAT;
-
i4mat_perm2.m,
applies a row and a column permutation to an I4MAT;
-
i4mat_perm2_uniform.m,
selects random row and column permutations of an I4MAT;
-
i4mat_print.m,
prints an I4MAT;
-
i4mat_print_some.m,
prints some of an I4MAT;
-
i4mat_product_elementwise.m,
computes the elementwise product of two I4MAT's.
-
i4mat_rank.m,
computes the rank of an I4MAT;
-
i4mat_ref.m,
returns the integer row echelon form of an I4MAT.
-
i4mat_row_reduce.m,
divides out a common factor in one row of an I4MAT.
-
i4mat_row_swap.m,
swaps two rows of an I4MAT.
-
i4mat_rref.m,
returns the integer reduced row echelon form of an I4MAT.
-
i4mat_rref_solve_binary.m,
seeks binary solutions (if any) of an integer row reduced echelon form
linear system.
-
i4mat_rref_solve_binary_nz.m,
seeks binary solutions (if any) of an integer row reduced echelon form
linear system, but only consider solutions with exactly NZ nonzeros.
-
i4mat_rref_system.m,
considers an underdetermined integer linear system A*x=b,
and uses the integer row reduced echelon form (IRREF)
to find the solvable augmented linear system, with degrees of
freedom indicated.
-
i4mat_sum.m,
returns the sum of the entries of an I4MAT.
-
i4mat_transpose.m,
transposes an I4MAT;
-
i4mat_transpose_print.m,
prints an I4MAT, transposed;
-
i4mat_transpose_print_some.m,
prints some of an I4MAT, transposed;
-
i4mat_u_solve.m,
solves an upper triangular linear system involving only integer values.
-
i4mat_u1_inverse.m,
returns the inverse of a unit upper triangular I4MAT;
-
i4mat_uniform_ab.m,
returns an I4MAT of pseudorandom values;
-
i4mat_width.m,
returns the printing width of an I4MAT;
-
i4row_compare.m,
compares two rows of an I4ROW.
-
i4row_find_item.m,
searches the rows of an I4ROW for a given value.
-
i4row_find_pair_wrap.m,
searches the rows of an I4ROW for a given pair of values.
-
i4row_max.m,
returns the row maximums of an I4ROW.
-
i4row_mean.m,
returns the row means of an I4ROW.
-
i4row_min.m,
returns the row minimums of an I4ROW.
-
i4row_sort_a.m,
ascending sorts the rows of an I4ROW.
-
i4row_sort_d.m,
descending sorts the rows of an I4ROW.
-
i4row_sort2_d.m,
descending sorts the rows of an I4ROW.
-
i4row_sorted_unique.m,
returns the unique rows of an I4ROW.
-
i4row_sorted_unique_count.m,
counts the unique rows of an I4ROW.
-
i4row_sum.m,
returns the row sums of an I4ROW.
-
i4row_swap.m,
swaps two rows of an I4ROW.
-
i4row_variance.m,
returns the row variances of an I4ROW.
-
i4rows_to_i4mat.m,
copies data from a rowwise vector to a columnwise doubly-indexed
array.
-
i4vec_add.m,
returns C = A + B for I4VEC's.
-
i4vec_amax.m,
returns the maximum absolute value of an entry in an I4VEC;
-
i4vec_amax_index.m,
returns the index of the maximum absolute value
of an entry in an I4VEC;
-
i4vec_amin.m,
returns the minimum absolute value of an entry in an I4VEC;
-
i4vec_amin_index.m,
returns the index of the minimum absolute value
of an entry in an I4VEC;
-
i4vec_aminz.m,
returns the minimum nonzero absolute value of an entry in an
I4VEC;
-
i4vec_aminz_index.m,
returns the index of the minimum nonzero absolute value
of an entry in an I4VEC;
-
i4vec_ascend_sub.m,
returns the longest ascending subsequence of an I4VEC;
-
i4vec_binary_next.m,
returns the next binary vector.
-
i4vec_bracket.m,
searches a sorted I4VEC for successive brackets of a value;
-
i4vec_choose.m,
evaluates the generalized binomial coefficient.
-
i4vec_compare.m,
compares two I4VEC's;
-
i4vec_concatenate.m,
concatenates two I4VEC's;
-
i4vec_cum.m,
returns the cumulative sums of an I4VEC;
-
i4vec_cum0.m,
returns the cumulative sums of an I4VEC;
-
i4vec_decrement.m,
decrements an I4VEC;
-
i4vec_direct_product.m,
forms the elements of the direct product of I4VEC's.
-
i4vec_direct_product2.m,
forms the elements of the direct product of I4VEC's.
-
i4vec_dot_product.m,
computes the dot product of two I4VEC's.
-
i4vec_find.m,
indexes the first occurrence of a specific value in an I4VEC.
-
i4vec_first_index.m,
indexes the first occurrence of values in an I4VEC.
-
i4vec_frac.m,
finds the K-th smallest entry of an I4VEC;
-
i4vec_gcd.m,
returns the greatest common divisor of the entries of an
I4VEC;
-
i4vec_heap_a.m,
sets an I4VEC to a ascending heap;
-
i4vec_heap_d.m,
sets an I4VEC to a descending heap;
-
i4vec_heap_d_extract.m,
extracts the maximum value from a descending heap.
-
i4vec_heap_d_insert.m,
inserts a new value into a descending heap.
-
i4vec_heap_d_max.m,
returns the maximum value in a descending heap of integers.
-
i4vec_histogram.m,
returns a histogram of the entries of an I4VEC;
-
i4vec_histogram_masked.m,
returns a histogram of a masked I4VEC;
-
i4vec_identity_row.m,
returns a row of the identity matrix as an I4VEC.
-
i4vec_imin.m,
returns the index of the minimum entry in an I4VEC.
-
i4vec_increment.m,
increments an I4VEC;
-
i4vec_index.m,
returns the first location of a given value in an I4VEC.
-
i4vec_index_delete_all.m,
deletes all occurrences of a value from an indexed sorted list;
-
i4vec_index_delete_dupes.m,
deletes duplicates from an indexed sorted list.
-
i4vec_index_delete_one.m,
deletes one copy of a value from an indexed sorted list.
-
i4vec_index_insert.m,
inserts a value in an indexed sorted list.
-
i4vec_index_insert_unique.m,
inserts a unique value in an indexed sorted list.
-
i4vec_index_order.m,
sorts an integer vector using an index vector.
-
i4vec_index_search.m,
searches for a value in an indexed sorted list.
-
i4vec_indexed_heap_d.m,
creates a descending heap from an indexed I4VEC.
-
i4vec_indexed_heap_d_extract.m,
extracts from heap descending indexed I4VEC.
-
i4vec_indexed_heap_d_insert.m,
inserts value into heap descending indexed I4VEC.
-
i4vec_indexed_heap_d_max.m,
maximum value in heap descending indexed I4VEC.
-
i4vec_indicator0.m,
sets an I4VEC to the indicator vector.
-
i4vec_indicator1.m,
sets an I4VEC to the indicator vector.
-
i4vec_insert.m,
inserts a value at a particular location in an I4VEC.
-
i4vec_is_ascending.m,
is true if an I4VEC is ascending;
-
i4vec_is_binary.m,
is true if an I4VEC has only 0 and 1 entries;
-
i4vec_is_descending.m,
is true if an I4VEC is descending;
-
i4vec_is_distinct.m,
is true if the entries of an I4VEC are distinct;
-
i4vec_is_equal.m,
is true if two I4VEC's are equal.
-
i4vec_is_even_all.m,
is true if all entries of an I4VEC are even.
-
i4vec_is_even_any.m,
is true if any entries of an I4VEC are even.
-
i4vec_is_lt_any.m,
is true if any A is less than B, for I4VEC's.
-
i4vec_is_negative_any.m,
is true if any entry of an I4VEC is negative;
-
i4vec_is_nonpositive_all.m,
is true if all entries of an I4VEC are nonpositive;
-
i4vec_is_nonzero_any.m,
is true if any entry of an I4VEC is nonzero;
-
i4vec_is_odd_all.m,
is true if all entries of an I4VEC are odd.
-
i4vec_is_odd_any.m,
is true if any entries of an I4VEC are odd.
-
i4vec_is_one.m,
is true if all entries of an I4VEC are 1;
-
i4vec_is_pairwise_prime.m,
is true if the entries of an I4VEC are pairwise prime;
-
i4vec_is_zero.m,
is true if all entries of an I4VEC are 0;
-
i4vec_lcm.m,
returns the lowest common multiple of the entries of an I4VEC;
-
i4vec_max.m,
returns the maximum entry in an I4VEC;
-
i4vec_max_index.m,
returns the index of the maximum entry in an I4VEC;
-
i4vec_max_index_last.m,
returns the index of the last maximum entry in an I4VEC;
-
i4vec_mean.m,
returns the mean of an I4VEC;
-
i4vec_mean_i4.m,
returns the I4 mean of an I4VEC;
-
i4vec_median.m,
returns the median of an I4VEC;
-
i4vec_merge_a.m,
merges two ascending-sorted I4VEC's;
-
i4vec_min.m,
returns the minimum entry in an I4VEC;
-
i4vec_min_index.m,
returns the index of the minimum entry in an I4VEC;
-
i4vec_min_mv.m,
determines U(1:N) /\ V for vectors U and a single vector V.
-
i4vec_negone.m,
returns an I4VEC of -1's;
-
i4vec_nonzero_count.m,
counts the nonzero entries in an I4VEC;
-
i4vec_nonzero_first.m,
left shifts the nonzero entries in an I4VEC;
-
i4vec_norm_l0.m,
returns the l0 "norm" of an I4VEC;
-
i4vec_one.m,
returns an I4VEC of 1's;
-
i4vec_order_type.m,
determines if an I4VEC is (non)strictly ascending/descending;
-
i4vec_part.m,
partitions an integer into N nearly equal parts;
-
i4vec_part_quick_a.m,
reorders an I4VEC as part of a quicksort;
-
i4vec_permute.m,
permutes an I4VEC in place;
-
i4vec_permute_uniform.m,
randomly permutes an I4VEC in place;
-
i4vec_print.m,
prints an I4VEC;
-
i4vec_print_mask.m,
prints masked elements of an I4VEC;
-
i4vec_print_part.m,
prints part of an I4VEC;
-
i4vec_print_select.m,
prints selected elements of an I4VEC;
-
i4vec_print_some.m,
prints some of an I4VEC;
-
i4vec_red.m,
divides out common factors in an I4VEC;
-
i4vec_reverse.m,
reverses the order of the entries of an I4VEC;
-
i4vec_rotate.m,
"rotates" the entries of an I4VEC;
-
i4vec_run_count.m,
counts the runs in an I4VEC;
-
i4vec_search_binary_a.m,
uses binary search on an ascending sorted I4VEC;
-
i4vec_search_binary_d.m,
uses binary search on a descending sorted I4VEC;
-
i4vec_sort_bubble_a.m,
ascending sorts an I4VEC using bubble sort;
-
i4vec_sort_bubble_d.m,
descending sorts an I4VEC using bubble sort;
-
i4vec_sort_heap_a.m,
ascending sorts an I4VEC using heap sort;
-
i4vec_sort_heap_d.m,
descending sorts an I4VEC using heap sort;
-
i4vec_sort_heap_index_a.m,
computes an index vector to ascending sort an I4VEC;
-
i4vec_sort_heap_index_d.m,
computes an index vector to descending sort an I4VEC;
-
i4vec_sort_insert_a.m,
ascending sorts an I4VEC using insertion sort;
-
i4vec_sort_insert_d.m,
descending sorts an I4VEC using insertion sort;
-
i4vec_sort_quick_a.m,
ascending sorts an I4VEC using quick sort;
-
i4vec_sort_shell_a.m,
ascending sorts an I4VEC using Shell's sort;
-
i4vec_sorted_undex.m,
returns unique sorted indexes for a sorted I4VEC.
-
i4vec_sorted_unique.m,
returns the unique elements in a sorted I4VEC;
-
i4vec_sorted_unique_count.m,
counts the number of unique elements in a sorted I4VEC;
-
i4vec_sorted_unique_hist.m,
creates a histogram of the unique elements in a sorted I4VEC;
-
i4vec_split_unsort.m,
"splits" an unsorted I4VEC based on a splitting value;
-
i4vec_std.m,
returns the standard deviation of an I4VEC;
-
i4vec_sum.m,
sums the entries of an I4VEC.
-
i4vec_sum_vec.m,
computes the pairwise sum of two I4VEC's.
-
i4vec_swap.m,
swaps two I4VEC's;
-
i4vec_transpose_print.m,
prints an I4VEC "transposed";
-
i4vec_undex.m,
returns unique sorted indexes for an I4VEC.
-
i4vec_uniform_ab.m,
returns a pseudorandom I4VEC in a given range;
-
i4vec_unique_count.m,
counts the number of unique elements in an unsorted I4VEC;
-
i4vec_unique_index.m
-
i4vec_value_index.m,
indexes I4VEC entries equal to a given value;
-
i4vec_value_num.m,
counts I4VEC entries equal to a given value;
-
i4vec_variance.m,
returns the variance of an I4VEC;
-
i4vec_width.m,
returns the "width" of an I4VEC;
-
i4vec2_compare.m,
compares pairs of integers stored in two vectors;
-
i4vec2_print.m,
prints a pair of I4VECs.
-
i4vec2_sort_a.m,
ascending sorts an I4VEC2;
-
i4vec2_sort_d.m,
descending sorts an I4VEC2;
-
i4vec2_sorted_unique.m,
finds unique elements in a sorted I4VEC2;
-
i4vec2_sorted_unique_count.m,
counts unique elements in a sorted I4VEC2;
-
ksub_next4.m,
selects the next subset of size K from a set of size N.
-
l4_to_i4.m,
converts an L4 to an I4;
-
l4_xor.m,
evaluates the exclusive OR of two L4's.
-
pascal_to_i4.m,
converts a pair of indices in Pascal's triangle to a linear index;
-
perm0_check.m,
checks a permutation of (0,...,N-1)
-
perm0_uniform.m,
selects a random permutation of 0, ...,N-1;
-
perm1_check.m,
checks a permutation of (1,...,N);
-
perm1_uniform.m,
selects a random permutation of 1, ..., N;
-
permutation_symbol.m,
evaluates the Levi-Civita permutation symbol.
-
prime.m,
a list of prime numbers.
-
r8_gamma_log.m,
returns the logarithm of the gamma function.
-
r8_uniform_ab.m,
returns a random R8 between given limits.
-
r8vec_is_integer.m,
is true if all entries of an R8VEC are integers;
-
r8vec_print.m,
prints an R8VEC;
-
sort_heap_external.m,
external sorts a list of values into ascending order;
-
timestamp.m,
prints the current YMDHMS date as a timestamp;
-
triangle_lower_to_i4.m,
converts a pair of indices in a lower triangle to an I4.
-
triangle_upper_to_i4.m,
converts a pair of indices in an upper triangle to an I4.
Examples and Tests:
Last revised on 01 Februrary 2019,