narray 0.5.9.9 → 0.6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +0,0 @@
1
- require "narray"
2
-
3
- m = NMatrix.float(3,3,3).indgen!
4
-
5
- puts
6
- puts 'm #=>'
7
- p m #=> NMatrix.float(3,3,3):
8
- puts
9
- puts 'm[1,1,true] #=>'
10
- p m[1,1,true] #=> NArray.float(3):
11
- puts
12
- puts 'm[0..1,2,true] #=>'
13
- p m[0..1,2,true] #=> NMatrix.float(2,1,3):
@@ -1,42 +0,0 @@
1
- require 'narray'
2
- #require 'irb/xmp'
3
- # xmp :: http://www.ruby-lang.org/en/raa-list.rhtml?name=xmp
4
- def xp(s)
5
- begin
6
- puts s+" #=>"
7
- p eval(s)
8
- rescue
9
- puts $!
10
- end
11
- puts
12
- end
13
-
14
- $m1 = NMatrix.float(2,2).indgen!
15
- $m2 = NMatrix[[0,1.2],[1.5,0]]
16
-
17
- $v1 = NVector[0.5,1.5]
18
- $v2 = NVector.float(2,2).indgen!
19
-
20
- $a = NArray.float(2,2).indgen!
21
-
22
- xp '$m1'
23
- xp '$m1.inverse'
24
- xp '$m2'
25
- xp '$m1*$m2'
26
- xp '$m2*$m1'
27
- xp '$m1+$m2'
28
- xp '3.14*$m1'
29
- xp '$m2*1.25'
30
- xp '$v1'
31
- xp '$v2'
32
- xp '1.25*$v1'
33
- xp 'NMath.sqrt($v2**2)'
34
- xp '$v1*$v2'
35
- xp '$m1*$v1'
36
- xp '$v2*$m2'
37
- xp '$m1.diagonal([98,99])'
38
- xp 'NMatrix.float(4,3).unit'
39
-
40
- puts "\n=== following will fail ...\n"
41
- xp '$m1+$v1'
42
- xp '$m1+1'
@@ -1,19 +0,0 @@
1
- require 'narray'
2
- require 'rational'
3
-
4
- #class Rational
5
- # def inspect
6
- # @numerator.to_s+"/"+@denominator.to_s
7
- # end
8
- #end
9
-
10
- srand(1)
11
- n=5
12
-
13
- m = NMatrix.object(n,n).collect{Rational(rand(10))}
14
-
15
- puts 'm #=>'
16
- p m
17
-
18
- puts 'm/m #=>'
19
- p m/m
@@ -1,46 +0,0 @@
1
- require 'narray'
2
-
3
- def test a
4
- print "a = "
5
- p a
6
- print "a.min = "
7
- p a.min
8
- print "a.max = "
9
- p a.max
10
- print "a.sum = "
11
- p a.sum
12
- print "a.mean = "
13
- p a.mean
14
- print "a.stddev = "
15
- p a.stddev
16
- end
17
-
18
- a = NArray[0,2,-2.5,3,1.4]
19
-
20
- test a
21
-
22
- a = NArray.float(5,1).indgen!(1)
23
- b = NArray.float(1,3).indgen!(1)
24
- a *= b
25
- test a
26
-
27
- print "a.min(0) = "
28
- p a.min(0)
29
- print "a.max(0) = "
30
- p a.max(0)
31
- print "a.min(1) = "
32
- p a.min(1)
33
- print "a.max(1) = "
34
- p a.max(1)
35
- print "a.sum(0) = "
36
- p a.sum(0)
37
- print "a.sum(1) = "
38
- p a.sum(1)
39
- print "a.mean(0) = "
40
- p a.mean(0)
41
- print "a.mean(1) = "
42
- p a.mean(1)
43
- print "a.stddev(0) = "
44
- p a.stddev(0)
45
- print "a.stddev(1) = "
46
- p a.stddev(1)
@@ -1,29 +0,0 @@
1
- require 'narray'
2
- require 'rational'
3
-
4
- n = 4
5
- a = NArray.object(4,4).fill!(Rational(1))
6
- b = NArray.object(4,4).indgen!(1).collect{|i| Rational(i)}
7
-
8
- print 'a #=> '
9
- p a
10
-
11
- print 'b #=> '
12
- p b
13
-
14
-
15
- class Rational
16
- def inspect
17
- self.to_s
18
- end
19
- end
20
-
21
- print 'a+b #=> '
22
- p a+b
23
-
24
-
25
- print 'a/b #=> '
26
- p a/b
27
-
28
- print 'a/b - b #=> '
29
- p a/b - b
data/src/test/testpow.rb DELETED
@@ -1,19 +0,0 @@
1
- require "narray"
2
-
3
- def test a
4
- puts 'a = '
5
- p a
6
- puts 'a**[[-3],[0],[7]] = '
7
- p a**[[-3],[0],[7]]
8
- puts 'a**[[-3.0],[0],[7.0]] = '
9
- p a**[[-3.0],[0],[7.0]]
10
- puts 'a**(1+0.im) = '
11
- p a**(1+0.im)
12
- puts 'a**1.0 = '
13
- p a**1.0
14
- puts
15
- end
16
-
17
- test NArray.int(4).indgen!*2-2
18
- test NArray.float(4).indgen!*2-2
19
- test NArray.complex(4).indgen!*2-2
@@ -1,23 +0,0 @@
1
- require 'narray'
2
-
3
- def test a
4
- print a," #=> "
5
- p eval(a)
6
- print "\n"
7
- end
8
-
9
- test "NArray.float(5).random(10)"
10
-
11
- test "NArray.float(5).random"
12
-
13
- test "NArray.int(5).random(10)"
14
-
15
- test "NArray.int(1000).random(10)"
16
-
17
- a = NArray.int(1000).random(10)
18
-
19
- idx = (a.eq 0).where
20
- print "a.eq 0 :: n=", idx.size, "\n"
21
-
22
- idx = (a.eq 10).where
23
- print "a.eq 10 :: "; p idx
@@ -1,11 +0,0 @@
1
- require 'narray'
2
-
3
- def testround a
4
- print "a = "; p a
5
- print "a.floor = "; p a.floor
6
- print "a.ceil = "; p a.ceil
7
- print "a.round = "; p a.round
8
- print "\n"
9
- end
10
-
11
- testround NArray.float(4,2).indgen!/4-2
data/src/test/testsort.rb DELETED
@@ -1,37 +0,0 @@
1
- require 'narray'
2
-
3
- def test a,b
4
- print a," #=> "
5
- p b
6
- end
7
-
8
- a = NArray.int(16).random!(100)
9
-
10
- test "a",a
11
- test "a.sort",a.sort
12
-
13
- print "\n# as string...\n"
14
- a = a.to_string
15
- test "a",a
16
- test "a.sort",a.sort
17
-
18
- print "\n# up to 0-rank...\n"
19
- a = NArray.int(4,4).random!(100)
20
- test "a",a
21
- test "a.sort(0)",a.sort(0)
22
-
23
- print "\n# big array test...\n"
24
- a = NArray.int(10,10,10,10,10).random!(100)
25
- test "a",a
26
- test "a.sort(1)",a.sort(1)
27
-
28
- print "\n# test sort_index...\n"
29
- a = NArray.int(7,4).random!(100)
30
- test "a",a
31
- test "a.sort_index(0)",idx=a.sort_index(0)
32
- test "a[a.sort_index]",a[idx]
33
-
34
- print "\n# following will fail...\n"
35
- a = NArray.complex(3,3).random!(100)
36
- test "a",a
37
- test "a.sort",a.sort
data/src/test/teststr.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'narray'
2
-
3
- a = NArray.float(3,3)
4
- p a.indgen!
5
- p a.to_string
6
- p NArray.complex(3,3).indgen!.div!(3).to_string
7
- p NArray.scomplex(3,3).indgen!.div!(3).to_string
8
- p NArray.byte(3,3).indgen!.add!(32).to_string
9
-
10
- a = NArray.int(3,3)
11
- p a.indgen!
12
- p a.to_string
13
- p NArray.sfloat(3,3).indgen!.to_string.to_string
@@ -1,18 +0,0 @@
1
- require 'narray'
2
-
3
- def test a,b
4
- print a," #=> "
5
- p b
6
- end
7
-
8
- a = NArray.int(4,3,2).indgen!
9
- test "a",a
10
-
11
- print "\n# transpose first and second...\n"
12
- test "a.transpose(1,0)",a.transpose(1,0)
13
-
14
- print "\n# transpose first and last...\n"
15
- test "a.transpose(-1,1..-2,0)",a.transpose(-1,1..-2,0)
16
-
17
- print "\n# transpose shift forward ...\n"
18
- test "a.transpose(1..-1,0)",a.transpose(1..-1,0)
@@ -1,27 +0,0 @@
1
- require 'narray'
2
-
3
- a = NArray.float(8).indgen!
4
-
5
- print "a = "
6
- p a
7
-
8
- t,f = ( (a>=5).or(a<2) ).where2
9
- print "t,f = ( (a>=5).or (a<2) ).where2\n"
10
- print "t = "; p t
11
- print "f = "; p f
12
-
13
- t,f = ( (a>=5).and(a<2) ).where2
14
- print "t,f = ( (a>=5).and (a<2) ).where2\n"
15
- print "t = "; p t
16
- print "f = "; p f
17
-
18
- print "\n vvv no-meaning !! vvv\n"
19
- t,f = ( (a>=5) && (a<2) ).where2
20
- print "t,f = ( (a>=5) && (a<2) ).where2\n"
21
- print "t = "; p t
22
- print "f = "; p f
23
-
24
- t,f = ( (a>=5) || (a<2) ).where2
25
- print "t,f = ( (a>=5) || (a<2) ).where2\n"
26
- print "t = "; p t
27
- print "f = "; p f