Project

General

Profile

Feature #10073 ยป add_test_for_laplace_expansion.patch

gogotanaka (Kazuki Tanaka), 10/06/2014 02:33 AM

View differences:

test/matrix/test_matrix.rb
274 274
    assert_raise(ExceptionForMatrix::ErrDimensionMismatch) { Matrix[[2,0,1],[0,-2,2]].cofactor(0, 0) }
275 275
  end
276
  def test_laplace_expansion
277
    assert_equal(1, Matrix[[1]].laplace_expansion(row: 0))
278
    assert_equal(45, Matrix[[7,6], [3,9]].laplace_expansion(row: 1))
279
    assert_equal(0, Matrix[[0,0],[0,0]].laplace_expansion(column: 0))
280
    assert_equal(-7, Matrix[[0,0,1],[0,7,6],[1,3,9]].laplace_expansion(column: 2))
281

  
282
    assert_equal(Vector[3, -2], Matrix[[Vector[1, 0], Vector[0, 1]], [2, 3]].laplace_expansion(row: 0))
283

  
284
    assert_raise(ExceptionForMatrix::ErrDimensionMismatch) { @m1.laplace_expansion(row: 1) }
285
    assert_raise(ArgumentError) { Matrix[[7,6], [3,9]].laplace_expansion() }
286
    assert_raise(ArgumentError) { Matrix[[7,6], [3,9]].laplace_expansion(foo: 1) }
287
    assert_raise(ArgumentError) { Matrix[[7,6], [3,9]].laplace_expansion(row: 1, column: 1) }
288
    assert_raise(ArgumentError) { Matrix[[7,6], [3,9]].laplace_expansion(row: 2) }
289
    assert_raise(ArgumentError) { Matrix[[0,0,1],[0,7,6],[1,3,9]].laplace_expansion(column: -1) }
290

  
291
    assert_raise(RuntimeError) { Matrix.empty(0, 0).laplace_expansion(row: 0) }
292
  end
293

  
276 294
  def test_regular?
277 295
    assert(Matrix[[1, 0], [0, 1]].regular?)
278 296
    assert(Matrix[[1, 0, 0], [0, 1, 0], [0, 0, 1]].regular?)