Class: MathieuArray

Inherits:
DefMethod show all
Defined in:
ext/numo/gsl/sf/parse_sf.rb

Constant Summary collapse

RE =
/^gsl_sf_mathieu_\w+_array$/

Instance Attribute Summary

Attributes inherited from ErbPP

#children, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DefMethod

#c_func, #c_iter, #c_name, #define_method_args, #id_op, #init_def, #op_map, #singleton

Methods included from DeclMethod

#def_alias, #def_alloc_func, #def_const, #def_method, #def_module_function, #def_singleton_method, #undef_alloc_func, #undef_method, #undef_singleton_method

Methods inherited from ErbPP

#add_child, #description, #find, #find_tmpl, #get, #init_def, #load_erb, #method_missing, #method_missing_alias, #result, #run, #set, #write

Constructor Details

#initialize(parent, tmpl, **h) ⇒ MathieuArray

Returns a new instance of MathieuArray.



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'ext/numo/gsl/sf/parse_sf.rb', line 154

def initialize(parent,tmpl,**h)
  super(parent,tmpl,**h)

  case h[:func_name]
  when "gsl_sf_mathieu_alloc"
    set name: "new"
    set singleton: true
  when /_array$/
    set name: h[:func_name].sub(/^gsl_sf_mathieu_/,"")
    set singleton: false
  end

  case func_name
  when /_(a|b)_array$/
    @mathieu_type = :characteristic
  when /_(c|s)e_array$/
    @mathieu_type = :angular
  when /_M(c|s)_array$/
    @mathieu_type = :radial
  end

  if @mathieu_type == :radial
    @preproc_code = "  if (c0!=1 || c0!=2) {\n      rb_raise(rb_eArgError,\"j should be 1 or 2\");\n  }\n  if (c1<0 || c2<0 || c1>c2) {\n      rb_raise(rb_eArgError,\"should be nmin>=0 && nmax>=0 && nmin<=nmax\");\n  }\n  shape[0] = c2-c1+1;\n"
    else
      @preproc_code = "  if (c0<0 || c1<0 || c0>c1) {\n      rb_raise(rb_eArgError,\"should be nmin>=0 && nmax>=0 && nmin<=nmax\");\n  }\n  shape[0] = c1-c0+1;\n"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ErbPP

Class Method Details

.lookup(h) ⇒ Object



139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'ext/numo/gsl/sf/parse_sf.rb', line 139

def self.lookup(h)
  case h[:func_name]
  when "gsl_sf_mathieu_alloc"
    "c_new_sizet_double"
  when RE
    arg_types = h[:args].map{|a| a[0].sub(/^const /,"")}
    tp = "gsl_sf_mathieu_workspace *"
    case arg_types
    when ["int"]*2+["double",tp,"double"];     "c_DFloat_f_int_x2_DFloat"
    when ["int"]*2+["double"]*2+[tp,"double"]; "c_DFloat_f_int_x2_DFloat_x2"
    when ["int"]*3+["double"]*2+[tp,"double"]; "c_DFloat_f_int_x3_DFloat_x2"
    end
  end
end