Search Comments and Ratings

go

Comments and Ratings

   
Date File Comment by Comment Rating
10 Sep 2009 multisetdiff like setdiff, but any repeated elements of A are removed only once for each time they occur in B Author: Ben Petschel Jos

Please ignore my previous thought as it is incorrect !!

10 Sep 2009 multisetdiff like setdiff, but any repeated elements of A are removed only once for each time they occur in B Author: Ben Petschel Jos

Nice utility! Just a thought, for numerical vectors, this might be more convenient:

C = union(A,B) ;
res = C(histc(A,C) > histc(B,C))

To deal with rows of matrices or cell array strings, one could convert A and B into indices using, e.g., the third output of unique.

01 Sep 2009 Pointers Toolbox basic functions to work with pointer variables and dynamic data types Author: Ben Petschel Philip

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

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

Great work!

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

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

31 Jul 2009 Fractions Toolbox create and manipulate fractions (K+N/D) using exact arithmetic Author: Ben Petschel Hamed, Khaled

Very useful toolbox, especially with the added precision of the vpi toolbox.

I think the demo_fr.m file needs an "echo on" at the beginning to see the header of each of the demo problems, rather than answers only (followed by echo off at the end).

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

Hi Khaled, thanks for pointing that out (I forgot to run "rehash path" when testing without the vpi toolbox). I've submitted an update which should become available soon. Let me know if you have any further problems.

31 Jul 2009 Fractions Toolbox create and manipulate fractions (K+N/D) using exact arithmetic Author: Ben Petschel Hamed, Khaled

It seems to require vpi to be in the Matlab path, or a previous instance of a vpi.

>> fr(1,7)
??? Error using ==> superiorto
Unknown class 'vpi' listed in 'SUPERIORTO'.

Error in ==> fr.fr at 201
superiorto('vpi','double','single','int8','uint8','int16', ...

30 Jul 2009 Fractions Toolbox create and manipulate fractions (K+N/D) using exact arithmetic Author: Ben Petschel D'Errico, John

Nifty

22 Jul 2009 sumsqint Finds all distinct ways of writing a number as the sum of squares, i.e. solve x^2+y^2=n for 0<=x<=y. Author: Ben Petschel D'Errico, John

A nifty piece of code. Well written. Good help. Fast - even on my old cpu.

tic,xy = sumsqint(vpi(51)^32);toc
Elapsed time is 3.341508 seconds.

xy
xy =
                    0 2094704750199298376445300801
     30716516552930718230081601 2094479526306800294009550720
    180465099249163605704475624 2086916466574667319894682335
    211048005566589191194875615 2084045760019167609213236376
    389810107080067581524800449 2058114688477231401347749200
    419948158440662717915958480 2052177266887488219864204351
    595187985793527352363191624 2008367310049272061252396065
    624574464800990440465293345 1999423599047000686612625976
    794508588038500176810750399 1938180614401189862809267680
    822844426109404969034724960 1926321634859606979062120001
    985743411858493353621318024 1848268897234675038039971295
   1012740232867550772089860575 1833615338951679921429565176
   1141312248313811332042623120 1756472129683923585457907649
   1166946244920716396566413249 1739547197397341212272914160
   1312474653765815584332588255 1632543498265760609883402024
   1336272971277049795744294824 1613121984458060091449141025
   1470279898076299222086296640 1492000339081815417640023999

 

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