#  JLMatrix - Matrix support for JRuby
#  Copyright (C) 2008 Approximatrix, LLC
#  http://www.approximatrix.com
#  
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#  NOTE: This software is licensed under the GPL and does not allow
#        linking to closed-source software.
#

require 'test/unit'
require 'jlmatrix'
 
class TC_Matrix < Test::Unit::TestCase

  # def setup
  # end

  # def teardown
  # end
 
  def test_included
    assert Matrix.instance_methods.member?('pinverse')
    assert Matrix.instance_methods.member?('pmultiply_1d')
  end
  
  def test_pmultiply
    a = Matrix.identity 50
    a = a*5.0
    b = Matrix.identity 50
    b = b*2.0
    c = a.pmultiply_1d_byrow(b,4)

    c.diagonal.each do |x|
        assert_in_delta 10.0, x, 1.0E-6
    end

    c = a.pmultiply_1d_bycolumn(b,4)
    
    c.diagonal.each do |x|
        assert_in_delta 10.0, x, 1.0E-6
    end

  end
  
  def test_set_thread_count
    
  	Matrix.set_thread_count(5)
  	assert_equal 5, Matrix.get_thread_count
  
  end
 
end
