<commit_before>/**
 * \file testComputeNodesWeights.cpp
 * This file is a unit test for ComputeGaussKronrodNodesWeights.h.
 * The test is used to compare two different approaches to computing Gauss-Kronrod node and
 * weight values for a single ruleset for agreement at the specified level of precision.
 */

#include <NumericalIntegration.h>

#include <iostream>
#include <fstream>
#include <iomanip>
#include <Eigen/Dense>

using namespace Eigen;

int test_nodes_weights_difference(const unsigned int N)
{
    //typedef float Scalar;
    //typedef double Scalar;
    typedef long double Scalar;
    //typedef mpfr::mpreal Scalar;
    //Scalar::set_default_prec(50);

    typedef Eigen::LaurieGautschi<Scalar> LaurieGautschiPolicy;
    typedef Eigen::Piessens<Scalar> PiessensPolicy;
    typedef Eigen::Monegato<Scalar> MonegatoPolicy;

    Eigen::Array<Scalar, Eigen::Dynamic, 1> xGKLaurieGautschi;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> wGKLaurieGautschi;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> xGLaurieGautschi;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> wGLaurieGautschi;

    Eigen::Array<Scalar, Eigen::Dynamic, 1> xGKPiessens;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> wGKPiessens;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> xGPiessens;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> wGPiessens;

    Eigen::Array<Scalar, Eigen::Dynamic, 1> xGKMonegato;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> wGKMonegato;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> xGMonegato;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> wGMonegato;

    LaurieGautschiPolicy::computeAbscissaeAndWeights(N,xGKLaurieGautschi,wGKLaurieGautschi,xGLaurieGautschi,wGLaurieGautschi);
    PiessensPolicy::computeAbscissaeAndWeights(N,xGKPiessens,wGKPiessens,xGPiessens,wGPiessens);
    MonegatoPolicy::computeAbscissaeAndWeights(N,xGKMonegato,wGKMonegato,xGMonegato,wGMonegato);

    double epsilon = 1e-16;

    using std::abs;
    for(DenseIndex i = 0; i < xGKLaurieGautschi.rows(); ++i)
    {
        if ((abs(xGKLaurieGautschi(i) - xGKPiessens(i)) > epsilon)
           || (abs(xGKLaurieGautschi(i) - xGKMonegato(i)) > epsilon)
           || (abs(xGKPiessens(i) - xGKMonegato(i)) > epsilon))
        {
            std::cout << "Failed xGK " << i << std::endl;
            return EXIT_FAILURE;
        }
    }

    for(DenseIndex i = 0; i < wGKLaurieGautschi.rows(); ++i)
    {
        if ((abs(wGKLaurieGautschi(i) - wGKPiessens(i)) > epsilon)
           || (abs(wGKLaurieGautschi(i) - wGKMonegato(i)) > epsilon)
           || (abs(wGKPiessens(i) - wGKMonegato(i)) > epsilon))
        {
            std::cout << "Failed wGK " << i << std::endl;
            return EXIT_FAILURE;
        }
    }
    
    // Note: Piessens and Monegato methods do not calculate the gauss nodes independently.
    //       Piessens and Monegato gauss nodes are taken directly from GaussKronrod nodes,
    //       and agreement in the GaussKronrod node test implies agreement for Gauss nodes.

    for(DenseIndex i = 0; i < wGLaurieGautschi.rows(); ++i)
    {
        if ((abs(wGLaurieGautschi(i) - wGPiessens(i)) > epsilon)
           || (abs(wGLaurieGautschi(i) - wGMonegato(i)) > epsilon)
           || (abs(wGPiessens(i) - wGMonegato(i)) > epsilon))
        {
            std::cout << "Failed wG " << i << std::endl;
            return EXIT_FAILURE;
        }
    }

    std::cout << "Tests Succeeded" << std::endl;
    return EXIT_SUCCESS;<commit_msg>Modifiy terminal output formatting of testComputeNodesWeights to match other tests.<commit_after>/**
 * \file testComputeNodesWeights.cpp
 * This file is a unit test for ComputeGaussKronrodNodesWeights.h.
 * The test is used to compare two different approaches to computing Gauss-Kronrod node and
 * weight values for a single ruleset for agreement at the specified level of precision.
 */

#include <NumericalIntegration.h>

#include <iostream>
#include <fstream>
#include <iomanip>
#include <Eigen/Dense>

using namespace Eigen;

int test_nodes_weights_difference(const unsigned int N)
{
    //typedef float Scalar;
    //typedef double Scalar;
    typedef long double Scalar;
    //typedef mpfr::mpreal Scalar;
    //Scalar::set_default_prec(50);

    typedef Eigen::LaurieGautschi<Scalar> LaurieGautschiPolicy;
    typedef Eigen::Piessens<Scalar> PiessensPolicy;
    typedef Eigen::Monegato<Scalar> MonegatoPolicy;

    Eigen::Array<Scalar, Eigen::Dynamic, 1> xGKLaurieGautschi;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> wGKLaurieGautschi;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> xGLaurieGautschi;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> wGLaurieGautschi;

    Eigen::Array<Scalar, Eigen::Dynamic, 1> xGKPiessens;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> wGKPiessens;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> xGPiessens;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> wGPiessens;

    Eigen::Array<Scalar, Eigen::Dynamic, 1> xGKMonegato;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> wGKMonegato;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> xGMonegato;
    Eigen::Array<Scalar, Eigen::Dynamic, 1> wGMonegato;

    LaurieGautschiPolicy::computeAbscissaeAndWeights(N,xGKLaurieGautschi,wGKLaurieGautschi,xGLaurieGautschi,wGLaurieGautschi);
    PiessensPolicy::computeAbscissaeAndWeights(N,xGKPiessens,wGKPiessens,xGPiessens,wGPiessens);
    MonegatoPolicy::computeAbscissaeAndWeights(N,xGKMonegato,wGKMonegato,xGMonegato,wGMonegato);

    double epsilon = 1e-16;

    using std::abs;
    for(DenseIndex i = 0; i < xGKLaurieGautschi.rows(); ++i)
    {
        if ((abs(xGKLaurieGautschi(i) - xGKPiessens(i)) > epsilon)
           || (abs(xGKLaurieGautschi(i) - xGKMonegato(i)) > epsilon)
           || (abs(xGKPiessens(i) - xGKMonegato(i)) > epsilon))
        {
            std::cout << "Failed xGK " << i << std::endl;
            return EXIT_FAILURE;
        }
    }

    for(DenseIndex i = 0; i < wGKLaurieGautschi.rows(); ++i)
    {
        if ((abs(wGKLaurieGautschi(i) - wGKPiessens(i)) > epsilon)
           || (abs(wGKLaurieGautschi(i) - wGKMonegato(i)) > epsilon)
           || (abs(wGKPiessens(i) - wGKMonegato(i)) > epsilon))
        {
            std::cout << "Failed wGK " << i << std::endl;
            return EXIT_FAILURE;
        }
    }
    
    // Note: Piessens and Monegato methods do not calculate the gauss nodes independently.
    //       Piessens and Monegato gauss nodes are taken directly from GaussKronrod nodes,
    //       and agreement in the GaussKronrod node test implies agreement for Gauss nodes.

    for(DenseIndex i = 0; i < wGLaurieGautschi.rows(); ++i)
    {
        if ((abs(wGLaurieGautschi(i) - wGPiessens(i)) > epsilon)
           || (abs(wGLaurieGautschi(i) - wGMonegato(i)) > epsilon)
           || (abs(wGPiessens(i) - wGMonegato(i)) > epsilon))
        {
            std::cout << "Failed wG " << i << std::endl;
            return EXIT_FAILURE;
        }
    }

    std::cout << "\n\tTests Succeeded!\n" << std::endl;
    return EXIT_SUCCESS;
{'fraction_non_alphanumeric': 0.12516240796881767, 'fraction_numerical': 0.0057745055579616, 'mean_word_length': 3.5638998682476943, 'pattern_counts': {'":': 0, '<': 93, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3289270', 'n_tokens_mistral': 2696, 'n_tokens_neox': 2548, 'n_words': 500}