Skip to content

Conversation

@gogotanaka
Copy link
Member

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.

@zzak
Copy link
Member

zzak commented May 25, 2014

@marcandre ping!

@marcandre
Copy link
Member

Sorry, not much time to look at this as I'm travelling.
I understand the request for collect_with_index but my first reaction is to try to find a better solution, even though none comes to mind easily.

@haileys
Copy link

haileys commented May 29, 2014

Any reason you can't use each_with_index.map?

@marcandre
Copy link
Member

@charliesome, the thing is, Matrix#map returns a Matrix, but Matrix.diagonal(1,2).each_with_index.map{42} returns an Array...
And Matrix.diagonal(1,2).map.with_index{|elem, (row, column)|} doesn't work as it gives out the "linear" indices, not the (row, column) pair that's wanted.

@marcandre
Copy link
Member

@gogotanaka I'm 👍 for adjucate, with the following points:

  1. We could use self.class.build instead of map_with_index
  2. I'm doubtful about abbreviation adj. Could be confuse with adjoint, which has less precise meaning. I think it's best to remove it altogether.
  3. I notice the use of rand in the tests, this could randomly fail if the matrix generated is singular, right?

I'm still thinking about map_with_index. I understand it is inconvenient to do that, but I find it really an ugly solution. Maybe build could accept a Matrix instead of a row and column arguments.

I'd say let's focus on adjucate for now; I'd like more concrete needs for map_with_index.

@gogotanaka
Copy link
Member Author

@marcandre Sorry for the late reply. Even though it might be something infelicity to say here, I take a leave of absence from my university, and I am traveling too. This is because I love programing(especially Ruby). If you don't mind, how about we go for coffee?

Sorry, It is infelicity here. By the way, thank for nice comments!

  1. We could use self.class.build instead of map_with_index

I thought ⬇️ is really beautiful.

collect_with_index do |_, row, column| cofactor(column, row) end 

But now, as you said, map_with_index is useful for thinking about only adjucate.

So I will change it.

But I really want to brush up Matrix class, this is just first step.

So when map_with_index is needed, I implement again.

  1. I'm doubtful about abbreviation adj. Could be confuse with adjoint, which has less precise meaning. I think it's best to remove it altogether.

Hmm, I think adj operator always means adjuate in the math, but I see your point. Ruby should be not for mathematician but rubyist. I will change.

  1. I notice the use of rand in the tests, this could randomly fail if the matrix generated is singular, right?

It's really my mistake.. sorry. ok, I will change.

@gogotanaka
Copy link
Member Author

@marcandre I have fixed all of what you said! Please check my code, when you have a time.

@gogotanaka gogotanaka changed the title Add two methods to matrix class Add #adjugate method to matrix class Jul 13, 2014
@gogotanaka
Copy link
Member Author

@gogotanaka gogotanaka closed this Jul 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants