Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adjugate matrix in octave

Tags:

matrix

octave

is there any function in gnu octave that adjunge matrix (similar to adjoint in matlab etc.)?

like image 698
Garret Raziel Avatar asked Dec 16 '22 19:12

Garret Raziel


2 Answers

The adjugate is probably not what you actually want.

If you want the normal adjoint (the conjugate transpose), then x' will give it to you for x. (The non-conjugated transpose is x.', or transpose(x). conj(x) gives the complex conjugate, and works on matrices and vectors as well.)

If you actually want the adjugate (aka classical adjoint), I don't believe Octave has it built in. There are a few ways to calculate this. If you can assume invertibility, then it's just det(x)*inv(x). If not, it's a bit more complicated. In general, the adjugate is the transpose of the cofactor matrix. The cofactor matrix replaces each element in the original matrix with its cofactor (plus or minus its minor, which is the determinant of the original matrix without that row and column. The plus or minus rule is the same for determinant expansion -- if the sum of the row and column is even, it's positive, if negative, it's odd).

The simplest codewise is probably to use the SVD (which is built-in) -- the adjugate is an antihomomorphism with adj(xy) = adj(y) adj(x). The SVD of x is a set of matrices u,s,v, with u*s*v' = x, s diagonal, u and v both unitary. adj(x) = adj(u*s*v') = adj(v')adj(s)adj(u). For invertible matrices, the adjugate is just the determinant times the inverse. For unitary matrices, this is just the conjugate transpose. adj(x) = det(v') v adj(s) det(u) u' = det(v'*u) v adj(s) u'. The adjugate of a diagonal matrix s is relatively easy to calculate -- each entry off the diagonal is zero, and each entry on the diagonal is the product of the others.

like image 148
wnoise Avatar answered Dec 23 '22 22:12

wnoise


After some tries I calculated the co-factors using the following command:

det(a)*inv(a).'

note the dots in the end are part of the command

like image 34
ilektrologos Avatar answered Dec 24 '22 00:12

ilektrologos