#  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_Math < Test::Unit::TestCase

  # def setup
  # end

  # def teardown
  # end

  def test_multiply
  	a = Vector.elements [1,2,3,4,5]
  	
  	b = nil
  	assert_nothing_raised do
  	  b = 2*a
  	end
  	
  	assert_instance_of Vector, b
  	
  	a.length.times do |i|
  	  assert_equal a[i]*2, b[i] 
  	end
  	
  	c = Vector.elements [1.0,2.0,3.0,4.0,5.0]
  	assert_nothing_raised do
  	  b = 2.0*c
  	end
  	
  	c.length.times do |i|
  	  assert_equal c[i]*2.0, b[i] 
  	end
  	
  	d = Matrix.columns [[1,2],[3,4]]
  	assert_nothing_raised do
  	  b = 2*d
  	end
  	
  	assert_equal 2, b[0,0]
  	assert_equal 4, b[1,0]
  	assert_equal 6, b[0,1]
  	assert_equal 8, b[1,1]
  	
  end

end