Rank: 12655 based on downloads (last 30 days) and 0 files submitted
photo

Derek O'Connor

E-mail
Company/University
University College, Dublin
Lat/Long
53.0, 6.0

Personal Profile:

Professional Interests:

 

Watch this Author's files

 

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

John,

The demo_vpi.m needs your consolidator function:

http://www.mathworks.com/matlabcentral/fileexchange/8354-consolidator

Great package.

Derek O'Connor

15 Sep 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter

John -- Thanks for pointing out that Int64 matrix multiplication is element-wise. I should have been more careful, given that the description clearly states that "multiplication and division are element-wise only". This of course explains the O(n^2) behavior.

On a more general point, I wish there was a consistent standard for matrix multiplicaton. For example, in O-Matrix, C= A*B is the same as Matlab, but C=A^2 gives cij = (aij)^2. This is really confusing. In Fortran 90, C=A*B gives cij = aij*bij.

15 Sep 2009 INT64 arithmetic in MATLAB Enables int64 Addition, subtraction, multiplication, division and modulus. Author: Petter

This seems to be an excellent package. I used it to test matrix multiplication
and obtained very surprising results : multiplying two 10^4x10^4 int64 matrices took about 2 secs while two doubles took about 35 secs. The double mat-mult used the Math Kernel and all 8 cores while the int64 did not use the Math Kernel.

Also, a 2-degree polyfit of the int64 mat-mult times was very good, i.e., t(n) is O(n^2)!

Can anyone enlighten me? Here is the test function:

function times = TimesInt64(v,degree);
% Test matrix multiplication using int64arithmetic
% int64arithmetic compiled with Microsoft Visual C++ 2008
% Dell Precision 690, 2xQuadcore Xeon 5345, 2.3GHz, 16GB
% Windows Vista 64
% Example : >> times = TimesInt64(1:15,2);

% Derek O'Connor Sept 2009

nvals = v'*10^3;
times = zeros(length(nvals),1);
c = intmax('int64');
for k = 1:length(nvals)
    n = nvals(k);
    A64=int64(floor(c*rand(n,n)));
    B64=int64(floor(c*rand(n,n)));

    tic; A64*B64; times(k) = toc;
end;

p=polyfit(nvals,times,degree);
ptimes = polyval(p,nvals);
plot(nvals,times,'.',nvals,ptimes,'-')

% End Function TimesInt64(v,degree)

% n times (secs)
% 1000 0.0176
% 2000 0.06972
% 3000 0.15354
% 4000 0.34136
% 5000 0.50145
% 6000 0.63655
% 7000 0.9838
% 8000 1.2829
% 9000 1.5717
% 10000 2.0059
% 11000 2.4728
% 12000 3.0439
% 13000 3.4914
% 14000 4.2588
% 15000 4.9525

% p(x) = 0.098649 - 5.6075e-005*x + 2.5027e-008*x^2

01 Aug 2009 Fractions Toolbox create and manipulate fractions (K+N/D) using exact arithmetic Author: Ben Petschel

This is a very useful toolbox, especially when used with
John D'Errico's Variable Precision Integer Toolbox.

Here are two tests I ran :

   function z = RumpFrac(x,y)

   % Testing John D'Errico's Variable Precision Integer Toolbox
   % and Ben Petschel's Fractions Toolbox using
   % Rump's polynomial. Derek O'Connor Aug 01 2009

     x = fr(vpi(x));
     y = fr(vpi(y));

    R1 = (33375/100)*y^6+ x^2*(11*x^2*y^2-y^6- 121*y^4- 2)
    R2 = (55/10)*y^8
    R3 = x/(2*y)
    z1 = R1+R2
    z = z1 + R3;

%
% R1 =
% -7917111340668961361101134701524942850
% R2 =
% 7917111340668961361101134701524942848
% R3 =
% 1 + 11425 / 66192
% z1 =
% -2
% z =
% -1 + 11425 / 66192 = -54767/66192 --- Correct.

% z = -1.180591620717411e+021 without first two statements

and

function z = JuddFrac(x,y)
   % Testing John D'Errico's Variable Precision Integer Toolbox
   % and Ben Petschel's Fractions Toolbox using
   % Judd's polynomial. Derek O'Connor Aug 01 2009

     x = fr(vpi(x));
     y = fr(vpi(y));

 J1 = 1682*x*y^4
 J2 = 3*x^3
 J3 = 29*x*y^2
 J4 = - 2*x^5
 z1 = J1+J2
 z2 = z1+J3
 z3 = z2+J4
 z4 = z3+832
 z = z4/107751

% z = JuddFrac(192119201,35675640);
% J1 =
% 523460426438903533308340192814390277120000
% J2 =
% 21273236588999014470832803
% J3 =
% 7091078862999671298158400
% J4 =
% -523460426438903561672655644813075853992002
% z1 =
% 523460426438903554581576781813404747952803
% z2 =
% 523460426438903561672655644813076046111203
% z3 =
% 192119201
% z4 =
% 192120033
% z =
% 1783 --- Correct.

% z = 7.721506064908910e-003 without first two statements

10 Jul 2009 Binary Search for numeric vector Search given value in a sorted vector, returns the index of location where the value is found. Author: Dr. Murtaza Khan

Dear Dr Khan,
The comma should not have been included at the end of the link

http://www.derekroconnor.net/NA/Notes/NA-4-Latex.pdf

Please note that your Binary Search of rows of m by n matrix
also suffers from this error.

http://www.mathworks.com/matlabcentral/fileexchange/9095

Derek O'Connor

 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com