File: testobject.rb

package info (click to toggle)
libnarray-ruby 0.5.9-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 564 kB
  • ctags: 564
  • sloc: ansic: 4,620; ruby: 1,513; python: 70; makefile: 5
file content (29 lines) | stat: -rw-r--r-- 320 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'narray'
require 'rational'

n = 4
a = NArray.object(4,4).fill!(Rational(1))
b = NArray.object(4,4).indgen!(1).collect{|i| Rational(i)}

print 'a #=> '
p a

print 'b #=> '
p b


class Rational
  def inspect
    self.to_s
  end
end

print 'a+b #=> '
p a+b


print 'a/b #=> '
p a/b

print 'a/b - b #=> '
p a/b - b