This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Compile error: MatrixXd

Tags: None
(comma "," separated)
User avatar
fearhope
Registered Member
Posts
20
Karma
0
OS

Compile error: MatrixXd

Tue Apr 03, 2012 10:12 am
Hi!
when I compiled the following code I got the error, "YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX". (with VS2010, Eigen v3.05)
MatrixXd m = MatrixXd::Random(100,100);
MatrixXd anglesMatrix1(i_Points.size(),i_Points.size());
all the lines having MatrixXd type have errors such as the above two lines.

I cannot find any mistake in my code. please somebody help me. what's the problem ? it might be a bug ?

Thanks in advance.
- Yeonchool.

my code is as follows.
Code: Select all
"Histogram.hpp"
#include <Eigen/Dense>
#include <Eigen/Core>
#include "typedef.h"
#include <math.h>
#include "opencv2/core/core.hpp"
#include <stdio.h>

using namespace Eigen;
using namespace std;
Math_Function cmathf;
using Eigen::MatrixXd;

namespace ShapeContext {
   class Histogram
    {
   public:
      static const int sr_MinPointsForPolygon_ = 3;
      static const int sr_NoInit_ = -1;

      static vector<MatrixXd> CreateHistogram(vector<cv::Point>& i_Points, int i_NumOfThetaBins, int i_NumOfBins, double o_Avg)
        {
            // compute theta angles
         assert(i_Points.size()>0);

         MatrixXd m = MatrixXd::Random(100,100);
         MatrixXd anglesMatrix1(i_Points.size(),i_Points.size());
         anglesMatrix1 = setAngleMatrix(i_Points, i_NumOfThetaBins);
         
            // compute cell in bin
            MatrixXd radiusMatrix(i_Points.size(), i_Points.size());;
         setRadiusMatrix(i_Points, i_NumOfBins, o_Avg, radiusMatrix);

         vector<MatrixXd> histogram;
         setBinsPointReference(anglesMatrix1, radiusMatrix, i_NumOfThetaBins, i_NumOfBins, i_Points.size(), histogram);


            return histogram;
        }


the error is as follows.
Code: Select all
d:\program files\pcl 1.3.1\3rdparty\eigen\include\eigen\src/Core/Matrix.h(241): error C2338: YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX
1>          d:\program files\pcl 1.3.1\3rdparty\eigen\include\eigen\src/Core/Matrix.h(237) : while compiling class template member function 'Eigen::Matrix<_Scalar,_Rows,_Cols>::Matrix(__w64 int)'
1>          with
1>          [
1>              _Scalar=double,
1>              _Rows=-1,
1>              _Cols=-1
1>          ]
1>          d:\users\ycp\project\objectmodeler_gui_mp v2.1\src\Histogram.hpp(18) : see reference to class template instantiation 'Eigen::Matrix<_Scalar,_Rows,_Cols>' being compiled
1>          with
1>          [
1>              _Scalar=double,
1>              _Rows=-1,
1>              _Cols=-1
1>          ]
1>
1>Build FAILED.
johnm1019
Registered Member
Posts
46
Karma
0

Re: Compile error: MatrixXd

Tue Apr 03, 2012 3:53 pm
as indicated in the debug output, which is line 18?
User avatar
fearhope
Registered Member
Posts
20
Karma
0
OS

Re: Compile error: MatrixXd

Tue Apr 03, 2012 4:01 pm
thanks for your kind reply.

it is
MatrixXd m = MatrixXd::Random(100,100); <--- line 18

however, all lines which have MatrixXd have same errors.
MatrixXd anglesMatrix1(i_Points.size(),i_Points.size());
MatrixXd radiusMatrix(i_Points.size(), i_Points.size());

johnm1019 wrote:as indicated in the debug output, which is line 18?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Compile error: MatrixXd  Topic is solved

Wed Apr 04, 2012 6:44 am
It seems you are calling the ctor Matrix(size) somewhere which is indeed only for vectors. PErhaps in the setAngleMatrix, or setBinsPointReference functions?
User avatar
fearhope
Registered Member
Posts
20
Karma
0
OS

Re: Compile error: MatrixXd

Wed Apr 04, 2012 9:46 am
Ggael, Thanks a lot for your kind reply !

I found the origin of error due to your guidance. it was caused by totally different class.
the structure is as follows.
Code: Select all
            CSContext (class)
               |     \         
              TPS   Histogram (classes)
   (error's origin)    (compiler pointed that this class had error)

In TPS class, I had used square brackets instead of parentheses  like
Code: Select all
MatrixXd newMap(x,y);       
newMap[fsIndex, sr_Xaxis] = ...

that was my mistake :'(

by the way, why the compiler was pointing other location as an error ?
anyway now it works well.

bravo ggael !!
ggael wrote:It seems you are calling the ctor Matrix(size) somewhere which is indeed only for vectors. PErhaps in the setAngleMatrix, or setBinsPointReference functions?


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]