Vectorize a series of interpn calculations with GPU

2 Ansichten (letzte 30 Tage)
deathtime
deathtime am 19 Mai 2023
Let's say I have a cell array with equal sized (but different) 4D datasets:
nPoints = 5;
dataCell = cell(1,nPoints);
for i = 1:nPoints
dataCell{i} = rand(3, 2, 4, 3);
end
For the data arays in each cell, I would like to carry out a 4D interpn. Let's say the interpolation sample arrays and targets for each dimension are as follows:
dimOneArray = [0.1 0.2 0.3];
dimTwoArray = [2 4];
dimThreeArray = [1 2 3 4];
dimFourArray = [0.3 0.6 0.9];
dimOneTarget = 0.15;
dimTwoTarget = 3;
dimThreeTarget = 2.5;
dimFourTarget = 0.4;
Then I would like to carry out nPoints interpn calculations in a vectorized manner i.e. I would like to produce the same result as below (interpArray) without a for loop:
interpArray = nan(nPoints, 1);
for i = 1:nPoints
interpArray(i) = interpn(dimOneArray, dimTwoArray, dimThreeArray, dimFourArray, cell2mat(dataCell(i)), dimOneTarget, dimTwoTarget, dimThreeTarget, dimFourTarget);
end
How would I use the GPU to carry out this calculation?

Antworten (0)

Kategorien

Mehr zu GPU Computing finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by