Project

General

Profile

Bug #6290 ยป hermitian-fix.diff

a simple fix to Matrix#hermitian?, and some test - kernigh (George Koehler), 04/14/2012 03:48 AM

View differences:

lib/matrix.rb
#
def hermitian?
Matrix.Raise ErrDimensionMismatch unless square?
each_with_index(:strict_upper).all? do |e, row, col|
each_with_index(:upper).all? do |e, row, col|
e == rows[col][row].conj
end
end
test/matrix/test_matrix.rb
assert_raise(ArgumentError) { @m1.minor(0) }
end
def test_hermitian?
i = Complex::I
assert(Matrix[[-2, -3-i, 3+i ],
[-3+i, 3, -5-7*i],
[ 3-i, -5+7*i, 9 ]].hermitian?)
assert(!Matrix[[-2, -3-i, 3+i ],
[-3+i, 3, 4-8*i],
[ 3-i, 4-8*i, 9 ]].hermitian?)
assert(!Matrix[[-2, -3-i, 3+i ],
[-3+i, 3, -5-7*i],
[ 3-i, -5+7*i, 9-4*i]].hermitian?)
end
def test_regular?
assert(Matrix[[1, 0], [0, 1]].regular?)
assert(Matrix[[1, 0, 0], [0, 1, 0], [0, 0, 1]].regular?)
    (1-1/1)