numo-narray 0.9.0.1-x86-mingw32
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.
- checksums.yaml +7 -0
 - data/Gemfile +4 -0
 - data/README.md +47 -0
 - data/Rakefile +41 -0
 - data/ext/numo/narray/SFMT-params.h +97 -0
 - data/ext/numo/narray/SFMT-params19937.h +46 -0
 - data/ext/numo/narray/SFMT.c +620 -0
 - data/ext/numo/narray/SFMT.h +157 -0
 - data/ext/numo/narray/array.c +525 -0
 - data/ext/numo/narray/data.c +901 -0
 - data/ext/numo/narray/depend.erb +33 -0
 - data/ext/numo/narray/extconf.rb +117 -0
 - data/ext/numo/narray/gen/bit.erb.c +811 -0
 - data/ext/numo/narray/gen/cogen.rb +18 -0
 - data/ext/numo/narray/gen/def/dcomplex.rb +32 -0
 - data/ext/numo/narray/gen/def/dfloat.rb +30 -0
 - data/ext/numo/narray/gen/def/int16.rb +29 -0
 - data/ext/numo/narray/gen/def/int32.rb +29 -0
 - data/ext/numo/narray/gen/def/int64.rb +29 -0
 - data/ext/numo/narray/gen/def/int8.rb +29 -0
 - data/ext/numo/narray/gen/def/robject.rb +30 -0
 - data/ext/numo/narray/gen/def/scomplex.rb +32 -0
 - data/ext/numo/narray/gen/def/sfloat.rb +30 -0
 - data/ext/numo/narray/gen/def/uint16.rb +29 -0
 - data/ext/numo/narray/gen/def/uint32.rb +29 -0
 - data/ext/numo/narray/gen/def/uint64.rb +29 -0
 - data/ext/numo/narray/gen/def/uint8.rb +29 -0
 - data/ext/numo/narray/gen/dtype.erb.c +328 -0
 - data/ext/numo/narray/gen/tmpl/accum.c +36 -0
 - data/ext/numo/narray/gen/tmpl/accum_binary.c +75 -0
 - data/ext/numo/narray/gen/tmpl/accum_index.c +58 -0
 - data/ext/numo/narray/gen/tmpl/allocate.c +35 -0
 - data/ext/numo/narray/gen/tmpl/aref.c +51 -0
 - data/ext/numo/narray/gen/tmpl/aset.c +61 -0
 - data/ext/numo/narray/gen/tmpl/binary.c +53 -0
 - data/ext/numo/narray/gen/tmpl/binary2.c +55 -0
 - data/ext/numo/narray/gen/tmpl/binary_s.c +34 -0
 - data/ext/numo/narray/gen/tmpl/bit_binary.c +94 -0
 - data/ext/numo/narray/gen/tmpl/bit_count.c +82 -0
 - data/ext/numo/narray/gen/tmpl/bit_unary.c +77 -0
 - data/ext/numo/narray/gen/tmpl/cast.c +37 -0
 - data/ext/numo/narray/gen/tmpl/cast_array.c +79 -0
 - data/ext/numo/narray/gen/tmpl/cast_numeric.c +22 -0
 - data/ext/numo/narray/gen/tmpl/coerce_cast.c +8 -0
 - data/ext/numo/narray/gen/tmpl/cond_binary.c +51 -0
 - data/ext/numo/narray/gen/tmpl/cond_unary.c +45 -0
 - data/ext/numo/narray/gen/tmpl/cum.c +42 -0
 - data/ext/numo/narray/gen/tmpl/each.c +43 -0
 - data/ext/numo/narray/gen/tmpl/each_with_index.c +64 -0
 - data/ext/numo/narray/gen/tmpl/extract.c +23 -0
 - data/ext/numo/narray/gen/tmpl/eye.c +91 -0
 - data/ext/numo/narray/gen/tmpl/fill.c +38 -0
 - data/ext/numo/narray/gen/tmpl/format.c +60 -0
 - data/ext/numo/narray/gen/tmpl/format_to_a.c +47 -0
 - data/ext/numo/narray/gen/tmpl/head.c +25 -0
 - data/ext/numo/narray/gen/tmpl/inspect.c +16 -0
 - data/ext/numo/narray/gen/tmpl/map_with_index.c +94 -0
 - data/ext/numo/narray/gen/tmpl/median.c +44 -0
 - data/ext/numo/narray/gen/tmpl/minmax.c +47 -0
 - data/ext/numo/narray/gen/tmpl/poly.c +49 -0
 - data/ext/numo/narray/gen/tmpl/pow.c +74 -0
 - data/ext/numo/narray/gen/tmpl/powint.c +17 -0
 - data/ext/numo/narray/gen/tmpl/qsort.c +149 -0
 - data/ext/numo/narray/gen/tmpl/rand.c +33 -0
 - data/ext/numo/narray/gen/tmpl/rand_norm.c +46 -0
 - data/ext/numo/narray/gen/tmpl/robj_allocate.c +32 -0
 - data/ext/numo/narray/gen/tmpl/seq.c +61 -0
 - data/ext/numo/narray/gen/tmpl/set2.c +56 -0
 - data/ext/numo/narray/gen/tmpl/sort.c +36 -0
 - data/ext/numo/narray/gen/tmpl/sort_index.c +86 -0
 - data/ext/numo/narray/gen/tmpl/store.c +31 -0
 - data/ext/numo/narray/gen/tmpl/store_array.c +5 -0
 - data/ext/numo/narray/gen/tmpl/store_from.c +53 -0
 - data/ext/numo/narray/gen/tmpl/store_numeric.c +22 -0
 - data/ext/numo/narray/gen/tmpl/to_a.c +41 -0
 - data/ext/numo/narray/gen/tmpl/unary.c +58 -0
 - data/ext/numo/narray/gen/tmpl/unary2.c +58 -0
 - data/ext/numo/narray/gen/tmpl/unary_s.c +57 -0
 - data/ext/numo/narray/index.c +822 -0
 - data/ext/numo/narray/kwarg.c +79 -0
 - data/ext/numo/narray/math.c +140 -0
 - data/ext/numo/narray/narray.c +1539 -0
 - data/ext/numo/narray/ndloop.c +1928 -0
 - data/ext/numo/narray/numo/compat.h +23 -0
 - data/ext/numo/narray/numo/intern.h +112 -0
 - data/ext/numo/narray/numo/narray.h +411 -0
 - data/ext/numo/narray/numo/ndloop.h +99 -0
 - data/ext/numo/narray/numo/template.h +140 -0
 - data/ext/numo/narray/numo/types/bit.h +19 -0
 - data/ext/numo/narray/numo/types/complex.h +410 -0
 - data/ext/numo/narray/numo/types/complex_macro.h +205 -0
 - data/ext/numo/narray/numo/types/dcomplex.h +11 -0
 - data/ext/numo/narray/numo/types/dfloat.h +12 -0
 - data/ext/numo/narray/numo/types/float_def.h +34 -0
 - data/ext/numo/narray/numo/types/float_macro.h +277 -0
 - data/ext/numo/narray/numo/types/int16.h +12 -0
 - data/ext/numo/narray/numo/types/int32.h +12 -0
 - data/ext/numo/narray/numo/types/int64.h +12 -0
 - data/ext/numo/narray/numo/types/int8.h +12 -0
 - data/ext/numo/narray/numo/types/int_macro.h +34 -0
 - data/ext/numo/narray/numo/types/robj_macro.h +218 -0
 - data/ext/numo/narray/numo/types/robject.h +21 -0
 - data/ext/numo/narray/numo/types/scomplex.h +11 -0
 - data/ext/numo/narray/numo/types/sfloat.h +13 -0
 - data/ext/numo/narray/numo/types/uint16.h +12 -0
 - data/ext/numo/narray/numo/types/uint32.h +12 -0
 - data/ext/numo/narray/numo/types/uint64.h +12 -0
 - data/ext/numo/narray/numo/types/uint8.h +12 -0
 - data/ext/numo/narray/numo/types/uint_macro.h +31 -0
 - data/ext/numo/narray/numo/types/xint_macro.h +133 -0
 - data/ext/numo/narray/rand.c +87 -0
 - data/ext/numo/narray/step.c +506 -0
 - data/ext/numo/narray/struct.c +872 -0
 - data/lib/2.1/numo/narray.so +0 -0
 - data/lib/2.2/numo/narray.so +0 -0
 - data/lib/2.3/numo/narray.so +0 -0
 - data/lib/erbpp/line_number.rb +126 -0
 - data/lib/erbpp/narray_def.rb +338 -0
 - data/lib/erbpp.rb +286 -0
 - data/lib/numo/narray.rb +6 -0
 - data/numo-narray.gemspec +35 -0
 - data/spec/bit_spec.rb +93 -0
 - data/spec/narray_spec.rb +249 -0
 - metadata +238 -0
 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         @@ -0,0 +1,126 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class CountLnString < String
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              def initialize(filename)
         
     | 
