Incorrect results of inverse tall array

2 visualizaciones (últimos 30 días)
chen zhe
chen zhe el 22 de Jun. de 2024
Comentada: chen zhe el 22 de Jun. de 2024
Hi,
I am using tall array and testing the inverse of A? (pseudo inverse). The system is linear Ax=b. A:245*9, x: 9*1, b:245*1.
However, with the same matrices, the results of gather(A/b) is incorrect, 1st to 7th elements are NaN, 8th is -inf. The last one is the same with non-tall array results.
C = load("C.mat")
C = struct with fields:
dataSitesAugm: [6615x9 double]
C = C.dataSitesAugm;
d = load("d.mat")
d = struct with fields:
functionValues: [6615x1 double]
d = d.functionValues;
A_ds = arrayDatastore([C d], "OutputType","same");
At = tall(A_ds);
A = At(:,1:9);
B1 = At(:,10);
X=A\B1; % solve X in equation A*X=B1
X_1=gather(X)
Evaluating tall expression using the Local MATLAB Session: - Pass 1 of 1: 0% complete - Pass 1 of 1: 9% complete - Pass 1 of 1: 22% complete - Pass 1 of 1: 36% complete - Pass 1 of 1: 50% complete - Pass 1 of 1: 63% complete - Pass 1 of 1: 77% complete - Pass 1 of 1: 91% complete - Pass 1 of 1: Completed in 7.7 sec Evaluation completed in 8.1 sec
X_1 = 9x1
NaN NaN NaN NaN Inf 0.8010 0.6198 0.4161 0.0042
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Y=C\d; % solve X in non-tall array, benchmark
Warning: Rank deficient, rank = 7, tol = 1.194634e-10.
Any one can help this case?
Thanks in advance.

Respuestas (1)

Ayush Modi
Ayush Modi el 22 de Jun. de 2024
Hi Chen,
Your code looks good to me. The issue might be with the data.
I tested the code with randomly generated matrix as well as the attached data. I am able to reproduce the issue with the attached data but is working fine with random data:
% Generate sample data
rng(0);
C = rand(245, 9);
d = rand(245, 1);
data = [C d];
A_ds = arrayDatastore(data, "OutputType", "same");
At = tall(A_ds);
A = At(:, 1:9);
B1 = At(:, 10);
X = A \ B1;
X_1 = gather(X);
Evaluating tall expression using the Local MATLAB Session: - Pass 1 of 1: 0% complete - Pass 1 of 1: Completed in 0.72 sec Evaluation completed in 1.1 sec
Y = C \ d;
disp('Results using tall arrays:');
Results using tall arrays:
disp(X_1);
0.0471 0.1917 0.1769 0.0630 0.0034 0.0588 0.1110 0.0537 0.2454
disp('Results using non-tall arrays:');
Results using non-tall arrays:
disp(Y);
0.0471 0.1917 0.1769 0.0630 0.0034 0.0588 0.1110 0.0537 0.2454
  1 comentario
chen zhe
chen zhe el 22 de Jun. de 2024
Yeah, could be the data issue.
But do you know why the non-tall array works well while the tall array with gather() cannot have the reasonable results?
Not sure if this is a bug.

Iniciar sesión para comentar.

Categorías

Más información sobre Tall Arrays en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by