Source code for naginterfaces.library.examples.sum.convcorr_real_ex
#!/usr/bin/env python3
"``naginterfaces.library.sum.convcorr_real`` Python Example."
# NAG Copyright 2017-2019.
# pylint: disable=invalid-name
from naginterfaces.library import sum as summ
[docs]def main():
"""
Example for :func:`naginterfaces.library.sum.convcorr_real`.
Circular convolution or correlation of two real vectors.
>>> main()
naginterfaces.library.sum.convcorr_real Python Example Results.
Circular convolution of two real vectors.
Convolution:
(2.000000, 2.000000, 2.000000, 2.000000, 2.000000).
"""
print('naginterfaces.library.sum.convcorr_real Python Example Results.')
print('Circular convolution of two real vectors.')
x = [1.0, 1.0, 1.0, 1.0, 1.0]
y = [0.5, 0.5, 0.5, 0.5, 0.0]
job = 1
conv_x = summ.convcorr_real(job, x, y).x
print('Convolution:')
print(
'(' +
', '.join(['{:f}'.format(xi) for xi in conv_x]) +
').'
)
if __name__ == '__main__':
import doctest
import sys
sys.exit(
doctest.testmod(
None, verbose=True, report=False,
optionflags=doctest.REPORT_NDIFF,
).failed
)