| 
      
 4 
     | 
    
         
            +
                @filename = filename
         
     | 
| 
      
 5 
     | 
    
         
            +
                @lnchar = "\n"
         
     | 
| 
      
 6 
     | 
    
         
            +
                @buf = ""
         
     | 
| 
      
 7 
     | 
    
         
            +
                @str = ""
         
     | 
| 
      
 8 
     | 
    
         
            +
                @countln = 1
         
     | 
| 
      
 9 
     | 
    
         
            +
                @current = 1
         
     | 
| 
      
 10 
     | 
    
         
            +
                super(report_line)
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              def report_line
         
     | 
| 
      
 14 
     | 
    
         
            +
                "#line #{@current} \"#{@filename}\"\n"
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              def concat0(s)
         
     | 
| 
      
 18 
     | 
    
         
            +
                ln(caller[0])
         
     | 
| 
      
 19 
     | 
    
         
            +
                @buf.concat(s)
         
     | 
| 
      
 20 
     | 
    
         
            +
                @str.concat(s)
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              def concat1(s)
         
     | 
| 
      
 24 
     | 
    
         
            +
                ln(caller[0])
         
     | 
| 
      
 25 
     | 
    
         
            +
                @buf.concat(s)
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              def ln(status=nil)
         
     | 
| 
      
 29 
     | 
    
         
            +
                case status
         
     | 
