Project

General

Profile

Actions

Feature #10056

closed

[PATCH 0/1]Add #adjugate method to matrix class

Added by gogotanaka (Kazuki Tanaka) over 10 years ago. Updated about 10 years ago.

Status:
Closed
Target version:
-
[ruby-dev:48425]

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

add_matrix#adjugate_method.patch (2.22 KB) add_matrix#adjugate_method.patch gogotanaka (Kazuki Tanaka), 07/18/2014 01:28 AM
update_news.patch (867 Bytes) update_news.patch gogotanaka (Kazuki Tanaka), 10/12/2014 06:57 AM
implement.patch (1.07 KB) implement.patch gogotanaka (Kazuki Tanaka), 10/12/2014 06:57 AM
add_test.patch (1.84 KB) add_test.patch gogotanaka (Kazuki Tanaka), 10/12/2014 06:57 AM

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

@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!

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0