0

如果我运行代码,则会发生错误: Segmentation fault (core dumped)

如果我在头文件中减小 MatSamplesDimM 的尺寸(例如从 300000 到 30000),或者我只是在主文件中声明 Matrix1 而不是 Matrix2,则问题不存在。该问题与我运行代码的环境(日食或终端)无关。

你有什么想法?非常感谢您的帮助!

StrangeBehavior.cpp 是我的主文件:

// System includes
#include <iostream>
#include <fstream>   //fstream: Stream class to both read and write from/to files; for output

// Boost includes
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/math/distributions/normal.hpp>      //to create normal distribution
#include <vector>                                   // stl vector header
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/stats.hpp>  //accumulator for mean, variance...
#include <boost/accumulators/statistics/mean.hpp>
#include <boost/bind/bind.hpp>
#include <boost/numeric/ublas/vector_proxy.hpp>     // for using row()...
#include <boost/numeric/ublas/matrix_proxy.hpp>     // for using row()...
#include <boost/numeric/ublas/vector_expression.hpp>   // for using inner_prod
#include <boost/numeric/ublas/matrix_expression.hpp>   // for using inner_prod, element_div
#include <boost/math/special_functions/gamma.hpp> // for Gamma function

#include "ParameterDeclaration.hpp"

using namespace std; // saves us typing std:: before vector


int main() {

    std::cout << "Starting " << std::endl;

          MatSamplesDimM    Matrix1;
          MatSamplesDimM    Matrix2;

    std::cout << "Finishing" << std::endl;
    return 0;
}

和 ParameterDeclaration.hpp 我的头文件:

#ifndef parameter_
#define parameter_


#include <iostream>

namespace ublas = boost::numeric::ublas;

typedef     ublas::bounded_matrix<double,300000,2>        MatSamplesDimM;


#endif
4

1 回答 1

0

尝试使用堆而不是堆栈。这意味着使用new分配矩阵。

于 2013-11-07T07:42:26.690 回答