@@ -29,7 +29,7 @@ struct _InternalMutFuncs
2929end
3030
3131# Constructor
32- function _InternalMutFuncs ( namef:: Vector )
32+ function _InternalMutFuncs ( namef:: Tuple )
3333 if length (namef) == 3
3434 return _InternalMutFuncs ( namef[1 ], namef[2 ], namef[3 ], Expr (:nothing ) )
3535 else
@@ -56,11 +56,11 @@ of `:_res`.
5656
5757"""
5858const _dict_binary_ops = Dict (
59- :+ => [ :add! , (:_res , :_arg1 , :_arg2 , :_k ), :(_res = _arg1 + _arg2)] ,
60- :- => [ :subst! , (:_res , :_arg1 , :_arg2 , :_k ), :(_res = _arg1 - _arg2)] ,
61- :* => [ :mul! , (:_res , :_arg1 , :_arg2 , :_k ), :(_res = _arg1 * _arg2)] ,
62- :/ => [ :div! , (:_res , :_arg1 , :_arg2 , :_k ), :(_res = _arg1 / _arg2)] ,
63- :^ => [ :pow! , (:_res , :_arg1 , :_arg2 , :_k ), :(_res = _arg1 ^ float (_arg2))] ,
59+ :+ => ( :add! , (:_res , :_arg1 , :_arg2 , :_k ), :(_res = _arg1 + _arg2)) ,
60+ :- => ( :subst! , (:_res , :_arg1 , :_arg2 , :_k ), :(_res = _arg1 - _arg2)) ,
61+ :* => ( :mul! , (:_res , :_arg1 , :_arg2 , :_k ), :(_res = _arg1 * _arg2)) ,
62+ :/ => ( :div! , (:_res , :_arg1 , :_arg2 , :_k ), :(_res = _arg1 / _arg2)) ,
63+ :^ => ( :pow! , (:_res , :_arg1 , :_arg2 , :_k ), :(_res = _arg1 ^ float (_arg2))) ,
6464);
6565
6666"""
@@ -83,50 +83,50 @@ added as the last entry of the vector.
8383
8484"""
8585const _dict_unary_ops = Dict (
86- :+ => [ :add! , (:_res , :_arg1 , :_k ), :(_res = + _arg1)] ,
87- :- => [ :subst! , (:_res , :_arg1 , :_k ), :(_res = - _arg1)] ,
88- :sqr => [ :sqr! , (:_res , :_arg1 , :_k ), :(_res = sqr (_arg1))] ,
89- :sqrt => [ :sqrt! , (:_res , :_arg1 , :_k ), :(_res = sqrt (_arg1))] ,
90- :exp => [ :exp! , (:_res , :_arg1 , :_k ), :(_res = exp (_arg1))] ,
91- :expm1 => [ :expm1! , (:_res , :_arg1 , :_k ), :(_res = expm1 (_arg1))] ,
92- :log => [ :log! , (:_res , :_arg1 , :_k ), :(_res = log (_arg1))] ,
93- :log1p => [ :log1p! , (:_res , :_arg1 , :_k ), :(_res = log1p (_arg1))] ,
94- :identity => [ :identity! , (:_res , :_arg1 , :_k ), :(_res = identity (_arg1))] ,
95- :zero => [ :zero! , (:_res , :_arg1 , :_k ), :(_res = zero (_arg1))] ,
96- :one => [ :one! , (:_res , :_arg1 , :_k ), :(_res = one (_arg1))] ,
97- :abs => [ :abs! , (:_res , :_arg1 , :_k ), :(_res = abs (_arg1))] ,
98- :abs2 => [ :abs2! , (:_res , :_arg1 , :_k ), :(_res = abs2 (_arg1))] ,
99- :deg2rad => [ :deg2rad! , (:_res , :_arg1 , :_k ), :(_res = deg2rad (_arg1))] ,
100- :rad2deg => [ :rad2deg! , (:_res , :_arg1 , :_k ), :(_res = rad2deg (_arg1))] ,
86+ :+ => ( :add! , (:_res , :_arg1 , :_k ), :(_res = + _arg1)) ,
87+ :- => ( :subst! , (:_res , :_arg1 , :_k ), :(_res = - _arg1)) ,
88+ :sqr => ( :sqr! , (:_res , :_arg1 , :_k ), :(_res = sqr (_arg1))) ,
89+ :sqrt => ( :sqrt! , (:_res , :_arg1 , :_k ), :(_res = sqrt (_arg1))) ,
90+ :exp => ( :exp! , (:_res , :_arg1 , :_k ), :(_res = exp (_arg1))) ,
91+ :expm1 => ( :expm1! , (:_res , :_arg1 , :_k ), :(_res = expm1 (_arg1))) ,
92+ :log => ( :log! , (:_res , :_arg1 , :_k ), :(_res = log (_arg1))) ,
93+ :log1p => ( :log1p! , (:_res , :_arg1 , :_k ), :(_res = log1p (_arg1))) ,
94+ :identity => ( :identity! , (:_res , :_arg1 , :_k ), :(_res = identity (_arg1))) ,
95+ :zero => ( :zero! , (:_res , :_arg1 , :_k ), :(_res = zero (_arg1))) ,
96+ :one => ( :one! , (:_res , :_arg1 , :_k ), :(_res = one (_arg1))) ,
97+ :abs => ( :abs! , (:_res , :_arg1 , :_k ), :(_res = abs (_arg1))) ,
98+ :abs2 => ( :abs2! , (:_res , :_arg1 , :_k ), :(_res = abs2 (_arg1))) ,
99+ :deg2rad => ( :deg2rad! , (:_res , :_arg1 , :_k ), :(_res = deg2rad (_arg1))) ,
100+ :rad2deg => ( :rad2deg! , (:_res , :_arg1 , :_k ), :(_res = rad2deg (_arg1))) ,
101101 #
102- :sin => [ :sincos! , (:_res , :_aux , :_arg1 , :_k ), :(_res = sin (_arg1)),
103- :(_aux = cos (_arg1))] ,
104- :cos => [ :sincos! , (:_aux , :_res , :_arg1 , :_k ), :(_res = cos (_arg1)),
105- :(_aux = sin (_arg1))] ,
106- :sinpi => [ :sincospi! , (:_res , :_aux , :_arg1 , :_k ), :(_res = sinpi (_arg1)),
107- :(_aux = cospi (_arg1))] ,
108- :cospi => [ :sincospi! , (:_aux , :_res , :_arg1 , :_k ), :(_res = cospi (_arg1)),
109- :(_aux = sinpi (_arg1))] ,
110- :tan => [ :tan! , (:_res , :_arg1 , :_aux , :_k ), :(_res = tan (_arg1)),
111- :(_aux = tan (_arg1)^ 2 )] ,
112- :asin => [ :asin! , (:_res , :_arg1 , :_aux , :_k ), :(_res = asin (_arg1)),
113- :(_aux = sqrt (1 - _arg1^ 2 ))] ,
114- :acos => [ :acos! , (:_res , :_arg1 , :_aux , :_k ), :(_res = acos (_arg1)),
115- :(_aux = sqrt (1 - _arg1^ 2 ))] ,
116- :atan => [ :atan! , (:_res , :_arg1 , :_aux , :_k ), :(_res = atan (_arg1)),
117- :(_aux = 1 + _arg1^ 2 )] ,
118- :sinh => [ :sinhcosh! , (:_res , :_aux , :_arg1 , :_k ), :(_res = sinh (_arg1)),
119- :(_aux = cosh (_arg1))] ,
120- :cosh => [ :sinhcosh! , (:_aux , :_res , :_arg1 , :_k ), :(_res = cosh (_arg1)),
121- :(_aux = sinh (_arg1))] ,
122- :tanh => [ :tanh! , (:_res , :_arg1 , :_aux , :_k ), :(_res = tanh (_arg1)),
123- :(_aux = tanh (_arg1)^ 2 )] ,
124- :asinh => [ :asinh! , (:_res , :_arg1 , :_aux , :_k ), :(_res = asinh (_arg1)),
125- :(_aux = sqrt (_arg1^ 2 + 1 ))] ,
126- :acosh => [ :acosh! , (:_res , :_arg1 , :_aux , :_k ), :(_res = acosh (_arg1)),
127- :(_aux = sqrt (_arg1^ 2 - 1 ))] ,
128- :atanh => [ :atanh! , (:_res , :_arg1 , :_aux , :_k ), :(_res = atanh (_arg1)),
129- :(_aux = 1 - _arg1^ 2 )] ,
102+ :sin => ( :sincos! , (:_res , :_aux , :_arg1 , :_k ), :(_res = sin (_arg1)),
103+ :(_aux = cos (_arg1))) ,
104+ :cos => ( :sincos! , (:_aux , :_res , :_arg1 , :_k ), :(_res = cos (_arg1)),
105+ :(_aux = sin (_arg1))) ,
106+ :sinpi => ( :sincospi! , (:_res , :_aux , :_arg1 , :_k ), :(_res = sinpi (_arg1)),
107+ :(_aux = cospi (_arg1))) ,
108+ :cospi => ( :sincospi! , (:_aux , :_res , :_arg1 , :_k ), :(_res = cospi (_arg1)),
109+ :(_aux = sinpi (_arg1))) ,
110+ :tan => ( :tan! , (:_res , :_arg1 , :_aux , :_k ), :(_res = tan (_arg1)),
111+ :(_aux = tan (_arg1)^ 2 )) ,
112+ :asin => ( :asin! , (:_res , :_arg1 , :_aux , :_k ), :(_res = asin (_arg1)),
113+ :(_aux = sqrt (1 - _arg1^ 2 ))) ,
114+ :acos => ( :acos! , (:_res , :_arg1 , :_aux , :_k ), :(_res = acos (_arg1)),
115+ :(_aux = sqrt (1 - _arg1^ 2 ))) ,
116+ :atan => ( :atan! , (:_res , :_arg1 , :_aux , :_k ), :(_res = atan (_arg1)),
117+ :(_aux = 1 + _arg1^ 2 )) ,
118+ :sinh => ( :sinhcosh! , (:_res , :_aux , :_arg1 , :_k ), :(_res = sinh (_arg1)),
119+ :(_aux = cosh (_arg1))) ,
120+ :cosh => ( :sinhcosh! , (:_aux , :_res , :_arg1 , :_k ), :(_res = cosh (_arg1)),
121+ :(_aux = sinh (_arg1))) ,
122+ :tanh => ( :tanh! , (:_res , :_arg1 , :_aux , :_k ), :(_res = tanh (_arg1)),
123+ :(_aux = tanh (_arg1)^ 2 )) ,
124+ :asinh => ( :asinh! , (:_res , :_arg1 , :_aux , :_k ), :(_res = asinh (_arg1)),
125+ :(_aux = sqrt (_arg1^ 2 + 1 ))) ,
126+ :acosh => ( :acosh! , (:_res , :_arg1 , :_aux , :_k ), :(_res = acosh (_arg1)),
127+ :(_aux = sqrt (_arg1^ 2 - 1 ))) ,
128+ :atanh => ( :atanh! , (:_res , :_arg1 , :_aux , :_k ), :(_res = atanh (_arg1)),
129+ :(_aux = 1 - _arg1^ 2 )) ,
130130);
131131
132132
@@ -146,8 +146,32 @@ _internalmutfunc_call( fn :: _InternalMutFuncs ) = (
146146 Expr ( :call , Meta. parse (" TaylorSeries.$(fn. namef) " ), fn. argsf... ), fn. defexpr, fn. auxexpr )
147147
148148
149+ """
150+ `_populate_dicts!()`
149151
152+ Function that populates the internal dictionaries [`_dict_unary_calls`](@ref) and
153+ [`_dict_binary_calls`](@ref)
150154"""
155+ function _populate_dicts! ()
156+ # Populates the constant vector `_dict_unary_calls`.
157+ _dict_unary_calls = Dict {Symbol, NTuple{3,Expr}} ()
158+ for kk in keys (_dict_unary_ops)
159+ res = _internalmutfunc_call ( _InternalMutFuncs (_dict_unary_ops[kk]) )
160+ push! (_dict_unary_calls, kk => res )
161+ end
162+
163+ # Populates the constant vector `_dict_binary_calls`.
164+ _dict_binary_calls = Dict {Symbol, NTuple{3,Expr}} ()
165+ for kk in keys (_dict_binary_ops)
166+ res = _internalmutfunc_call ( _InternalMutFuncs (_dict_binary_ops[kk]) )
167+ push! (_dict_binary_calls, kk => res )
168+ end
169+ return _dict_unary_calls, _dict_binary_calls
170+ end
171+
172+ const _dict_unary_calls, _dict_binary_calls = _populate_dicts! ()
173+
174+ @doc """
151175`_dict_unary_calls::Dict{Symbol, NTuple{2,Expr}}`
152176
153177Dictionary with the expressions that define the
@@ -158,16 +182,16 @@ internal mutating functions.
158182
159183Evaluating the entries generates expressions that represent
160184the actual calls to the internal mutating functions.
161- """
162- const _dict_unary_calls = Dict {Symbol, NTuple{3,Expr}} ()
185+ """ _dict_unary_calls
186+ # const _dict_unary_calls = Dict{Symbol, NTuple{3,Expr}}()
163187
164- # Populates the constant vector `_dict_unary_calls`.
165- for kk in keys (_dict_unary_ops)
166- res = _internalmutfunc_call ( _InternalMutFuncs (_dict_unary_ops[kk]) )
167- push! (_dict_unary_calls, kk => res )
168- end
188+ # # Populates the constant vector `_dict_unary_calls`.
189+ # for kk in keys(_dict_unary_ops)
190+ # res = _internalmutfunc_call( _InternalMutFuncs(_dict_unary_ops[kk]) )
191+ # push!(_dict_unary_calls, kk => res )
192+ # end
169193
170- """
194+ @doc """
171195`_dict_binary_calls::Dict{Symbol, NTuple{2,Expr}}`
172196
173197Dictionary with the expressions that define the
@@ -178,10 +202,6 @@ internal mutating functions.
178202
179203Evaluating the entries generates symbols that represent
180204the actual calls to the internal mutating functions.
181- """
182- const _dict_binary_calls = Dict {Symbol, NTuple{3,Expr}} ()
183- # Populates the constant vector `_dict_binary_calls`.
184- for kk in keys (_dict_binary_ops)
185- res = _internalmutfunc_call ( _InternalMutFuncs (_dict_binary_ops[kk]) )
186- push! (_dict_binary_calls, kk => res )
187- end
205+ """ _dict_binary_calls
206+ # const _dict_binary_calls = Dict{Symbol, NTuple{3,Expr}}()
207+
0 commit comments