narray 0.5.9.9 → 0.6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/src/ChangeLog +36 -0
- data/src/README.en +5 -6
- data/src/README.ja +4 -5
- data/src/SPEC.en +12 -9
- data/src/SPEC.ja +12 -9
- data/src/depend +1 -1
- data/src/extconf.rb +4 -19
- data/src/lib/narray_ext.rb +43 -2
- data/src/mkop.rb +11 -1
- data/src/na_func.c +92 -11
- data/src/na_linalg.c +2 -0
- data/src/narray.c +21 -12
- data/src/narray.h +3 -3
- data/src/narray_local.h +1 -0
- metadata +7 -48
- data/src/bench/all.rb +0 -88
- data/src/bench/bench.m +0 -61
- data/src/bench/bench.py +0 -89
- data/src/bench/bench.rb +0 -59
- data/src/bench/dummy.m +0 -0
- data/src/bench/dummy.py +0 -13
- data/src/bench/dummy.rb +0 -0
- data/src/test/statistics.rb +0 -22
- data/src/test/testarray.rb +0 -20
- data/src/test/testbit.rb +0 -27
- data/src/test/testcast.rb +0 -14
- data/src/test/testcomplex.rb +0 -35
- data/src/test/testfftw.rb +0 -16
- data/src/test/testindex.rb +0 -11
- data/src/test/testindexary.rb +0 -26
- data/src/test/testindexset.rb +0 -55
- data/src/test/testmask.rb +0 -40
- data/src/test/testmath.rb +0 -48
- data/src/test/testmath2.rb +0 -46
- data/src/test/testmatrix.rb +0 -13
- data/src/test/testmatrix2.rb +0 -42
- data/src/test/testmatrix3.rb +0 -19
- data/src/test/testminmax.rb +0 -46
- data/src/test/testobject.rb +0 -29
- data/src/test/testpow.rb +0 -19
- data/src/test/testrandom.rb +0 -23
- data/src/test/testround.rb +0 -11
- data/src/test/testsort.rb +0 -37
- data/src/test/teststr.rb +0 -13
- data/src/test/testtrans.rb +0 -18
- data/src/test/testwhere.rb +0 -27
data/src/test/testmatrix.rb
DELETED
@@ -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):
|
data/src/test/testmatrix2.rb
DELETED
@@ -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'
|
data/src/test/testmatrix3.rb
DELETED
@@ -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
|
data/src/test/testminmax.rb
DELETED
@@ -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)
|
data/src/test/testobject.rb
DELETED
@@ -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
|
data/src/test/testrandom.rb
DELETED
@@ -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
|
data/src/test/testround.rb
DELETED
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
|
data/src/test/testtrans.rb
DELETED
@@ -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)
|
data/src/test/testwhere.rb
DELETED
@@ -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
|