Code covered by the BSD License
 demo_vpi
 base2vpi(B,base)bin2vpi: converts an integer in an arbitrary base into vpi (decimal) form
 bin2vpi(B)bin2vpi: converts a binary representation of an integer into vpi (decimal) form
 binomfactors(n,k)binomfactors: list all factors of the binomial coefficient nchoosek(n,k)
 catdigits(N,M)catdigits: concatenates the digits of N and M into an aggregate number
 createPrimesListcreatePrimesList  For users of older matlab releases, this function will generate a compatible _primeslist_ file
 factorialfactors(n)factorialfactors: efficient computation of the prime factors of factorial(n)
 fibonacci(n,modulus)fibonacci: vpi tool to efficiently compute the n'th Fibonacci number and the n'th Lucas number
 getprimeslist
loads the primeslist file, and decompresses it, returning the list of primes up to 2^26
 ispalindrome(N)ispalindrome: test if the number N (vpi or numeric, or a digit string as a vector) is a palindrome
 iszero(INT)vpi/iszero: test to see if a numeric object is zero
 legendresymbol(a,p)legendresymbol: computes the legendre symbol (a/p) for prime p
 lineardiophantine(A,B,C)lineardiophantine: solve the linear Diophantine equation, A*x + B*y = C
 mersenne(p)mersenne: identify whether 2^p1 is a Mersenne prime, using the LucasLehmer test
 minv(a,p)
 modfibonacci(n,modulus)fibonacci: compute the n'th Fibonacci number and the n'th Lucas number, all modulo a given value
 modrank(A,p)modrank: compute the rank of an integer array, modulo p
 modroot(a,p)
 modsolve(A,rhs,p)
 nextprime(N,direction,kpr...nextprime: finds the next larger prime number directly above (or below) N
 numberOfPartitions(N)numberOfPartitions: compute the number of partitions of the positive integer n
 powermod(a,d,n)vpi/powermod: Compute mod(a^d,n)
 quadraticresidues(N)quadraticresidues: returns a list of the possible quadratic residues of the integer N
 quotient(numerator,denomi...quotient: divides two integers, computing a quotient and remainder
 subfactorial(N)subfactorial: The subfactorial of an integer (or integers) N, known as !N
 totient(N)vpi/totient: the number of positive integers less than N that are coprime to N
 vpi(N)vpi: Creator function for a variable precision integer

View all files
Variable Precision Integer Arithmetic
by
John D'Errico
19 Jan 2009
(Updated
31 Jul 2013)
Arithmetic with integers of fully arbitrary size. Arrays and vectors of vpi numbers are supported.

createPrimesList 
function createPrimesList
% createPrimesList  For users of older matlab releases, this function will generate a compatible _primeslist_ file
% usage: createPrimesList
%
% Note that createPrimesList will take a half minute or so to run, but
% having done so, then it needs never run it again, as it will overwrite
% your _primeslist_ file in the @vpi directory. Thenceforth, users of vpi
% with older matlab releases will be able to use factor. factor actually
% will call createPrimesList automatically if it has a problem loading
% that file.
%
% see also: getprimeslist, primes
%
% Author: John D'Errico
% email: woodchips@rochester.rr.com
% Release: 1.0
% Release date: 7/22/09
% get the path to the vpi directory
% we know that createPrimesList must live there
vpipath = which('createPrimesList');
vpipath = fileparts(vpipath);
% this is the full name (path included) of the
% _primeslist_ .mat file
primeslistfilename = fullfile(vpipath,'@vpi','_primeslist_.mat');
% create the primeslist variable
primeslist = primes(2^26);
% since no pair of primes are spaced farther
% apart than 220 in this range, we can compress
% the entire list by a simple diff then a uint8.
primeslist = uint8(diff(primeslist));
% and save it to the proper location
save(primeslistfilename,'primeslist')


Contact us