File: testsort.rb

package info (click to toggle)
ruby-narray 0.6.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 468 kB
  • sloc: ansic: 4,498; ruby: 1,329; python: 91; makefile: 7
file content (37 lines) | stat: -rw-r--r-- 676 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
30
31
32
33
34
35
36
37
require 'narray'

def test a,b
  print a," #=> "
  p b
end

a = NArray.int(16).random!(100)

test "a",a
test "a.sort",a.sort

print "\n# as string...\n"
a = a.to_string
test "a",a
test "a.sort",a.sort

print "\n# up to 0-rank...\n"
a = NArray.int(4,4).random!(100)
test "a",a
test "a.sort(0)",a.sort(0)

print "\n# big array test...\n"
a = NArray.int(10,10,10,10,10).random!(100)
test "a",a
test "a.sort(1)",a.sort(1)

print "\n# test sort_index...\n"
a = NArray.int(7,4).random!(100)
test "a",a
test "a.sort_index(0)",idx=a.sort_index(0)
test "a[a.sort_index]",a[idx]

print "\n# following will fail...\n"
a = NArray.complex(3,3).random!(100)
test "a",a
test "a.sort",a.sort