Outer product of two 512*512*300 matrices
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone.
I wandering if any of you know how to do outer product for two matricess. The dimension of them are 512*512*300.
thank you.
3 Kommentare
Alexander
am 3 Okt. 2023
Afaik the cross product is defined only for vectors. But I'm interested to know if there are other definitions.
John D'Errico
am 3 Okt. 2023
Bearbeitet: John D'Errico
am 3 Okt. 2023
@Alexander Paul A CROSS product is defined for vectors. (And really, only for vectors of length 3 in classic terms. I do have a colleague who extended that definition to vectors of length 3, but it was of no real utiity that I recall.) In fact, cross is defined for arrays of vectors too, but there it applies to each vector in the array.
help cross
The thing is, the request was for an outer product.
Antworten (1)
John D'Errico
am 3 Okt. 2023
Bearbeitet: John D'Errico
am 3 Okt. 2023
Since there has been no response to my request for clarification...
The request was for an outer product. An outer product is a very different animanl from a cross product. For example, the classical outer product between two vectors will create the element-wise product of every combinations of elements, thus a times table.
x = 1:5;
y = primes(15);
y'*x
Here, * does all the work for us. But we could also have used .* (or even bsxfun) as well.
y'.*x
The nice thing about .* or bsxfun is it will apply to higher dimensional arrays too. For example...
x = [1 2;3 4];
y = randi(9,[3,4])
Now we MIGHT decide to create an outer product here as:
z = x.*reshape(y,[1 1 size(y)])
size(z)
So every element of x scalar-multiplied by every element of y.
The problem is, if the arrays have size 512*512*300, then the outer product as I have shown it here would have size 512*512*300*512*512*300.
That is a pretty large array.
512*512*300*512*512*300
ans*8/1024^3
so approximately 46 million gigabytes of memory. You could cut that in half using singles of course. (Sigh. I hope nobody takes the idea about singles seriously.)
1 Kommentar
Alexander
am 3 Okt. 2023
Bearbeitet: Alexander
am 3 Okt. 2023
Thank you for this clear explanation. In German "Kreuzprodukt" and "Äußeres Produkt" is equivalent. I'm now investigating what an english "Outer Product" in german language is. The english wikipedia is more precise, and I will investigate this.
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!