Csound Csound-dev Csound-tekno Search About

[Csnd] return imaginary part from an array of complex numbers

Date2018-10-02 12:05
FromMauro Giubileo
Subject[Csnd] return imaginary part from an array of complex numbers

Hi, I know there exists a "c2r" opcode to get only the "real" part from an array arranged in interleaved (real, imaginary) format. But what if I want only the "imaginary" part? No native opcode for that?

Best Regards,
Mauro


Date2018-10-02 12:15
FromAnders Genell
SubjectRe: [Csnd] return imaginary part from an array of complex numbers
Maybe you could use the phs opcode in combination with abs and pol2rect or something to extract it?

Regards,
Anders

2 okt. 2018 kl. 13:05 skrev Mauro Giubileo <mgiubileo@COMPUTERALTAFED.IT>:

Hi, I know there exists a "c2r" opcode to get only the "real" part from an array arranged in interleaved (real, imaginary) format. But what if I want only the "imaginary" part? No native opcode for that?

Best Regards,
Mauro

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-10-02 14:17
FromMauro Giubileo
SubjectRe: [Csnd] return imaginary part from an array of complex numbers

Mmmh... I think it's doable, but I hoped for something much simpler and rapid like:

kRe[] c2r kComplexArray  ; c2r exists :-)
kIm[] c2i kComplexArray  ; c2i doesn't exist :-(

Or maybe, in just one opcode:

kRe[], kIm[] c2ri kComplexArray

I think I can make an UDO that does that, but it woud be nice if it was a native opcode.

Regards,
Mauro

 


Il 2018-10-02 13:15 Anders Genell ha scritto:

 
Maybe you could use the phs opcode in combination with abs and pol2rect or something to extract it?
 
Regards,
Anders

2 okt. 2018 kl. 13:05 skrev Mauro Giubileo <mgiubileo@COMPUTERALTAFED.IT>:

Hi, I know there exists a "c2r" opcode to get only the "real" part from an array arranged in interleaved (real, imaginary) format. But what if I want only the "imaginary" part? No native opcode for that?

Best Regards,
Mauro

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Date2018-10-02 15:43
FromVictor Lazzarini
SubjectRe: [Csnd] return imaginary part from an array of complex numbers
That’s easily done.

But more generally we should have an interleave/deinterleave pair to do this. For
all uses.
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 2 Oct 2018, at 14:17, Mauro Giubileo  wrote:
> 
> Mmmh... I think it's doable, but I hoped for something much simpler and rapid like:
> 
> kRe[] c2r kComplexArray  ; c2r exists :-)
> kIm[] c2i kComplexArray  ; c2i doesn't exist :-(
> 
> Or maybe, in just one opcode:
> 
> kRe[], kIm[] c2ri kComplexArray
> 
> I think I can make an UDO that does that, but it woud be nice if it was a native opcode.
> 
> Regards,
> Mauro
> 
>  
> 
> 
> Il 2018-10-02 13:15 Anders Genell ha scritto:
> 
>>  
>> Maybe you could use the phs opcode in combination with abs and pol2rect or something to extract it?
>>  
>> Regards,
>> Anders
>> 
>> 2 okt. 2018 kl. 13:05 skrev Mauro Giubileo :
>> 
>>> Hi, I know there exists a "c2r" opcode to get only the "real" part from an array arranged in interleaved (real, imaginary) format. But what if I want only the "imaginary" part? No native opcode for that?
>>> 
>>> Best Regards,
>>> Mauro
>>> 
>>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> 
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-10-02 15:51
FromAnders Genell
SubjectRe: [Csnd] return imaginary part from an array of complex numbers
Yes, I agree it would be fitting to have a native opcode for the imaginary part and it would be nicely symmetric to the real part opcode.
But until then something like this might work (untested)? I don't know if you need brackets for kPhs inside the sin expression to clarify its array nature...

kPhs[] phs kComplexArray
kMags[] mags kComplexArray
kImag[] = kMags * sin(kPhs)
 
