[완료] 동적할당 부분에서 멈추는데...왜 이런지 모르겟습니다.

eldrids의 이미지

using namespace techsoft;
typedef techsoft::matrix<double>	dMatrix;

template <class T>
class matrix
{
public:
   typedef T value_type;
   typedef valarray<T> array_type;
 
   // Constructors
   matrix ();
   matrix (size_t nRow, size_t nCol);
   matrix (size_t nRow, size_t nCol, const T& e);
   matrix (size_t nRow, size_t nCol, const T* Array, MatArrayType aType = C_ARRAY);
   matrix (size_t nRow, size_t nCol, const valarray<T>& vec);
    ~matrix ();
}

 struct base_mat
   {
      valarray<T> val;
      size_t nrow, ncol;
      int	 refcnt;
 
      base_mat (size_t row, size_t col)
            : nrow( row), ncol( col), val( row * col) { refcnt = 1; }
 
      base_mat (const T& v, size_t row, size_t col)
            : nrow( row), ncol( col), val( v, row * col) { refcnt = 1; }
 
      base_mat (const T* v, size_t row, size_t col)
            : nrow( row), ncol( col), val( v, row * col) { refcnt = 1; }
 
      base_mat (size_t row, size_t col, const valarray<T>& v)
            : nrow( row), ncol( col), val( v) { refcnt = 1; }
 
      ~base_mat () {;}
   }

template <class T> inline
matrix<T>::matrix (size_t nRow, size_t nCol)
{
    mPtr = allocator( Allocate, nRow, nCol);
}
 
template <class T>
matrix<T>::matrix (size_t nRow, size_t nCol, const T& e)
{
    mPtr = new base_mat( e, nRow, nCol);
    allocator( Record);
}
 
template <class T>
matrix<T>::matrix (size_t row, size_t col, const T* val, MatArrayType aType)
{
    if (aType == C_ARRAY)
    {
        mPtr = new base_mat( val, row, col); <= 이부분에서 멈춥니다.( base_mat 함수는 위에 있습니다)
        allocator( Record);
    }
    else
    {
        mPtr = allocator( Allocate, row, col);
        T *pv = &mPtr->val[0];
 
        for (size_t k=0, j=0; j < col; j++)
            for (size_t i=0; i < row; i++)
                pv[i*col+j] = val[k++];
    }
}
 
 
template <class T>
matrix<T>::matrix (size_t nRow, size_t nCol, const valarray<T>& vec)
{
   mPtr = new base_mat( nRow, nCol, vec);
   allocator( Record);
}

        double _b[4][3] = {
		{ x.s_,    -x.v_[2],  x.v_[1] },
		{ x.v_[2],  x.s_,    -x.v_[0] },
		{-x.v_[1],  x.v_[0],  x.s_    },
		{-x.v_[0], -x.v_[1], -x.v_[2] }};
 
        dMatrix B(4,3,&_b[0][0]); <=이부분에서 멈춥니다.(하위 소스는 위에 있습니다.)
 
        B = B*0.5*dt;
 
	const double _q[3][3] = { 
		{1, 0, 0 },
		{0, 1, 0 },
		{0, 0, 1},
	};
 
	// Covariance matrix of porcess noises
	const dMatrix Q(3, 3, &_q[0][0]); 
 
	// Predicted state estimate
	x = x * Quaternion (w[0]*dt, w[1]*dt, w[2]*dt);

벌써 일주일 넘게 해결을 못하고 있습니다.

visual Studio에서 잘 돌아가는 소스였는데 말이죠..

IAR 컴파일러로 옴겨서 컴파일해보니 컴파일은 잘되었습니다.

근데 matrix::matrix (size_t nRow, size_t nCol, const valarray& vec) 함수에서

mPtr = new base_mat( val, row, col); <= 이부분에서 멈춥니다.( base_mat 함수는 위에 있습니다)

동적할당부분에서 멈추네요...

hwatk의 이미지

우선 생성자 중에 const dMatrix Q(3, 3, &_q[0][0]); 이면,
matrix (size_t nRow, size_t nCol, const T* Array, MatArrayType aType = C_ARRAY); 이 호출될 것 같은데,
이쪽 부분 소스를 올리면 답변 받기가 쉬울것 같습니다.

정황상 2-d array 접근 관련으로 보이는데, 다음과 같이 바꾸면 문제가 없어지는지요?

	const double _q[3*3] = { 
                1, 0, 0, 
                0, 1, 0,
		0, 0, 1,
	};
 

eldrids의 이미지

matrix (size_t nRow, size_t nCol, const T* Array, MatArrayType aType = C_ARRAY);
는 파라메타가 4갭니다만...
3개쓰는데 이걸 쓸리는 없다고 생각합니다.

matrix (size_t nRow, size_t nCol, const T& e); 가 맞다고 생각합니다.

그리고 밑에 있는 건 문법상 틀리네요.

eldrids의 이미지

전부 프린트문으로 디버그하니깐..

matrix (size_t nRow, size_t nCol, const T* Array, MatArrayType aType = C_ARRAY);

이 함수로 빠지네요..

eldrids의 이미지

쓰는 MPU 의 힙 할당이 적어서 그런거같네요..
컴파일러에서 힙 할당을 늘려주니 잘 넘어가는군요..

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.