Incorrect results of inverse tall array
Afficher commentaires plus anciens
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 = C.dataSitesAugm;
d = load("d.mat")
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)
Y=C\d; % solve X in non-tall array, benchmark
Any one can help this case?
Thanks in advance.
Réponses (1)
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);
Y = C \ d;
disp('Results using tall arrays:');
disp(X_1);
disp('Results using non-tall arrays:');
disp(Y);
1 commentaire
chen zhe
le 22 Juin 2024
Catégories
En savoir plus sur Geographic Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!