square

语法

square(X)

详情

返回 X 的平方。返回结果的数据类型为 DOUBLE 类型。

与 Python 中 numpy.squarescipy.signal.square 的区别:numpy.square 用于计算平方,是 ufunc,按 NumPy 类型规则决定返回 dtype,并支持复数、广播、outwhere 等参数;scipy.signal.square 用于生成周期方波信号,输入是时间 t 和占空比 duty;DolphinDB 的 square 用于返回 X 的平方,返回 DOUBLE 类型结果。

参数

X 可以是标量、数据对、向量或矩阵。

返回值

DOUBLE 类型的标量、数据对、向量或矩阵。

例子

square(3);
// output
9

square(2 4 NULL 6);
// output
[4,16,,36]

square(1..4$2:2);
#0 #1
1 9
4 16