clibgen can not generate operator() in the C++ matrix class.
1 view (last 30 days)
Show older comments
I tried to create a matrix class by C++ which can use some operatr such as * or + to work on matrix or vector.
The header file is listed as,
#pragma once
#include <vector>
#include<iostream>
#define ill_condition pow(10,-14)
class QSMatrix
{
public:
QSMatrix();
QSMatrix(const QSMatrix & rhs);
QSMatrix(unsigned rows_, unsigned cols_);
QSMatrix(unsigned rows_, unsigned cols_, const double & initial_);
~QSMatrix();
void setElement(const unsigned& row, const unsigned& col, double value);
QSMatrix& operator=(const QSMatrix & rhs);
// Matrix mathematical operations
QSMatrix operator+(const QSMatrix & rhs);
QSMatrix & operator+=(const QSMatrix & rhs);
QSMatrix operator-(const QSMatrix & rhs);
QSMatrix & operator-=(const QSMatrix & rhs);
QSMatrix operator*(const QSMatrix & rhs);
QSMatrix & operator*=(const QSMatrix & rhs);
QSMatrix transpose();
// Matrix/scalar operations
QSMatrix operator+(const double& rhs);
QSMatrix operator-(const double& rhs);
QSMatrix operator*(const double& rhs);
QSMatrix operator/(const double& rhs);
double det();
QSMatrix cofactor();
QSMatrix inverse();
// int LUPDecompose(QSMatrix &tempMat, std::vector<double> &p);
// QSMatrix LUPInvert();
// double LUPDeterminant();
// Matrix/vector operations
std::vector<double> operator*(const std::vector<double> & rhs);
std::vector<double> diag_vec();
// Access the individual elements
double & operator()(const unsigned& row, const unsigned& col);
const double & operator()(const unsigned& row, const unsigned& col) const;
// Access the row and column sizes
unsigned get_rows() const;
unsigned get_cols() const;
private:
std::vector<std::vector<double>> val;
unsigned rows;
unsigned cols;
};
After I used the cligen package to generate the MATLAB interface, all methods are generated except ones with operator().
I wonder is that possible to create the operator () interface in MATLAB.
Thank you!
0 Comments
Answers (0)
See Also
Categories
Find more on Call C++ from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!