Filter löschen
Filter löschen

How to invert 3D matrices?

25 Ansichten (letzte 30 Tage)
gsourop
gsourop am 15 Dez. 2016
Bearbeitet: James Tursa am 15 Jul. 2021
Hi everyone,
I have a 3D matrix so A with dimensions 3x2x5 and I need to invert the following folmula inv(A'A). I need to transpose transpose(A(1,:,:), then transpose(A(2,:,:) and transpose(A(3,:,:) In case a inv(A) I can use the MultiSolver function in http://uk.mathworks.com/matlabcentral/fileexchange/24260-multiple-same-size-linear-solver, but how can I invert the product a transposed 3D matrix A with A? I have tried
inv_X_f=permute(MultiSolver(permute(X_f,[1 3 2]).*X_f,eye(3)),[1 2 3]);
Thanks in advance.
  1 Kommentar
Walter Roberson
Walter Roberson am 15 Dez. 2016
(A'A) is not defined for 3 dimensional A.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

James Tursa
James Tursa am 15 Dez. 2016
Bearbeitet: James Tursa am 15 Jul. 2021
Step 1)
Get your 2D matrix pages into the 1st two dimensions. This makes each 2D page contiguous in memory and is somewhat of an unwritten standard for many other functions that operate on 2D pages. So:
Ap = permute(A,[2 3 1]);
Step 2)
Do the page multiplies with Ap using one of the following utilities. Note that some of these utilities require building a mex routine and thus need a C compiler installed. For methods that require the 2D transposes to be explicitly formed first, you could just use another permute. E.g.,
ApT = permute(A,[3 2 1]);
MULTIPROD:
MMX:
MTIMESX:
PAGEMTIMES:
Step 3)
Now you are ready to use Multisolver:
Long term, I would advise that you always have your 2D pages in the 1st two dimensions in all of your code. This avoids the necessity of doing all of those permutes which require the entire data set to be copied in memory.

Weitere Antworten (1)

KSSV
KSSV am 15 Dez. 2016
A=rand(3,2,5);
B=zeros(3,3,5);
for i = 1:5
B(:,:,i)=inv(A(:,:,i)*A(:,:,i)');
end

Kategorien

Mehr zu Characters and Strings 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!

Translated by