# Volk atan

**URL:** <https://www.ruby-forum.com/t/volk-atan/234360>\
**Category:** GNU Radio\
**Created:** [February 26, 2015, 3:27pm UTC](https://www.ruby-forum.com/t/volk-atan/234360 "2015-02-26T15:27:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [February 26, 2015, 3:27pm UTC](https://www.ruby-forum.com/t/volk-atan/234360/1 "2015-02-26T15:27:55Z")

</div>

Hi everybody,

I’m using “volk\_32fc\_s32f\_atan2\_32f\_a” to compute phase of signal. 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?

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.

Best,  
Mostafa

---

<div class="post-metadata">

**Author:** ![mostafa\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5e9695/32.png) [@mostafa\_a](https://www.ruby-forum.com/u/mostafa_a)\
**Post date:** [February 26, 2015, 10:06pm UTC](https://www.ruby-forum.com/t/volk-atan/234360/2 "2015-02-26T22:06:55Z")

</div>

Hi Mostafa,

On Thu, Feb 26, 2015 at 8:26 AM, Mostafa A.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](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
