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
 
| 
         @@ -0,0 +1,328 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            /*
         
     | 
| 
      
 2 
     | 
    
         
            +
              <%=type_name%>.c
         
     | 
| 
      
 3 
     | 
    
         
            +
              Numerical Array Extension for Ruby
         
     | 
| 
      
 4 
     | 
    
         
            +
                (C) Copyright 1999-2011,2013 by Masahiro TANAKA
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              This program is free software.
         
     | 
| 
      
 7 
     | 
    
         
            +
              You can distribute/modify this program
         
     | 
| 
      
 8 
     | 
    
         
            +
              under the same terms as Ruby itself.
         
     | 
| 
      
 9 
     | 
    
         
            +
              NO WARRANTY.
         
     | 
| 
      
 10 
     | 
    
         
            +
            */
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            #include <ruby.h>
         
     | 
| 
      
 13 
     | 
    
         
            +
            #include <math.h>
         
     | 
| 
      
 14 
     | 
    
         
            +
            #include "numo/narray.h"
         
     | 
| 
      
 15 
     | 
    
         
            +
            #include "numo/template.h"
         
     | 
| 
      
 16 
     | 
    
         
            +
            #include "SFMT.h"
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            #define m_map(x) m_num_to_data(rb_yield(m_data_to_num(x)))
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            <%
         
     | 
| 
      
 21 
     | 
    
         
            +
            def_id "cast"
         
     | 
| 
      
 22 
     | 
    
         
            +
            def_id "eq"
         
     | 
| 
      
 23 
     | 
    
         
            +
            def_id "ne"
         
     | 
| 
      
 24 
     | 
    
         
            +
            def_id "pow"
         
     | 
| 
      
 25 
     | 
    
         
            +
            def_id "mulsum"
         
     | 
| 
      
 26 
     | 
    
         
            +
            if is_complex
         
     | 
| 
      
 27 
     | 
    
         
            +
              def_id "real"
         
     | 
| 
      
 28 
     | 
    
         
            +
              def_id "imag"
         
     | 
| 
      
 29 
     | 
    
         
            +
            else
         
     | 
| 
      
 30 
     | 
    
         
            +
              def_id "divmod"
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
      
 32 
     | 
    
         
            +
            if is_float
         
     | 
| 
      
 33 
     | 
    
         
            +
              def_id "nearly_eq"
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
| 
      
 35 
     | 
    
         
            +
            if is_comparable
         
     | 
| 
      
 36 
     | 
    
         
            +
              def_id "gt"
         
     | 
| 
      
 37 
     | 
    
         
            +
              def_id "ge"
         
     | 
| 
      
 38 
     | 
    
         
            +
              def_id "lt"
         
     | 
| 
      
 39 
     | 
    
         
            +
              def_id "le"
         
     | 
| 
      
 40 
     | 
    
         
            +
            end
         
     | 
| 
      
 41 
     | 
    
         
            +
            if is_object
         
     | 
| 
      
 42 
     | 
    
         
            +
              def_id "bit_and"
         
     | 
| 
      
 43 
     | 
    
         
            +
              def_id "bit_or"
         
     | 
| 
      
 44 
     | 
    
         
            +
              def_id "bit_xor"
         
     | 
| 
      
 45 
     | 
    
         
            +
              def_id "bit_not"
         
     | 
| 
      
 46 
     | 
    
         
            +
              def_id "abs"
         
     | 
| 
      
 47 
     | 
    
         
            +
              def_id "minus"
         
     | 
| 
      
 48 
     | 
    
         
            +
              def_id "inverse"
         
     | 
| 
      
 49 
     | 
    
         
            +
              def_id "square"
         
     | 
| 
      
 50 
     | 
    
         
            +
              def_id "floor"
         
     | 
| 
      
 51 
     | 
    
         
            +
              def_id "round"
         
     | 
| 
      
 52 
     | 
    
         
            +
              def_id "ceil"
         
     | 
| 
      
 53 
     | 
    
         
            +
              def_id "nan?"
         
     | 
| 
      
 54 
     | 
    
         
            +
              def_id "infinite?"
         
     | 
| 
      
 55 
     | 
    
         
            +
              def_id "finite?"
         
     | 
| 
      
 56 
     | 
    
         
            +
              def_id ">" ,"op_gt"
         
     | 
| 
      
 57 
     | 
    
         
            +
              def_id ">=","op_ge"
         
     | 
| 
      
 58 
     | 
    
         
            +
              def_id "<" ,"op_lt"
         
     | 
| 
      
 59 
     | 
    
         
            +
              def_id "<=","op_le"
         
     | 
| 
      
 60 
     | 
    
         
            +
            end
         
     | 
| 
      
 61 
     | 
    
         
            +
            %>
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            <% IdVar.declaration.each do |x| %><%=
         
     | 
| 
      
 64 
     | 
    
         
            +
             x %>
         
     | 
| 
      
 65 
     | 
    
         
            +
            <% end %>
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            #include "numo/types/<%=type_name%>.h"
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            VALUE cT;
         
     | 
| 
      
 70 
     | 
    
         
            +
            extern VALUE cRT;
         
     | 
| 
      
 71 
     | 
    
         
            +
            #ifdef mTM
         
     | 
| 
      
 72 
     | 
    
         
            +
            VALUE mTM;
         
     | 
| 
      
 73 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            <%
         
     | 
| 
      
 76 
     | 
    
         
            +
            if is_object
         
     | 
| 
      
 77 
     | 
    
         
            +
              def_allocate "robj_allocate"
         
     | 
| 
      
 78 
     | 
    
         
            +
            end
         
     | 
| 
      
 79 
     | 
    
         
            +
            def_method "allocate", 0
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            def_method "extract", 0
         
     | 
| 
      
 82 
     | 
    
         
            +
            store_numeric
         
     | 
| 
      
 83 
     | 
    
         
            +
            cast_array
         
     | 
| 
      
 84 
     | 
    
         
            +
            store_array
         
     | 
| 
      
 85 
     | 
    
         
            +
            if is_complex
         
     | 
| 
      
 86 
     | 
    
         
            +
              store_from "DComplex","dcomplex","m_from_dcomplex"
         
     | 
| 
      
 87 
     | 
    
         
            +
              store_from "SComplex","scomplex","m_from_scomplex"
         
     | 
| 
      
 88 
     | 
    
         
            +
            end
         
     | 
| 
      
 89 
     | 
    
         
            +
            store_from "DFloat","double",   "m_from_real"
         
     | 
| 
      
 90 
     | 
    
         
            +
            store_from "SFloat","float",    "m_from_real"
         
     | 
| 
      
 91 
     | 
    
         
            +
            store_from "Int64", "int64_t",  "m_from_real"
         
     | 
| 
      
 92 
     | 
    
         
            +
            store_from "Int32", "int32_t",  "m_from_real"
         
     | 
| 
      
 93 
     | 
    
         
            +
            store_from "Int16", "int16_t",  "m_from_real"
         
     | 
| 
      
 94 
     | 
    
         
            +
            store_from "Int8",  "int8_t",   "m_from_real"
         
     | 
| 
      
 95 
     | 
    
         
            +
            store_from "UInt64","u_int64_t","m_from_real"
         
     | 
| 
      
 96 
     | 
    
         
            +
            store_from "UInt32","u_int32_t","m_from_real"
         
     | 
| 
      
 97 
     | 
    
         
            +
            store_from "UInt16","u_int16_t","m_from_real"
         
     | 
| 
      
 98 
     | 
    
         
            +
            store_from "UInt8", "u_int8_t", "m_from_real"
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
            def_method "store", 1
         
     | 
| 
      
 101 
     | 
    
         
            +
            def_singleton "cast", 1
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
            def_method "aref", -1, "aref", :op=>"[]"
         
     | 
| 
      
 104 
     | 
    
         
            +
            def_method "aset", -1, "aset", :op=>"[]="
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
            def_method "coerce_cast", 1
         
     | 
| 
      
 107 
     | 
    
         
            +
            def_method "to_a", 0
         
     | 
| 
      
 108 
     | 
    
         
            +
            def_method "fill", 1
         
     | 
| 
      
 109 
     | 
    
         
            +
            def_method "format", -1
         
     | 
| 
      
 110 
     | 
    
         
            +
            def_method "format_to_a", -1
         
     | 
| 
      
 111 
     | 
    
         
            +
            def_method "inspect", 0
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
            def_method "each", 0
         
     | 
| 
      
 114 
     | 
    
         
            +
            unary "map"
         
     | 
| 
      
 115 
     | 
    
         
            +
            def_method "each_with_index", 0
         
     | 
| 
      
 116 
     | 
    
         
            +
            def_method "map_with_index", 0
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
            # Arithmetic
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            unary2 "abs", "rtype", "cRT"
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            binary "add", "+"
         
     | 
| 
      
 123 
     | 
    
         
            +
            binary "sub", "-"
         
     | 
| 
      
 124 
     | 
    
         
            +
            binary "mul", "*"
         
     | 
| 
      
 125 
     | 
    
         
            +
            binary "div", "/"
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
            if !is_complex
         
     | 
| 
      
 128 
     | 
    
         
            +
              binary "mod", "%"
         
     | 
| 
      
 129 
     | 
    
         
            +
              binary2 "divmod"
         
     | 
| 
      
 130 
     | 
    
         
            +
            end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
            pow
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
            unary "minus", "-@"
         
     | 
| 
      
 135 
     | 
    
         
            +
            unary "inverse"
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
            # Complex
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
            if is_complex
         
     | 
| 
      
 140 
     | 
    
         
            +
              unary "conj"
         
     | 
| 
      
 141 
     | 
    
         
            +
              unary "im"
         
     | 
| 
      
 142 
     | 
    
         
            +
              unary2 "real", "rtype", "cRT"
         
     | 
| 
      
 143 
     | 
    
         
            +
              unary2 "imag", "rtype", "cRT"
         
     | 
| 
      
 144 
     | 
    
         
            +
              unary2 "arg",  "rtype", "cRT"
         
     | 
| 
      
 145 
     | 
    
         
            +
              def_alias "angle","arg"
         
     | 
| 
      
 146 
     | 
    
         
            +
              set2 "set_imag", "rtype", "cRT"
         
     | 
| 
      
 147 
     | 
    
         
            +
              set2 "set_real", "rtype", "cRT"
         
     | 
| 
      
 148 
     | 
    
         
            +
              def_alias "imag=","set_imag"
         
     | 
| 
      
 149 
     | 
    
         
            +
              def_alias "real=","set_real"
         
     | 
| 
      
 150 
     | 
    
         
            +
            else
         
     | 
| 
      
 151 
     | 
    
         
            +
              def_alias "conj", "copy"
         
     | 
| 
      
 152 
     | 
    
         
            +
              def_alias "im", "copy"
         
     | 
| 
      
 153 
     | 
    
         
            +
            end
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
            def_alias "conjugate","conj"
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
            # base_cond
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
            cond_binary "eq"
         
     | 
| 
      
 160 
     | 
    
         
            +
            cond_binary "ne"
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
            # nearly_eq  : x=~y is true if |x-y| <= (|x|+|y|)*epsilon
         
     | 
| 
      
 163 
     | 
    
         
            +
            if is_float
         
     | 
| 
      
 164 
     | 
    
         
            +
              cond_binary "nearly_eq"
         
     | 
| 
      
 165 
     | 
    
         
            +
            else
         
     | 
| 
      
 166 
     | 
    
         
            +
              def_alias "nearly_eq", "eq"
         
     | 
| 
      
 167 
     | 
    
         
            +
            end
         
     | 
| 
      
 168 
     | 
    
         
            +
            def_alias "close_to", "nearly_eq"
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
            # Integer
         
     | 
| 
      
 171 
     | 
    
         
            +
            if is_int
         
     | 
| 
      
 172 
     | 
    
         
            +
              binary "bit_and", "&"
         
     | 
| 
      
 173 
     | 
    
         
            +
              binary "bit_or" , "|"
         
     | 
| 
      
 174 
     | 
    
         
            +
              binary "bit_xor", "^"
         
     | 
| 
      
 175 
     | 
    
         
            +
              unary  "bit_not", "~"
         
     | 
| 
      
 176 
     | 
    
         
            +
              def_alias "floor", "copy"
         
     | 
| 
      
 177 
     | 
    
         
            +
              def_alias "round", "copy"
         
     | 
| 
      
 178 
     | 
    
         
            +
              def_alias "ceil",  "copy"
         
     | 
| 
      
 179 
     | 
    
         
            +
            end
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
            if is_float && is_real
         
     | 
| 
      
 182 
     | 
    
         
            +
              unary "floor"
         
     | 
| 
      
 183 
     | 
    
         
            +
              unary "round"
         
     | 
| 
      
 184 
     | 
    
         
            +
              unary "ceil"
         
     | 
| 
      
 185 
     | 
    
         
            +
            end
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
            if is_comparable
         
     | 
| 
      
 188 
     | 
    
         
            +
              cond_binary "gt"
         
     | 
| 
      
 189 
     | 
    
         
            +
              cond_binary "ge"
         
     | 
| 
      
 190 
     | 
    
         
            +
              cond_binary "lt"
         
     | 
| 
      
 191 
     | 
    
         
            +
              cond_binary "le"
         
     | 
| 
      
 192 
     | 
    
         
            +
              def_alias ">", "gt"
         
     | 
| 
      
 193 
     | 
    
         
            +
              def_alias ">=","ge"
         
     | 
| 
      
 194 
     | 
    
         
            +
              def_alias "<", "lt"
         
     | 
| 
      
 195 
     | 
    
         
            +
              def_alias "<=","le"
         
     | 
| 
      
 196 
     | 
    
         
            +
            end
         
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
      
 198 
     | 
    
         
            +
            # Float
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
            if is_float
         
     | 
