On Tuesday, January 21, 2003, 9:47:51 AM, Mathieu wrote:


> On Mon, 20 Jan 2003, Gavin Sinclair wrote:
>>  - #slice would be a good alias for #minor

> The problem with #minor is that it's not a minor, it's a slice.

Sigh... now we get into the "this method is badly named, but changing
it would break code" conundrum.  Probably not something to make a fuss
about.  I would rename #minor to #slice and then alias them.

>>  - Matrix#diagonalize() should return a [M:Matrix,D:Matrix] pair such that
>>    M*D*M.inverse == self
>>  - ** is too slow.  Using matrix diagonalisation is a more efficient algorithm
>>    and works for all exponents, not just positive integers.  Here is a more
>>    efficient **
>>            def ** n
>>                 m, d = diagonalize
>>                 (0...d.row_size).each { |i| d[i,i] **= n }
>>                 (m * d * m).inverse
>>            end

> This is not the code I gave you. I wrote m*d*m.inverse, not
> (m*d*m).inverse; the parentheses make a big difference.

Whoops!  So it does.

>>  - #r should be something more normal, like #modulus (with #r an alias)

> #abs is good, especially because (x-y).abs on vectors is a metric.
> (see http://mathworld.wolfram.com/Metric.html)

> However it wouldn't be good to think of a matrix determinant as an
> absolute value, despite mathematicians using the same notation... one
> reason is that a det can be negative, while abs's are expected not to.

We're talking about vectors here, not matrices.  So Vector#abs can be
an alias to Vector#r, and Matrix#abs is left undefined.

Gavin