@@ -33,7 +33,7 @@ private static readonly MethodInfo
3333 /// <summary>
3434 /// A set of default functions.
3535 /// </summary>
36- public static readonly Dictionary < string , ApplyFunction > Defaults = new Dictionary < string , ApplyFunction > ( StringComparer . OrdinalIgnoreCase )
36+ public static Dictionary < string , ApplyFunction > Defaults { get ; set ; } = new Dictionary < string , ApplyFunction > ( StringComparer . OrdinalIgnoreCase )
3737 {
3838 { "abs" , Abs } ,
3939 { "sgn" , Sgn } ,
@@ -54,6 +54,7 @@ private static readonly MethodInfo
5454 { "acos" , Acos } , { "arccos" , Acos } ,
5555 { "atan" , Atan } , { "arctan" , Atan } ,
5656 { "atan2" , Atan2 } ,
57+ { "atanh" , Atanh } ,
5758 { "hypot" , Hypot } ,
5859 { "u" , U } , { "du(0)" , Zero } ,
5960 { "u2" , U2 } , { "du2(0)" , DU2 } ,
@@ -69,7 +70,12 @@ private static readonly MethodInfo
6970 { "min" , Min } ,
7071 { "max" , Max } ,
7172 { "rnd" , Random } , { "rand" , Random } ,
72- { "if" , If }
73+ { "if" , If } ,
74+ { "limit" , Limit } ,
75+ { "db" , Decibels } ,
76+ { "arg" , Argument } ,
77+ { "real" , ( ils , args ) => ils . Call ( HelperFunctions . Real , args ) } ,
78+ { "imag" , ( ils , args ) => ils . Call ( HelperFunctions . Imag , args ) } ,
7379 } ;
7480
7581 private static IReadOnlyList < Node > Check ( this IReadOnlyList < Node > nodes , int expected )
@@ -98,6 +104,20 @@ private static void OnFunctionFound(object sender, FunctionFoundEventArgs<Comple
98104 }
99105 }
100106
107+ /// <summary>
108+ /// Helper methods that changes the equality comparer for function names.
109+ /// </summary>
110+ /// <param name="comparer">The name comparer.</param>
111+ public static void RemapFunctions ( IEqualityComparer < string > comparer )
112+ {
113+ var nmap = new Dictionary < string , ApplyFunction > ( comparer ) ;
114+ foreach ( var map in Defaults )
115+ {
116+ nmap . Add ( map . Key , map . Value ) ;
117+ }
118+ Defaults = nmap ;
119+ }
120+
101121 // No-argument functions
102122 private static void Random ( IILState < Complex > ils , IReadOnlyList < Node > arguments )
103123 {
@@ -138,6 +158,8 @@ private static void Nint(IILState<Complex> ils, IReadOnlyList<Node> arguments)
138158 ils . PushInt ( 0 ) ;
139159 ils . Generator . Emit ( OpCodes . Call , _round ) ;
140160 }
161+ private static void Decibels ( IILState < Complex > ils , IReadOnlyList < Node > arguments ) => ils . Call ( HelperFunctions . Decibels , arguments ) ;
162+ private static void Argument ( IILState < Complex > ils , IReadOnlyList < Node > arguments ) => ils . Call ( HelperFunctions . Phase , arguments ) ;
141163
142164 // Two-argument functions
143165 private static void Pow ( IILState < Complex > ils , IReadOnlyList < Node > arguments ) => ils . Call ( Complex . Pow , arguments ) ;
@@ -153,6 +175,7 @@ private static void Round(IILState<Complex> ils, IReadOnlyList<Node> arguments)
153175 ils . Generator . Emit ( OpCodes . Call , _round ) ;
154176 }
155177 private static void Atan2 ( IILState < Complex > ils , IReadOnlyList < Node > arguments ) => ils . Call ( HelperFunctions . Atan2 , arguments ) ;
178+ private static void Atanh ( IILState < Complex > ils , IReadOnlyList < Node > arguments ) => ils . Call ( HelperFunctions . Atanh , arguments ) ;
156179 private static void Hypot ( IILState < Complex > ils , IReadOnlyList < Node > arguments ) => ils . Call ( HelperFunctions . Hypot , arguments ) ;
157180
158181 // Three-argument functions
@@ -164,6 +187,7 @@ private static void If(IILState<Complex> ils, IReadOnlyList<Node> arguments)
164187 ilsc . PushDouble ( 0.5 ) ;
165188 ilsc . PushCheck ( OpCodes . Bgt_S , arguments [ 1 ] , arguments [ 2 ] ) ;
166189 }
190+ private static void Limit ( IILState < Complex > ils , IReadOnlyList < Node > arguments ) => ils . Call ( HelperFunctions . Limit , arguments ) ;
167191
168192 // N-argument functions
169193 private static void Pwl ( IILState < Complex > ils , IReadOnlyList < Node > arguments )
0 commit comments