[prev in list] [next in list] [prev in thread] [next in thread]
List: gnuradio-discuss
Subject: Re: [Discuss-gnuradio] volk atan
From: "West, Nathan" <natw () ostatemail ! okstate ! edu>
Date: 2015-02-26 21:05:23
Message-ID: CALkxiLJeg9u01R-dYowzaWLj9B0Q7vNekSVxowkC26w-J0H-BA () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi Mostafa,
On Thu, Feb 26, 2015 at 8:26 AM, Mostafa Alizadeh <m.alizadehee@gmail.com>
wrote:
> Hi everybody,
>
> I'm using "volk_32fc_s32f_atan2_32f_a" to compute phase of signal.
>
If you are calling the _a version make sure that you *know* your buffer is
aligned because you have allocated it yourself or have done an alignment
check. Otherwise it is best to just call the dispatcher,
volk_32fc_s32f_atan2_32f, and it will do the alignment check for you.
> It's important to know: what is the output phase interval of this
> function? Is it within [-pi/2,pi/2] as an standard atan function?
>
It's the same as the standard atan2f (from your C implementations math.h)
which is a 2-argument atan. atan2's usually return [-pi,pi] which is also
the case with volk_32fc_s32f_atan2_32f. You can verify this yourself with a
sample that follows.
>
> This shows its importance when we're dealing with quadrature modulations
> when you need to wrap the phase between [0,2pi] interval instead of
> [-pi/2,pi/2].
>
> As I see the output of this function, it also has the phase greater than
> pi/2, so I guess it automatically wrap the phase. I didn't see any hint
> about this on the comments, so to be sure, I asked this.
>
Good point. It's worth documenting that the output is [-pi, pi]. I'll add
that in. Thanks for the suggestion!
>
> Best,
> Mostafa
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>
#include <stdio.h>
#include <volk/volk.h>
int main()
{
int N = 10;
unsigned int alignment = volk_get_alignment();
lv_32fc_t* in = (lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment);
float* out = (float*)volk_malloc(sizeof(float)*N, alignment);
float scale = 1.f; // we want unit circle
float delta = 2.f*M_PI/(float)N;
for(unsigned int ii = 0; ii < N; ++ii){
// Generate points around the unit circle
float real = std::cos((float)ii * delta);
float imag = std::sin((float)ii * delta);
in[ii] = lv_cmake(real, imag);
}
volk_32fc_s32f_atan2_32f(out, in, scale, N);
for(unsigned int ii = 0; ii < N; ++ii){
printf("atan2(%1.2f, %1.2f) = %1.2f\n",
lv_cimag(in[ii]), lv_creal(in[ii]), out[ii]);
}
volk_free(in);
volk_free(out);
return 0;
}
Nathan
[Attachment #5 (text/html)]
<div dir="ltr">Hi Mostafa,<br><div><br>On Thu, Feb 26, 2015 at 8:26 AM, Mostafa \
Alizadeh <span dir="ltr"><<a href="mailto:m.alizadehee@gmail.com" \
target="_blank">m.alizadehee@gmail.com</a>></span> wrote:<br><div \
class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" \
style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi everybody, \
<div><br></div><div>I'm using "volk_32fc_s32f_atan2_32f_a" to compute \
phase of signal.</div></div></blockquote><div>If you are calling the _a version make \
sure that you *know* your buffer is aligned because you have allocated it yourself or \
have done an alignment check. Otherwise it is best to just call the dispatcher, \
volk_32fc_s32f_atan2_32f, and it will do the alignment check for you. <br></div><div> \
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px \
solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div> It's important to \
know: what is the output phase interval of this function? Is it within [-pi/2,pi/2] \
as an standard atan function?</div></div></blockquote><div><br></div><div>It's \
the same as the standard atan2f (from your C implementations math.h) which is a \
2-argument atan. atan2's usually return [-pi,pi] which is also the case with \
volk_32fc_s32f_atan2_32f. You can verify this yourself with a sample that \
follows.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px \
0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div \
dir="ltr"><div><br></div><div>This shows its importance when we're dealing with \
quadrature modulations when you need to wrap the phase between [0,2pi] interval \
instead of [-pi/2,pi/2].</div><div><br></div><div>As I see the output of this \
function, it also has the phase greater than pi/2, so I guess it automatically wrap \
the phase. I didn't see any hint about this on the comments, so to be sure, I \
asked this. </div></div></blockquote><div><br></div><div>Good point. It's worth \
documenting that the output is [-pi, pi]. I'll add that in. Thanks for the \
suggestion!<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px \
0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div \
dir="ltr"><div><br></div><div>Best, </div><span class=""><font \
color="#888888"><div>Mostafa </div></font></span></div> \
<br>_______________________________________________<br> Discuss-gnuradio mailing \
list<br> <a href="mailto:Discuss-gnuradio@gnu.org">Discuss-gnuradio@gnu.org</a><br>
<a href="https://lists.gnu.org/mailman/listinfo/discuss-gnuradio" \
target="_blank">https://lists.gnu.org/mailman/listinfo/discuss-gnuradio</a><br> \
<br></blockquote><div><br>#include <stdio.h><br>#include \
<volk/volk.h><br><br>int main()<br>{<br> int N = 10;<br> unsigned int \
alignment = volk_get_alignment();<br> lv_32fc_t* in = \
(lv_32fc_t*)volk_malloc(sizeof(lv_32fc_t)*N, alignment);<br> float* out = \
(float*)volk_malloc(sizeof(float)*N, alignment);<br> float scale = 1.f; // we \
want unit circle<br><br> float delta = 2.f*M_PI/(float)N;<br> for(unsigned \
int ii = 0; ii < N; ++ii){<br> // Generate points around the unit \
circle<br> float real = std::cos((float)ii * delta);<br> \
float imag = std::sin((float)ii * delta);<br> in[ii] = lv_cmake(real, \
imag);<br> }<br><br> volk_32fc_s32f_atan2_32f(out, in, scale, N);<br><br> \
for(unsigned int ii = 0; ii < N; ++ii){<br> printf("atan2(%1.2f, \
%1.2f) = %1.2f\n",<br> lv_cimag(in[ii]), lv_creal(in[ii]), \
out[ii]);<br> }<br><br> volk_free(in);<br> volk_free(out);<br> return \
0;<br>} <br></div></div><br><br></div><div \
class="gmail_extra">Nathan<br></div></div></div>
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic