@@ -183,6 +183,44 @@ object MathUtil {
183183 else if (xt == 5 || xt == 6 ) mool(applyUnaryMath(f, _), x.asInstanceOf [LList ])
184184 else new TError (1 )
185185 }
186+ def exp (x : Type ): Type = applyUnaryMath(Math .exp(_), x)
187+ def ln (x : Type ): Type = applyUnaryMath(Math .log(_), x)
188+ def sin (x : Type ): Type = applyUnaryMath(Math .sin(_), x)
189+ def cos (x : Type ): Type = applyUnaryMath(Math .cos(_), x)
190+ def tan (x : Type ): Type = applyUnaryMath(Math .tan(_), x)
191+ def csc (x : Type ): Type = applyUnaryMath(1.0 / Math .sin(_), x)
192+ def sec (x : Type ): Type = applyUnaryMath(1.0 / Math .cos(_), x)
193+ def cot (x : Type ): Type = applyUnaryMath(1.0 / Math .tan(_), x)
194+ def asin (x : Type ): Type = applyUnaryMath(Math .asin(_), x)
195+ def acos (x : Type ): Type = applyUnaryMath(Math .acos(_), x)
196+ def atan (x : Type ): Type = applyUnaryMath(Math .atan(_), x)
197+ def acsc (x : Type ): Type = applyUnaryMath(y => Math .asin(1.0 / y), x)
198+ def asec (x : Type ): Type = applyUnaryMath(y => Math .acos(1.0 / y), x)
199+ def acot (x : Type ): Type = applyUnaryMath(Math .PI / 2 - Math .atan(_), x)
200+ def sinh (x : Type ): Type = applyUnaryMath(Math .sinh(_), x)
201+ def cosh (x : Type ): Type = applyUnaryMath(Math .cosh(_), x)
202+ def tanh (x : Type ): Type = applyUnaryMath(Math .tanh(_), x)
203+ def csch (x : Type ): Type = applyUnaryMath(1.0 / Math .sinh(_), x)
204+ def sech (x : Type ): Type = applyUnaryMath(1.0 / Math .cosh(_), x)
205+ def coth (x : Type ): Type = applyUnaryMath(1.0 / Math .tanh(_), x)
206+ def asinh (x : Double ) = Math .log(Math .hypot(1.0 , x) + x)
207+ def acosh (x : Double ) = Math .log(Math .sqrt(Math .pow(x, 2 ) - 1.0 ) + x)
208+ def atanh (x : Double ) = 0.5 * (Math .log(x + 1 ) - Math .log(1 - x))
209+ def asinh (x : Type ): Type = applyUnaryMath(asinh(_), x)
210+ def acosh (x : Type ): Type = applyUnaryMath(acosh(_), x)
211+ def atanh (x : Type ): Type = applyUnaryMath(atanh(_), x)
212+ def acsch (x : Type ): Type = applyUnaryMath(y => asinh(1.0 / y), x)
213+ def asech (x : Type ): Type = applyUnaryMath(y => acosh(1.0 / y), x)
214+ def acoth (x : Type ): Type = applyUnaryMath(y => 0.5 * Math .log((y + 1 )/ (y - 1 )), x)
215+ def atan (x : Type , y : Type ): Type = {
216+ (x, y) match {
217+ case (xl : LList , yl : LList ) => motl(atan(_, _), xl, yl)
218+ case (xl : LList , _) => mool(atan(_, _), xl, y)
219+ case (_, yl : LList ) => mool((a, b) => atan(b, a), yl, x)
220+ case (x : TNumerical , y : TNumerical ) => TFish (Math .atan2(y.doubleValue, x.doubleValue))
221+ case _ => new TError (1 )
222+ }
223+ }
186224 def idivide (x : Type , y : Type ): Type = {
187225 val xt = x.getType; val yt = y.getType
188226 if ((xt == 5 || xt == 6 ) && (yt == 5 || yt == 6 )) motl(idivide, x.asInstanceOf [LList ], y.asInstanceOf [LList ])
@@ -289,7 +327,7 @@ object MathUtil {
289327 (x, y) match {
290328 case (xl : LList , yl : LList ) => motl(shl(_, _), xl, yl)
291329 case (xl : LList , _) => mool(shl(_, _), xl, y)
292- case (_, yl : LList ) => shl(y , x)
330+ case (_, yl : LList ) => mool((a, b) => shl(b, a), yl , x)
293331 case (xm : TMountain , ym : TNumerical ) => {
294332 new TMountain (xm.getVal.shiftLeft(ym.intValue))
295333 }
@@ -306,7 +344,7 @@ object MathUtil {
306344 (x, y) match {
307345 case (xl : LList , yl : LList ) => motl(shr(_, _), xl, yl)
308346 case (xl : LList , _) => mool(shr(_, _), xl, y)
309- case (_, yl : LList ) => shr(y , x)
347+ case (_, yl : LList ) => mool((a, b) => shr(b, a), yl , x)
310348 case (xm : TMountain , ym : TNumerical ) => {
311349 new TMountain (xm.getVal.shiftRight(ym.intValue))
312350 }
0 commit comments