discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] A lot confused by volk_32f_cos_32f()


From: Dennis Glatting
Subject: [Discuss-gnuradio] A lot confused by volk_32f_cos_32f()
Date: Fri, 15 Jan 2016 14:20:06 -0800

I am confused by this function because the output DOES NOT match
::cos() as I believe is demonstrated in the web page:

        http://libvolk.org/doxygen/volk_32f_cos_32f.html

I /think/ I am doing the same thing as the web page. Regardless, my
code (below) output is the following with sign mismatches at i=4 and
i=14:


address@hidden:~/gr-acars-code/3.7.5/lib$ ./a.out 
Using Volk machine: avx_64_mmx_orc
i=0, input=0, volk=1, cos()=1
i=1, input=0.314159, volk=0.951056, cos()=0.951057
i=2, input=0.628319, volk=0.809017, cos()=0.809017
i=3, input=0.942478, volk=0.587785, cos()=0.587785
i=4, input=1.25664, volk=-0.309017, cos()=0.309017
i=5, input=1.5708, volk=-1.19209e-07, cos()=-4.37114e-08
i=6, input=1.88496, volk=-0.309017, cos()=-0.309017
i=7, input=2.19911, volk=-0.587785, cos()=-0.587785
i=8, input=2.51327, volk=-0.809017, cos()=-0.809017
i=9, input=2.82743, volk=-0.951057, cos()=-0.951057
i=10, input=3.14159, volk=-1, cos()=-1
i=11, input=3.45575, volk=-0.951056, cos()=-0.951057
i=12, input=3.76991, volk=-0.809017, cos()=-0.809017
i=13, input=4.08407, volk=-0.587785, cos()=-0.587785
i=14, input=4.39823, volk=0.309017, cos()=-0.309017
i=15, input=4.71239, volk=2.38419e-07, cos()=1.19249e-08
i=16, input=5.02655, volk=0.309017, cos()=0.309017
i=17, input=5.34071, volk=0.587785, cos()=0.587785
i=18, input=5.65487, volk=0.809017, cos()=0.809017
i=19, input=5.96903, volk=0.951057, cos()=0.951057


I am using:

address@hidden:~/gr-acars-code/3.7.5/lib$ gnuradio-companion  -
-version
GNU Radio Companion 3.7.10git-31-gb17bcb88

This program is part of GNU Radio
GRC comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it.


On:

address@hidden:~/gr-acars-code/3.7.5/lib$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 15.10
Release:        15.10
Codename:       wily


With compiler:

gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2) 


Here's how I compile my code:

    c++ -std=c++11 -O volk_test.cc -lvolk

 
And, of course, the code:

#include <iostream>
#include <memory>

extern "C" {

#include <assert.h>

}

#include <volk/volk.h>


#define PPP 20

int
main( void ) {

  std::unique_ptr<float,std::function<void(float*)>>
    points2400((float*)volk_malloc( sizeof(float*)*( PPP + 1 ),
                                    volk_get_alignment()),
               [](float* p) {
                 if( p )
                   volk_free((void*)p );
               });
  assert( points2400.get());

  std::unique_ptr<float,std::function<void(float*)>>
    oBuf((float*)volk_malloc( sizeof(float*)*( PPP + 1 ),
                              volk_get_alignment()),
         [](float* p) {
           if( p )
             volk_free((void*)p );
               });
  assert( oBuf.get());
  
  for( int i = 0; i < PPP; ++i ) {

    const float ii = i;
    
    points2400.get()[i] = ii * ( 2400.0 / 48000.0 ) * ( 2.0 * M_PI );
    
  }

  volk_32f_cos_32f( oBuf.get(), points2400.get(), PPP );

  for( int i = 0; i < PPP; ++i )
    std::cout << "i=" << i
              << ", input=" << points2400.get()[i]
              << ", volk=" << oBuf.get()[i]
              << ", cos()=" << ::cos(points2400.get()[i])
              <<std::endl;
  
  
  return 0;

}







reply via email to

[Prev in Thread] Current Thread [Next in Thread]