Last change
on this file since 4 was
4,
checked in by zhangj, 10 years ago
|
Initial import--MML version from SOLEIL@2013
|
File size:
570 bytes
|
Rev | Line | |
---|
[4] | 1 | function M = adjoint(A) |
---|
| 2 | % adjoint: (conjugate) transpose of cofactor matrix of a square matrix |
---|
| 3 | % usage: M = adjoint(A) |
---|
| 4 | % |
---|
| 5 | % arguments: (input) |
---|
| 6 | % A - Any square double or sympoly array |
---|
| 7 | % |
---|
| 8 | % M - The adjoint of A |
---|
| 9 | % |
---|
| 10 | % See also inv |
---|
| 11 | % |
---|
| 12 | % Author: John D'Errico |
---|
| 13 | % e-mail: woodchips@rochester.rr.com |
---|
| 14 | % Release: 1.3 |
---|
| 15 | % Release date: 10/18/06 |
---|
| 16 | |
---|
| 17 | [n,m] = size(A); |
---|
| 18 | if n~=m |
---|
| 19 | error 'A is not a square matrix.' |
---|
| 20 | end |
---|
| 21 | |
---|
| 22 | M = A; |
---|
| 23 | for i = 1:n |
---|
| 24 | ii = setdiff(1:n,i); |
---|
| 25 | for j = 1:n |
---|
| 26 | jj = setdiff(1:n,j); |
---|
| 27 | M(j,i) = (-1)^(i+j)*det(A(ii,jj)); |
---|
| 28 | end |
---|
| 29 | end |
---|
| 30 | |
---|
| 31 | % Just in case M is complex |
---|
| 32 | M = conj(M); |
---|
Note: See
TracBrowser
for help on using the repository browser.