Rank: 44054 based on 0 downloads (last 30 days) and 0 file submitted
photo

Gabriel

E-mail

Personal Profile:

 

Watch this Author's files

 

Comments and Ratings by Gabriel View all
Updated File Comments Rating
06 Jun 2011 Variable Precision Integer Arithmetic Arithmetic with integers of fully arbitrary size. Arrays and vectors of vpi numbers are supported. Author: John D'Errico

@Sarla

Use isprime(vpi(p))?
It's probably faster than factoring the whole thing. It return 1 when the number is prime.

06 Jun 2011 Variable Precision Integer Arithmetic Arithmetic with integers of fully arbitrary size. Arrays and vectors of vpi numbers are supported. Author: John D'Errico

06 Jun 2011 Variable Precision Integer Arithmetic Arithmetic with integers of fully arbitrary size. Arrays and vectors of vpi numbers are supported. Author: John D'Errico

-_-

Lesson learned... Thank you =)
Is there a limit to the exponent in powermod?

06 Jun 2011 Variable Precision Integer Arithmetic Arithmetic with integers of fully arbitrary size. Arrays and vectors of vpi numbers are supported. Author: John D'Errico

Thank you for this great package. I am definitely not a pro programmer but I wrote a little function because I needed something like powermod from the Matlab symbolic toolbox. I might have made mistakes, but it seemed a lot faster to use this to compute the modulo of a power.
function result = powermod(x,power,modulus)
intermediateResult = x;
flag = 1;
for i=1:32
intermediateResult = mod(intermediateResult^2,modulus);
if(bitget(power,i))
if(flag)
moduloResult = intermediateResult;
flag = 0;
else
moduloResult = moduloResult*intermediateResult;
end
end
end
result = mod(moduloResult,modulus);
end

Contact us