Regards,
Anders

On Tue, Oct 2, 2018 at 3:17 PM Mauro Giubileo <mgiubileo@computeraltafed.it> wrote:

Mmmh... I think it's doable, but I hoped for something much simpler and rapid like:

kRe[] c2r kComplexArray  ; c2r exists :-)
kIm[] c2i kComplexArray  ; c2i doesn't exist :-(

Or maybe, in just one opcode:

kRe[], kIm[] c2ri kComplexArray

I think I can make an UDO that does that, but it woud be nice if it was a native opcode.

Regards,
Mauro

 


Il 2018-10-02 13:15 Anders Genell ha scritto:

 
Maybe you could use the phs opcode in combination with abs and pol2rect or something to extract it?
 
Regards,
Anders

2 okt. 2018 kl. 13:05 skrev Mauro Giubileo <mgiubileo@COMPUTERALTAFED.IT>:

Hi, I know there exists a "c2r" opcode to get only the "real" part from an array arranged in interleaved (real, imaginary) format. But what if I want only the "imaginary" part? No native opcode for that?

Best Regards,
Mauro

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-10-02 19:19
FromMauro Giubileo
SubjectRe: [Csnd] return imaginary part from an array of complex numbers

Something like:

kCmplx[]     ri2c  kRe[], kIm[]   ; real and imaginary arrays -> interleaved array
kRe[], kIm[] c2ri  kCmplx[]       ; interleaved array -> real and imaginary arrays

Regards,
Mauro
 


Il 2018-10-02 16:43 Victor Lazzarini ha scritto:

That's easily done.

But more generally we should have an interleave/deinterleave pair to do this. For
all uses.
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

On 2 Oct 2018, at 14:17, Mauro Giubileo <mgiubileo@COMPUTERALTAFED.IT> wrote:

Mmmh... I think it's doable, but I hoped for something much simpler and rapid like:

kRe[] c2r kComplexArray  ; c2r exists :-)
kIm[] c2i kComplexArray  ; c2i doesn't exist :-(

Or maybe, in just one opcode:

kRe[], kIm[] c2ri kComplexArray

I think I can make an UDO that does that, but it woud be nice if it was a native opcode.

Regards,
Mauro

 


Il 2018-10-02 13:15 Anders Genell ha scritto:

 
Maybe you could use the phs opcode in combination with abs and pol2rect or something to extract it?
 
Regards,
Anders

2 okt. 2018 kl. 13:05 skrev Mauro Giubileo <mgiubileo@COMPUTERALTAFED.IT>:

Hi, I know there exists a "c2r" opcode to get only the "real" part from an array arranged in interleaved (real, imaginary) format. But what if I want only the "imaginary" part? No native opcode for that?

Best Regards,
Mauro

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-10-02 19:35
FromMauro Giubileo
SubjectRe: [Csnd] return imaginary part from an array of complex numbers

No, there is no need for the [] in the right side of the expression. Your code might work but 'mags' and 'phs' opcodes require the complex array to be in a particular format returned by the rfft opcode.

Regards,
Mauro


Il 2018-10-02 16:51 Anders Genell ha scritto:

Yes, I agree it would be fitting to have a native opcode for the imaginary part and it would be nicely symmetric to the real part opcode.
But until then something like this might work (untested)? I don't know if you need brackets for kPhs inside the sin expression to clarify its array nature...
 
kPhs[] phs kComplexArray
kMags[] mags kComplexArray
kImag[] = kMags * sin(kPhs)
 
Regards,
Anders

On Tue, Oct 2, 2018 at 3:17 PM Mauro Giubileo <mgiubileo@computeraltafed.it> wrote:

Mmmh... I think it's doable, but I hoped for something much simpler and rapid like:

kRe[] c2r kComplexArray  ; c2r exists :-)
kIm[] c2i kComplexArray  ; c2i doesn't exist :-(

Or maybe, in just one opcode:

kRe[], kIm[] c2ri kComplexArray

I think I can make an UDO that does that, but it woud be nice if it was a native opcode.

