Tus comentarios

Thank you for your question.


Frankly, we didn't expect that conversion to string would be an important part of numerical computations (e.g. running in O(n^2) loop or similar). That is why we didn't optimize it to the maximum extent. I guess your case is very special in this regard.

What do you with the number after conversion (e.g. numeric computations)? I am pretty sure computations will be way more faster compared to vpa.


We have just updated toolbox distribution/installer with the 'flintmax.m' already included.

Please download and use the latest toolbox version.

There is a quick way to make the built-in 'nchoosek()' work with toolbox. Create flintmax.m file in [toolbox_folder]\@char directory with following content:

function r = flintmax( classname )

if strcmpi('mp',classname)
r = 2^ceil(mp.Digits() * mp('log2(10)'));
else
r = builtin('flintmax',classname);
end
end

Restart MATLAB and test 'nchoosek()', e.g.:

>> mp.Digits(100);
>> x = nchoosek(mp(1000),50)

x = 

9460461017585217574825413104128279942327590136138287606176460370151247948488653144064

Toolbox doesn't include this function at the moment. Now I am considering to add it.

How do you use it? Just to compute binomial coefficient or to generate all combinations?

In our changelog we use 100 digits, but speed-up is implemented for any precision level.


Ok, we can make quadruple even faster, e.g. like this:

>> mp.Digits(34);M=500;A=(rand(M,'mp'))*10;

>> tic; expm(A); toc; % new Elapsed time is 5.859282 seconds. >> tic; expm(A); toc; % old Elapsed time is 26.809653 seconds.

Roughly ~5 times speed-up. 


Give me a minute, I will send you mpexpm.p with appropriate changes for quadruple.

Speed-up is valid for all precisions, including quadruple.  For quadruple speed is improved by ~2 times, e.g.:

>> mp.Digits(34);M=500;A=(rand(M,'mp'))*10;

>> tic; expm(A); toc; % new Elapsed time is 12.147127 seconds. >> tic; expm(A); toc;  % old Elapsed time is 26.809653 seconds.

We can make it 4 times for quadruple is well, let me know if you are interested.

We have just included lsqnonneg into the newest toolbox version. Please re-download it from our webpage. Examples:

>> mp.Digits(34);
>> C = mp('[0.0372 0.2869; 0.6861 0.7071; 0.6233 0.6245; 0.6344 0.6170]');
>> d = mp('[0.8587; 0.1781; 0.0747; 0.8405]');
>> x = lsqnonneg(C,d)

x =

0
0.6929343971302933831938176511663673
>> mp.Digits(100);
>> C = mp('[0.0372 0.2869; 0.6861 0.7071; 0.6233 0.6245; 0.6344 0.6170]');
>> d = mp('[0.8587; 0.1781; 0.0747; 0.8405]');
>> x = lsqnonneg(C,d)

x =

0
0.6929343971302933831938176511663670971062510...868165705163788676921766095

Options and multiple outputs are also supported.

Let me know how it works for your problem.

Thank you for confirmation!