| 
      
 30 
     | 
    
         
            +
                when /:(\d+):/
         
     | 
| 
      
 31 
     | 
    
         
            +
                  n = $1.to_i
         
     | 
| 
      
 32 
     | 
    
         
            +
                else
         
     | 
| 
      
 33 
     | 
    
         
            +
                  n = status.to_i
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
                return if n == @current
         
     | 
| 
      
 36 
     | 
    
         
            +
                if @current != @countln || @postpone
         
     | 
| 
      
 37 
     | 
    
         
            +
                  if /^\s*$/ =~ @str || /\A#line / =~ @buf
         
     | 
| 
      
 38 
     | 
    
         
            +
                    @postpone = true
         
     | 
| 
      
 39 
     | 
    
         
            +
                  elsif @in_comment
         
     | 
| 
      
 40 
     | 
    
         
            +
                    @postpone = false
         
     | 
| 
      
 41 
     | 
    
         
            +
                  else
         
     | 
| 
      
 42 
     | 
    
         
            +
                    concat(report_line)
         
     | 
| 
      
 43 
     | 
    
         
            +
                    @postpone = false
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
                concat(@buf)
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                b = @buf.gsub(/".*?(?<!\\)"/,'""')
         
     | 
| 
      
 49 
     | 
    
         
            +
                /^.*(\/\*)(.*?)$/ =~ b
         
     | 
| 
      
 50 
     | 
    
         
            +
                x = $2
         
     | 
| 
      
 51 
     | 
    
         
            +
                /^.*(\*\/)(.*?)$/ =~ b
         
     | 
| 
      
 52 
     | 
    
         
            +
                y = $2
         
     | 
| 
      
 53 
     | 
    
         
            +
                if x
         
     | 
| 
      
 54 
     | 
    
         
            +
                  if y
         
     | 
| 
      
 55 
     | 
    
         
            +
                    if x.size < y.size
         
     | 
| 
      
 56 
     | 
    
         
            +
                      #:in_comment
         
     | 
| 
      
 57 
     | 
    
         
            +
                      @in_comment = true
         
     | 
| 
      
 58 
     | 
    
         
            +
                    else
         
     | 
| 
      
 59 
     | 
    
         
            +
                      #:out_comment
         
     | 
| 
      
 60 
     | 
    
         
            +
                      @in_comment = false
         
     | 
| 
      
 61 
     | 
    
         
            +
                    end
         
     | 
| 
      
 62 
     | 
    
         
            +
                  else
         
     | 
| 
      
 63 
     | 
    
         
            +
                    #:in_comment
         
     | 
| 
      
 64 
     | 
    
         
            +
                    @in_comment = true
         
     | 
| 
      
 65 
     | 
    
         
            +
                  end
         
     | 
| 
      
 66 
     | 
    
         
            +
                else
         
     | 
| 
      
 67 
     | 
    
         
            +
                  if y
         
     | 
| 
      
 68 
     | 
    
         
            +
                    #:out_comment
         
     | 
| 
      
 69 
     | 
    
         
            +
                    @in_comment = false
         
     | 
| 
      
 70 
     | 
    
         
            +
                  else
         
     | 
| 
      
 71 
     | 
    
         
            +
                    #:keep
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                @countln = @current + @buf.count(@lnchar)
         
     | 
| 
      
 76 
     | 
    
         
            +
                @current = n
         
     | 
| 
      
 77 
     | 
    
         
            +
                @buf = ""
         
     | 
| 
      
 78 
     | 
    
         
            +
                @str = ""
         
     | 
| 
      
 79 
     | 
    
         
            +
              end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
              def d(s)
         
     | 
| 
      
 82 
     | 
    
         
            +
              p [s, [x,y], r]
         
     | 
| 
      
 83 
     | 
    
         
            +
              r
         
     | 
| 
      
 84 
     | 
    
         
            +
            end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
            class ERB
         
     | 
| 
      
 89 
     | 
    
         
            +
              alias result_orig result
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
              def result(b=new_toplevel)
         
     | 
| 
      
 92 
     | 
    
         
            +
                src = src_with_cpp_line
         
     | 
| 
      
 93 
     | 
    
         
            +
                if @safe_level
         
     | 
| 
      
 94 
     | 
    
         
            +
                  proc {
         
     | 
| 
      
 95 
     | 
    
         
            +
                    $SAFE = @safe_level
         
     | 
| 
      
 96 
     | 
    
         
            +
                    eval(src, b, (@filename || '(erb)'), 0)
         
     | 
| 
      
 97 
     | 
    
         
            +
                  }.call
         
     | 
