Rank: 3181 based on 11 downloads (last 30 days) and 5 files submitted
photo

Steven Gregory

E-mail
Lat/Long
35.97389, 114.855

Personal Profile:

origami
daschunds
group theory

Professional Interests:
esd

 

Watch this Author's files

 

Files Posted by Steven View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
28 Jan 2011 vecgcd Computes the GCD of the elements of the integer vector V. Author: Steven Gregory gcd, number theory 4 3
24 Jan 2011 egcd.m Extended greatest common divisor. Finds g = GCD(x(1), ..., x(end)) and v such that g == sum(v.*x). Author: Steven Gregory mathematics, vpi, number theory 2 0
12 Aug 2010 nextperm Outputs the next permutation of the ordered tuple x. Author: Steven Gregory permutation, permutation iterator, mathematics 2 2
27 Apr 2009 modinv(x, N) Computes multiplicative inverse of x modulo N Author: Steven Gregory vpi, mod, mathematics, modular arithmetic 2 6
  • 3.0
3.0 | 2 ratings
23 Apr 2009 logmod Computes y such that mod(a^y, p^N) == x Author: Steven Gregory vpi, mod, modular arithmetic, mathematics 1 2
  • 5.0
5.0 | 2 ratings
Comments and Ratings by Steven View all
Updated File Comments Rating
05 Oct 2011 modinv(x, N) Computes multiplicative inverse of x modulo N Author: Steven Gregory

It's not an error. The number returned is y such that mod(x*y, N) == 1 is TRUE. If you want it to be a positive number, then add N to it.

25 Mar 2011 modinv(x, N) Computes multiplicative inverse of x modulo N Author: Steven Gregory

This module, and any others tagged vpi, require John D'Errico's vpi suite of programs. As listed under "Other requirements".

16 Apr 2009 logmod Computes y such that mod(a^y, p^N) == x Author: Steven Gregory

Thanks for the 5 stars. I wrote this program in Mathematica because I am doing something number theory -ish (for fun) that required it. I prefer Matlab as I think of Mathematica as a really expensive Swiss army knife. I really don't expect anyone else to need it but when I saw your VPI software I just had to try it out.

I don't have a lot of free time and I hadn't noticed that you updated the VPI software. I'm sorry I hadn't because it would have saved me some effort as well as cleaned up my code somewhat.

I promise as soon as the alligators subside a bit, I will update the program.

I have a Microsoft Word 2003 document that describes the algorithm if anyone is interested. I will add that to the upgrade as soon as I figure out how to do it.

13 Apr 2009 nextperm Outputs the next permutation of the ordered tuple x. Author: Steven Gregory

I don't know how to edit my own submission. The description should read "Using lexical order on the set {1, 2, ..., N}...".

Comments and Ratings on Steven's Files View all
Updated File Comment by Comments Rating
06 Feb 2012 vecgcd Computes the GCD of the elements of the integer vector V. Author: Steven Gregory Alex

I noted a mistake in my above code. the following line should go before the other code.

v = abs(sort(v, 'descend'));

06 Feb 2012 vecgcd Computes the GCD of the elements of the integer vector V. Author: Steven Gregory Alex

I took a look and made some quick modifications to speed up the loop.

current_gcd = 0;
for i = 1: length(v)
loop_gcd = mod(v(i), current_gcd);
if(loop_gcd > 0)
  currernt_gcd = loop_gcd;
end
end

This reduces your computation time by about 1/3 for small vectors. I imagine this will increase with larger vectors, because you do not run into issues where the v vector is increasing in size as the while loop continues. Also, as the above commenter noted, you have a line that should be commented out (e x = g).

Also, this adjustment means that it doesn't matter if it is a row or column vector.

10 Oct 2011 modinv(x, N) Computes multiplicative inverse of x modulo N Author: Steven Gregory Nanthini

thanks Steven...i got it...

05 Oct 2011 modinv(x, N) Computes multiplicative inverse of x modulo N Author: Steven Gregory Gregory, Steven

It's not an error. The number returned is y such that mod(x*y, N) == 1 is TRUE. If you want it to be a positive number, then add N to it.

04 Oct 2011 modinv(x, N) Computes multiplicative inverse of x modulo N Author: Steven Gregory Nanthini

hi i used your modinv function the program is given below

a= input('Please input a vpi number: ','s');
f=vpi(a);
e=nextprime(f);
d=modinv(vpi(e),vpi('10641850662478050775300838063179295326495311244216495264720240475083278486076641392553755151560108920715482251286670052918931640724590870256900164694640700350819991051744179236211734410573176997209650364459122853571059016377162766023444746540824998138258407652750335008405190180074534476000047130911251907798499684299595857553973251414375363400538217657736630155539478633941291033068252991757356109381559827851766572043021641234224646877436996703749498922980940934823068060307119029571082281451848485625212652649192958086070122442905758802027526434401481214679307640378414874445695431164943304505187971133265334792817439396071458544945483012899852152133643802968883876'));
disp(d);

For this i got output like this
Please input a vpi number: 78932798709875897985798239632962
  -521510991024643651399669163491559260313526227617474791885763042505857
664977385561168456997539245033945323802087603744630561104830663196609729
027089135771997781645557505192562664968792519121732948128932325159571954
569243970932264987495930313006348655908194700156297275119605911309222114
908823626023733986115222495783413651229506339868566939895630365025986535
210301856596816873363852149927397763766351293662529444692448582845757980
384646334165589784970212497170690948718484808254845836093034729679728997
842249100410667287038983219348274168413156054636466230079069467248343347
119255305695342572748941360728235707527909213139658151308501287396735563
0404723105668513063513

i got negative value for variable 'd'....
The result should be in positive but the result displayed by this function is negative please suggest some idea to rectify this error....

Top Tags Applied by Steven
mathematics, number theory, vpi, mod, modular arithmetic
Files Tagged by Steven View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
28 Jan 2011 vecgcd Computes the GCD of the elements of the integer vector V. Author: Steven Gregory gcd, number theory 4 3
24 Jan 2011 egcd.m Extended greatest common divisor. Finds g = GCD(x(1), ..., x(end)) and v such that g == sum(v.*x). Author: Steven Gregory mathematics, vpi, number theory 2 0
12 Aug 2010 nextperm Outputs the next permutation of the ordered tuple x. Author: Steven Gregory permutation, permutation iterator, mathematics 2 2
27 Apr 2009 modinv(x, N) Computes multiplicative inverse of x modulo N Author: Steven Gregory vpi, mod, mathematics, modular arithmetic 2 6
  • 3.0
3.0 | 2 ratings
23 Apr 2009 logmod Computes y such that mod(a^y, p^N) == x Author: Steven Gregory vpi, mod, modular arithmetic, mathematics 1 2
  • 5.0
5.0 | 2 ratings

Contact us at files@mathworks.com