You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
968 B

3 years ago
%--------------------------
% @Author: Jingqiao Hu
% @Date: 2021-05-18 20:58:57
% @LastEditTime: 2021-05-18 21:27:03
% A : [9, m]
%--------------------------
function invA = inv_3rank(A)
detA = det_3rank(A); % 1,m
indicator = [(-1)^(1+1), (-1)^(1+2), (-1)^(1+3);
(-1)^(1+2), (-1)^(2+2), (-1)^(3+2);
(-1)^(1+3), (-1)^(2+3), (-1)^(3+3);];
indicator = indicator(:); % 9,1
M11 = A(5,:) .* A(9,:) - A(6,:) .* A(8,:);
M12 = A(4,:) .* A(9,:) - A(6,:) .* A(7,:);
M13 = A(4,:) .* A(8,:) - A(5,:) .* A(7,:);
M21 = A(2,:) .* A(9,:) - A(3,:) .* A(8,:);
M22 = A(1,:) .* A(9,:) - A(3,:) .* A(7,:);
M23 = A(1,:) .* A(8,:) - A(2,:) .* A(7,:);
M31 = A(2,:) .* A(6,:) - A(3,:) .* A(5,:);
M32 = A(1,:) .* A(6,:) - A(3,:) .* A(4,:);
M33 = A(5,:) .* A(1,:) - A(2,:) .* A(4,:);
M = [M11; M12; M13; M21; M22; M23; M31; M32; M33];
invA = detA .* (indicator .* M);
end
% 1,4,7
% 2,5,8
% 3,6,9