Armadillo Related Gnuraduradio Config

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

C++ Prototype

mwArray toeplitz(const mwArray &c, const mwArray &r);


mwArray toeplitz(const mwArray &r);
C++ Syntax
#include "matlab.hpp"

mwArray c, r; // Input argument(s)


mwArray T; // Return value

T = toeplitz(c,r);
T = toeplitz(r);

Hey Marcus,

I added the following lines to my CMakeLists.txt, following from


what gr-specest had:
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
find_package(Armadillo)
include(Armadillo)

And when i run 'make' it results in:


-- A library with BLAS API found.
-- A library with BLAS API found.
-- A library with LAPACK API found.
CMake Error at CMakeLists.txt:125 (include):
include could not find load file:

Armadillo
(The other lines are just the standard outputs in the console)
Line 125 is include(Armadillo). I guess thats where error is,
although pybombs tells me armadillo is installed. Is there a way to
manually link it?

Thanks,
Rich

category: baseline
depends:
- blas
- lapack
inherit: cmake
satisfy:
deb: libarmadillo-dev
rpm: armadillo-devel
port: armadillo
source: wget+http://sourceforge.net/projects/arma/files/
armadillo-8.200.2.tar.xz
vars:
config_opt: ' -DINSTALL_LIB_DIR=$prefix/lib '
https://www.youtube.com/watch?v=8Wzb1mgZ0EE

I added the following lines to my CMakeLists.txt, following from


what gr-specest had:
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
find_package(Armadillo)
include(Armadillo)

And when i run 'make' it results in:


-- A library with BLAS API found.
-- A library with BLAS API found.
-- A library with LAPACK API found.
CMake Error at CMakeLists.txt:125 (include):
include could not find load file:

Armadillo
(The other lines are just the standard outputs in the console)
Line 125 is include(Armadillo). I guess thats where error is,
although pybombs tells me armadillo is installed. Is there a way to
manually link it?

Thanks,
Rich

