add

Syntax

add(X, Y)

Parameters

X and Y is a scalar/pair/vector/matrix. If X or Y is a pair/vector/matrix, the other is a scalar or a pair/vector/matrix of the same size.

Comparison of the functionality and implementation of DolphinDB add versus numpy.add and pandas Series.add / DataFrame.add:

Comparison Dimension DolphinDB add numpy.add pandas add
Core functionality Supports element-wise addition for scalars, vectors, matrices, etc. Supports scalars and ndarrays, follows NumPy broadcasting rules Index-aligned addition, supports scalar broadcasting
Index alignment Index sequences and index matrices can be aligned by index Not supported Can specify alignment by index or columns
Null/missing value handling NULL propagation (NULL + any value = NULL); can specify fill value using withNullFill function NaN propagation (NaN + any number = NaN) Automatically handled; fill value can be specified via fill_value

Details

Return the element-by-element sum of X and Y.

Examples

add(3,2)
// output: 5

1:2+6
// output: 7:8

1:2+3:4
// output: 4:6

3+1..3
// output: [4,5,6]

add(1..3, 4..6)
// output: [5,7,9]

(1..3).add(4..6)
// output: [5,7,9]

x=reshape(1..6, 3:2)
x
0 1
1 4
2 5
3 6
x+1.5
0 1
2.5 5.5
3.5 6.5
4.5 7.5
y=reshape(5..10, 3:2)
y
0 1
5 8
6 9
7 10
x+y
0 1
6 12
8 14
10 16

Refer to "+" operator

Related function: sub