pyyeti.ytools.max_complex_vector_sum¶
- pyyeti.ytools.max_complex_vector_sum(x, y)[source]¶
Compute maximum complex vector from x and y components
- Parameters:
x, y (complex scalar or 1d array_like) – The x and y complex components to sum. If 1d arrays, each element is independently analyzed.
- Returns:
hypot (complex scalar or 1d ndarray) – The maximum vector sum of the complex vectors x and y
theta (real scalar or 1d ndarray) – The maximizing angle(s)
c (real scalar or 1d ndarray) – The cosine of the maximizing angle(s)
s (real scalar or 1d ndarray) – The sine of the maximizing angle(s)
Notes
The return value hypot is the vector sum:
hypot = cos(theta) * x + sin(theta) * y
where, for each element in x and y, the angle theta maximizes the magnitude of hypot:
abs(hypot)
Examples
>>> import numpy as np >>> from pyyeti import ytools >>> x = 1.0 + 2.0j >>> y = 3.0 + 4.0j >>> h, th, c, s = ytools.max_complex_vector_sum(x, y) >>> h (3.148096...+4.467164...j) >>> th 1.154305... >>> c 0.404553... >>> s 0.914514... >>> with ytools.np_printoptions(precision=6): ... x = [3.0, 1.0 + 2.0j] ... y = [4.0, 3.0 + 4.0j] ... h, th, c, s = ytools.max_complex_vector_sum(x, y) ... print(h) ... print(th) ... print(c) ... print(s) [ 5.000000+0.j 3.148096+4.467164j] [ 0.927295 1.154306] [ 0.6 0.404554] [ 0.8 0.914514]