Regards,
Mauro

 


Il 2018-10-02 13:15 Anders Genell ha scritto:

 
Maybe you could use the phs opcode in combination with abs and pol2rect or something to extract it?
 
Regards,
Anders

2 okt. 2018 kl. 13:05 skrev Mauro Giubileo <mgiubileo@COMPUTERALTAFED.IT>:

Hi, I know there exists a "c2r" opcode to get only the "real" part from an array arranged in interleaved (real, imaginary) format. But what if I want only the "imaginary" part? No native opcode for that?

Best Regards,
Mauro

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-10-02 19:49
FromAnders Genell
SubjectRe: [Csnd] return imaginary part from an array of complex numbers
Ah. I didn’t realize there was a particular format...
Does Csound handle any other kind of complex number format?

Regards,
Anders

2 okt. 2018 kl. 20:35 skrev Mauro Giubileo <mgiubileo@COMPUTERALTAFED.IT>:

No, there is no need for the [] in the right side of the expression. Your code might work but 'mags' and 'phs' opcodes require the complex array to be in a particular format returned by the rfft opcode.

Regards,
Mauro


Il 2018-10-02 16:51 Anders Genell ha scritto:

Yes, I agree it would be fitting to have a native opcode for the imaginary part and it would be nicely symmetric to the real part opcode.
But until then something like this might work (untested)? I don't know if you need brackets for kPhs inside the sin expression to clarify its array nature...
 
kPhs[] phs kComplexArray
kMags[] mags kComplexArray
kImag[] = kMags * sin(kPhs)
 
Regards,
Anders

On Tue, Oct 2, 2018 at 3:17 PM Mauro Giubileo <mgiubileo@computeraltafed.it> wrote:

Mmmh... I think it's doable, but I hoped for something much simpler and rapid like:

kRe[] c2r kComplexArray  ; c2r exists :-)
kIm[] c2i kComplexArray  ; c2i doesn't exist :-(

Or maybe, in just one opcode:

kRe[], kIm[] c2ri kComplexArray

I think I can make an UDO that does that, but it woud be nice if it was a native opcode.

Regards,
Mauro

 


Il 2018-10-02 13:15 Anders Genell ha scritto:

 
Maybe you could use the phs opcode in combination with abs and pol2rect or something to extract it?
 
Regards,
Anders

2 okt. 2018 kl. 13:05 skrev Mauro Giubileo <mgiubileo@COMPUTERALTAFED.IT>:

Hi, I know there exists a "c2r" opcode to get only the "real" part from an array arranged in interleaved (real, imaginary) format. But what if I want only the "imaginary" part? No native opcode for that?

Best Regards,
Mauro

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-10-03 09:01
FromVictor Lazzarini
SubjectRe: [Csnd] return imaginary part from an array of complex numbers
The interleave and deinterleave opcodes are up in git now

k/ivar[] interleave k/ivar1[],k/ivar2[] 
k/ivar1[], k/ivar2[] deinterleave k/ivar[]


