'Armadillo C++ Auto Type Bad Alloc

Can someone explain why in Debug mode is working okay, but in release i see bad_allocation ?

#include <iostream>
#define ARMA_DONT_USE_WRAPPER
#include <armadillo>

int main()
{
    arma::cx_mat testMat;
    testMat.set_size(40, 19586);
    auto nPositions = static_cast<arma::sword>(floor(19586/2));
    arma::cx_rowvec a {19586, arma::fill::randu};
    for ( int i = 0 ; i < 40; ++i)
    {
            // testMat.row(i) = arma::shift(arma::fft(a), nPositions); // very slow
            auto result = (arma::shift(arma::fft(a), nPositions));
            result.print("result");
    }
    std::cout << " i am done \n";
}

( with arma::cx_rowvec is wokring okay, but bad perfomane )

gcc 11.2 
armadillo armadillo-10.8.2

Thank you in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source