SVD behavior in mp different from Matlab when applied to negative scalar
I have the following question:
In one of my examples I need to compute the Singular Value Decomposition (SVD) of a negative scalar, specifically -0.7276.
In double precision, Matlab returns:
>> [U S V]=svd(-0.7276)
In MP, I obtain:
s=mp('-0,7276');
>> [U,S,V]=svd(s)
The definition of SVD states that the matrix S should have nonnegative diagonal entries. In the above example, the first two elements seem to be multiplied by -1 compared to Matlab output. While the product doesn't change, the unexpected negative sign of the singular value causes problems in subsequent code.
Is this a bug or is there an option to make it return the same output as Matlab's svd?
The 4.2.3.11967 release of the toolbox was used.
Thank you,
Denis
Dear Denis,
Thank you very much for the report!
Indeed, this is bug and it has been fixed in latest build.
Please download updated version: http://goo.gl/pMXV3
Thank you,
Pavel.
How can I run FresnelS and FresnelC functions?
When I add the multiprecision computing toolbox and type FresnelS(1) in matlab command, I get the following error message.
Cannot find an exact (case-sensitive) match for 'FresnelS'
The closest match is: fresnels in C:\Program
Files\MATLAB\R2016a\toolbox\symbolic\symbolic\@double\fresnels.m
Also, when I type fresnels(mp(1)), I get
Undefined function 'fresnels' for input arguments of type 'mp'.
How can I solve this problem?
Nonequidistant FFT
Dear Pavel,
It would be great to support the non-equidistant Fast Fourier Transform.
https://www-user.tu-chemnitz.de/~potts/nfft/
Regards,
Didier
Integer matrix
I have matrices they are made of integers. Do I need to define mp even for integers? For example:
N=100;
A=(zeros(N+1,N+1));
for l=1:N;
for k=mod(l-1,2):3:l;
A(k+1,l+1)=3*l;
end
end
and
p=0:1:N;
kron(p',p);
and
I=ones(N+1,1);
II=(-1).^(0:N);
G=kron(I,II);
Integer is normally considered as infinite precision. I use these matrices in further calculation with non-integer matrices, therefore, results. But using mp.Digits(100) for example costs me a lot in here for no gain actually.
Error using pinv
??? Error using ==> mp>mp.pinv at 2964
Extremely slow interp1
Hi,
Could you please advise why interp1 with mp is so slow compared to original matlab interp1? belwo is the example I'm running. Thank you for your kind help
mohsen
% Grid length and useful vectors
N = 200;
kp = mp(linspace(1e-6,5,N))';
n = mp( ones(1,2)); nn = mp(ones(N,1));
% parameters & given values
gam = 2; beta = 0.96;
R = 1.05; w0 = 3.44;
prob = mp([0.9500, 0.0500; 0.6750, 0.3250]);
w = mp(sort( w0*( .995 + randn(N,1)/7.5 ) ));
W = [w, 0*nn];
% initialize
Cp = mp(R)*kp*n; k = Cp;
% convergence criterion
Cp_crit = 1;
% Interpolate until convergence
ii = 0; tic
while Cp_crit > 1e-3
Cp0 = Cp;
EMUp = (Cp.^(-mp(gam)))*prob';
C = (mp(beta*R)*EMUp).^(-1/mp(gam));
k = ( kp*n + C - W)/mp(R);
% Use the relation between C and k to ropose a new vector Cp corresponding to kp
for i=1:2
% Update the function by interpolation.
Cp(:,i) = interp1(k(:,i), C(:,i), kp,'linear','extrap');
end
Cp_crit = max(max(abs(Cp0-Cp)./(1+abs(Cp))));
ii = ii+ 1;
end
toc
disp(Cp_crit)
Bug in relational operations
Hi.
I think there is a bug in the relational operations "equal" and "unequal"
test(:,1)=(1:4)';
testmp=mp(test);
This works:
test==1
ans =
1
0
0
0
testmp==1
ans =
1
0
0
0
This doesn't
1==test
ans =
1
0
0
0
1==testmp
ans =
1
This has worked in previous versions though.
Best regards,
Michael
use save and load
more precisely as save sets of objects containing mp elements, then load them ?,
or such as saving array mp text and then load ?
Customer support service by UserEcho