Class: Kibuvits_krl171bt4_formula

Inherits:
Object
  • Object
show all
Defined in:
lib/kibuvits_ruby_library_krl171bt4_.rb

Overview

The class Kibuvits_krl171bt4_formula exists mainly for duck typing.

Everything is stored to the public field, which is a hash table, and the main idea is that a formula consists of components that are described by 2 variables in the hashtable:

x) An array of other formulaes, integers or symbols, like the Pi.

x) A string that is a name of the function that ties the

array elements together. For example, it might be multiplication,
werhe the order of elements in the array is relevant in cases
of matrixes, or the function might be summation, where usually
the order of arguments, in thins case, the array elements,
is not relevant.

One calls the formula component that are described by the array and the string a formulicle. (It’s a bit like the word: particle. The word “funclet” seems to be already used by other people for other denotates.)

The format of the hashtable is simplistic enough to be read form the source of the Kibuvits_krl171bt4_formula.create_formulicle

Constant Summary collapse

@@lc_s_formulicle_name =
's_formulicle_name_'
@@lc_ar_formulicle_elements =
'ar_formulicle_elements_'
@@lc_s_numerator =
'numerator'
@@lc_s_denominator =
'denominator'
@@lc_s_fraction =
'fraction'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeKibuvits_krl171bt4_formula

Returns a new instance of Kibuvits_krl171bt4_formula.



12935
12936
12937
12938
12939
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 12935

def initialize
   @ht=Hash.new
   @s_id=Kibuvits_krl171bt4_GUID_generator.generate_GUID();
   @s_formulicles_set_name=nil
end

Instance Attribute Details

#htObject (readonly)

The content of the @ht is editable despite the attr_reader.



12928
12929
12930
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 12928

def ht
  @ht
end

#s_formulicles_set_nameObject

The s_formulicles_set_name is useful for determining, how to interpret the set of formulicles.



12933
12934
12935
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 12933

def s_formulicles_set_name
  @s_formulicles_set_name
end

#s_idObject (readonly)

GUID



12929
12930
12931
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 12929

def s_id
  @s_id
end

Class Method Details

.selftestObject



13011
13012
13013
13014
13015
13016
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 13011

def Kibuvits_krl171bt4_formula.selftest
   ar_msgs=Array.new
   bn=binding()
   kibuvits_krl171bt4_testeval bn, "Kibuvits_krl171bt4_formula.test_1"
   return ar_msgs
end

Instance Method Details

#clearObject

Deletes all formulicles.

This function exists just in case one changes the specification of the Kibuvits_krl171bt4_formula later.



12975
12976
12977
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 12975

def clear
   @ht.clear
end

#create_formulicle(s_name, ar) ⇒ Object

There are no type restrictions set to the elements of the ar. For example, the elements might be matrices, Kibuvits_krl171bt4_formula instances, etc., but a recommendation is to use BigDecimal instances in stead of Float and Fixnum instances, because that avoids Fixnum related truncation and Float related rounding errors.



12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 12951

def create_formulicle(s_name, ar)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, String, s_name
      kibuvits_krl171bt4_typecheck bn, Array, ar
   end # if
   kibuvits_krl171bt4_throw 's_name.length==0' if s_name.length==0
   @ht[@@lc_s_formulicle_name+s_name]=s_name
   @ht[@@lc_ar_formulicle_elements+s_name]=ar
end

#create_fraction(ar_or_x_numerator, ar_or_x_denominator) ⇒ Object

———-start-of-convenience-methods—————————-



12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 12981

def create_fraction(ar_or_x_numerator, ar_or_x_denominator)
   # If the single element at the numerator array is itself an
   # array, then one has to wrapt it to the fraction array outside
   # of this function, because the following 2 lines are not capable
   # of distinquishing the 2 cases.
   ar_numerator=Kibuvits_krl171bt4_ix.normalize2array(ar_or_x_numerator)
   ar_denominator=Kibuvits_krl171bt4_ix.normalize2array(ar_or_x_denominator)
   kibuvits_krl171bt4_throw "ar_numerator.size==0" if ar_numerator.size==0
   kibuvits_krl171bt4_throw "ar_denominator.size==0" if ar_denominator.size==0

   create_formulicle(@@lc_s_numerator,ar_numerator)
   create_formulicle(@@lc_s_denominator,ar_denominator)
   @s_formulicles_set_name=@@lc_s_fraction
end

#create_Riemann_integral(forumla_for_the_function, formula_for_the_dx_part, upper_limit = nil, lower_limit = nil) ⇒ Object

create_fraction



12996
12997
12998
12999
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 12996

def create_Riemann_integral(forumla_for_the_function,formula_for_the_dx_part,
   upper_limit=nil,lower_limit=nil)
   # TODO: complete it
end

#delete_formulicle(s_name) ⇒ Object

create_formulicle



12962
12963
12964
12965
12966
12967
12968
12969
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 12962

def delete_formulicle(s_name)
   if KIBUVITS_krl171bt4_b_DEBUG
      bn=binding()
      kibuvits_krl171bt4_typecheck bn, String, s_name
   end # if
   Hash.new.delete(@@lc_s_formulicle_name+s_name)
   Hash.new.delete(@@lc_ar_formulicle_elements+s_name)
end