コード例 #1
0
ファイル: tree.hpp プロジェクト: jwscook/solver
 BoxT
 makeBoxAround(
         const Interval<DIM, T>& interval) const
 {
     Vector<DIM, T> lower = interval.minima();
     Vector<DIM, T> upper = interval.maxima();
     return makeBoxAround(lower, upper);
 }
コード例 #2
0
ファイル: AdaptiveGauss.hpp プロジェクト: jwscook/solver
    virtual
    T
    value(const Interval<DIM, T>& interval,
          const uint order) override
    {
        const uint numberOfQuadraturePoints = order + 1;

        calculateNewNodesAndWeightsIfNecessary(order);
        const auto index = indexFromOrder(order);
        auto nodes =
            mPreviouslyCalculatedUnscaledNodes[index];
        auto weights =
            mPreviouslyCalculatedUnscaledWeights[index];
        assert(numberOfQuadraturePoints == nodes.size());
        assert(weights.size() == nodes.size());

        std::array<std::vector<T>, DIM> arrayOfNodes, arrayOfWeights;
        arrayOfNodes.fill(nodes);
        arrayOfWeights.fill(weights);

        const auto minima = interval.minima();
        const auto maxima = interval.maxima();
        GaussLegendreOps<DIM, T>::scaleNodes(minima, maxima, arrayOfNodes);
        GaussLegendreOps<DIM, T>::scaleWeights(minima, maxima, arrayOfWeights);

        const auto allIndices = this->calculateAllIndicies(
                    numberOfQuadraturePoints);
        T integral(0.0);
        for (auto indices : allIndices) {
            std::array<T, DIM> weights, nodes;
            for (uint i = 0; i < DIM; ++i) {
                assert(i < indices.size());
                assert(indices[i] < numberOfQuadraturePoints);
                weights[i] = arrayOfWeights[i][indices[i]];
                nodes[i] = arrayOfNodes[i][indices[i]];
            }
            Vector<DIM, T> location(nodes);

            assert(interval.isInside(location));
            const auto weight = ContainerUtilities::product<DIM, T>(
                        weights);

            integral += weight * mFunc(location);
        }
        return integral;
    }