| 
      
 201 
     | 
    
         
            +
              cond_unary "isnan"
         
     | 
| 
      
 202 
     | 
    
         
            +
              cond_unary "isinf"
         
     | 
| 
      
 203 
     | 
    
         
            +
              cond_unary "isfinite"
         
     | 
| 
      
 204 
     | 
    
         
            +
            end
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
            accum "sum","dtype","cT"
         
     | 
| 
      
 207 
     | 
    
         
            +
            accum "prod","dtype","cT"
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
            if is_float
         
     | 
| 
      
 210 
     | 
    
         
            +
              accum "mean","dtype","cT"
         
     | 
| 
      
 211 
     | 
    
         
            +
              accum "stddev","rtype","cRT"
         
     | 
| 
      
 212 
     | 
    
         
            +
              accum "var","rtype","cRT"
         
     | 
| 
      
 213 
     | 
    
         
            +
              accum "rms","rtype","cRT"
         
     | 
| 
      
 214 
     | 
    
         
            +
            end
         
     | 
| 
      
 215 
     | 
    
         
            +
             
     | 
| 
      
 216 
     | 
    
         
            +
            if is_comparable
         
     | 
| 
      
 217 
     | 
    
         
            +
              accum "min","dtype","cT"
         
     | 
| 
      
 218 
     | 
    
         
            +
              accum "max","dtype","cT"
         
     | 
| 
      
 219 
     | 
    
         
            +
              accum_index "max_index"
         
     | 
| 
      
 220 
     | 
    
         
            +
              accum_index "min_index"
         
     | 
| 
      
 221 
     | 
    
         
            +
              def_method "minmax",-1
         
     | 
| 
      
 222 
     | 
    
         
            +
            end
         
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
      
 224 
     | 
    
         
            +
            cum "cumsum","add"
         
     | 
| 
      
 225 
     | 
    
         
            +
            cum "cumprod","mul"
         
     | 
| 
      
 226 
     | 
    
         
            +
             
     | 
| 
      
 227 
     | 
    
         
            +
            # dot
         
     | 
| 
      
 228 
     | 
    
         
            +
            accum_binary "mulsum"
         
     | 
| 
      
 229 
     | 
    
         
            +
             
     | 
| 
      
 230 
     | 
    
         
            +
            # rmsdev
         
     | 
| 
      
 231 
     | 
    
         
            +
            # prod
         
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
      
 233 
     | 
    
         
            +
            # shuffle
         
     | 
| 
      
 234 
     | 
    
         
            +
            # histogram
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
            def_method "seq",-1
         
     | 
| 
      
 237 
     | 
    
         
            +
            def_method "eye",-1
         
     | 
| 
      
 238 
     | 
    
         
            +
            def_alias  "indgen", "seq"
         
     | 
| 
      
 239 
     | 
    
         
            +
             
     | 
| 
      
 240 
     | 
    
         
            +
            if !is_object
         
     | 
| 
      
 241 
     | 
    
         
            +
              def_method "rand", 0
         
     | 
| 
      
 242 
     | 
    
         
            +
            end
         
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
            # y = a[0] + a[1]*x + a[2]*x^2 + a[3]*x^3 + ... + a[n]*x^n
         
     | 
| 
      
 245 
     | 
    
         
            +
            def_method "poly",-2
         
     | 
| 
      
 246 
     | 
    
         
            +
             
     | 
| 
      
 247 
     | 
    
         
            +
            if is_comparable && !is_object
         
     | 
| 
      
 248 
     | 
    
         
            +
              qsort type_name,"dtype","*(dtype*)"
         
     | 
| 
      
 249 
     | 
    
         
            +
              def_method "sort",-1
         
     | 
| 
      
 250 
     | 
    
         
            +
              qsort type_name+"_index","dtype*","**(dtype**)"
         
     | 
| 
      
 251 
     | 
    
         
            +
              def_method "sort_index",-1
         
     | 
| 
      
 252 
     | 
    
         
            +
              def_method "median",-1
         
     | 
| 
      
 253 
     | 
    
         
            +
            end
         
     | 
| 
      
 254 
     | 
    
         
            +
             
     | 
| 
      
 255 
     | 
    
         
            +
            # Math
         
     | 
| 
      
 256 
     | 
    
         
            +
            # histogram
         
     | 
| 
      
 257 
     | 
    
         
            +
             
     | 
| 
      
 258 
     | 
    
         
            +
            if has_math
         
     | 
| 
      
 259 
     | 
    
         
            +
              math "sqrt"
         
     | 
| 
      
 260 
     | 
    
         
            +
              math "cbrt"
         
     | 
| 
      
 261 
     | 
    
         
            +
              math "log"
         
     | 
| 
      
 262 
     | 
    
         
            +
              math "log2"
         
     | 
| 
      
 263 
     | 
    
         
            +
              math "log10"
         
     | 
| 
      
 264 
     | 
    
         
            +
              math "exp"
         
     | 
| 
      
 265 
     | 
    
         
            +
              math "exp2"
         
     | 
| 
      
 266 
     | 
    
         
            +
              math "exp10"
         
     | 
| 
      
 267 
     | 
    
         
            +
              math "sin"
         
     | 
| 
      
 268 
     | 
    
         
            +
              math "cos"
         
     | 
| 
      
 269 
     | 
    
         
            +
              math "tan"
         
     | 
| 
      
 270 
     | 
    
         
            +
              math "asin"
         
     | 
| 
      
 271 
     | 
    
         
            +
              math "acos"
         
     | 
| 
      
 272 
     | 
    
         
            +
              math "atan"
         
     | 
| 
      
 273 
     | 
    
         
            +
              math "sinh"
         
     | 
| 
      
 274 
     | 
    
         
            +
              math "cosh"
         
     | 
| 
      
 275 
     | 
    
         
            +
              math "tanh"
         
     | 
| 
      
 276 
     | 
    
         
            +
              math "asinh"
         
     | 
| 
      
 277 
     | 
    
         
            +
              math "acosh"
         
     | 
| 
      
 278 
     | 
    
         
            +
              math "atanh"
         
     | 
| 
      
 279 
     | 
    
         
            +
              if !is_complex
         
     | 
| 
      
 280 
     | 
    
         
            +
                math "atan2",2
         
     | 
| 
      
 281 
     | 
    
         
            +
                math "hypot",2
         
     | 
| 
      
 282 
     | 
    
         
            +
                math "erf"
         
     | 
| 
      
 283 
     | 
    
         
            +
                math "erfc"
         
     | 
| 
      
 284 
     | 
    
         
            +
                math "ldexp",2
         
     | 
| 
      
 285 
     | 
    
         
            +
              end
         
     | 
| 
      
 286 
     | 
    
         
            +
            end
         
     | 
| 
      
 287 
     | 
    
         
            +
            %>
         
     | 
