Sha256: b04e61d8b6e7aa335fd9e3f188a2a8112c1707d1cbb1649c5e5d25adf71f6480

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

# = NMatrix
#
# A linear algebra library for scientific computation in Ruby.
# NMatrix is part of SciRuby.
#
# NMatrix was originally inspired by and derived from NArray, by
# Masahiro Tanaka: http://narray.rubyforge.org
#
# == Copyright Information
#
# SciRuby is Copyright (c) 2010 - 2012, Ruby Science Foundation
# NMatrix is Copyright (c) 2012, Ruby Science Foundation
#
# Please see LICENSE.txt for additional copyright notices.
#
# == Contributing
#
# By contributing source code to SciRuby, you agree to be bound by
# our Contributor Agreement:
#
# * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
#
# == spec_helper.rb
#
# Common data for testing. 
require "./lib/nmatrix"

MATRIX43A_ARRAY = [14.0, 9.0, 3.0, 2.0, 11.0, 15.0, 0.0, 12.0, 17.0, 5.0, 2.0, 3.0]
MATRIX32A_ARRAY = [12.0, 25.0, 9.0, 10.0, 8.0, 5.0]

COMPLEX_MATRIX43A_ARRAY = MATRIX43A_ARRAY.zip(MATRIX43A_ARRAY.reverse).collect { |ary| Complex(ary[0], ary[1]) }
COMPLEX_MATRIX32A_ARRAY = MATRIX32A_ARRAY.zip(MATRIX32A_ARRAY.reverse).collect { |ary| Complex(ary[0], -ary[1]) }

RATIONAL_MATRIX43A_ARRAY = MATRIX43A_ARRAY.collect { |x| x.to_r }
RATIONAL_MATRIX32A_ARRAY = MATRIX32A_ARRAY.collect { |x| x.to_r }

def create_matrix(stype) #:nodoc:
  m = stype == :yale ? NMatrix.new(stype, 3, :int32) : NMatrix.new(stype, [3,3], 0, :int32)

  m[0,0] = 0
  m[0,1] = 1
  m[0,2] = 2
  m[1,0] = 3
  m[1,1] = 4
  m[1,2] = 5
  m[2,0] = 6
  m[2,1] = 7
  m[2,2] = 8

  m
end

def create_vector(stype) #:nodoc:
  m = stype == :yale ? NVector.new(stype, 10, :int32) : NVector.new(stype, 10, 0, :int32)

  m[0] = 1
  m[1] = 2
  m[2] = 3
  m[3] = 4
  m[4] = 5
  m[5] = 6
  m[6] = 7
  m[7] = 8
  m[8] = 9
  m[9] = 10

  m
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nmatrix-0.0.6 spec/spec_helper.rb
nmatrix-0.0.5 spec/spec_helper.rb