========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 2 Oct 2018, at 19:49, Anders Genell  wrote:
> 
> Ah. I didn’t realize there was a particular format...
> Does Csound handle any other kind of complex number format?
> 
> Regards,
> Anders
> 
> 2 okt. 2018 kl. 20:35 skrev Mauro Giubileo :
> 
>> No, there is no need for the [] in the right side of the expression. Your code might work but 'mags' and 'phs' opcodes require the complex array to be in a particular format returned by the rfft opcode.
>> 
>> Regards,
>> Mauro
>> 
>> 
>> 
>> Il 2018-10-02 16:51 Anders Genell ha scritto:
>> 
>>> Yes, I agree it would be fitting to have a native opcode for the imaginary part and it would be nicely symmetric to the real part opcode.
>>> But until then something like this might work (untested)? I don't know if you need brackets for kPhs inside the sin expression to clarify its array nature...
>>>  
>>> kPhs[] phs kComplexArray
>>> kMags[] mags kComplexArray
>>> kImag[] = kMags * sin(kPhs)
>>>  
>>> Regards,
>>> Anders
>>> 
>>> On Tue, Oct 2, 2018 at 3:17 PM Mauro Giubileo  wrote:
>>> Mmmh... I think it's doable, but I hoped for something much simpler and rapid like:
>>> 
>>> kRe[] c2r kComplexArray  ; c2r exists :-)
>>> kIm[] c2i kComplexArray  ; c2i doesn't exist :-(
>>> 
>>> Or maybe, in just one opcode:
>>> 
>>> kRe[], kIm[] c2ri kComplexArray
>>> 
>>> I think I can make an UDO that does that, but it woud be nice if it was a native opcode.
>>> 
>>> Regards,
>>> Mauro
>>> 
>>>  
>>> 
>>> 
>>> Il 2018-10-02 13:15 Anders Genell ha scritto:
>>> 
>>>  
>>> Maybe you could use the phs opcode in combination with abs and pol2rect or something to extract it?
>>>  
>>> Regards,
>>> Anders
>>> 
>>> 2 okt. 2018 kl. 13:05 skrev Mauro Giubileo :
>>> 
>>> Hi, I know there exists a "c2r" opcode to get only the "real" part from an array arranged in interleaved (real, imaginary) format. But what if I want only the "imaginary" part? No native opcode for that?
>>> 
>>> Best Regards,
>>> Mauro
>>> 
>>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>> 
>>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-10-03 11:07
FromMauro Giubileo
SubjectRe: [Csnd] return imaginary part from an array of complex numbers

Very nice, thanks! :-)

Regards,
Mauro


Il 2018-10-03 10:01 Victor Lazzarini ha scritto:

The interleave and deinterleave opcodes are up in git now

k/ivar[] interleave k/ivar1[],k/ivar2[]
k/ivar1[], k/ivar2[] deinterleave k/ivar[]


========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952

On 2 Oct 2018, at 19:49, Anders Genell <anders.genell@gmail.com> wrote:

Ah. I didn't realize there was a particular format...
Does Csound handle any other kind of complex number format?

Regards,
Anders

2 okt. 2018 kl. 20:35 skrev Mauro Giubileo <mgiubileo@COMPUTERALTAFED.IT>:

No, there is no need for the [] in the right side of the expression. Your code might work but 'mags' and 'phs' opcodes require the complex array to be in a particular format returned by the rfft opcode.

Regards,
Mauro



Il 2018-10-02 16:51 Anders Genell ha scritto:

Yes, I agree it would be fitting to have a native opcode for the imaginary part and it would be nicely symmetric to the real part opcode.
But until then something like this might work (untested)? I don't know if you need brackets for kPhs inside the sin expression to clarify its array nature...
 
kPhs[] phs kComplexArray
kMags[] mags kComplexArray
kImag[] = kMags * sin(kPhs)
 
Regards,
Anders

On Tue, Oct 2, 2018 at 3:17 PM Mauro Giubileo <mgiubileo@computeraltafed.it> wrote:
Mmmh... I think it's doable, but I hoped for something much simpler and rapid like:

kRe[] c2r kComplexArray  ; c2r exists :-)
kIm[] c2i kComplexArray  ; c2i doesn't exist :-(

Or maybe, in just one opcode:

kRe[], kIm[] c2ri kComplexArray

I think I can make an UDO that does that, but it woud be nice if it was a native opcode.

Regards,
Mauro

 


Il 2018-10-02 13:15 Anders Genell ha scritto:

 
Maybe you could use the phs opcode in combination with abs and pol2rect or something to extract it?
 
Regards,
Anders

2 okt. 2018 kl. 13:05 skrev Mauro Giubileo <mgiubileo@COMPUTERALTAFED.IT>:

Hi, I know there exists a "c2r" opcode to get only the "real" part from an array arranged in interleaved (real, imaginary) format. But what if I want only the "imaginary" part? No native opcode for that?

Best Regards,
Mauro

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here