| 
      
 288 
     | 
    
         
            +
            static VALUE <%= find_tmpl('store').c_func %>(VALUE,VALUE);
         
     | 
| 
      
 289 
     | 
    
         
            +
            <%
         
     | 
| 
      
 290 
     | 
    
         
            +
            Function.codes.each do |x| %>
         
     | 
| 
      
 291 
     | 
    
         
            +
            <%= x %>
         
     | 
| 
      
 292 
     | 
    
         
            +
            <% end %>
         
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
      
 294 
     | 
    
         
            +
            void
         
     | 
| 
      
 295 
     | 
    
         
            +
            Init_nary_<%=tp%>()
         
     | 
| 
      
 296 
     | 
    
         
            +
            {
         
     | 
| 
      
 297 
     | 
    
         
            +
                volatile VALUE hCast;
         
     | 
| 
      
 298 
     | 
    
         
            +
             
     | 
| 
      
 299 
     | 
    
         
            +
                cT = rb_define_class_under(mNumo, "<%=class_name%>", cNArray);
         
     | 
| 
      
 300 
     | 
    
         
            +
                <% for x in class_alias %>
         
     | 
| 
      
 301 
     | 
    
         
            +
                // alias of <%=class_name%>
         
     | 
| 
      
 302 
     | 
    
         
            +
                rb_define_const(mNumo, "<%=x%>", <%=type_var%>);
         
     | 
| 
      
 303 
     | 
    
         
            +
                <% end %>
         
     | 
| 
      
 304 
     | 
    
         
            +
                <% if has_math %>
         
     | 
| 
      
 305 
     | 
    
         
            +
                mTM = rb_define_module_under(cT, "Math"); <% end %>
         
     | 
| 
      
 306 
     | 
    
         
            +
             
     | 
| 
      
 307 
     | 
    
         
            +
                rb_define_const(cT, ELEMENT_BIT_SIZE,  INT2FIX(sizeof(dtype)*8));
         
     | 
| 
      
 308 
     | 
    
         
            +
                rb_define_const(cT, ELEMENT_BYTE_SIZE, INT2FIX(sizeof(dtype)));
         
     | 
| 
      
 309 
     | 
    
         
            +
                rb_define_const(cT, CONTIGUOUS_STRIDE, INT2FIX(sizeof(dtype)));
         
     | 
| 
      
 310 
     | 
    
         
            +
             
     | 
| 
      
 311 
     | 
    
         
            +
                rb_define_singleton_method(cT, "[]", <%=cast_func%>, -2);
         
     | 
| 
      
 312 
     | 
    
         
            +
             
     | 
| 
      
 313 
     | 
    
         
            +
                <% if is_object %>
         
     | 
| 
      
 314 
     | 
    
         
            +
                rb_undef_method(rb_singleton_class(cT),"from_string");
         
     | 
| 
      
 315 
     | 
    
         
            +
                rb_undef_method(cT,"to_string");
         
     | 
| 
      
 316 
     | 
    
         
            +
                <% end %>
         
     | 
| 
      
 317 
     | 
    
         
            +
             
     | 
| 
      
 318 
     | 
    
         
            +
                <% Function.definitions.each do |x| %>
         
     | 
| 
      
 319 
     | 
    
         
            +
                <%= x %><% end %>
         
     | 
| 
      
 320 
     | 
    
         
            +
                <% IdVar.assignment.each do |x| %>
         
     | 
| 
      
 321 
     | 
    
         
            +
                <%= x %><% end %>
         
     | 
| 
      
 322 
     | 
    
         
            +
             
     | 
| 
      
 323 
     | 
    
         
            +
                hCast = rb_hash_new();
         
     | 
| 
      
 324 
     | 
    
         
            +
                rb_define_const(cT, "UPCAST", hCast);
         
     | 
| 
      
 325 
     | 
    
         
            +
                rb_hash_aset(hCast, rb_cArray,   cT);
         
     | 
| 
      
 326 
     | 
    
         
            +
                <% for x in upcast %>
         
     | 
| 
      
 327 
     | 
    
         
            +
                <%= x %><% end %>
         
     | 
| 
      
 328 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            static void
         
     | 
| 
      
 2 
     | 
    
         
            +
            <%=c_iter%>(na_loop_t *const lp)
         
     | 
| 
      
 3 
     | 
    
         
            +
            {
         
     | 
| 
      
 4 
     | 
    
         
            +
                size_t   n;
         
     | 
| 
      
 5 
     | 
    
         
            +
                char    *p1, *p2;
         
     | 
| 
      
 6 
     | 
    
         
            +
                ssize_t  s1;
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                INIT_COUNTER(lp, n);
         
     | 
| 
      
 9 
     | 
    
         
            +
                INIT_PTR(lp, 0, p1, s1);
         
     | 
| 
      
 10 
     | 
    
         
            +
                p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                *(<%=dtype%>*)p2 = f_<%=method%>(n,p1,s1);
         
     | 
| 
      
 13 
     | 
    
         
            +
            }
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            /*
         
     | 
| 
      
 16 
     | 
    
         
            +
              <%=method.capitalize%> of self.
         
     | 
| 
      
 17 
     | 
    
         
            +
              @overload <%=method%>(*args)
         
     | 
| 
      
 18 
     | 
    
         
            +
              @param [Array of Numeric,Range] args  Affected dimensions.
         
     | 
| 
      
 19 
     | 
    
         
            +
              @return [Numo::<%=class_name%>] <%=method%> of self.
         
     | 
| 
      
 20 
     | 
    
         
            +
            */
         
     | 
| 
      
 21 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 22 
     | 
    
         
            +
            <%=c_func%>(int argc, VALUE *argv, VALUE self)
         
     | 
| 
      
 23 
     | 
    
         
            +
            {
         
     | 
| 
      
 24 
     | 
    
         
            +
                VALUE v, reduce;
         
     | 
| 
      
 25 
     | 
    
         
            +
                ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}};
         
     | 
| 
      
 26 
     | 
    
         
            +
                ndfunc_arg_out_t aout[1] = {{<%=tpclass%>,0}};
         
     | 
| 
      
 27 
     | 
    
         
            +
                ndfunc_t ndf = { <%=c_iter%>, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2, 1, ain, aout };
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                reduce = na_reduce_dimension(argc, argv, 1, &self);
         
     | 
| 
      
 30 
     | 
    
         
            +
                v =  na_ndloop(&ndf, 2, self, reduce);
         
     | 
| 
      
 31 
     | 
    
         
            +
            <% if tpclass == "cT" %>
         
     | 
| 
      
 32 
     | 
    
         
            +
                return numo_<%=tp%>_extract(v);
         
     | 
| 
      
 33 
     | 
    
         
            +
            <% else %>
         
     | 
| 
      
 34 
     | 
    
         
            +
                return rb_funcall(v,rb_intern("extract"),0);
         
     | 
| 
      
 35 
     | 
    
         
            +
            <% end %>
         
     | 
| 
      
 36 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,75 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            static void
         
     | 
