Fastest way to multiply each block of an array with another matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Mnr
el 23 de Dic. de 2015
Comentada: Mnr
el 23 de Dic. de 2015
Hello all,
I have a 12x4xN array which I would like to multiply each 12x4 block by a 4x16 matrix in order to get a 12x16xN array. Could somebody please help me with a fast way of doing that? Thank you!
0 comentarios
Respuesta aceptada
James Tursa
el 23 de Dic. de 2015
Editada: James Tursa
el 23 de Dic. de 2015
If you have a C compiler:
A = your 12 x 4 x N array;
B = your 4 x 16 matrix;
out = mtimesx(A,B);
You can find mtimesx here:
If you don't have a C compiler, then you can try MULTIPROD:
Más respuestas (1)
Andrei Bobrov
el 23 de Dic. de 2015
Let A - your array with size [12x4xN]
B - matrix 4x16
sa = size(A);
sb = size(B);
out = zeros([sa(1),sb(2),sa(3)]);
for jj = 1:sa(3)
out(:,:,jj) = A(:,:,jj)*B;
end
Ver también
Categorías
Más información sobre Data Types en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!