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


C++ MatrixXf::partialPivLu方法代码示例

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


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

示例1: main

int main(int argc, char **argv) {

    init();
    header();
  
    ///// CONFIGURATION /////
    constexpr unsigned int nData = 100u;          // Number of uniformly sampled points
    constexpr unsigned int nDataSample = 10000u;  // Number of points used for plotting and l2 norm
    ////////////////////////////////////
    
    const Interval<float> interval(0.0f,1.0f);

    //generate and plot samples
    FunctionSample<nDataSample, float> samplePlot(interval, F);
    RandomSample<nData, float> sample(interval, F);

    const PlotBox<float>& box = PlotBox<float>(interval.inf,interval.sup,samplePlot.min(),samplePlot.max()).dilate(1.0);
    //build tree with samples (ALLOCATION)
    TreeNode<float> *tree = new IntegerGrid<float>(interval);

    for (unsigned int i = 0; i < nData; i++) {
        tree->insert(sample[i]);
    } 
    
    //remove bad nodes (check GRP criterion)
    tree->computePlacementCondition(1,0.5);
    
    //map wavelets to tree nodes
    DeslaurierDubuc<float,10> db;
    WaveletMapper<float> simpleDDTreeMapper = [&db](unsigned int j, int k)->Wavelet<float>& { return db; };
    unsigned int n = tree->countValidNodes();
    
    std::cout << n << " samples out of " << nData << " met the GRP criterion !" << std::endl;

    //compute wavelet coefficients
    using Eigen::VectorXf;
    using Eigen::MatrixXf;
    MatrixXf A = MatrixXf::Random(n,n);
    VectorXf b = VectorXf::Random(n);

    tree->fillSystem(A,b,simpleDDTreeMapper);
    VectorXf coefficients = A.partialPivLu().solve(b);
    
    float epsilon = (A*coefficients -b).maxCoeff();
    std::cout << "Maximum sample error : " << epsilon << std::endl;

    //build wavelet tree with the coefficients
    WaveletTree<float> *waveletTree = WaveletTree<float>::makeTree(tree, simpleDDTreeMapper, coefficients);

    FunctionSample<nDataSample, float> reconstructedSample(interval, *waveletTree);
    float L2_distance = (samplePlot - reconstructedSample).norm();
    std::cout << "l2 norm of the residue ||F' - F|| = " << L2_distance << " !" << std::endl;

    //plot everything
    Gnuplot gp("tee plot.gp | gnuplot -persist");
    gp << "set term wxt dashed\n";
    gp << "set multiplot\n";
    gp << "set notitle\n";
    samplePlot.plotLine(gp, box);
    sample.plotPoints(gp, box);
    tree->plotValidPoints(gp, box);
    waveletTree->plot(gp, box, nDataSample);

    gp << "unset multiplot\n";
    gp << "set term wxt 1 dashed\n";
    gp << "set multiplot\n";
    gp << "unset label\n";
    tree->plot(gp, box, true, true);
    tree->plotValid(gp, box);

    //gp << "unset multiplot\n";
    //gp << "set term wxt 2\n";
    //gp << "set multiplot\n";
    //gp << "unset label\n";
    //waveletTree->plot(gp, box, nDataSample);

    footer();

    return EXIT_SUCCESS;
}
开发者ID:Poulpy21,项目名称:papers,代码行数:80,代码来源:main.cpp


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