Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xuri
excelize
提交
6e812a27
excelize
项目概览
xuri
/
excelize
通知
13
Star
2
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
excelize
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
已验证
提交
6e812a27
编写于
4月 02, 2021
作者:
xurime
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#65 fn: BESSELI and BESSELJ
上级
a002a241
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
73 addition
and
0 deletion
+73
-0
calc.go
calc.go
+60
-0
calc_test.go
calc_test.go
+13
-0
未找到文件。
calc.go
浏览文件 @
6e812a27
...
...
@@ -227,6 +227,8 @@ var tokenPriority = map[string]int{
// AVERAGE
// AVERAGEA
// BASE
// BESSELI
// BESSELJ
// BIN2DEC
// BIN2HEX
// BIN2OCT
...
...
@@ -1226,6 +1228,64 @@ func formulaCriteriaEval(val string, criteria *formulaCriteria) (result bool, er
// Engineering Functions
// BESSELI function the modified Bessel function, which is equivalent to the
// Bessel function evaluated for purely imaginary arguments. The syntax of
// the Besseli function is:
//
// BESSELI(x,n)
//
func
(
fn
*
formulaFuncs
)
BESSELI
(
argsList
*
list
.
List
)
formulaArg
{
if
argsList
.
Len
()
!=
2
{
return
newErrorFormulaArg
(
formulaErrorVALUE
,
"BESSELI requires 2 numeric arguments"
)
}
return
fn
.
bassel
(
argsList
,
true
)
}
// BESSELJ function returns the Bessel function, Jn(x), for a specified order
// and value of x. The syntax of the function is:
//
// BESSELJ(x,n)
//
func
(
fn
*
formulaFuncs
)
BESSELJ
(
argsList
*
list
.
List
)
formulaArg
{
if
argsList
.
Len
()
!=
2
{
return
newErrorFormulaArg
(
formulaErrorVALUE
,
"BESSELJ requires 2 numeric arguments"
)
}
return
fn
.
bassel
(
argsList
,
false
)
}
// bassel is an implementation of the formula function BESSELI and BESSELJ.
func
(
fn
*
formulaFuncs
)
bassel
(
argsList
*
list
.
List
,
modfied
bool
)
formulaArg
{
x
,
n
:=
argsList
.
Front
()
.
Value
.
(
formulaArg
)
.
ToNumber
(),
argsList
.
Back
()
.
Value
.
(
formulaArg
)
.
ToNumber
()
if
x
.
Type
!=
ArgNumber
{
return
x
}
if
n
.
Type
!=
ArgNumber
{
return
n
}
max
,
x1
:=
100
,
x
.
Number
*
0.5
x2
:=
x1
*
x1
x1
=
math
.
Pow
(
x1
,
n
.
Number
)
n1
,
n2
,
n3
,
n4
,
add
:=
fact
(
n
.
Number
),
1.0
,
0.0
,
n
.
Number
,
false
result
:=
x1
/
n1
t
:=
result
*
0.9
for
result
!=
t
&&
max
!=
0
{
x1
*=
x2
n3
++
n1
*=
n3
n4
++
n2
*=
n4
t
=
result
if
modfied
||
add
{
result
+=
(
x1
/
n1
/
n2
)
}
else
{
result
-=
(
x1
/
n1
/
n2
)
}
max
--
add
=
!
add
}
return
newNumberFormulaArg
(
result
)
}
// BIN2DEC function converts a Binary (a base-2 number) into a decimal number.
// The syntax of the function is:
//
...
...
calc_test.go
浏览文件 @
6e812a27
...
...
@@ -47,6 +47,11 @@ func TestCalcCellValue(t *testing.T) {
"=2>=3"
:
"FALSE"
,
"=1&2"
:
"12"
,
// Engineering Functions
// BESSELI
"=BESSELI(4.5,1)"
:
"15.389222753735925"
,
"=BESSELI(32,1)"
:
"5.502845511211247e+12"
,
// BESSELJ
"=BESSELJ(1.9,2)"
:
"0.329925727692387"
,
// BIN2DEC
"=BIN2DEC(
\"
10
\"
)"
:
"2"
,
"=BIN2DEC(
\"
11
\"
)"
:
"3"
,
...
...
@@ -1008,6 +1013,14 @@ func TestCalcCellValue(t *testing.T) {
mathCalcError
:=
map
[
string
]
string
{
"=1/0"
:
"#DIV/0!"
,
// Engineering Functions
// BESSELI
"=BESSELI()"
:
"BESSELI requires 2 numeric arguments"
,
"=BESSELI(
\"\"
,0)"
:
"strconv.ParseFloat: parsing
\"\"
: invalid syntax"
,
"=BESSELI(0,
\"\"
)"
:
"strconv.ParseFloat: parsing
\"\"
: invalid syntax"
,
// BESSELJ
"=BESSELJ()"
:
"BESSELJ requires 2 numeric arguments"
,
"=BESSELJ(
\"\"
,0)"
:
"strconv.ParseFloat: parsing
\"\"
: invalid syntax"
,
"=BESSELJ(0,
\"\"
)"
:
"strconv.ParseFloat: parsing
\"\"
: invalid syntax"
,
// BIN2DEC
"=BIN2DEC()"
:
"BIN2DEC requires 1 numeric argument"
,
"=BIN2DEC(
\"\"
)"
:
"strconv.ParseFloat: parsing
\"\"
: invalid syntax"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录