Multiply each 3D gpuArray page column with each other

1 vue (au cours des 30 derniers jours)
Mantas Vaitonis
Mantas Vaitonis le 12 Juil 2018
Commenté : Mantas Vaitonis le 12 Juil 2018
Hello to All, Can anyone give advice on the following matter? Lets say I have 3D gpuArray a (XxYxZ) with random numbers, I need to multiply every column of each page with other columns. A dumb version would look something like this:
D=pagefun(@times,a(:,1,:),a(:,1:end,:));
As you can see here only first column would be multiplied with others, but I need all columns. And yes I understand that this code does not work, it is just an example of what I am trying to achieve. Multiply each 3D gpuArray page column with each other

Réponse acceptée

Joss Knight
Joss Knight le 12 Juil 2018
It's hard to be sure whether you are literally after what you wrote, or whether you have just articulated it wrong. If you literally just want to multiply every column of a by every other column, then you don't need pagefun, because this is an element-wise operation. You can just use scalar dimension expansion.
[r, c, p] = size(a);
D = reshape(a, r, 1, c, p) .* reshape(a, r, c, 1, p);
  1 commentaire
Mantas Vaitonis
Mantas Vaitonis le 12 Juil 2018
Yes this did what I needed, thank You.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Parallel Computing Fundamentals dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by