exp2

Syntax

exp2(X)

Details

Return 2 raised to the power of X.

The exp2 function in DolphinDB and the exp2 function in NumPy are consistent in their core functionality. However, their design focuses differ:

  • DolphinDB exp2 emphasizes vectorization and distributed computing capabilities, allowing it to operate efficiently on vectors, matrices, and table columns, especially in large-scale data scenarios.
  • NumPy exp2, as part of a general-purpose numerical computing library, is built on the ufunc (universal function) mechanism, providing richer low-level control parameters, such as:
    • out: supports writing results into a specified array for in-place computation
    • where: supports conditional element-wise computation
    • dtype: controls the data type of computation and output
    • casting: controls type casting rules
    • order: specifies the memory layout of the output array
    • subok: controls whether to preserve subclass types

It is important to note that these parameters are not specific to exp2, but are common features of NumPy ufuncs.

Parameters

X is a scalar/pair/vector/matrix.

Returns

DOUBLE type with the same data form as X.

Examples

exp2(3);
// output: 8

exp2(2 4 NULL 6);
// output: [4,16,,64]

exp2(1..4$2:2);
#0 #1
2 8
4 16