@@ -384,8 +384,11 @@ def convolve(a, v, mode="full", method="auto"):
384
384
probability theory, the sum of two independent random variables is
385
385
distributed according to the convolution of their individual
386
386
distributions.
387
+
387
388
If `v` is longer than `a`, the arrays are swapped before computation.
389
+
388
390
For full documentation refer to :obj:`numpy.convolve`.
391
+
389
392
Parameters
390
393
----------
391
394
a : {dpnp.ndarray, usm_ndarray}
@@ -407,6 +410,8 @@ def convolve(a, v, mode="full", method="auto"):
407
410
``max(M, N) - min(M, N) + 1``. The convolution product is only given
408
411
for points where the signals overlap completely. Values outside
409
412
the signal boundary have no effect.
413
+
414
+ Default: ``'full'``.
410
415
method : {'auto', 'direct', 'fft'}, optional
411
416
'direct':
412
417
The convolution is determined directly from sums.
@@ -416,14 +421,18 @@ def convolve(a, v, mode="full", method="auto"):
416
421
'auto':
417
422
Automatically chooses direct or Fourier method based on
418
423
an estimate of which is faster.
424
+
419
425
Note: Use of the FFT convolution on input containing NAN or INF
420
426
will lead to the entire output being NAN or INF.
421
427
Use method='direct' when your input contains NAN or INF values.
428
+
422
429
Default: ``'auto'``.
430
+
423
431
Returns
424
432
-------
425
433
out : ndarray
426
434
Discrete, linear convolution of `a` and `v`.
435
+
427
436
See Also
428
437
--------
429
438
:obj:`dpnp.correlate` : Cross-correlation of two 1-dimensional sequences.
@@ -437,26 +446,33 @@ def convolve(a, v, mode="full", method="auto"):
437
446
circular convolution). Since multiplication is more efficient (faster)
438
447
than convolution, the function implements two approaches - direct and fft
439
448
which are regulated by the keyword `method`.
449
+
440
450
References
441
451
----------
442
452
.. [1] Uncyclopedia, "Convolution",
443
453
https://en.wikipedia.org/wiki/Convolution
454
+
444
455
Examples
445
456
--------
446
457
Note how the convolution operator flips the second array
447
458
before "sliding" the two across one another:
459
+
448
460
>>> import dpnp as np
449
461
>>> a = np.array([1, 2, 3], dtype=np.float32)
450
462
>>> v = np.array([0, 1, 0.5], dtype=np.float32)
451
463
>>> np.convolve(a, v)
464
+
452
465
array([0. , 1. , 2.5, 4. , 1.5], dtype=float32)
453
466
Only return the middle values of the convolution.
454
467
Contains boundary effects, where zeros are taken
455
468
into account:
469
+
456
470
>>> np.convolve(a, v, 'same')
471
+
457
472
array([1. , 2.5, 4. ], dtype=float32)
458
473
The two arrays are of the same length, so there
459
474
is only one position where they completely overlap:
475
+
460
476
>>> np.convolve(a, v, 'valid')
461
477
array([2.5], dtype=float32)
462
478
"""
0 commit comments