• Daniel

    Are there OpenCV alternatives to the armadillo code?

    acu? cv::accumulate?

    Rand? cv::Mat?

    • Eric

      Hi Daniel,

      For arma::accu, it accumulate (sum) all elements of matrix/vector, so you can use cv::sum to do the same thing, however, for 1-channel image, you should use cv::sum like:
      _sum = cv::sum(M)[0], since cv::sum calculates all the 3/4 channels of matrix.
      For randu/randn, what OpenCV API does is pretty much like what Armadillo does.
      For more details, you may want to check OpenCV Docs: http://docs.opencv.org/modules/core/doc/operations_on_arrays.html

  • segmentation fault

    mat
    concatenateMat(vector &vec){
    int height = vec[0].n_rows; // segmentation fault here.

    i compiled with:

    g++ pro.cpp -o pro -O2 -larmadillo -std=c++11

    • Eric

      Hi Keghn,

      I just tried to compile and run the code on my github (use cmake), there’s no such problem and runs perfectly, I think the problem is due to your armadillo version or c++11 maybe? Could you try to compile it use earlier version of c++? Thanks!

    • Miler

      I have the same problem.

      Could you fix it?

  • $ cmake -version
    cmake version 2.8.12.2

    $ cd single-layer-rbm-master
    $ cmake .
    $ make

    — The C compiler identification is GNU 4.8.2
    — The CXX compiler identification is GNU 4.8.2
    — Check for working C compiler: /usr/bin/cc
    — Check for working C compiler: /usr/bin/cc — works
    — Detecting C compiler ABI info
    — Detecting C compiler ABI info – done
    — Check for working CXX compiler: /usr/bin/c++
    — Check for working CXX compiler: /usr/bin/c++ — works
    — Detecting CXX compiler ABI info
    — Detecting CXX compiler ABI info – done
    — Configuring done
    — Generating done
    — Build files have been written to: /home/keghn/armadillo-4.650.4/0p/single-layer-rbm-master

    $ make
    [100%] Building CXX object CMakeFiles/RBM.dir/RBM.cc.o
    In file included from /usr/include/c++/4.8/random:35:0,
    from /home/keghn/armadillo-4.650.4/0p/single-layer-rbm-master/RBM.cc:14:
    /usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
    #error This file requires compiler and library support for the \
    ^
    /home/keghn/armadillo-4.650.4/0p/single-layer-rbm-master/RBM.cc: In function ‘void read_Mnist(std::string, std::vector<arma::Mat >&)’:
    /home/keghn/armadillo-4.650.4/0p/single-layer-rbm-master/RBM.cc:50:41: error: no matching function for call to ‘std::basic_ifstream::basic_ifstream(std::string&, const openmode&)’
    ifstream file (filename, ios::binary);
    ^
    /home/keghn/armadillo-4.650.4/0p/single-layer-rbm-master/RBM.cc:50:41: note: candidates are:
    In file included from /usr/include/armadillo:21:0,
    from /home/keghn/armadillo-4.650.4/0p/single-layer-rbm-master/RBM.cc:10:
    /usr/include/c++/4.8/fstream:467:7: note: std::basic_ifstream::basic_ifstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits; std::ios_base::openmode = std::_Ios_Openmode]
    basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in)
    ^
    /usr/include/c++/4.8/fstream:467:7: note: no known conversion for argument 1 from ‘std::string {aka std::basic_string}’ to ‘const char*’
    /usr/include/c++/4.8/fstream:453:7: note: std::basic_ifstream::basic_ifstream() [with _CharT = char; _Traits = std::char_traits]
    basic_ifstream() : __istream_type(), _M_filebuf()
    ^
    /usr/include/c++/4.8/fstream:453:7: note: candidate expects 0 arguments, 2 provided
    /usr/include/c++/4.8/fstream:427:11: note: std::basic_ifstream::basic_ifstream(const std::basic_ifstream&)
    class basic_ifstream : public basic_istream
    ^
    /usr/include/c++/4.8/fstream:427:11: note: candidate expects 1 argument, 2 provided
    /home/keghn/armadillo-4.650.4/0p/single-layer-rbm-master/RBM.cc: In function ‘void save2txt(arma::mat&, std::string, int)’:
    /home/keghn/armadillo-4.650.4/0p/single-layer-rbm-master/RBM.cc:109:16: error: ‘to_string’ is not a member of ‘std’
    string s = std::to_string(step);
    ^
    make[2]: *** [CMakeFiles/RBM.dir/RBM.cc.o] Error 1
    make[1]: *** [CMakeFiles/RBM.dir/all] Error 2
    make: *** [all] Error 2

    I do not know if i am using Cmake right everyone i know avoid it like the plague.