square

Syntax

square(X)

Details

Return the square of X. The data type of the result is always DOUBLE.

Differences from Python’s numpy.square and scipy.signal.square: numpy.square calculates squares, is a ufunc, determines the return dtype according to NumPy type rules, and supports complex numbers, broadcasting, out, where, and other ufunc arguments. scipy.signal.square generates a periodic square-wave signal, where the input is time t and the duty cycle duty. DolphinDB’s square returns the square of X as DOUBLE values.

Parameters

X is a scalar/pair/vector/matrix.

Returns

A DOUBLE scalar, pair, vector, or matrix.

Examples

square(3);
// output: 9

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

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