####################################################################
####
# Find specest build dependencies
####################################################################
####
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
find_package(Armadillo)
find_package(FFTW3f)
include(Armadillo)
IF (ARMADILLO_FOUND)
MESSAGE("-- Found Armadillo, building MUSIC")
ELSE(ARMADILLO_FOUND)
MESSAGE("-- As armadillo wasn't found, the MUSIC algorithm
will not be built")
ENDIF(ARMADILLO_FOUND)

set(GR_REQUIRED_MODULES RUNTIME BLOCKS FILTER FFT)


find_package(Gnuradio 3.7.0)
# Not sure if we still need this
#IF(UNIX AND ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8"))
#LIST(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit
fix
#SET(LIB_POSTFIX 64)
#ENDIF(UNIX AND ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8"))

####################################################################
####
# Setup the include and linker paths
####################################################################
####
include_directories(
${CMAKE_SOURCE_DIR}/lib
${CMAKE_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/lib
${CMAKE_BINARY_DIR}/include
${Boost_INCLUDE_DIRS}
${CPPUNIT_INCLUDE_DIRS}
${GNURADIO_ALL_INCLUDE_DIRS}
${FFTW3F_INCLUDE_DIRS}
)

link_directories(
${Boost_LIBRARY_DIRS}
${CPPUNIT_LIBRARY_DIRS}
${GNURADIO_RUNTIME_LIBRARY_DIRS}
${GNURADIO_BLOCKS_LIBRARY_DIRS}
${GNURADIO_FILTER_LIBRARY_DIRS}
${GNURADIO_FFT_LIBRARY_DIRS}
)

Howto build:
~~~~~~~~~~~~
In order to sucessfully build the gr-specest modules you will need:
* cmake > 2.8
* swig
* libgnuradio-core
* libuhd
* gfortran (others might work as well, not tested)
* liblapack-dev
* libblas-dev

A note on Fortran: The fort77 compiler does *not* work here.


However, if
you have both a current gfortran version and the old fort77
installed, it
might happen that CMake detects the wrong version. Either specify
the
compiler manually or delete the old Fortran compiler.

After checking out the code from the repository, change to the gr-
specest
directory. If you want to build with a different compiler such as
clang
you might have to do something like:

export CXX=clang++
export CC=clang

before.

Create a new directory e.g. 'build' to do an out of source build:

mkdir build
cd build
cmake ../
make
make test # optional
make install # might need a 'sudo' depending on your installation
directory

For more information refer to the cmake documentation.

Howto add your own blocks to the GNU Radio Spectral Estimation
Toolbox:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
* Use gr_modtool add for C++ blocks or append '-l python' for Python
blocks.

Adding a new C++ file that does not depend on Armadillo:


--------------------------------------------------------
* As stated above, use gr_modtool as it handles all the block
related build system stuff for you.
* If you want to add additional C++ files, add them in the
CMakeLists.txt files in the include and lib folders.

Adding a new C++ file that does depend on Armadillo:


-----------------------------------------------------
* For now, don't do it, as we're trying to get rid of the dependency
sooner or later

Adding a new Fortran file:


--------------------------
* As stated above, Fortran code goes into lib/
* Up to now we're wrapping the fortran code into specesti_
implementation blocks
so we don't have unittests to directly test the fortran code
* Your code goes into specesti_{c,z,f,d}yourblock.f90
* To include your files in the buildsystem add them to the file
lib/CMakeLists.txt by editing the following variables:
* F_SRCS (Sourcecode)

Adding a new Python file:


--------------------------
* As stated above, gr_modtool handles this for blocks.
* If you want to add other Python files, put them in the python
folder and add the files in the CMakeLists.txt there.

Swig integration:
-----------------
* Handled by gr_modtool for blocks in the swig folder. Other files
go there as well, please
refer to the SWIG documentation for details on how to do it.

Enjoy, and please report any bugs or improvements to:


felix dot wunsch at kit dot edu

CMAKEFILE>TXT in include header

####################################################################
####
# Install public header files
####################################################################
####
if(ARMADILLO_FOUND)
set(CXX_ARMADILLO_HDRS
correst_algo.h
music_armadillo_algo.h
music_vcf.h
music.h
music_spectrum_vcf.h
)
else()
set(CXX_ARMADILLO_HDRS)
endif()
install(FILES
api.h
reciprocal_ff.h
pad_vector.h
stream_to_vector_overlap.h
moving_average_vff.h
adaptiveweighting_vff.h
arfcov_algo.h
arfcov_vcc.h
fcov.h
arfmcov_algo.h
arfmcov_vcc.h
fmcov.h
arburg_algo.h
arburg_vcc.h
burg.h
welch.h
esprit_algo.h
esprit_fortran_algo.h
esprit_vcf.h
esprit_spectrum_vcf.h
esprit.h
welchsp.h
cyclo_fam_calcspectrum_algo.h
cyclo_fam_calcspectrum_vcf.h
cyclo_fam.h
music_fortran_algo.h
music_algo.h
${CXX_ARMADILLO_HDRS}
DESTINATION include/specest
)

CMAKELIST.txt in lib

####################################################################
####
# Setup library
####################################################################
####
include(GrPlatform) #define LIB_SUFFIX

####################################################################
####
# Fortran lib
####################################################################
####
add_library(gnuradio-specest-fortran SHARED
zcorrest_algo.f90
zesprit_common_algo.f90
zesprit_algo.f90
zesprit_spectrum_algo.f90
zmusic_common_algo.f90
zmusic_spectrum_algo.f90
zmusic_algo.f90
)
target_link_libraries(gnuradio-specest-fortran ${LAPACK_LIBRARIES} $
{BLAS_LIBRARIES})

####################################################################
####
# Configure Armadillo dependency
####################################################################
####
if(ARMADILLO_FOUND)
set(CXX_ARMADILLO_SRCS
correst_algo.cc
music_armadillo_algo.cc
music_vcf_impl.cc
music_impl.cc
music_spectrum_vcf_impl.cc
)
else()
set(CXX_ARMADILLO_SRCS)
set(ARMADILLO_LIBRARIES)
endif()

####################################################################
####
# Main library
####################################################################
####
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})
list(APPEND specest_sources
reciprocal_ff_impl.cc
pad_vector_impl.cc
stream_to_vector_overlap_impl.cc
moving_average_vff_impl.cc
adaptiveweighting_vff_impl.cc
arfcov_algo.cc
arfcov_vcc_impl.cc
fcov_impl.cc
arfmcov_algo.cc
arfmcov_vcc_impl.cc
fmcov_impl.cc
arburg_algo.cc
arburg_vcc_impl.cc
burg_impl.cc
welch_impl.cc
esprit_fortran_algo.cc
esprit_vcf_impl.cc
esprit_spectrum_vcf_impl.cc
esprit_impl.cc
music_fortran_algo.cc
welchsp_impl.cc
cyclo_fam_calcspectrum_algo.cc
cyclo_fam_calcspectrum_vcf_impl.cc
cyclo_fam_impl.cc
${CXX_ARMADILLO_SRCS}
)

