pow
Syntax
pow(X, Y)
Alias: power
Details
Raise all elements of X to the power of Y. The data type of the result is always DOUBLE, even if both X and Y are integers.
Note:
- The core functionality of DolphinDB
powis the same as that of numpy.power and Python's built-in pow. The differences are as follows:- Python's built-in
powoperates on Python numeric objects and additionally supports the three-parameter formpow(base, exp, mod)for efficient modular exponentiation. numpy.powersupports more parameters, such asout,where, andcasting.
- Python's built-in
scipy.stats.poweris a function used to simulate the power of a statistical hypothesis test and is completely different from DolphinDBpow.
Parameters
X and Y is a scalar/vector/matrix.
Returns
A DOUBLE scalar, vector or matrix.
Examples
x=1 2 3;
pow(x,3);
// output: [1,8,27]
pow(3,x);
// output: [3,9,27]
y=4.5 5.5 6.5;
pow(x,y);
// output: [1,45.254834,1262.665039]
pow(y,x);
// output: [4.5,30.25,274.625]
m=1..10$2:5;
m;
| #0 | #1 | #2 | #3 | #4 |
|---|---|---|---|---|
| 1 | 3 | 5 | 7 | 9 |
| 2 | 4 | 6 | 8 | 10 |
typestr(pow(3,4));
// output: DOUBLE
