Hi, list, I put together a few abstractions I wanted to share. These are just basic operations for complex arithmetic (I left out conjugate, addition, and subtraction, since I thought they were too basic). cmult~ -- multiplies two complex signals; inlets are ordered from left to right: sig1-real, sig1-imaginary, sig2-real, sig2-imaginary (this is consistent for all the rest too) conj_mult~ -- multiplies sig1 by the complex conjugate of sig2 cnorm~ -- computes sqrt(real^2+imag^2), Would this be more efficient using expr? cnormsq~ -- computes real^2+imag^2. Same question as cnorm~ cdiv~ -- divides sig1 by sig2. Wherever sig2 is zero, the result is zero rather than undefined. It is still not advised to use cdiv~ unless you have a signal that you know has all of its frequencies cdiv_thresh~ -- accepts a threshold argument, and divides sig1 by sig2 whenever the complex norm squared of sig2 is greater than the threshold. Returns zero otherwise. Later, Chuck
Great work! I'd suggest modeling fbar's approach and making a *-help.pd file for either each of them, or the whole group at least.
Also, even if they seem trivial, if you are making this library of abstractions for something like CVS (which would be GREAT), it would be nice to have the conjugate, addition, and subtraction also.
Thanks for sharing this!
~Kyle
On 2/24/07, Charles Henry czhenry@gmail.com wrote:
Hi, list, I put together a few abstractions I wanted to share. These are just basic operations for complex arithmetic (I left out conjugate, addition, and subtraction, since I thought they were too basic). cmult~ -- multiplies two complex signals; inlets are ordered from left to right: sig1-real, sig1-imaginary, sig2-real, sig2-imaginary (this is consistent for all the rest too) conj_mult~ -- multiplies sig1 by the complex conjugate of sig2 cnorm~ -- computes sqrt(real^2+imag^2), Would this be more efficient using expr? cnormsq~ -- computes real^2+imag^2. Same question as cnorm~ cdiv~ -- divides sig1 by sig2. Wherever sig2 is zero, the result is zero rather than undefined. It is still not advised to use cdiv~ unless you have a signal that you know has all of its frequencies cdiv_thresh~ -- accepts a threshold argument, and divides sig1 by sig2 whenever the complex norm squared of sig2 is greater than the threshold. Returns zero otherwise. Later, Chuck
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Good stuff, thanks for solving these common complex operations as useful abstractions Chuck.
Just to add a word to the previous discussion, I picked up a little paperback called "Imagining Numbers" by Barry Mazur which is a great idiots introduction to number theory, cartesian and polar forms and the basis for complex numbers, all done with geometry, diagrams and hardly any equations. There's plenty of dinner party conversation as a history mathematicians like Girolamo Cardano, Nicolas Chuquet, Dal Faro and Bombelli which explains the context to needing imaginary numbers to solve problems. When you understand why ordinary cardinal numbers can't solve certain problems it makes a whole lot more sense why i was invented. I can reccomend this to any non-mathematician who wants a gentle intro before getting stuck into something more formal.
a.
On Sat, 24 Feb 2007 22:50:41 -0600 "Charles Henry" czhenry@gmail.com wrote:
Hi, list, I put together a few abstractions I wanted to share. These are just basic operations for complex arithmetic (I left out conjugate, addition, and subtraction, since I thought they were too basic). cmult~ -- multiplies two complex signals; inlets are ordered from left to right: sig1-real, sig1-imaginary, sig2-real, sig2-imaginary (this is consistent for all the rest too) conj_mult~ -- multiplies sig1 by the complex conjugate of sig2 cnorm~ -- computes sqrt(real^2+imag^2), Would this be more efficient using expr? cnormsq~ -- computes real^2+imag^2. Same question as cnorm~ cdiv~ -- divides sig1 by sig2. Wherever sig2 is zero, the result is zero rather than undefined. It is still not advised to use cdiv~ unless you have a signal that you know has all of its frequencies cdiv_thresh~ -- accepts a threshold argument, and divides sig1 by sig2 whenever the complex norm squared of sig2 is greater than the threshold. Returns zero otherwise. Later, Chuck