| 
      
 2 
     | 
    
         
            +
            <%=c_iter%>(na_loop_t *const lp)
         
     | 
| 
      
 3 
     | 
    
         
            +
            {
         
     | 
| 
      
 4 
     | 
    
         
            +
                size_t   i;
         
     | 
| 
      
 5 
     | 
    
         
            +
                char    *p1, *p2, *p3;
         
     | 
| 
      
 6 
     | 
    
         
            +
                ssize_t  s1, s2, s3;
         
     | 
| 
      
 7 
     | 
    
         
            +
                dtype    x, y, z;
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                INIT_COUNTER(lp, i);
         
     | 
| 
      
 10 
     | 
    
         
            +
                INIT_PTR(lp, 0, p1, s1);
         
     | 
| 
      
 11 
     | 
    
         
            +
                INIT_PTR(lp, 1, p2, s2);
         
     | 
| 
      
 12 
     | 
    
         
            +
                INIT_PTR(lp, 2, p3, s3);
         
     | 
| 
      
 13 
     | 
    
         
            +
                if (s3==0) {
         
     | 
| 
      
 14 
     | 
    
         
            +
                    // Reduce loop
         
     | 
| 
      
 15 
     | 
    
         
            +
                    GET_DATA(p3,dtype,z);
         
     | 
| 
      
 16 
     | 
    
         
            +
                    for (; i--;) {
         
     | 
| 
      
 17 
     | 
    
         
            +
                        GET_DATA_STRIDE(p1,s1,dtype,x);
         
     | 
| 
      
 18 
     | 
    
         
            +
                        GET_DATA_STRIDE(p2,s2,dtype,y);
         
     | 
| 
      
 19 
     | 
    
         
            +
                        m_<%=method%>(x,y,z);
         
     | 
| 
      
 20 
     | 
    
         
            +
                    }
         
     | 
| 
      
 21 
     | 
    
         
            +
                    SET_DATA(p3,dtype,z);
         
     | 
| 
      
 22 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 23 
     | 
    
         
            +
                    for (; i--;) {
         
     | 
| 
      
 24 
     | 
    
         
            +
                        GET_DATA_STRIDE(p1,s1,dtype,x);
         
     | 
| 
      
 25 
     | 
    
         
            +
                        GET_DATA_STRIDE(p2,s2,dtype,y);
         
     | 
| 
      
 26 
     | 
    
         
            +
                        GET_DATA(p3,dtype,z);
         
     | 
| 
      
 27 
     | 
    
         
            +
                        m_<%=method%>(x,y,z);
         
     | 
| 
      
 28 
     | 
    
         
            +
                        SET_DATA_STRIDE(p3,s3,dtype,z);
         
     | 
| 
      
 29 
     | 
    
         
            +
                    }
         
     | 
| 
      
 30 
     | 
    
         
            +
                }
         
     | 
| 
      
 31 
     | 
    
         
            +
            }
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 35 
     | 
    
         
            +
            <%=c_func%>_self(int argc, VALUE *argv, VALUE self)
         
     | 
| 
      
 36 
     | 
    
         
            +
            {
         
     | 
| 
      
 37 
     | 
    
         
            +
                VALUE v, reduce;
         
     | 
| 
      
 38 
     | 
    
         
            +
                VALUE naryv[2];
         
     | 
| 
      
 39 
     | 
    
         
            +
                ndfunc_arg_in_t ain[4] = {{cT,0},{cT,0},{sym_reduce,0},{sym_init,0}};
         
     | 
| 
      
 40 
     | 
    
         
            +
                ndfunc_arg_out_t aout[1] = {{cT,0}};
         
     | 
| 
      
 41 
     | 
    
         
            +
                ndfunc_t ndf = { <%=c_iter%>, STRIDE_LOOP_NIP, 4, 1, ain, aout };
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                if (argc < 1) {
         
     | 
| 
      
 44 
     | 
    
         
            +
                    rb_raise(rb_eArgError,"wrong number of arguments (%d for >=1)",argc);
         
     | 
| 
      
 45 
     | 
    
         
            +
                }
         
     | 
| 
      
 46 
     | 
    
         
            +
                // should fix below: [self.ndim,other.ndim].max or?
         
     | 
| 
      
 47 
     | 
    
         
            +
                naryv[0] = self;
         
     | 
| 
      
 48 
     | 
    
         
            +
                naryv[1] = argv[0];
         
     | 
| 
      
 49 
     | 
    
         
            +
                reduce = na_reduce_dimension(argc-1, argv+1, 2, naryv);
         
     | 
| 
      
 50 
     | 
    
         
            +
                v =  na_ndloop(&ndf, 4, self, argv[0], reduce, m_<%=method%>_init);
         
     | 
| 
      
 51 
     | 
    
         
            +
                return numo_<%=tp%>_extract(v);
         
     | 
| 
      
 52 
     | 
    
         
            +
            }
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            /*
         
     | 
| 
      
 56 
     | 
    
         
            +
              Binary <%=method%>.
         
     | 
| 
      
 57 
     | 
    
         
            +
              @overload <%=op_map%> other
         
     | 
| 
      
 58 
     | 
    
         
            +
              @param [Numo::NArray,Numeric] other
         
     | 
| 
      
 59 
     | 
    
         
            +
              @return [Numo::NArray] <%=method%> of self and other.
         
     | 
| 
      
 60 
     | 
    
         
            +
            */
         
     | 
| 
      
 61 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 62 
     | 
    
         
            +
            <%=c_func%>(int argc, VALUE *argv, VALUE self)
         
     | 
