Taking the Inverse of a Tall Array To Solve a Linear System of Equations

조회 수: 1 (최근 30일)
Ayden Clay
Ayden Clay 2020년 5월 23일
편집: Ayden Clay 2020년 5월 23일
Hi, I'm working with some large data sets and have begun using tall arrays for the first time. I was happy to hear that the inverse function (\) was available for tall arrays, but am having some trouble on implementation. Below is a none-working example (you may need to set your own output directory), if F is tall or not doesn't change anything.
function [SOL] = MinWorkExample
outDIR = 'M:\project\MATLAB Folder\PhD\TESTAREA\InterpolationForPaper\PHFtall';
fileIDX = 1;
rowsPerFile = 1e3;
rowsWritten = 0;
totalRows = 1e5;
while rowsWritten<totalRows
rowsToWrite = min(rowsPerFile, totalRows-rowsWritten);
datas = rand(1,totalRows);
fname = fullfile(outDIR,sprintf('datas_%05d.mat',fileIDX));
save(fname,'datas');
fileIDX = 1 + fileIDX;
rowsWritten = rowsToWrite + rowsWritten;
end
ds = fileDatastore(fullfile(outDIR, '*.mat'), ...
'ReadFcn', @(fname) getfield(load(fname), 'datas'), ...
'UniformRead', true);
CONMAT = tall(ds);
% Either F does not work.
% F = rand(totalRows,1);
F = tall(rand(totalRows,1));
SOL = CONMAT\F;

답변 (1개)

Ayden Clay
Ayden Clay 2020년 5월 23일
So! I'm a collossal idiot. The error note was incredibly well written, and described my exact problem. Turns out that if I repeat the process but write in columns rather than rows, we're all good.
In the same nomenclature as the question, here is a working version:
function [SOL] = MinWorkExample
outDIR = '\PHFtall';
fileIDX = 1;
ColsPerFile = 1e3;
ColsWritten = 0;
totalCols = 1e5;
while ColsWritten<totalCols
colsToWrite = min(ColsPerFile, totalCols-ColsWritten);
datas = rand(totalCols,1);
fname = fullfile(outDIR,sprintf('datas_%05d.mat',fileIDX));
save(fname,'datas');
fileIDX = 1 + fileIDX;
ColsWritten = colsToWrite + ColsWritten;
end
ds = fileDatastore(fullfile(outDIR, '*.mat'), ...
'ReadFcn', @(fname) getfield(load(fname), 'datas'), ...
'UniformRead', true);
CONMAT = tall(ds);
F = tall(rand(1,totalCols));
SOL = CONMAT\F;
  댓글 수: 1
Ayden Clay
Ayden Clay 2020년 5월 23일
편집: Ayden Clay 2020년 5월 23일
Nevermind. This causes a further issue in that the data is vertically concatenated, producing a large Nx1 vector. Still working on a fix.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Tall Arrays에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by