本文整理汇总了C++中DiagonalMatrix::as_column方法的典型用法代码示例。如果您正苦于以下问题:C++ DiagonalMatrix::as_column方法的具体用法?C++ DiagonalMatrix::as_column怎么用?C++ DiagonalMatrix::as_column使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiagonalMatrix
的用法示例。
在下文中一共展示了DiagonalMatrix::as_column方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: my_main
int my_main()
{
{
// Get the data
ColumnVector X(6);
ColumnVector Y(6);
X << 1 << 2 << 3 << 4 << 6 << 8;
Y << 3.2 << 7.9 << 11.1 << 14.5 << 16.7 << 18.3;
// Do the fit
Model_3pe model(X); // the model object
NonLinearLeastSquares NLLS(model); // the non-linear least squares
// object
ColumnVector Para(3); // for the parameters
Para << 9 << -6 << .5; // trial values of parameters
cout << "Fitting parameters\n";
NLLS.Fit(Y,Para); // do the fit
// Inspect the results
ColumnVector SE; // for the standard errors
NLLS.GetStandardErrors(SE);
cout << "\n\nEstimates and standard errors\n" <<
setw(10) << setprecision(2) << (Para | SE) << endl;
Real ResidualSD = sqrt(NLLS.ResidualVariance());
cout << "\nResidual s.d. = " << setw(10) << setprecision(2) <<
ResidualSD << endl;
SymmetricMatrix Correlations;
NLLS.GetCorrelations(Correlations);
cout << "\nCorrelationMatrix\n" <<
setw(10) << setprecision(2) << Correlations << endl;
ColumnVector Residuals;
NLLS.GetResiduals(Residuals);
DiagonalMatrix Hat;
NLLS.GetHatDiagonal(Hat);
cout << "\nX, Y, Residual, Hat\n" << setw(10) << setprecision(2) <<
(X | Y | Residuals | Hat.as_column()) << endl;
// recover var/cov matrix
SymmetricMatrix D;
D << SE.as_diagonal() * Correlations * SE.as_diagonal();
cout << "\nVar/cov\n" << setw(14) << setprecision(4) << D << endl;
}
#ifdef DO_FREE_CHECK
FreeCheck::Status();
#endif
return 0;
}
示例2: my_main
int my_main() // called by main()
{
Tracer tr("my_main "); // for tracking exceptions
int n = 7; // this is the order we will work with
int i, j;
// declare a matrix
SymmetricMatrix H(n);
// load values for Hilbert matrix
for (i = 1; i <= n; ++i) for (j = 1; j <= i; ++j)
H(i, j) = 1.0 / (i + j - 1);
// print the matrix
cout << "SymmetricMatrix H" << endl;
cout << setw(10) << setprecision(7) << H << endl;
// calculate its eigenvalues and eigenvectors and print them
Matrix U; DiagonalMatrix D;
eigenvalues(H, D, U);
cout << "Eigenvalues of H" << endl;
cout << setw(17) << setprecision(14) << D.as_column() << endl;
cout << "Eigenvector matrix, U" << endl;
cout << setw(10) << setprecision(7) << U << endl;
// check orthogonality
cout << "U * U.t() (should be near identity)" << endl;
cout << setw(10) << setprecision(7) << (U * U.t()) << endl;
// check decomposition
cout << "U * D * U.t() (should be near H)" << endl;
cout << setw(10) << setprecision(7) << (U * D * U.t()) << endl;
return 0;
}