当前位置: 首页>>代码示例>>C++>>正文


C++ Matrix2::column方法代码示例

本文整理汇总了C++中Matrix2::column方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix2::column方法的具体用法?C++ Matrix2::column怎么用?C++ Matrix2::column使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix2的用法示例。


在下文中一共展示了Matrix2::column方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testEigenDecomposition

/**
 * Example of a test. To be completed.
 *
 */
bool testEigenDecomposition()
{
    unsigned int nbok = 0;
    unsigned int nb = 0;

    typedef EigenDecomposition<2,double> Eigen2;
    typedef Eigen2::Vector Vector2;
    typedef Eigen2::Matrix Matrix2;

    trace.beginBlock ( "Testing block ..." );
    // [4 1]
    // [1 2]
    Matrix2 A;
    A.setComponent( 0, 0, 4 );
    A.setComponent( 0, 1, 1 );
    A.setComponent( 1, 0, 1 );
    A.setComponent( 1, 1, 2 );
    Matrix2 P;
    Vector2 v;
    Eigen2::getEigenDecomposition( A, P, v );
    trace.info() << "Input matrix: " << A << std::endl;
    trace.info() << "Eigenvectors: " << P << std::endl;
    trace.info() << "Eigenvalues: " << v << std::endl;
    Vector2 V0 = P.column( 0 );
    Vector2 V1 = P.column( 1 );
    Vector2 V0_exp( 0.3826834323650898, -0.9238795325112868 );
    Vector2 V1_exp( 0.9238795325112868, 0.3826834323650898);
    double v0_exp = 1.585786437626905;
    double v1_exp = 4.414213562373095;
    double error_V0 = (V0-V0_exp).norm();
    double error_V1 = (V1-V1_exp).norm();
    double error_v0 = fabs( v[0] - v0_exp );
    double error_v1 = fabs( v[1] - v1_exp );
    trace.info() << "error_V0 = " << error_V0 << std::endl;
    trace.info() << "error_V1 = " << error_V1 << std::endl;
    trace.info() << "error_v0 = " << error_v0 << std::endl;
    trace.info() << "error_v1 = " << error_v1 << std::endl;
    double epsilon = 1e-10;
    ++nb, nbok += error_V0 < epsilon ? 1 : 0;
    trace.info() << "(" << nbok << "/" << nb << ") "
                 << "error_V0 < epsilon, i.e. " <<  error_V0 << " < " << epsilon << std::endl;
    ++nb, nbok += error_V1 < epsilon ? 1 : 0;
    trace.info() << "(" << nbok << "/" << nb << ") "
                 << "error_V1 < epsilon, i.e. " <<  error_V1 << " < " << epsilon << std::endl;
    ++nb, nbok += error_v0 < epsilon ? 1 : 0;
    trace.info() << "(" << nbok << "/" << nb << ") "
                 << "error_v0 < epsilon, i.e. " <<  error_v0 << " < " << epsilon << std::endl;
    ++nb, nbok += error_v1 < epsilon ? 1 : 0;
    trace.info() << "(" << nbok << "/" << nb << ") "
                 << "error_v1 < epsilon, i.e. " <<  error_v1 << " < " << epsilon << std::endl;
    trace.endBlock();

    return nbok == nb;
}
开发者ID:Victor-Ostromoukhov,项目名称:DGtal,代码行数:58,代码来源:testEigenDecomposition.cpp


注:本文中的Matrix2::column方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。