Contents
- Testing the RBD algorithm for data coompression
- Exact decomposition for tensorial function
- Approximate decomposition
- Efficiency and accuracy of RBD
Called Functions
Testing the RBD algorithm for data coompression
clear all close all [X,Y] = meshgrid(-1:0.0004:1,-1:0.0004:1);
Exact decomposition for tensorial function
For an example, RBD decomposes the following three functions exactly.



Z = sin(pi*(X)).*cos(pi*(Y)); % need 1 [Z1, Z2] = RBD(Z,1e-13,22); max(max(abs(Z1*Z2 - Z))) Z = sin(pi*(X)).*cos(pi*(Y)) + 0.1*sin(10*pi*(X)).*cos(10*pi*(Y)); %need 2 [Z1, Z2] = RBD(Z,1e-13,22); max(max(abs(Z1*Z2 - Z))) Z = sin(pi*(X)).*cos(pi*(Y)) + 0.1*sin(10*pi*(X)).*cos(10*pi*(Y)) + 0.01*sin(100*pi*(X)).*cos(100*pi*(Y)); %need 3 [Z1, Z2] = RBD(Z,1e-13,22); max(max(abs(Z1*Z2 - Z)))
Reduced system getting singular - to stop with 1 basis functions ans = 4.3299e-15 Reduced system getting singular - to stop with 2 basis functions ans = 3.9968e-15 Reduced system getting singular - to stop with 3 basis functions ans = 1.7875e-14
Approximate decomposition
As an example, we test it on the following non-tensorial nonlinear function having multiple scales

with:



Z = 0.6*sin(pi*(X+2*Y)).*cos(pi*(2*X-Y)) + 0.1*sin(10*pi*(X-3*Y)).*cos(10*pi*(3*X+Y)) + sin(pi*(3*X.^2.*Y)).*cos(pi*(6*sqrt(abs(X))./(Y+2))); tic [Z1, Z2] = RBD(Z,1e-13,22); t_R = toc; tic [U,S,V] = svds(Z,22); t_S = toc;
Efficiency and accuracy of RBD
The RBD is 16 times faster than SVD for this data set.
More importantly, we plot the accuracy of the two methods as the size of the compressed space increases. And we observe that they have similar accuracy.
We also visualize this nontrivial dataset by plotting the contour plot of 
fprintf('The SVDs time over the RBD time is %f\n',t_S/t_R); error = zeros(22,2); for j=1:22 tm1 = Z1(:,1:j)*Z2(1:j,:); tm2 = U(:,1:j)*S(1:j,1:j)*V(:,1:j)'; error(j,1) = max(max(abs(tm1 - Z))); error(j,2) = max(max(abs(tm2 - Z))); end plot(1:22,error(:,1), '-rd','LineWidth',2); hold plot(1:22,error(:,2), '-ks','LineWidth',2); legend('RBD','SVD'); set(gca,'fontsize',15,'fontweight','bold','yscale','log'); Zred = Z1*Z2; figure contourf(X,Y,Zred) set(gca,'fontsize',20,'fontweight','bold')
The SVDs time over the RBD time is 15.200370 Current plot held