Class: Kibuvits_krl171bt4_numerics_set_0
- Inherits:
-
Object
- Object
- Kibuvits_krl171bt4_numerics_set_0
- Includes:
- Singleton
- Defined in:
- lib/kibuvits_ruby_library_krl171bt4_.rb
Class Method Summary collapse
-
.i_factorial_t1(i_n) ⇒ Object
i_factorial_t1.
-
.i_product_of_primes_t1(ixs_low, ixs_high) ⇒ Object
i_product_of_primes_t1.
Instance Method Summary collapse
-
#i_factorial_t1(i_n) ⇒ Object
Calculates the factorial of i_n .
-
#i_product_of_primes_t1(ixs_low, ixs_high) ⇒ Object
ixs_low and ixs_high are sindexes longterm.softf1.com/specifications/array_indexing_by_separators/ of an array that is created by Prime.take(i_number_of_primes).
-
#initialize ⇒ Kibuvits_krl171bt4_numerics_set_0
constructor
A new instance of Kibuvits_krl171bt4_numerics_set_0.
Constructor Details
#initialize ⇒ Kibuvits_krl171bt4_numerics_set_0
Returns a new instance of Kibuvits_krl171bt4_numerics_set_0.
17921 17922 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 17921 def initialize end |
Class Method Details
.i_factorial_t1(i_n) ⇒ Object
i_factorial_t1
17993 17994 17995 17996 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 17993 def Kibuvits_krl171bt4_numerics_set_0.i_factorial_t1(i_n) i_out=Kibuvits_krl171bt4_numerics_set_0.instance.i_factorial_t1(i_n) return i_out end |
.i_product_of_primes_t1(ixs_low, ixs_high) ⇒ Object
i_product_of_primes_t1
17954 17955 17956 17957 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 17954 def Kibuvits_krl171bt4_numerics_set_0.i_product_of_primes_t1(ixs_low,ixs_high) i_out=Kibuvits_krl171bt4_numerics_set_0.instance.i_product_of_primes_t1(ixs_low,ixs_high) return i_out end |
Instance Method Details
#i_factorial_t1(i_n) ⇒ Object
Calculates the factorial of i_n .
For shorter code it is recommended to use the kibuvits_krl171bt4_factorial(…) in stead of calling i this function directly.
17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 17987 17988 17989 17990 17991 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 17967 def i_factorial_t1(i_n) if KIBUVITS_krl171bt4_b_DEBUG bn=binding() # Allowing the i_n to be a Bignum is a bit crazy in 2014, # but may be in the future that might not be that crazy. kibuvits_krl171bt4_typecheck bn, [Fixnum,Bignum], i_n kibuvits_krl171bt4_assert_is_smaller_than_or_equal_to(bn,0,i_n, "\n GUID='ad8ff056-326b-49a5-a266-c13290a118e7'\n\n") end # if i_out=1 # factorial(0)==1 return i_out if i_n==0 func_star=lambda do |x_a,x_b| x_out=x_a*x_b return x_out end # func_star ar_n=Array.new # For i_n==2, the ar_n==[0,1,2], ar_n.size==3 . # To avoid multiplication with 0, ar_n[0]==1 . # Therefore, for i_n==2, ar_n==[1,2] . i_n.times{|i| ar_n<<(i+1)} # i starts from 0 x_identity_element=1 i_out=Kibuvits_krl171bt4_ix.x_apply_binary_operator_t1( x_identity_element,ar_n,func_star) return i_out end |
#i_product_of_primes_t1(ixs_low, ixs_high) ⇒ Object
ixs_low and ixs_high are sindexes longterm.softf1.com/specifications/array_indexing_by_separators/ of an array that is created by Prime.take(i_number_of_primes)
This function here is pretty expensive.
17931 17932 17933 17934 17935 17936 17937 17938 17939 17940 17941 17942 17943 17944 17945 17946 17947 17948 17949 17950 17951 17952 |
# File 'lib/kibuvits_ruby_library_krl171bt4_.rb', line 17931 def i_product_of_primes_t1(ixs_low,ixs_high) if KIBUVITS_krl171bt4_b_DEBUG bn=binding() kibuvits_krl171bt4_assert_is_smaller_than_or_equal_to(bn, 0, ixs_low,"\n GUID='43048141-8b37-4b0a-92b6-c13290a118e7'\n\n") kibuvits_krl171bt4_assert_is_smaller_than_or_equal_to(bn, ixs_low, ixs_high,"\n GUID='e101cd19-bbe9-4b40-8586-c13290a118e7'\n\n") kibuvits_krl171bt4_typecheck bn, Fixnum, ixs_low kibuvits_krl171bt4_typecheck bn, Fixnum, ixs_high end # if x_identity_element=1 x_identity_element if ixs_low==ixs_high ar_primes=Prime.take(ixs_high) ar_factors=Kibuvits_krl171bt4_ix.sar(ar_primes,ixs_low,ixs_high) func_star=lambda do |x_a,x_b| x_out=x_a*x_b return x_out end # func_star i_out=Kibuvits_krl171bt4_ix.x_apply_binary_operator_t1( x_identity_element,ar_factors,func_star) return i_out end |