Skip to content

Commit

Permalink
Adding Yn math function
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikmota committed Jun 23, 2024
1 parent 24df591 commit fd1f571
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions evaldo/builtins_math.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,34 @@ var Builtins_math = map[string]*env.Builtin{
}
},
},
"yn": {
Argsn: 1,
Doc: "Returns the order-n Bessel function of the second kind.",
Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object {
switch v1 := arg0.(type) {
case env.Integer:
switch v2 := arg1.(type) {
case env.Integer:
return *env.NewDecimal(math.Yn(int(v1.Value), float64(v2.Value)))
case env.Decimal:
return *env.NewDecimal(math.Yn(int(v1.Value), v2.Value))
default:
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.DecimalType}, "yn")
}
case env.Decimal:
switch v2 := arg1.(type) {
case env.Integer:
return *env.NewDecimal(math.Yn(int(v1.Value), float64(v2.Value)))
case env.Decimal:
return *env.NewDecimal(math.Yn(int(v1.Value), v2.Value))
default:
return MakeArgError(ps, 2, []env.Type{env.IntegerType, env.DecimalType}, "yn")
}
default:
return MakeArgError(ps, 1, []env.Type{env.IntegerType, env.DecimalType}, "yn")
}
},
},
"pi": {
Argsn: 0,
Doc: "Return Pi constant.",
Expand Down

0 comments on commit fd1f571

Please sign in to comment.