Matlab Mex file using a vector class definition

I am trying to create a Mex file from C ++ source code to use it with Matlab. I have a compilation of errors due to handling the definition of a class of vectors, which I do not understand very well. I would like to know how can I change the code to work. Below I show the corresponding parts of the code, which I divided into four sections to clarify (computational code, MexFunction code, definition of a vector class, and compilation of errors):

Settlement code:

#include "mex.h"
#include "SAT_VecMat.h"

void AccelSolrad (const Vector& r, const Vector& r_Sun, double Area, double mass,
    double CR, double P0, double AU,const Vector& Accel )

mexFunction code:

...
const Vector& r_sat(3);       // dummy argument name for r
const Vector& r_sol(3);       // dummy argument name for r_Sun      
const Vector& outMatrix(3);   // dummy argument name for Accel
...
r_sat = mxGetPr(prhs[0]);
r_sol = mxGetPr(prhs[1]);
plhs[0] = mxCreateDoubleMatrix(1,3,mxREAL);
outMatrix = mxGetPr(plhs[0]);

The definition of a vector class included in SAT_VecMat.h:

class Vector
{

  public:

    friend class Matrix;

    // Constructors    
    Vector ();                              // Vector without elements
    Vector (int Size);                      // Nullvector of specified size 
    Vector (const Vector& V);               // Vector copy
    Vector (const double* p, int N);        // Array copy
    Vector (double x, double y, double z);  // 3dim-Vector
    Vector (double x, double y, double z,   // 6dim-Vector
            double X, double Y, double Z);  

    // Destructor
    ~Vector();

    // Size
    int size() const { return n; };
    Vector& resize(int Size);

    // Assignment
    Vector& operator=(const double value);
    Vector& operator=(const Vector& V);

    // Component access (Fortran notation)
    double  operator () (int i) const { return v[i]; };
    double& operator () (int i)       { return v[i]; };
    Vector slice (int first, int last) const;
...

Compilation errors:

    >> mex AccelSolrad.cpp

    AccelSolrad.cpp 

    c:\program files\matlab\r2009b\extern\include\matrix.h(332) : error C2371: 'char16_t' : redefinition; different basic types

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\yvals.h(576) : see declaration of 'char16_t' 

AccelSolrad.cpp(14) : error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const Vector' (or there is no acceptable conversion) 
        d:\po\ejemplos\SAT_VecMat.h(69): could be 'Vector &Vector::operator =(const double)' 
        d:\po\ejemplos\SAT_VecMat.h(70): or       'Vector &Vector::operator =(const Vector &)' 
        while trying to match the argument list '(const Vector, Vector)' 

AccelSolrad.cpp(18) : error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const Vector' (or there is no acceptable conversion) 
        d:\po\ejemplos\SAT_VecMat.h(69): could be 'Vector &Vector::operator =(const double)' 
        d:\po\ejemplos\SAT_VecMat.h(70): or       'Vector &Vector::operator =(const Vector &)' 
        while trying to match the argument list '(const Vector, Vector)' 

AccelSolrad.cpp(94) : error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const Vector' (or there is no acceptable conversion) 
        d:\po\ejemplos\SAT_VecMat.h(69): could be 'Vector &Vector::operator =(const double)' 
        d:\po\ejemplos\SAT_VecMat.h(70): or       'Vector &Vector::operator =(const Vector &)' 
        while trying to match the argument list '(const Vector, double *)' 

AccelSolrad.cpp(96) : error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const Vector' (or there is no acceptable conversion) 
        d:\po\ejemplos\SAT_VecMat.h(69): could be 'Vector &Vector::operator =(const double)' 
        d:\po\ejemplos\SAT_VecMat.h(70): or       'Vector &Vector::operator =(const Vector &)' 
        while trying to match the argument list '(const Vector, double *)' 

AccelSolrad.cpp(112) : error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const Vector' (or there is no acceptable conversion) 
        d:\po\ejemplos\SAT_VecMat.h(69): could be 'Vector &Vector::operator =(const double)' 
        d:\po\ejemplos\SAT_VecMat.h(70): or       'Vector &Vector::operator =(const Vector &)' 
        while trying to match the argument list '(const Vector, double *)' 

  C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: Compile of 'AccelSolrad.cpp' failed. 
+3
source share
2 answers

Update:

, char16_t, , , Visual Studio 2010 MATLAB R2009b. MATLAB. . R2009b.

, :

 Vector& r_sat(3);

, ++: , , , 3, . r_sat Vector.

:

r_sat = mxGetPr(prhs[0]);

mxGetPr() , Vector operator=, double* .

, - :

r_sat = Vector(mxGetPr(prhs[0]), 3); // use the Vector(double*, int N) constructor

:

  • Vector - ++, C.
  • Windows, lcc, MATLAB, C, ++. ++ MEX, mex -setup ++ ( Visual Studio).
  • mex , C ++ MEX ( , C ++ ) . AccelSolrad.c AccelSolrad.cpp, .
+6

, -... const obj&.

:

const Vector& r_sat(3);

r_span . r_span , . .

+1

All Articles