| 
      
 98 
     | 
    
         
            +
                else
         
     | 
| 
      
 99 
     | 
    
         
            +
                  #open("tmpout","w"){|f| f.write src} if /dtype/=~@filename
         
     | 
| 
      
 100 
     | 
    
         
            +
                  eval(src, b, (@filename || '(erb)'), 0)
         
     | 
| 
      
 101 
     | 
    
         
            +
                end
         
     | 
| 
      
 102 
     | 
    
         
            +
              end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
              alias src_orig src
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
              def src
         
     | 
| 
      
 107 
     | 
    
         
            +
                src_with_cpp_line
         
     | 
| 
      
 108 
     | 
    
         
            +
              end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
              def src_with_cpp_line
         
     | 
| 
      
 111 
     | 
    
         
            +
                @src.each_line.with_index.map do |line, num|
         
     | 
| 
      
 112 
     | 
    
         
            +
                  line.gsub!(/_erbout.concat "/,'_erbout.concat0 "')
         
     | 
| 
      
 113 
     | 
    
         
            +
                  line.gsub!(/_erbout.concat\(/,'_erbout.concat1(')
         
     | 
| 
      
 114 
     | 
    
         
            +
                  if num==0
         
     | 
| 
      
 115 
     | 
    
         
            +
                    # skip
         
     | 
| 
      
 116 
     | 
    
         
            +
                  elsif num==1
         
     | 
| 
      
 117 
     | 
    
         
            +
                    f = @filename.dump
         
     | 
| 
      
 118 
     | 
    
         
            +
                    line.sub!(/_erbout = '';/, "_erbout = CountLnString.new(#{f});")
         
     | 
| 
      
 119 
     | 
    
         
            +
                  elsif /^; _erbout\.force_encoding/ =~ line
         
     | 
| 
      
 120 
     | 
    
         
            +
                    line.sub!(/^;/,";_erbout.ln(#{num});")
         
     | 
| 
      
 121 
     | 
    
         
            +
                  end
         
     | 
| 
      
 122 
     | 
    
         
            +
                  line
         
     | 
| 
      
 123 
     | 
    
         
            +
                end.join
         
     | 
| 
      
 124 
     | 
    
         
            +
              end
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,338 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'erbpp'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module DefMethod
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              def def_id(meth,var=nil)
         
     | 
| 
      
 6 
     | 
    
         
            +
                IdVar.new(self, meth, var)
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              def def_method(meth, n_arg, tmpl=nil, opts={})
         
     | 
| 
      
 10 
     | 
    
         
            +
                h = {:method => meth, :n_arg => n_arg}
         
     | 
| 
      
 11 
     | 
    
         
            +
                h.merge!(opts)
         
     | 
| 
      
 12 
     | 
    
         
            +
                tmpl ||= meth
         
     | 
| 
      
 13 
     | 
    
         
            +
                Function.new(self, tmpl, h)
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              def def_singleton(meth, n_arg, tmpl=nil, opts={})
         
     | 
| 
      
 17 
     | 
    
         
            +
                def_method(meth, n_arg, tmpl, :singleton => true)
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              def def_alias(dst, src)
         
     | 
| 
      
 21 
     | 
    
         
            +
                Alias.new(self, dst, src)
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              def def_allocate(tmpl)
         
     | 
| 
      
 25 
     | 
    
         
            +
                h = {:method => "allocate", :singleton => true}
         
     | 
| 
      
 26 
     | 
    
         
            +
                Allocate.new(self, tmpl, h)
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              def binary(meth, ope=nil)
         
     | 
| 
      
 30 
     | 
    
         
            +
                ope = meth if ope.nil?
         
     | 
| 
      
 31 
     | 
    
         
            +
                def_method(meth, 1, "binary", :op => ope)
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              def binary2(meth, ope=nil)
         
     | 
| 
      
 35 
     | 
    
         
            +
                ope = meth if ope.nil?
         
     | 
| 
      
 36 
     | 
    
         
            +
                def_method(meth, 1, "binary2", :op =>ope)
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              def unary(meth, ope=nil)
         
     | 
| 
      
 40 
     | 
    
         
            +
                def_method(meth, 0, "unary", :op => ope)
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              def pow
         
     | 
| 
      
 44 
     | 
    
         
            +
                def_method("pow", 1, "pow", :op => "**")
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              def unary2(meth, dtype, tpclass)
         
     | 
| 
      
 48 
     | 
    
         
            +
                h = {:dtype => dtype, :tpclass => tpclass}
         
     | 
| 
      
 49 
     | 
    
         
            +
                def_method(meth, 0, "unary2", h)
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              def set2(meth, dtype, tpclass)
         
     | 
| 
      
 53 
     | 
    
         
            +
                h = {:dtype => dtype, :tpclass => tpclass}
         
     | 
| 
      
 54 
     | 
    
         
            +
                def_method(meth, 1, "set2", h)
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              def cond_binary(meth,op=nil)
         
     | 
| 
      
 58 
     | 
    
         
            +
                def_method(meth, 1, "cond_binary", :op => op)
         
     | 
| 
      
 59 
     | 
    
         
            +
              end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
              def cond_unary(meth)
         
     | 
| 
      
 62 
     | 
    
         
            +
                def_method(meth, 0, "cond_unary")
         
     | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
              def bit_binary(meth, op=nil)
         
     | 
| 
      
 66 
     | 
    
         
            +
                h = {:op=>op}
         
     | 
| 
      
 67 
     | 
    
         
            +
                h[:aliases] = [meth] if op
         
     | 
| 
      
 68 
     | 
    
         
            +
                def_method(meth, 1, "bit_binary", h)
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              def bit_unary(meth, op=nil)
         
     | 
| 
      
 72 
     | 
    
         
            +
                h = {:op=>op}
         
     | 
| 
      
 73 
     | 
    
         
            +
                h[:aliases] = [meth] if op
         
     | 
| 
      
 74 
     | 
    
         
            +
                def_method(meth, 0, "bit_unary", h)
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
              def bit_count(meth)
         
     | 
| 
      
 78 
     | 
    
         
            +
                def_method(meth, -1, "bit_count")
         
     | 
| 
      
 79 
     | 
    
         
            +
              end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
              def accum(meth, dtype, tpclass)
         
     | 
| 
      
 82 
     | 
    
         
            +
                h = {:dtype => dtype, :tpclass => tpclass}
         
     | 
| 
      
 83 
     | 
    
         
            +
                def_method(meth, -1, "accum", h)
         
     | 
| 
      
 84 
     | 
    
         
            +
              end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
              def accum_index(meth)
         
     | 
| 
      
 87 
     | 
    
         
            +
                def_method(meth, -1, "accum_index")
         
     | 
| 
      
 88 
     | 
    
         
            +
              end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
              def cum(meth, cmacro)
         
     | 
| 
      
 91 
     | 
    
         
            +
                def_method(meth, -1, "cum", cmacro:cmacro)
         
     | 
| 
      
 92 
     | 
    
         
            +
              end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
              def accum_binary(meth, ope=nil)
         
     | 
| 
      
 95 
     | 
    
         
            +
                ope = meth if ope.nil?
         
     | 
| 
      
 96 
     | 
    
         
            +
                def_method(meth, -1, "accum_binary", :op => ope)
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              def qsort(tp, dtype, dcast)
         
     | 
| 
      
 100 
     | 
    
         
            +
                h = {:tp => tp, :dtype => dtype, :dcast => dcast}
         
     | 
| 
      
 101 
     | 
    
         
            +
                NodefFunction.new(self, "qsort", h)
         
     | 
| 
      
 102 
     | 
    
         
            +
              end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
              def math(meth, n=1)
         
     | 
| 
      
 105 
     | 
    
         
            +
                h = {:method => meth, :mod_var => 'mTM', :n_arg => n}
         
     | 
| 
      
 106 
     | 
    
         
            +
                case n
         
     | 
| 
      
 107 
     | 
    
         
            +
                when 1
         
     | 
| 
      
 108 
     | 
    
         
            +
                  ModuleFunction.new(self, "unary_s", h)
         
     | 
| 
      
 109 
     | 
    
         
            +
                when 2
         
     | 
| 
      
 110 
     | 
    
         
            +
                  ModuleFunction.new(self, "binary_s", h)
         
     | 
| 
      
 111 
     | 
    
         
            +
                when 3
         
     | 
| 
      
 112 
     | 
    
         
            +
                  ModuleFunction.new(self, "ternary_s", h)
         
     | 
| 
      
 113 
     | 
    
         
            +
                else
         
     | 
| 
      
 114 
     | 
    
         
            +
                  raise "invalid n=#{n}"
         
     | 
| 
      
 115 
     | 
    
         
            +
                end
         
     | 
| 
      
 116 
     | 
    
         
            +
              end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
              def store_numeric
         
     | 
| 
      
 119 
     | 
    
         
            +
                StoreNum.new(self,"store_numeric")
         
     | 
| 
      
 120 
     | 
    
         
            +
              end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
              def store_array
         
     | 
| 
      
 123 
     | 
    
         
            +
                StoreArray.new(self,"store_array")
         
     | 
| 
      
 124 
     | 
    
         
            +
              end
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
              def cast_array
         
     | 
| 
      
 127 
     | 
    
         
            +
                CastArray.new(self,"cast_array")
         
     | 
| 
      
 128 
     | 
    
         
            +
              end
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
              def store_from(cname,dtype,macro)
         
     | 
| 
      
 131 
     | 
    
         
            +
                Store.new(self,"store_from",cname.downcase,dtype,"numo_c"+cname,macro)
         
     | 
| 
      
 132 
     | 
    
         
            +
              end
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
              def store
         
     | 
| 
      
 135 
     | 
    
         
            +
                Function.new(self,"store","store")
         
     | 
| 
      
 136 
     | 
    
         
            +
              end
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
              def find_method(meth)
         
     | 
| 
      
 139 
     | 
    
         
            +
                Function::DEFS.find{|x| x.kind_of?(Function) and meth == x.method }
         
     | 
| 
      
 140 
     | 
    
         
            +
              end
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
              def find_tmpl(meth)
         
     | 
| 
      
 143 
     | 
    
         
            +
                Function::DEFS.find{|x| x.kind_of?(Function) and meth == x.tmpl }
         
     | 
| 
      
 144 
     | 
    
         
            +
              end
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
              def cast_func
         
     | 
| 
      
 147 
     | 
    
         
            +
                "numo_#{tp}_s_cast"
         
     | 
| 
      
 148 
     | 
    
         
            +
              end
         
     | 
| 
      
 149 
     | 
    
         
            +
            end
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
            # ----------------------------------------------------------------------
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
            class DataType < ErbPP
         
     | 
| 
      
 154 
     | 
    
         
            +
              include DefMethod
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
              def initialize(erb_path, type_file)
         
     | 
| 
      
 157 
     | 
    
         
            +
                super(nil, erb_path)
         
     | 
| 
      
 158 
     | 
    
         
            +
                @class_alias = []
         
     | 
| 
      
 159 
     | 
    
         
            +
                @upcast = []
         
     | 
| 
      
 160 
     | 
    
         
            +
                @mod_var = "cT"
         
     | 
| 
      
 161 
     | 
    
         
            +
                @tmpl_dir = File.join(File.dirname(erb_path),"tmpl")
         
     | 
| 
      
 162 
     | 
    
         
            +
                load_type(type_file) if type_file
         
     | 
| 
      
 163 
     | 
    
         
            +
              end
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
              attr_reader :tmpl_dir
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
              def load_type(file)
         
     | 
| 
      
 168 
     | 
    
         
            +
                eval File.read(file)
         
     | 
| 
      
 169 
     | 
    
         
            +
              end
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
              attrs = %w[
         
     | 
| 
      
 172 
     | 
    
         
            +
                class_name
         
     | 
| 
      
 173 
     | 
    
         
            +
                ctype
         
     | 
| 
      
 174 
     | 
    
         
            +
                blas_char
         
     | 
| 
      
 175 
     | 
    
         
            +
                complex_class_name
         
     | 
| 
      
 176 
     | 
    
         
            +
                complex_type
         
     | 
| 
      
 177 
     | 
    
         
            +
                real_class_name
         
     | 
| 
      
 178 
     | 
    
         
            +
                real_ctype
         
     | 
| 
      
 179 
     | 
    
         
            +
                has_math
         
     | 
| 
      
 180 
     | 
    
         
            +
                is_bit
         
     | 
| 
      
 181 
     | 
    
         
            +
                is_int
         
     | 
| 
      
 182 
     | 
    
         
            +
                is_float
         
     | 
| 
      
 183 
     | 
    
         
            +
                is_real
         
     | 
| 
      
 184 
     | 
    
         
            +
                is_complex
         
     | 
| 
      
 185 
     | 
    
         
            +
                is_object
         
     | 
| 
      
 186 
     | 
    
         
            +
                is_comparable
         
     | 
| 
      
 187 
     | 
    
         
            +
                mod_var
         
     | 
| 
      
 188 
     | 
    
         
            +
              ]
         
     | 
| 
      
 189 
     | 
    
         
            +
              define_attrs attrs
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
              def type_name
         
     | 
| 
      
 192 
     | 
    
         
            +
                @type_name ||= class_name.downcase
         
     | 
| 
      
 193 
     | 
    
         
            +
              end
         
     | 
| 
      
 194 
     | 
    
         
            +
              alias tp type_name
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
              def type_var
         
     | 
| 
      
 197 
     | 
    
         
            +
                @type_var ||= "numo_c"+class_name
         
     | 
| 
      
 198 
     | 
    
         
            +
              end
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
              def math_var
         
     | 
| 
      
 201 
     | 
    
         
            +
                @math_var ||= "numo_m"+class_name+"Math"
         
     | 
| 
      
 202 
     | 
    
         
            +
              end
         
     | 
| 
      
 203 
     | 
    
         
            +
             
     | 
| 
      
 204 
     | 
    
         
            +
              def real_class_name(arg=nil)
         
     | 
| 
      
 205 
     | 
    
         
            +
                if arg.nil?
         
     | 
| 
      
 206 
     | 
    
         
            +
                  @real_class_name ||= class_name
         
     | 
| 
      
 207 
     | 
    
         
            +
                else
         
     | 
| 
      
 208 
     | 
    
         
            +
                  @real_class_name = arg
         
     | 
| 
      
 209 
     | 
    
         
            +
                end
         
     | 
| 
      
 210 
     | 
    
         
            +
              end
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
              def real_ctype(arg=nil)
         
     | 
| 
      
 213 
     | 
    
         
            +
                if arg.nil?
         
     | 
| 
      
 214 
     | 
    
         
            +
                  @real_ctype ||= ctype
         
     | 
| 
      
 215 
     | 
    
         
            +
                else
         
     | 
| 
      
 216 
     | 
    
         
            +
                  @real_ctype = arg
         
     | 
| 
      
 217 
     | 
    
         
            +
                end
         
     | 
| 
      
 218 
     | 
    
         
            +
              end
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
              def real_type_var
         
     | 
| 
      
 221 
     | 
    
         
            +
                @real_type_var ||= "numo_c"+real_class_name
         
     | 
| 
      
 222 
     | 
    
         
            +
              end
         
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
      
 224 
     | 
    
         
            +
              def real_type_name
         
     | 
| 
      
 225 
     | 
    
         
            +
                @real_type_name ||= real_class_name.downcase
         
     | 
| 
      
 226 
     | 
    
         
            +
              end
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
              def class_alias(*args)
         
     | 
| 
      
 229 
     | 
    
         
            +
                @class_alias.concat(args)
         
     | 
| 
      
 230 
     | 
    
         
            +
              end
         
     | 
| 
      
 231 
     | 
    
         
            +
             
     | 
| 
      
 232 
     | 
    
         
            +
              def upcast(c=nil,t=nil)
         
     | 
| 
      
 233 
     | 
    
         
            +
                if c
         
     | 
| 
      
 234 
     | 
    
         
            +
                  if t
         
     | 
| 
      
 235 
     | 
    
         
            +
                    t = "numo_c#{t}"
         
     | 
| 
      
 236 
     | 
    
         
            +
                  else
         
     | 
| 
      
 237 
     | 
    
         
            +
                    t = "cT"
         
     | 
| 
      
 238 
     | 
    
         
            +
                  end
         
     | 
| 
      
 239 
     | 
    
         
            +
                  @upcast << "rb_hash_aset(hCast, numo_c#{c}, #{t});"
         
     | 
| 
      
 240 
     | 
    
         
            +
                else
         
     | 
| 
      
 241 
     | 
    
         
            +
                  @upcast
         
     | 
| 
      
 242 
     | 
    
         
            +
                end
         
     | 
| 
      
 243 
     | 
    
         
            +
              end
         
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
              def upcast_rb(c,t=nil)
         
     | 
| 
      
 246 
     | 
    
         
            +
                if t
         
     | 
| 
      
 247 
     | 
    
         
            +
                  t = "numo_c#{t}"
         
     | 
| 
      
 248 
     | 
    
         
            +
                else
         
     | 
| 
      
 249 
     | 
    
         
            +
                  t = "cT"
         
     | 
| 
      
 250 
     | 
    
         
            +
                end
         
     | 
| 
      
 251 
     | 
    
         
            +
                if c=="Integer"
         
     | 
| 
      
 252 
     | 
    
         
            +
                  @upcast << "rb_hash_aset(hCast, rb_cFixnum, #{t});"
         
     | 
| 
      
 253 
     | 
    
         
            +
                  @upcast << "rb_hash_aset(hCast, rb_cBignum, #{t});"
         
     | 
| 
      
 254 
     | 
    
         
            +
                else
         
     | 
| 
      
 255 
     | 
    
         
            +
                  @upcast << "rb_hash_aset(hCast, rb_c#{c}, #{t});"
         
     | 
| 
      
 256 
     | 
    
         
            +
                end
         
     | 
| 
      
 257 
     | 
    
         
            +
              end
         
     | 
| 
      
 258 
     | 
    
         
            +
            end
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
             
     | 
| 
      
 261 
     | 
    
         
            +
            # ----------------------------------------------------------------------
         
     | 
| 
      
 262 
     | 
    
         
            +
             
     | 
| 
      
 263 
     | 
    
         
            +
             
     | 
| 
      
 264 
     | 
    
         
            +
            class Allocate < Function
         
     | 
| 
      
 265 
     | 
    
         
            +
              def definition
         
     | 
| 
      
 266 
     | 
    
         
            +
                "rb_define_alloc_func(#{mod_var}, #{c_func});"
         
     | 
| 
      
 267 
     | 
    
         
            +
              end
         
     | 
| 
      
 268 
     | 
    
         
            +
            end
         
     | 
| 
      
 269 
     | 
    
         
            +
             
     | 
| 
      
 270 
     | 
    
         
            +
            # ----------------------------------------------------------------------
         
     | 
| 
      
 271 
     | 
    
         
            +
             
     | 
| 
      
 272 
     | 
    
         
            +
            class Store < Function
         
     | 
| 
      
 273 
     | 
    
         
            +
              DEFS = []
         
     | 
| 
      
 274 
     | 
    
         
            +
             
     | 
| 
      
 275 
     | 
    
         
            +
              def initialize(parent,tmpl,tpname,dtype,tpclass,macro)
         
     | 
| 
      
 276 
     | 
    
         
            +
                super(parent,tmpl)
         
     | 
| 
      
 277 
     | 
    
         
            +
                @tpname=tpname
         
     | 
| 
      
 278 
     | 
    
         
            +
                @dtype=dtype
         
     | 
| 
      
 279 
     | 
    
         
            +
                @tpclass=tpclass
         
     | 
| 
      
 280 
     | 
    
         
            +
                @macro=macro
         
     | 
| 
      
 281 
     | 
    
         
            +
                DEFS.push(self)
         
     | 
| 
      
 282 
     | 
    
         
            +
              end
         
     | 
| 
      
 283 
     | 
    
         
            +
              attr_reader :tmpl, :tpname, :dtype, :tpclass, :macro
         
     | 
| 
      
 284 
     | 
    
         
            +
             
     | 
| 
      
 285 
     | 
    
         
            +
              def c_func
         
     | 
| 
      
 286 
     | 
    
         
            +
                "numo_#{tp}_store_#{tpname}"
         
     | 
| 
      
 287 
     | 
    
         
            +
              end
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
              def c_iter
         
     | 
| 
      
 290 
     | 
    
         
            +
                "iter_#{tp}_store_#{tpname}"
         
     | 
| 
      
 291 
     | 
    
         
            +
              end
         
     | 
| 
      
 292 
     | 
    
         
            +
             
     | 
| 
      
 293 
     | 
    
         
            +
              def definition
         
     | 
| 
      
 294 
     | 
    
         
            +
                nil
         
     | 
| 
      
 295 
     | 
    
         
            +
              end
         
     | 
| 
      
 296 
     | 
    
         
            +
             
     | 
| 
      
 297 
     | 
    
         
            +
              def condition
         
     | 
| 
      
 298 
     | 
    
         
            +
                "rb_obj_is_kind_of(obj,#{tpclass})"
         
     | 
| 
      
 299 
     | 
    
         
            +
              end
         
     | 
| 
      
 300 
     | 
    
         
            +
             
     | 
| 
      
 301 
     | 
    
         
            +
              def self.definitions
         
     | 
| 
      
 302 
     | 
    
         
            +
                a = []
         
     | 
| 
      
 303 
     | 
    
         
            +
                DEFS.each do |i|
         
     | 
| 
      
 304 
     | 
    
         
            +
                  a.push(i) if i.condition
         
     | 
| 
      
 305 
     | 
    
         
            +
                end
         
     | 
| 
      
 306 
     | 
    
         
            +
                a
         
     | 
| 
      
 307 
     | 
    
         
            +
              end
         
     | 
| 
      
 308 
     | 
    
         
            +
            end
         
     | 
| 
      
 309 
     | 
    
         
            +
             
     | 
| 
      
 310 
     | 
    
         
            +
            class StoreNum < Store
         
     | 
| 
      
 311 
     | 
    
         
            +
              def initialize(parent,tmpl)
         
     | 
| 
      
 312 
     | 
    
         
            +
                super(parent,tmpl,"numeric",nil,nil,nil)
         
     | 
| 
      
 313 
     | 
    
         
            +
              end
         
     | 
| 
      
 314 
     | 
    
         
            +
             
     | 
| 
      
 315 
     | 
    
         
            +
              def condition
         
     | 
| 
      
 316 
     | 
    
         
            +
                "FIXNUM_P(obj) || TYPE(obj)==T_FLOAT || TYPE(obj)==T_BIGNUM || rb_obj_is_kind_of(obj,rb_cComplex)"
         
     | 
| 
      
 317 
     | 
    
         
            +
              end
         
     | 
| 
      
 318 
     | 
    
         
            +
            end
         
     | 
| 
      
 319 
     | 
    
         
            +
             
     | 
| 
      
 320 
     | 
    
         
            +
            class StoreArray < Store
         
     | 
| 
      
 321 
     | 
    
         
            +
              def initialize(parent,tmpl)
         
     | 
| 
      
 322 
     | 
    
         
            +
                super(parent,tmpl,"array",nil,nil,nil)
         
     | 
| 
      
 323 
     | 
    
         
            +
              end
         
     | 
| 
      
 324 
     | 
    
         
            +
             
     | 
| 
      
 325 
     | 
    
         
            +
              def c_func
         
     | 
| 
      
 326 
     | 
    
         
            +
                "numo_#{tp}_#{tmpl}"
         
     | 
| 
      
 327 
     | 
    
         
            +
              end
         
     | 
| 
      
 328 
     | 
    
         
            +
             
     | 
| 
      
 329 
     | 
    
         
            +
              def condition
         
     | 
| 
      
 330 
     | 
    
         
            +
                "TYPE(obj)==T_ARRAY"
         
     | 
| 
      
 331 
     | 
    
         
            +
              end
         
     | 
| 
      
 332 
     | 
    
         
            +
            end
         
     | 
| 
      
 333 
     | 
    
         
            +
             
     | 
| 
      
 334 
     | 
    
         
            +
            class CastArray < StoreArray
         
     | 
| 
      
 335 
     | 
    
         
            +
              def condition
         
     | 
| 
      
 336 
     | 
    
         
            +
                nil
         
     | 
| 
      
 337 
     | 
    
         
            +
              end
         
     | 
| 
      
 338 
     | 
    
         
            +
            end
         
     |