Feature #10056
closed[PATCH 0/1]Add #adjugate method to matrix class
Description
Add Matrix#adjugate to make a matrix adjugate.
Adjugate is really important operator to handle matrix (especially Exploring Data with ruby)
# Property
* Any n-th matrix `m`(object of Matrix class) Satisfy the following conditions
Matrix.identity(n) == (m.adjugate * m) / m.det
# Differential vector or matrix
Let A = (a(i, j)) is n-th matrix, A(i, j) is adjugate matrix excluding the j and column i row A.
def. ∂det(A)/∂a(i,j) = (-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
Updated by gogotanaka (Kazuki Tanaka) over 10 years ago
Updated by hsbt (Hiroshi SHIBATA) over 10 years ago
- Status changed from Open to Assigned
- Assignee set to marcandre (Marc-Andre Lafortune)
Updated by nagachika (Tomoyuki Chikanaga) over 10 years ago
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) = I
assert_equal(Matrix.identity(2), Matrix.identity(2).adjugate)
assert_equal(Matrix.identity(3), Matrix.identity(3).adjugate)
## adj(A * B) = ajd(B) * adj(A)
a = Matrix[[4, 1, -3], [0, 3, 7], [11, -4, 2]]
b = Matrix[[-7, 7, -10], [9, -3, -2], [-1, 3, 9]]
assert_equal((a * b).adjugate, b.adjugate * a.adjugate)
## adj(cA) = c^(n-1) * adj(A)
assert_equal((3**2) * a.adjugate, (3 * a).adjugate)
Marc-Andre, how do you think?
Updated by gogotanaka (Kazuki Tanaka) about 10 years ago
- File update_news.patch update_news.patch added
- File implement.patch implement.patch added
- File add_test.patch add_test.patch added
@Tomoyuki Chikanaga san
Sorry for my delay. I was little bit puzzled about how to test well.
I suppose it's better to add not only #adjugate
but also all of such a testcase about properties by instance variable.
I'm gonna make another ticket :)
Right now, I added testcase for Matrix#adjugate
and separated patches. It ready for merging.
Take your time.
Updated by marcandre (Marc-Andre Lafortune) about 10 years ago
- Category set to lib
- Status changed from Assigned to Closed
Committed, thanks for this request!