在类中使用模板的特征矩阵
我想创建一个类,该类使用矩阵的类型和尺寸在构造函数调用过程中由用户确定的矩阵。我尝试使用一个类模板,然后将其参数用于实例化类成员中的所有内容,但我会遇到错误。
完成此操作的最佳方法是什么?
这是我的错误代码:
#pragma once
#include "Arduino.h"
#include "eigen.h"
#include <Eigen/LU>
#include <Eigen/Geometry>
using namespace Eigen;
template<typename type, static const int _numMeas, static const int _numStates>
class pf
{
public:
pf(const Matrix<type, _numMeas, _numMeas>& _R, const Matrix<type, _numStates, _numStates>& _Q)
{
};
private:
int numMeas = _numMeas;
int numStates = _numStates;
Matrix<type, _numMeas, _numMeas> R;
Matrix<type, _numStates, _numStates> Q;
};
I want to create a class that uses matrices whose types and sizes are determined by the user during the constructor call. I tried to use a class template whose arguments are then used to instantiate everything in the class members, but I'm getting errors.
What is the best way to accomplish this?
Here is my erroring code:
#pragma once
#include "Arduino.h"
#include "eigen.h"
#include <Eigen/LU>
#include <Eigen/Geometry>
using namespace Eigen;
template<typename type, static const int _numMeas, static const int _numStates>
class pf
{
public:
pf(const Matrix<type, _numMeas, _numMeas>& _R, const Matrix<type, _numStates, _numStates>& _Q)
{
};
private:
int numMeas = _numMeas;
int numStates = _numStates;
Matrix<type, _numMeas, _numMeas> R;
Matrix<type, _numStates, _numStates> Q;
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论