discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: Library for matrix operations? (eigenvalues, pseudoinverse)


From: Laura Arjona
Subject: Re: Library for matrix operations? (eigenvalues, pseudoinverse)
Date: Thu, 6 Feb 2020 10:16:22 -0800

Thank you again for your responses.

I installed Armadillo, BLAS, and LAPACK. Armadillo seems to be working, since I can do basic operations with matrices using it

Whenever I try to use the pinv function inside  my OOT block, I get the error :  AttributeError: 'module' object has no attribute 'cca_update'
I just comment the line about the pinv, and no error appears.

I have added the packages in the CMakelist, and I made sure that the libraries were added in the armadillo file arma_config.hpp.
See details below.
Thank you!


cca_update_impl::general_work (int noutput_items,
                       gr_vector_int &ninput_items,
                       gr_vector_const_void_star &input_items,
                       gr_vector_void_star &output_items)
    {
      .......
      .............

      arma::mat mat_GT;
      arma::mat mat_NS;
      arma::mat Cx;
      arma::mat Cy;
      arma::mat Cxy;
      arma::sp_mat A;

     Cx = mat_NS*mat_NS.t();
     Cy = mat_GT*mat_GT.t();
     Cxy = mat_NS*mat_GT.t();
    A = pinv(Cx)*Cxy*pinv(Cy)*Cxy.t()


}


CMakeLists.txt file in my OOT Module
########################################################################
# Find gnuradio build dependencies
########################################################################
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)
message(STATUS "LAPACK libraries: ${LAPACK_LIBRARIES}")
message(STATUS "BLAS libraries: ${BLAS_LIBRARIES}")
find_package(Armadillo)

output of cmake ../
- A library with BLAS API found.
-- A library with BLAS API found.
-- A library with LAPACK API found.
-- LAPACK libraries: /usr/lib/x86_64-linux-gnu/liblapack.so;/usr/lib/x86_64-linux-gnu/libf77blas.so;/usr/lib/x86_64-linux-gnu/libatlas.so
-- BLAS libraries: /usr/lib/x86_64-linux-gnu/libf77blas.so;/usr/lib/x86_64-linux-gnu/libatlas.so
-- Found Armadillo, building MUSIC


arma_config.hpp file
CMakeLists.txt file in my OOT Module
#if !defined(ARMA_USE_LAPACK)
#define ARMA_USE_LAPACK
//// Comment out the above line if you don't have LAPACK or a high-speed replacement for LAPACK,
//// such as Intel MKL, AMD ACML, or the Accelerate framework.
//// LAPACK is required for matrix decompositions (eg. SVD) and matrix inverse.
#endif

#if !defined(ARMA_USE_BLAS)
#define ARMA_USE_BLAS
//// Comment out the above line if you don't have BLAS or a high-speed replacement for BLAS,
//// such as OpenBLAS, GotoBLAS, Intel MKL, AMD ACML, or the Accelerate framework.
//// BLAS is used for matrix multiplication.
//// Without BLAS, matrix multiplication will still work, but might be slower.
#endif

On Fri, Jan 17, 2020 at 3:18 PM Laura Arjona <address@hidden> wrote:
Thank you all so much for the detailed responses, really appreciate it.

To give some background, my application is to build a CCA  (canonical correlation analysis)  filter as an OOT C++ block. And the inputs are two digital signals (represented as matrices) - one of them I receive and decode real time with my SDR (using usrp n210 with ubuntu).

I am going to try Eigen and Armadillo to start with.

Cheers
Laura.

On Thu, Jan 16, 2020 at 2:33 PM Müller, Marcus (CEL) <address@hidden> wrote:
True, Eigen is pretty popular for people needing to do Matrix
operations – I wasn't aware they even have Matrix decompositions[1]!
(in hindsight... considering the library name...)
I like Eigen, but there's two caveats, I find:

1. indexing is done with () instead of [] (I guess it's made for people
who come from Matlab)
2. It's very much mathematician's software – I found (but that's about
a decade in the past, at the very least, so older compilers, older
processors, older Eigen) that things like Matrix·Matrix products were
relatively slow

I do recommend it to students that simply need some Matrix
functionality, as performance usually is of secondary concern and can
be optimized as soon as the software works.

Best regards,
Marcus

[1]
http://eigen.tuxfamily.org/dox/group__TopicLinearAlgebraDecompositions.html
On Fri, 2020-01-17 at 11:16 +1300, Jeremy Reeve wrote:
> Hi Laura,
>
> Just to add to the suggestions, I've seen Eigen [1] used in the past.
> It's a template library (headers only) and has no external
> dependencies other than the standard library and that might be
> something to consider given your use-case.
>
> [1] http://eigen.tuxfamily.org/index.php?title=Main_Page
>
> Jeremy
>
> On Fri, 17 Jan 2020 at 10:02, Laura Arjona <address@hidden> wrote:
> > Hi all,
> >
> > Is there any library to use in gnuradio for algebra operations, such as matrix eigenvalues, and pseudoinverse? Or I'd need to code them myself in C++?
> >
> > I need to integrate those operations into my OOT C++ blocks.
> >
> > Thanks for your time
> >
> > Best
> >
> > --
> > Laura Arjona
> > Washington Research Foundation Innovation Postdoctoral Fellow in Neuroengineering
> >
> > Paul G. Allen School of Computer Science & Engineering
> > 185 E Stevens Way NE
> > University of Washington
> > Seattle, WA 98195-2350


--
Laura Arjona 
Washington Research Foundation Innovation Postdoctoral Fellow in Neuroengineering

Paul G. Allen School of Computer Science & Engineering
185 E Stevens Way NE
University of Washington
Seattle, WA 98195-2350


--
Laura Arjona 
Washington Research Foundation Innovation Postdoctoral Fellow in Neuroengineering

Paul G. Allen School of Computer Science & Engineering
185 E Stevens Way NE
University of Washington
Seattle, WA 98195-2350

reply via email to

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