[ruby-dev:48484] [ruby-trunk - Feature #10056] [PATCH 0/1]Add #adjugate method to matrix class
From:
nagachika00@...
Date:
2014-08-21 03:15:49 UTC
List:
ruby-dev #48484
Issue #10056 has been updated by Tomoyuki Chikanaga.
Hello,
The patch seems fine to me.
I'd like to add some assertions for the testcase.
These are deribed from "Properties of Adjugate matrix" in Wikipedia. tanaka=
san, how about it?
## adj(I) =3D I
assert_equal(Matrix.identity(2), Matrix.identity(2).adjugate)
assert_equal(Matrix.identity(3), Matrix.identity(3).adjugate)
## adj(A * B) =3D ajd(B) * adj(A)
a =3D Matrix[[4, 1, -3], [0, 3, 7], [11, -4, 2]]
b =3D Matrix[[-7, 7, -10], [9, -3, -2], [-1, 3, 9]]
assert_equal((a * b).adjugate, b.adjugate * a.adjugate)
## adj(cA) =3D c^(n-1) * adj(A)
assert_equal((3**2) * a.adjugate, (3 * a).adjugate)
Marc-Andre, how do you think?
----------------------------------------
Feature #10056: [PATCH 0/1]Add #adjugate method to matrix class
https://bugs.ruby-lang.org/issues/10056#change-48430
* Author: gogo tanaka
* Status: Assigned
* Priority: Normal
* Assignee: Marc-Andre Lafortune
* Category:=20
* Target version:=20
----------------------------------------
Add Matrix#adjugate to make a matrix adjugate.
Adjugate is really important operator to handle matrix (especially Explorin=
g Data with ruby)
```ruby:
# Property
* Any n-th matrix `m`(object of Matrix class) Satisfy the following condit=
ions
Matrix.identity(n) =3D=3D (m.adjugate * m) / m.det
# Differential vector or matrix
Let A =3D (a(i, j)) is n-th matrix, A(i, j) is adjugate matrix excluding th=
e j and column i row A.
def. =E2=88=82det(A)/=E2=88=82a(i,j) =3D (-1) ** (i + j) * det(A(i, j))
```
Some people regards adjugate matrix as Hermitian adjoint.
I regard adjuate matrix as transpose of the cofactor matrix by referencing=
http://en.wikipedia.org/wiki/Adjugate_matrix.
---Files--------------------------------
add_matrix#adjugate_method.patch (2.22 KB)
--=20
https://bugs.ruby-lang.org/