Module: NArrayType

Defined in:
ext/numo/narray/gen/narray_def.rb

Overview


Instance Method Summary collapse

Instance Method Details

#class_alias(*args) ⇒ Object



139
140
141
142
143
144
145
146
147
148
# File 'ext/numo/narray/gen/narray_def.rb', line 139

def class_alias(*args)
  case a = @opts[:class_alias]
  when Array
  when nil
    a = @opts[:class_alias] = []
  else
    a = @opts[:class_alias] = [a]
  end
  a.concat(args)
end

#math_varObject



111
112
113
# File 'ext/numo/narray/gen/narray_def.rb', line 111

def math_var
  @opts[:math_var] ||= "numo_m"+class_name+"Math"
end

#real_class_name(arg = nil) ⇒ Object



115
116
117
118
119
120
121
# File 'ext/numo/narray/gen/narray_def.rb', line 115

def real_class_name(arg=nil)
  if arg.nil?
    @opts[:real_class_name] ||= class_name
  else
    @opts[:real_class_name] = arg
  end
end

#real_ctype(arg = nil) ⇒ Object



123
124
125
126
127
128
129
# File 'ext/numo/narray/gen/narray_def.rb', line 123

def real_ctype(arg=nil)
  if arg.nil?
    @opts[:real_ctype] ||= ctype
  else
    @opts[:real_ctype] = arg
  end
end

#real_type_nameObject



135
136
137
# File 'ext/numo/narray/gen/narray_def.rb', line 135

def real_type_name
  @opts[:real_type_name] ||= real_class_name.downcase
end

#real_type_varObject



131
132
133
# File 'ext/numo/narray/gen/narray_def.rb', line 131

def real_type_var
  @opts[:real_type_var] ||= "numo_c"+real_class_name
end

#type_nameObject Also known as: tp



102
103
104
# File 'ext/numo/narray/gen/narray_def.rb', line 102

def type_name
  @opts[:type_name] ||= class_name.downcase
end

#type_varObject



107
108
109
# File 'ext/numo/narray/gen/narray_def.rb', line 107

def type_var
  @opts[:type_var] ||= "numo_c"+class_name
end

#upcast(c = nil, t = nil) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'ext/numo/narray/gen/narray_def.rb', line 150

def upcast(c=nil,t=nil)
  @opts[:upcast] ||= []
  if c
    if t
      t = "numo_c#{t}"
    else
      t = "cT"
    end
    @opts[:upcast] << "rb_hash_aset(hCast, numo_c#{c}, #{t});"
  else
    @opts[:upcast]
  end
end

#upcast_rb(c, t = nil) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'ext/numo/narray/gen/narray_def.rb', line 164

def upcast_rb(c,t=nil)
  @opts[:upcast] ||= []
  if t
    t = "numo_c#{t}"
  else
    t = "cT"
  end
  if c=="Integer"
    @opts[:upcast] << "#ifdef RUBY_INTEGER_UNIFICATION"
    @opts[:upcast] << "rb_hash_aset(hCast, rb_cInteger, #{t});"
    @opts[:upcast] << "#else"
    @opts[:upcast] << "rb_hash_aset(hCast, rb_cFixnum, #{t});"
    @opts[:upcast] << "rb_hash_aset(hCast, rb_cBignum, #{t});"
    @opts[:upcast] << "#endif"
  else
    @opts[:upcast] << "rb_hash_aset(hCast, rb_c#{c}, #{t});"
  end
end