add_library(gnuradio-specest SHARED ${specest_sources})


target_link_libraries(gnuradio-specest gnuradio-specest-fortran
${ARMADILLO_LIBRARIES}
${Boost_LIBRARIES}
${GNURADIO_RUNTIME_LIBRARIES}
${GNURADIO_BLOCKS_LIBRARIES}
${GNURADIO_FILTER_LIBRARIES}
${GNURADIO_FFT_LIBRARIES}
${FFTW3F_LIBRARIES}
)
set_target_properties(gnuradio-specest PROPERTIES DEFINE_SYMBOL
"gnuradio_specest_EXPORTS")

####################################################################
####
# Install built library files
####################################################################
####
install(TARGETS gnuradio-specest gnuradio-specest-fortran
LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file
ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file
RUNTIME DESTINATION bin # .dll file
)

####################################################################
####
# Find gnuradio build dependencies
####################################################################
####
find_package(Armadillo "7.300")
if (ARMADILLO_FOUND)
include_directories(${ARMADILLO_INCLUDE_DIRS})
message(STATUS "Armadillo found")
else ()
message(FATAL_ERROR "Armadillo required to compile doa")
endif ()
find_package(CppUnit)
find_package(Doxygen)

# Search for GNU Radio and its components and versions. Add any
# components required to the list of GR_REQUIRED_COMPONENTS (in all
# caps such as FILTER or FFT) and change the version to the minimum
# API compatible version required.
set(GR_REQUIRED_COMPONENTS RUNTIME)
find_package(Gnuradio "3.7.2" REQUIRED)
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)

if(NOT CPPUNIT_FOUND)
message(FATAL_ERROR "CppUnit required to compile doa")
endif()

- Download, compile, and install the Armadillo linear algebra


library

-$ wget http://sourceforge.net/projects/arma/files/
armadillo-3.2.3.tar.gz
-$ tar xvfz armadillo-3.2.3.tar.gz
-$ cd armadillo-3.2.3
+$ wget http://sourceforge.net/projects/arma/files/
armadillo-3.4.3.tar.gz
+$ tar xvfz armadillo-3.4.3.tar.gz
+$ cd armadillo-3.4.3
$ cmake .
$ make
$ sudo make install
@@ -89,15 +89,15 @@

nstalling Armadillo

This guide will show you step-by-step how to install Armadillo, the
C++ linear algebra library, in your home directory.
Installation at the datalab
Armadillo, LAPACK and BLAS is already installed. Just remember to
link to these. In Qt Creator, just add the following line to
your .pro file:
LIBS += -llapack -lblas -larmadillo

If not present already, install LAPACK, Boost and BLAS with


sudo apt-get install liblapack-dev
sudo apt-get install libblas-dev
sudo apt-get install libboost-dev
Install Armadillo using
sudo apt-get install libarmadillo-dev
You're done installing Armadillo!

You might also like