本文整理汇总了C++中LinearRegression::setBasis方法的典型用法代码示例。如果您正苦于以下问题:C++ LinearRegression::setBasis方法的具体用法?C++ LinearRegression::setBasis怎么用?C++ LinearRegression::setBasis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinearRegression
的用法示例。
在下文中一共展示了LinearRegression::setBasis方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv) {
QApplication app(argc, argv);
std::vector<Eigen::Matrix<double, 2, 1> > data;
LinearRegression<2> dist;
for (double x = -10; x < 10; x += 0.01) {
dist.setBasis((Eigen::Matrix<double, 1, 1>() << x).finished());
data.push_back(dist.getSample());
}
ScatterPlot<2> plot("LinearRegressionRndScatterPlot1v", data);
plot.show();
return app.exec();
}
示例2: main
int main(int argc, char** argv) {
QApplication app(argc, argv);
std::vector<Eigen::Matrix<double, 3, 1> > data;
LinearRegression<3> dist;
for (double x = -10; x < 10; x += 0.1)
for (double y = -10; y < 10; y += 0.1) {
dist.setBasis(Eigen::Matrix<double, 2, 1>(x, y));
data.push_back(dist.getSample());
}
ScatterPlot<3> plot("LinearRegressionRndScatterPlot2v", data);
plot.show();
return app.exec();
}
示例3: main
int main(int argc, char** argv) {
LinearRegression<2> linearRegression;
std::cout << "Default parameters: " << std::endl << linearRegression
<< std::endl;
std::cout << "l.getLinearBasisFunction(): " << std::endl <<
linearRegression.getLinearBasisFunction() << std::endl;
std::cout << "l.getVariance(): " << linearRegression.getVariance()
<< std::endl;
std::cout << "l.setLinearBasisFunction(2.0, 2.0)" << std::endl;
std::cout << "l.setVariance(2.0)" << std::endl;
std::cout << "l.setBasis(2.0)" << std::endl;
linearRegression.setLinearBasisFunction(LinearBasisFunction<double, 2>(
Eigen::Matrix<double, 2, 1>(2.0, 2.0)));
linearRegression.setVariance(2.0);
linearRegression.setBasis((Eigen::Matrix<double, 1, 1>() << 2.0).finished());
if (linearRegression.getLinearBasisFunction().getCoefficients() !=
Eigen::Matrix<double, 2, 1>(2.0, 2.0))
return 1;
if (linearRegression.getVariance() != 2.0)
return 1;
if (linearRegression.getBasis() !=
(Eigen::Matrix<double, 1, 1>() << 2.0).finished())
return 1;
std::cout << "New parameters: " << std::endl << linearRegression
<< std::endl;
std::cout << "l.getValue(2): " << linearRegression(
Eigen::Matrix<double, 2, 1>(2, 6)) << std::endl;
std::cout << "l.getSample(): " << std::endl << linearRegression.getSample()
<< std::endl;
std::cout << "l.getMean(): " << linearRegression.getMean() << std::endl;
LinearRegression<2> linCopy(linearRegression);
std::cout << "Copy constructor: " << std::endl << linCopy << std::endl
<< std::endl;
if (linCopy.getLinearBasisFunction().getCoefficients() !=
linearRegression.getLinearBasisFunction().getCoefficients())
return 1;
if (linCopy.getVariance() != linearRegression.getVariance())
return 1;
LinearRegression<2> linAssign = linearRegression;
std::cout << "Assignment operator: " << std::endl << linAssign << std::endl;
if (linAssign.getLinearBasisFunction().getCoefficients() !=
linearRegression.getLinearBasisFunction().getCoefficients())
return 1;
if (linAssign.getVariance() != linearRegression.getVariance())
return 1;
return 0;
}