犰狳 C++自动类型错误分配

发布于 2025-01-11 14:28:17 字数 769 浏览 5 评论 0原文

有人可以解释为什么在调试模式下工作正常,但在发行版中我看到 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";
}

(使用 arma::cx_rowvec 可以正常工作,但性能不佳)

gcc 11.2 
armadillo armadillo-10.8.2

提前谢谢您。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文