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


C++ DataTable::getNumVariables方法代码示例

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


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

示例1: compareDataTables

bool compareDataTables(DataTable &a, DataTable &b)
{
    if (a.getNumVariables() != b.getNumVariables())
        return false;

    auto ait = a.cbegin(), bit = b.cbegin();
    for (; ait != a.cend() && bit != b.cend(); ait++, bit++)
    {
        for (unsigned int i = 0; i < a.getNumVariables(); i++)
        {
//            std::cout << std::setprecision(SAVE_DOUBLE_PRECISION) << ait->getX().at(i) << " == " << std::setprecision(SAVE_DOUBLE_PRECISION) << bit->getX().at(i) << " ";
            if (!equalsWithinRange(ait->getX().at(i), bit->getX().at(i)))
                return false;
        }

//            std::cout << std::setprecision(SAVE_DOUBLE_PRECISION) << ait->getY().at(j) << " == " << std::setprecision(SAVE_DOUBLE_PRECISION) << bit->getY().at(j) << " ";
        if (!equalsWithinRange(ait->getY(), bit->getY()))
            return false;
//        std::cout << std::endl;
    }

//    std::cout << "Finished comparing samples..." << std::endl;

    return ait == a.cend() && bit == b.cend();
}
开发者ID:chongbingbao,项目名称:splinter,代码行数:25,代码来源:testingutilities.cpp

示例2: Exception

DataTable operator+(const DataTable &lhs, const DataTable &rhs)
{
    if(lhs.getNumVariables() != rhs.getNumVariables()) {
        throw Exception("operator+(DataTable, DataTable): trying to add two DataTable's of different dimensions!");
    }

    DataTable result;
    for(auto it = lhs.cbegin(); it != lhs.cend(); it++) {
        result.addSample(*it);
    }
    for(auto it = rhs.cbegin(); it != rhs.cend(); it++) {
        result.addSample(*it);
    }

    return result;
}
开发者ID:bgrimstad,项目名称:splinter,代码行数:16,代码来源:datatable.cpp

示例3: lambda

PSpline::PSpline(const DataTable &samples, double lambda)
    : lambda(lambda)
{
    // Check data
    assert(samples.isGridComplete());

    std::vector< std::vector<double> > xdata = samples.getTableX();

    numVariables = samples.getNumVariables();

    // Assuming a cubic spline
    std::vector<unsigned int> basisDegrees(samples.getNumVariables(), 3);
    basis = BSplineBasis(xdata, basisDegrees, KnotVectorType::FREE);
    computeControlPoints(samples);

    init();

    checkControlPoints();
}
开发者ID:chongbingbao,项目名称:splinter,代码行数:19,代码来源:pspline.cpp

示例4: if

RBFSpline::RBFSpline(const DataTable &samples, RadialBasisFunctionType type, bool normalized)
    : samples(samples),
      normalized(normalized),
      precondition(false),
      dim(samples.getNumVariables()),
      numSamples(samples.getNumSamples())
{
    if (type == RadialBasisFunctionType::THIN_PLATE_SPLINE)
    {
        fn = std::shared_ptr<RadialBasisFunction>(new ThinPlateSpline());
    }
    else if (type == RadialBasisFunctionType::MULTIQUADRIC)
    {
        fn = std::shared_ptr<RadialBasisFunction>(new Multiquadric());
    }
    else if (type == RadialBasisFunctionType::INVERSE_QUADRIC)
    {
        fn = std::shared_ptr<RadialBasisFunction>(new InverseQuadric());
    }
    else if (type == RadialBasisFunctionType::INVERSE_MULTIQUADRIC)
    {
        fn = std::shared_ptr<RadialBasisFunction>(new InverseMultiquadric());
    }
    else if (type == RadialBasisFunctionType::GAUSSIAN)
    {
        fn = std::shared_ptr<RadialBasisFunction>(new Gaussian());
    }
    else
    {
        fn = std::shared_ptr<RadialBasisFunction>(new ThinPlateSpline());
    }

    /* Want to solve the linear system A*w = b,
     * where w is the vector of weights.
     * NOTE: the system is dense and by default badly conditioned.
     * It should be solved by a specialized solver such as GMRES
     * with preconditioning (e.g. ACBF) as in matlab.
     * NOTE: Consider trying the Łukaszyk–Karmowski metric (for two variables)
     */
    //SparseMatrix A(numSamples,numSamples);
    //A.reserve(numSamples*numSamples);
    DenseMatrix A; A.setZero(numSamples, numSamples);
    DenseMatrix b; b.setZero(numSamples,1);

    int i=0;
    for(auto it1 = samples.cbegin(); it1 != samples.cend(); ++it1, ++i)
    {
        double sum = 0;
        int j=0;
        for(auto it2 = samples.cbegin(); it2 != samples.cend(); ++it2, ++j)
        {
            double val = fn->eval(dist(*it1, *it2));
            if(val != 0)
            {
                //A.insert(i,j) = val;
                A(i,j) = val;
                sum += val;
            }
        }

        double y = it1->getY();
        if(normalized) b(i) = sum*y;
        else b(i) = y;
    }

    //A.makeCompressed();

    if(precondition)
    {
        // Calcualte precondition matrix P
        DenseMatrix P = computePreconditionMatrix();

        // Preconditioned A and b
        DenseMatrix Ap = P*A;
        DenseMatrix bp = P*b;

        A = Ap;
        b = bp;
    }

#ifndef NDEBUG
    std::cout << "Computing RBF weights using dense solver." << std::endl;
#endif // NDEBUG

    // SVD analysis
    Eigen::JacobiSVD<DenseMatrix> svd(A, Eigen::ComputeThinU | Eigen::ComputeThinV);
    auto svals = svd.singularValues();
    double svalmax = svals(0);
    double svalmin = svals(svals.rows()-1);
    double rcondnum = (svalmax <= 0.0 || svalmin <= 0.0) ? 0.0 : svalmin/svalmax;

#ifndef NDEBUG
    std::cout << "The reciprocal of the condition number is: " << rcondnum << std::endl;
    std::cout << "Largest/smallest singular value: " << svalmax << " / " << svalmin << std::endl;
#endif // NDEBUG

    // Solve for weights
    weights = svd.solve(b);

#ifndef NDEBUG
//.........这里部分代码省略.........
开发者ID:novacrazy,项目名称:multivariate-splines,代码行数:101,代码来源:rbfspline.cpp

示例5: PSplineApproximant

PSplineApproximant::PSplineApproximant(const DataTable &samples, double lambda)
    : PSplineApproximant(samples, std::vector<unsigned int>(samples.getNumVariables(), 3), lambda)
{
}
开发者ID:pmukherj,项目名称:splinter,代码行数:4,代码来源:psplineapproximant.cpp


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