| 
      
 63 
     | 
    
         
            +
            {
         
     | 
| 
      
 64 
     | 
    
         
            +
                VALUE klass, v;
         
     | 
| 
      
 65 
     | 
    
         
            +
                if (argc < 1) {
         
     | 
| 
      
 66 
     | 
    
         
            +
                    rb_raise(rb_eArgError,"wrong number of arguments (%d for >=1)",argc);
         
     | 
| 
      
 67 
     | 
    
         
            +
                }
         
     | 
| 
      
 68 
     | 
    
         
            +
                klass = na_upcast(CLASS_OF(self),CLASS_OF(argv[0]));
         
     | 
| 
      
 69 
     | 
    
         
            +
                if (klass==cT) {
         
     | 
| 
      
 70 
     | 
    
         
            +
                    return <%=c_func%>_self(argc, argv, self);
         
     | 
| 
      
 71 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 72 
     | 
    
         
            +
                    v = rb_funcall(klass, id_cast, 1, self);
         
     | 
| 
      
 73 
     | 
    
         
            +
                    return rb_funcall2(v, rb_intern("<%=method%>"), argc, argv);
         
     | 
| 
      
 74 
     | 
    
         
            +
                }
         
     | 
| 
      
 75 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,58 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <% [64,32].each do |i| %>
         
     | 
| 
      
 2 
     | 
    
         
            +
            #define idx_t int<%=i%>_t
         
     | 
| 
      
 3 
     | 
    
         
            +
            static void
         
     | 
| 
      
 4 
     | 
    
         
            +
            <%=c_iter%>_index<%=i%>(na_loop_t *const lp)
         
     | 
| 
      
 5 
     | 
    
         
            +
            {
         
     | 
| 
      
 6 
     | 
    
         
            +
                size_t   n, idx;
         
     | 
| 
      
 7 
     | 
    
         
            +
                char    *d_ptr, *i_ptr, *o_ptr;
         
     | 
| 
      
 8 
     | 
    
         
            +
                ssize_t  d_step, i_step;
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                INIT_COUNTER(lp, n);
         
     | 
| 
      
 11 
     | 
    
         
            +
                INIT_PTR(lp, 0, d_ptr, d_step);
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                idx = f_<%=method%>(n,d_ptr,d_step);
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                INIT_PTR(lp, 1, i_ptr, i_step);
         
     | 
| 
      
 16 
     | 
    
         
            +
                o_ptr = NDL_PTR(lp,2);
         
     | 
| 
      
 17 
     | 
    
         
            +
                *(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
         
     | 
| 
      
 18 
     | 
    
         
            +
            }
         
     | 
| 
      
 19 
     | 
    
         
            +
            #undef idx_t
         
     | 
| 
      
 20 
     | 
    
         
            +
            <% end %>
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            /*
         
     | 
| 
      
 23 
     | 
    
         
            +
             *  call-seq:
         
     | 
| 
      
 24 
     | 
    
         
            +
             *     narray.<%=method%>() => Integer
         
     | 
| 
      
 25 
     | 
    
         
            +
             *     narray.<%=method%>(dim0,dim1,..) => Integer or Numo::Int32/64
         
     | 
| 
      
 26 
     | 
    
         
            +
             *
         
     | 
| 
      
 27 
     | 
    
         
            +
             *  Return an index of result.
         
     | 
| 
      
 28 
     | 
    
         
            +
             *
         
     | 
| 
      
 29 
     | 
    
         
            +
             *     Numo::NArray[3,4,1,2].min_index => 3
         
     | 
| 
      
 30 
     | 
    
         
            +
             */
         
     | 
| 
      
 31 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 32 
     | 
    
         
            +
            <%=c_func%>(int argc, VALUE *argv, VALUE self)
         
     | 
| 
      
 33 
     | 
    
         
            +
            {
         
     | 
| 
      
 34 
     | 
    
         
            +
                narray_t *na;
         
     | 
| 
      
 35 
     | 
    
         
            +
                VALUE idx, reduce;
         
     | 
| 
      
 36 
     | 
    
         
            +
                ndfunc_arg_in_t ain[3] = {{Qnil,0},{Qnil,0},{sym_reduce,0}};
         
     | 
| 
      
 37 
     | 
    
         
            +
                ndfunc_arg_out_t aout[1] = {{0,0,0}};
         
     | 
| 
      
 38 
     | 
    
         
            +
                ndfunc_t ndf = {0, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE|NDF_EXTRACT, 3,1, ain,aout};
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                GetNArray(self,na);
         
     | 
| 
      
 41 
     | 
    
         
            +
                if (na->ndim==0) {
         
     | 
| 
      
 42 
     | 
    
         
            +
                    return INT2FIX(0);
         
     | 
| 
      
 43 
     | 
    
         
            +
                }
         
     | 
| 
      
 44 
     | 
    
         
            +
                if (na->size > (~(u_int32_t)0)) {
         
     | 
| 
      
 45 
     | 
    
         
            +
                    aout[0].type = numo_cInt64;
         
     | 
| 
      
 46 
     | 
    
         
            +
                    idx = rb_narray_new(numo_cInt64, na->ndim, na->shape);
         
     | 
| 
      
 47 
     | 
    
         
            +
                    ndf.func = <%=c_iter%>_index64;
         
     | 
| 
      
 48 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 49 
     | 
    
         
            +
                    aout[0].type = numo_cInt32;
         
     | 
| 
      
 50 
     | 
    
         
            +
                    idx = rb_narray_new(numo_cInt32, na->ndim, na->shape);
         
     | 
| 
      
 51 
     | 
    
         
            +
                    ndf.func = <%=c_iter%>_index32;
         
     | 
| 
      
 52 
     | 
    
         
            +
                }
         
     | 
| 
      
 53 
     | 
    
         
            +
                rb_funcall(idx, rb_intern("seq"), 0);
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                reduce = na_reduce_dimension(argc, argv, 1, &self);
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                return na_ndloop(&ndf, 3, self, idx, reduce);
         
     | 
| 
      
 58 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 2 
     | 
    
         
            +
            <%=c_func%>(VALUE self)
         
     | 
| 
      
 3 
     | 
    
         
            +
            {
         
     | 
| 
      
 4 
     | 
    
         
            +
                narray_t *na;
         
     | 
| 
      
 5 
     | 
    
         
            +
                char *ptr;
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                GetNArray(self,na);
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                switch(NA_TYPE(na)) {
         
     | 
| 
      
 10 
     | 
    
         
            +
                case NARRAY_DATA_T:
         
     | 
| 
      
 11 
     | 
    
         
            +
                    ptr = NA_DATA_PTR(na);
         
     | 
| 
      
 12 
     | 
    
         
            +
                    if (na->size > 0 && ptr == NULL) {
         
     | 
| 
      
 13 
     | 
    
         
            +
                        ptr = xmalloc(sizeof(dtype) * na->size);
         
     | 
| 
      
 14 
     | 
    
         
            +
                        <% if is_object %>
         
     | 
| 
      
 15 
     | 
    
         
            +
                        {   size_t i;
         
     | 
| 
      
 16 
     | 
    
         
            +
                            VALUE *a = (VALUE*)ptr;
         
     | 
| 
      
 17 
     | 
    
         
            +
                            for (i=na->size; i--;) {
         
     | 
| 
      
 18 
     | 
    
         
            +
                                *a++ = Qnil;
         
     | 
| 
      
 19 
     | 
    
         
            +
                            }
         
     | 
| 
      
 20 
     | 
    
         
            +
                        }
         
     | 
| 
      
 21 
     | 
    
         
            +
                        <% end %>
         
     | 
| 
      
 22 
     | 
    
         
            +
                        NA_DATA_PTR(na) = ptr;
         
     | 
| 
      
 23 
     | 
    
         
            +
                    }
         
     | 
| 
      
 24 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 25 
     | 
    
         
            +
                case NARRAY_VIEW_T:
         
     | 
| 
      
 26 
     | 
    
         
            +
                    rb_funcall(NA_VIEW_DATA(na), rb_intern("allocate"), 0);
         
     | 
| 
      
 27 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 28 
     | 
    
         
            +
                case NARRAY_FILEMAP_T:
         
     | 
| 
      
 29 
     | 
    
         
            +
                    //ptr = ((narray_filemap_t*)na)->ptr;
         
     | 
| 
      
 30 
     | 
    
         
            +
                    // to be implemented
         
     | 
| 
      
 31 
     | 
    
         
            +
                default:
         
     | 
| 
      
 32 
     | 
    
         
            +
                    rb_bug("invalid narray type : %d",NA_TYPE(na));
         
     | 
| 
      
 33 
     | 
    
         
            +
                }
         
     | 
| 
      
 34 
     | 
    
         
            +
                return self;
         
     | 
| 
      
 35 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,51 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            /*
         
     | 
| 
      
 2 
     | 
    
         
            +
              Array element referenece or slice view.
         
     | 
| 
      
 3 
     | 
    
         
            +
              @overload [](dim0,...,dimL)
         
     | 
| 
      
 4 
     | 
    
         
            +
              @param [Numeric,Range,etc] dim0,...,dimL  Multi-dimensional Index.
         
     | 
| 
      
 5 
     | 
    
         
            +
              @return [Numeric,NArray::<%=class_name%>] Element object or NArray view.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              --- Returns the element at +dim0+, +dim1+, ... are Numeric indices
         
     | 
| 
      
 8 
     | 
    
         
            +
              for each dimension, or returns a NArray View as a sliced subarray if
         
     | 
| 
      
 9 
     | 
    
         
            +
              +dim0+, +dim1+, ... includes other than Numeric index, e.g., Range
         
     | 
| 
      
 10 
     | 
    
         
            +
              or Array or true.
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  a = Numo::DFloat.new(4,5).seq
         
     | 
| 
      
 13 
     | 
    
         
            +
                  => Numo::DFloat#shape=[4,5]
         
     | 
| 
      
 14 
     | 
    
         
            +
                  [[0, 1, 2, 3, 4],
         
     | 
| 
      
 15 
     | 
    
         
            +
                   [5, 6, 7, 8, 9],
         
     | 
| 
      
 16 
     | 
    
         
            +
                   [10, 11, 12, 13, 14],
         
     | 
| 
      
 17 
     | 
    
         
            +
                   [15, 16, 17, 18, 19]]
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  a[1,1]
         
     | 
| 
      
 20 
     | 
    
         
            +
                  => 6.0
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  a[1..3,1]
         
     | 
| 
      
 23 
     | 
    
         
            +
                  => Numo::DFloat#shape=[3]
         
     | 
| 
      
 24 
     | 
    
         
            +
                  [6, 11, 16]
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  a[1,[1,3,4]]
         
     | 
| 
      
 27 
     | 
    
         
            +
                  => Numo::DFloat#shape=[3]
         
     | 
| 
      
 28 
     | 
    
         
            +
                  [6, 8, 9]
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  a[true,2].fill(99)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  a
         
     | 
| 
      
 32 
     | 
    
         
            +
                  => Numo::DFloat#shape=[4,5]
         
     | 
| 
      
 33 
     | 
    
         
            +
                  [[0, 1, 99, 3, 4],
         
     | 
| 
      
 34 
     | 
    
         
            +
                   [5, 6, 99, 8, 9],
         
     | 
| 
      
 35 
     | 
    
         
            +
                   [10, 11, 99, 13, 14],
         
     | 
| 
      
 36 
     | 
    
         
            +
                   [15, 16, 99, 18, 19]]
         
     | 
| 
      
 37 
     | 
    
         
            +
             */
         
     | 
| 
      
 38 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 39 
     | 
    
         
            +
            <%=c_func%>(int argc, VALUE *argv, VALUE self)
         
     | 
| 
      
 40 
     | 
    
         
            +
            {
         
     | 
| 
      
 41 
     | 
    
         
            +
                ssize_t pos;
         
     | 
| 
      
 42 
     | 
    
         
            +
                char *ptr;
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                pos = na_get_scalar_position(self, argc, argv, sizeof(dtype));
         
     | 
| 
      
 45 
     | 
    
         
            +
                if (pos == -1) {
         
     | 
| 
      
 46 
     | 
    
         
            +
                    return na_aref_main(argc, argv, self, 0);
         
     | 
| 
      
 47 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 48 
     | 
    
         
            +
                    ptr = na_get_pointer_for_read(self) + pos;
         
     | 
| 
      
 49 
     | 
    
         
            +
                    return m_extract(ptr);
         
     | 
| 
      
 50 
     | 
    
         
            +
                }
         
     | 
| 
      
 51 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,61 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            /*
         
     | 
| 
      
 2 
     | 
    
         
            +
              Array element(s) set.
         
     | 
| 
      
 3 
     | 
    
         
            +
              @overload []=(dim0,..,dimL,val)
         
     | 
| 
      
 4 
     | 
    
         
            +
              @param [Numeric,Range,etc] dim0,..,dimL  Multi-dimensional Index.
         
     | 
| 
      
 5 
     | 
    
         
            +
              @param [Numeric,Numo::NArray,etc] val  Value(s) to be set to self.
         
     | 
| 
      
 6 
     | 
    
         
            +
              @return [Numeric] returns val (last argument).
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              --- Replace element(s) at +dim0+, +dim1+, ... (index/range/array/true
         
     | 
| 
      
 9 
     | 
    
         
            +
              for each dimention). Broadcasting mechanism is applied.
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  a = Numo::DFloat.new(3,4).seq
         
     | 
| 
      
 12 
     | 
    
         
            +
                  => Numo::DFloat#shape=[3,4]
         
     | 
| 
      
 13 
     | 
    
         
            +
                  [[0, 1, 2, 3],
         
     | 
| 
      
 14 
     | 
    
         
            +
                   [4, 5, 6, 7],
         
     | 
| 
      
 15 
     | 
    
         
            +
                   [8, 9, 10, 11]]
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  a[1,2]=99
         
     | 
| 
      
 18 
     | 
    
         
            +
                  a
         
     | 
| 
      
 19 
     | 
    
         
            +
                  => Numo::DFloat#shape=[3,4]
         
     | 
| 
      
 20 
     | 
    
         
            +
                  [[0, 1, 2, 3],
         
     | 
| 
      
 21 
     | 
    
         
            +
                   [4, 5, 99, 7],
         
     | 
| 
      
 22 
     | 
    
         
            +
                   [8, 9, 10, 11]]
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  a[1,[0,2]] = [101,102]
         
     | 
| 
      
 25 
     | 
    
         
            +
                  a
         
     | 
| 
      
 26 
     | 
    
         
            +
                  => Numo::DFloat#shape=[3,4]
         
     | 
| 
      
 27 
     | 
    
         
            +
                  [[0, 1, 2, 3],
         
     | 
| 
      
 28 
     | 
    
         
            +
                   [101, 5, 102, 7],
         
     | 
| 
      
 29 
     | 
    
         
            +
                   [8, 9, 10, 11]]
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  a[1,true]=99
         
     | 
| 
      
 32 
     | 
    
         
            +
                  a
         
     | 
| 
      
 33 
     | 
    
         
            +
                  => Numo::DFloat#shape=[3,4]
         
     | 
| 
      
 34 
     | 
    
         
            +
                  [[0, 1, 2, 3],
         
     | 
| 
      
 35 
     | 
    
         
            +
                   [99, 99, 99, 99],
         
     | 
| 
      
 36 
     | 
    
         
            +
                   [8, 9, 10, 11]]
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            */
         
     | 
| 
      
 39 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 40 
     | 
    
         
            +
            <%=c_func%>(int argc, VALUE *argv, VALUE self)
         
     | 
| 
      
 41 
     | 
    
         
            +
            {
         
     | 
| 
      
 42 
     | 
    
         
            +
                ssize_t pos;
         
     | 
| 
      
 43 
     | 
    
         
            +
                char *ptr;
         
     | 
| 
      
 44 
     | 
    
         
            +
                VALUE a;
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                argc--;
         
     | 
| 
      
 47 
     | 
    
         
            +
                if (argc==0) {
         
     | 
| 
      
 48 
     | 
    
         
            +
                    <%=c_func.sub(/_aset/,"_store")%>(self, argv[argc]);
         
     | 
| 
      
 49 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 50 
     | 
    
         
            +
                    pos = na_get_scalar_position(self, argc, argv, sizeof(dtype));
         
     | 
| 
      
 51 
     | 
    
         
            +
                    if (pos == -1) {
         
     | 
| 
      
 52 
     | 
    
         
            +
                        a = na_aref_main(argc, argv, self, 0);
         
     | 
| 
      
 53 
     | 
    
         
            +
                        <%=c_func.sub(/_aset/,"_store")%>(a, argv[argc]);
         
     | 
| 
      
 54 
     | 
    
         
            +
                    } else {
         
     | 
| 
      
 55 
     | 
    
         
            +
                        ptr = na_get_pointer_for_read(self) + pos;
         
     | 
| 
      
 56 
     | 
    
         
            +
                        *(dtype*)ptr = m_num_to_data(argv[argc]);
         
     | 
| 
      
 57 
     | 
    
         
            +
                    }
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                }
         
     | 
| 
      
 60 
     | 
    
         
            +
                return argv[argc];
         
     | 
| 
      
 61 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,53 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            static void
         
     | 
| 
      
 2 
     | 
    
         
            +
            <%=c_iter%>(na_loop_t *const lp)
         
     | 
| 
      
 3 
     | 
    
         
            +
            {
         
     | 
| 
      
 4 
     | 
    
         
            +
                size_t   i, n;
         
     | 
| 
      
 5 
     | 
    
         
            +
                char    *p1, *p2, *p3;
         
     | 
| 
      
 6 
     | 
    
         
            +
                ssize_t  s1, s2, s3;
         
     | 
| 
      
 7 
     | 
    
         
            +
                dtype    x, y;
         
     | 
| 
      
 8 
     | 
    
         
            +
                INIT_COUNTER(lp, n);
         
     | 
| 
      
 9 
     | 
    
         
            +
                INIT_PTR(lp, 0, p1, s1);
         
     | 
| 
      
 10 
     | 
    
         
            +
                INIT_PTR(lp, 1, p2, s2);
         
     | 
| 
      
 11 
     | 
    
         
            +
                INIT_PTR(lp, 2, p3, s3);
         
     | 
| 
      
 12 
     | 
    
         
            +
                for (i=n; i--;) {
         
     | 
| 
      
 13 
     | 
    
         
            +
                    GET_DATA_STRIDE(p1,s1,dtype,x);
         
     | 
| 
      
 14 
     | 
    
         
            +
                    GET_DATA_STRIDE(p2,s2,dtype,y);
         
     | 
| 
      
 15 
     | 
    
         
            +
            <% if is_int and %w[div mod divmod].include? method %>
         
     | 
| 
      
 16 
     | 
    
         
            +
                    if (y==0) {
         
     | 
| 
      
 17 
     | 
    
         
            +
                        lp->err_type = rb_eZeroDivError;
         
     | 
| 
      
 18 
     | 
    
         
            +
                        return;
         
     | 
| 
      
 19 
     | 
    
         
            +
                    }
         
     | 
| 
      
 20 
     | 
    
         
            +
            <% end %>
         
     | 
| 
      
 21 
     | 
    
         
            +
                    x = m_<%=method%>(x,y);
         
     | 
| 
      
 22 
     | 
    
         
            +
                    SET_DATA_STRIDE(p3,s3,dtype,x);
         
     | 
| 
      
 23 
     | 
    
         
            +
                }
         
     | 
| 
      
 24 
     | 
    
         
            +
            }
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 27 
     | 
    
         
            +
            <%=c_func%>_self(VALUE self, VALUE other)
         
     | 
| 
      
 28 
     | 
    
         
            +
            {
         
     | 
| 
      
 29 
     | 
    
         
            +
                ndfunc_arg_in_t ain[2] = {{cT,0},{cT,0}};
         
     | 
| 
      
 30 
     | 
    
         
            +
                ndfunc_arg_out_t aout[1] = {{cT,0}};
         
     | 
| 
      
 31 
     | 
    
         
            +
                ndfunc_t ndf = { <%=c_iter%>, STRIDE_LOOP, 2, 1, ain, aout };
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                return na_ndloop(&ndf, 2, self, other);
         
     | 
| 
      
 34 
     | 
    
         
            +
            }
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            /*
         
     | 
| 
      
 37 
     | 
    
         
            +
              Binary <%=method%>.
         
     | 
| 
      
 38 
     | 
    
         
            +
              @overload <%=op_map%> other
         
     | 
| 
      
 39 
     | 
    
         
            +
              @param [Numo::NArray,Numeric] other
         
     | 
| 
      
 40 
     | 
    
         
            +
              @return [Numo::NArray] self <%=op_map%> other
         
     | 
| 
      
 41 
     | 
    
         
            +
            */
         
     | 
| 
      
 42 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 43 
     | 
    
         
            +
            <%=c_func%>(VALUE self, VALUE other)
         
     | 
| 
      
 44 
     | 
    
         
            +
            {
         
     | 
| 
      
 45 
     | 
    
         
            +
                VALUE klass, v;
         
     | 
| 
      
 46 
     | 
    
         
            +
                klass = na_upcast(CLASS_OF(self),CLASS_OF(other));
         
     | 
| 
      
 47 
     | 
    
         
            +
                if (klass==cT) {
         
     | 
| 
      
 48 
     | 
    
         
            +
                    return <%=c_func%>_self(self, other);
         
     | 
| 
      
 49 
     | 
    
         
            +
                } else {
         
     | 
| 
      
 50 
     | 
    
         
            +
                    v = rb_funcall(klass, id_cast, 1, self);
         
     | 
| 
      
 51 
     | 
    
         
            +
                    return rb_funcall(v, <%=id_op%>, 1, other);
         
     | 
| 
      
 52 
     | 
    
         
            +
                }
         
     | 
| 
      
 53 
     | 
    
         
            +
            }
         
     |