Class: Symbol

Inherits:
Object
  • Object
show all
Defined in:
lib/symath/type.rb,
lib/symath/value.rb,
lib/symath/definition/variable.rb

Instance Method Summary collapse

Instance Method Details

#*(other) ⇒ Object



351
352
353
# File 'lib/symath/value.rb', line 351

def *(other)
  return self.to_m*other.to_m
end

#**(other) ⇒ Object



359
360
361
# File 'lib/symath/value.rb', line 359

def **(other)
  return self.to_m**other.to_m
end

#+(other) ⇒ Object



339
340
341
# File 'lib/symath/value.rb', line 339

def +(other)
  return self.to_m + other.to_m
end

#-(other) ⇒ Object



343
344
345
# File 'lib/symath/value.rb', line 343

def -(other)
  return self.to_m - other.to_m
end

#-@Object



347
348
349
# File 'lib/symath/value.rb', line 347

def -@()
  return - self.to_m
end

#/(other) ⇒ Object



355
356
357
# File 'lib/symath/value.rb', line 355

def /(other)
  return self.to_m/other.to_m
end

#^(other) ⇒ Object



363
364
365
# File 'lib/symath/value.rb', line 363

def ^(other)
  return self.to_m^other.to_m
end

#to_m(type = 'real') ⇒ Object



274
275
276
277
278
279
280
281
282
283
# File 'lib/symath/definition/variable.rb', line 274

def to_m(type = 'real')
  begin
    # Look up the already defined symbol
    # (we might want to check that it is a constant or variable)
    return SyMath::Definition.get(self)
  rescue
    # Not defined. Define it now.
    return SyMath::Definition::Variable.new(self, type)
  end
end

#to_t(**args) ⇒ Object



275
276
277
278
279
280
281
# File 'lib/symath/type.rb', line 275

def to_t(**args)
  if args.empty? and SyMath::Type.types.key?(self)
    return SyMath::Type.types[self]
  end

  return SyMath::Type.new(self, **args)
end