Sha256: b9d03eb7a631ebfc6aa49b78dc86fcd4f0da3a29fed690fd25c3468e30ef93e9

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

require 'rubygems'
require "test/unit"
require 'shoulda'

require 'env'
require 'mdarray'

class MDArrayTest < Test::Unit::TestCase

  context "Arithmetic Tests" do

    setup do

      # create a = [20 30 40 50]
      @a = MDArray.arange(20, 60, 10)
      # create b = [0 1 2 3]
      @b = MDArray.arange(4)
      # create c = [1.87 5.34 7.18 8.84]
      @c = MDArray.double([4], [1.87, 5.34, 7.18, 8.84])
      # create d = [[1 2] [3 4]]
      @d = MDArray.int([2, 2], [1, 2, 3, 4])
      # creates an array from a function (actually a block).  The name fromfunction
      # is preserved to maintain API compatibility with NumPy (is it necessary?)
      @e = MDArray.fromfunction("double", [4, 5, 6]) do |x, y, z|
        3.21 * (x + y + z)
      end
      @f = MDArray.fromfunction("double", [4, 5, 6]) do |x, y, z|
        9.57 * x + y + z
      end
      @g = MDArray.byte([1], [60])
      @h = MDArray.byte([1], [13])
      @i = MDArray.double([4], [2.0, 6.0, 5.0, 9.0])
            
    end # setup

    #-------------------------------------------------------------------------------------
    #
    #-------------------------------------------------------------------------------------

    should "do basic lazy operations" do

      op = @a.add_(@b)
      p op
      p op.type
      op.exec(3)

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mdarray-0.4.3.pre-java test/test_lazy.rb
mdarray-0.4.2-java test/test_lazy.rb
mdarray-0.4.0-java test/test_lazy.rb