<commit_before>#include <iostream>
#include <iomanip>
#include <iosfwd>
#include <cmath>
#include <limits>

using namespace std;

#include "LibUtilities/Foundations/Foundations.hpp"
#include <LibUtilities/Foundations/Points.h>
#include <LibUtilities/Foundations/PolyEPoints.h>

using namespace Nektar;
using namespace Nektar::LibUtilities;


// Quintic polynomial
long double polyFunc(long double x)
{
    return  (((3.0*x*x - 5.0)*x + 1.0)*x - 2.0)*x + 3.0;
}

// Derivative of the Quintic polynomial
long double derivativePolyFunc(long double x)
{
    return ((15.0*x*x - 15.0)*x   + 2.0)*x - 2.0;
}

// A Fourier function that integrates to 0 with the Trapezoidal rule
long double fourierFunc(long double x, int N)
{
    long double z = M_PI*(x + 1.0);
    return (cos(N/2.0*z) + sin((N/2.0 - 2.0)*z))/M_PI;
}

// Derivative of the Fourier function above
long double derivativeFourierFunc(long double x, int N)
{
    long double z = M_PI*(x + 1.0);
    long double a = (N-4.0)/2.0;
    long double b = N/2.0;
    return M_PI*M_PI*(a*cos(a*z) - b*sin(b*z));
}

long double function(long double x, int N, PointsType type)
{
    long double y = 0;
    if( type == eFourierEvenlySpaced)
    {
        y = fourierFunc(x,N);
    } else
    {
        y = polyFunc(x);
    }
    return y;
}

long double derivativeFunction(long double x, int N, PointsType type)
{
    long double yDerivative = 0;
    if(type == eFourierEvenlySpaced)
    {
         yDerivative = derivativeFourierFunc(x, N);
    }
    else
    {
         yDerivative = derivativePolyFunc(x);
    }
    return yDerivative;
}

long double integrationFunction(int nPts, PointsType type)
{
   long double integral = 0;
   switch(type)
   {
       case  eFourierEvenlySpaced:
          integral = 0;
       break;
       default:
          integral = (long double)20.0/3.0;           
   }
   return integral;
}

long double integrandWeightFunction(long double x, PointsType type)
{
    long double weight = 1;

    switch(type)
    {
        case eGaussGaussChebyshev:
        case eGaussRadauMChebyshev:
        case eGaussRadauPChebyshev:
        case eGaussLobattoChebyshev: 
            weight = 1.0 / sqrt(1.0 - x*x);
        break;

        case eGaussRadauMAlpha0Beta1:
            // weight = 1.0 + x; // ?
        break;

        case eGaussRadauMAlpha0Beta2: 
            // weight = (1.0 + x)*(1.0 + x); // ?
        break;
                

        default:
            weight = 1.0;
    }
    return weight;
}
// This routine projects a polynomial or trigonmetric functions which
// has energy in all modes of the expansions and report an error.

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

    // Argument check: Display a help message if the count is wrong
    if(argc != 3)
    {
        cerr << "Usage: FoundationDemo Points1D-Type nPts" << endl;

        cerr << "Where type is an integer value which dictates the basis as:\n";
        for(int i=0; i<SIZE_PointsType; ++i) {
            cerr << setw(30) << kPointsTypeStr[i] << " = " << i << endl;
        }

        cerr << "Note type = 13, 14, and 15 are for two dimensional bases" << endl;
        cerr << "\nExample: FoundationDemo 5 6" << endl;
        cerr << "\n\t Tests GaussGaussChebyshev on 6 points" << endl;

        return 1; // Aborts main() function
    }

    // Read in the type for the points from the caller
    PointsType pointsType = (PointsType) atoi(argv[1]);
    if(pointsType == eNoPointsType)
    {
        cerr << "pointsType = " << pointsType << endl;
        cerr << "kPointsTypeStr["<<pointsType<<"] = " << kPointsTypeStr[pointsType] << endl;
        ErrorUtil::Error(ErrorUtil::efatal,__FILE__, __LINE__,
                  "No Points Type requested",0);
    }

    // Read in the number of points at which the function will be evaluated
    int nPts = atoi(argv[2]);

    // Show the set up to the user
    cout << "Points type:               " << kPointsTypeStr[pointsType] << endl;
    cout << "Number of points:          " << nPts << endl;
    
    // Display the example test function to the user
    if( pointsType == eFourierEvenlySpaced )
    {
        cout << "Trigonometric function:    ";
        cout << "f(x) = (cos(N/2.0*z) + sin((N/2.0 - 2.0)*z))/M_PI, where z = M_PI*(x + 1.0)" << endl;
    }
    else
    {
        cout << "Quintic polynomial:        ";
        cout << "p(x) = (((3.0*x*x - 5.0)*x + 1.0)*x - 2.0)*x + 3.0" << endl;
    }

    
    // Obtain a reference to a Points object via an appropriate PointsKey object
    PointsKey key(nPts, pointsType);
    boost::shared_ptr<Points<NekDouble> > points = PointsManager()[key];
    //const ptr<Points<NekDouble> > points = PointsManager()[key];

    // Get the abscissas and their matching quadrature weights
   //    SharedArray<const NekDouble> z, w;
    Array<OneD, const NekDouble> z, w;
    points->GetZW(z,w);

    // Evaluate the example function at the z[i] points in the interval [-1,1].
    // This generates the data samples, which we store in the y vector and use later
    // during interpolation/integration/differentiation
    //    SharedArray<NekDouble> y(nPts);
    Array<OneD, NekDouble> y(nPts);
    for(int i = 0; i < nPts; ++i)
    {
        y[i] = function( z[i], nPts, pointsType );<commit_msg>added Gauss-Konrod in test (only integration)<commit_after>#include <iostream>
#include <iomanip>
#include <iosfwd>
#include <cmath>
#include <limits>

using namespace std;

#include "LibUtilities/Foundations/Foundations.hpp"
#include <LibUtilities/Foundations/Points.h>
#include <LibUtilities/Foundations/PolyEPoints.h>

using namespace Nektar;
using namespace Nektar::LibUtilities;


// Quintic polynomial
long double polyFunc(long double x)
{
    return  (((3.0*x*x - 5.0)*x + 1.0)*x - 2.0)*x + 3.0;
}

// Derivative of the Quintic polynomial
long double derivativePolyFunc(long double x)
{
    return ((15.0*x*x - 15.0)*x   + 2.0)*x - 2.0;
}

// A Fourier function that integrates to 0 with the Trapezoidal rule
long double fourierFunc(long double x, int N)
{
    long double z = M_PI*(x + 1.0);
    return (cos(N/2.0*z) + sin((N/2.0 - 2.0)*z))/M_PI;
}

// Derivative of the Fourier function above
long double derivativeFourierFunc(long double x, int N)
{
    long double z = M_PI*(x + 1.0);
    long double a = (N-4.0)/2.0;
    long double b = N/2.0;
    return M_PI*M_PI*(a*cos(a*z) - b*sin(b*z));
}

long double function(long double x, int N, PointsType type)
{
    long double y = 0;
    if( type == eFourierEvenlySpaced)
    {
        y = fourierFunc(x,N);
    } else
    {
        y = polyFunc(x);
    }
    return y;
}

long double derivativeFunction(long double x, int N, PointsType type)
{
    long double yDerivative = 0;
    if(type == eFourierEvenlySpaced)
    {
         yDerivative = derivativeFourierFunc(x, N);
    }
    else
    {
         yDerivative = derivativePolyFunc(x);
    }
    return yDerivative;
}

long double integrationFunction(int nPts, PointsType type)
{
   long double integral = 0;
   switch(type)
   {
       case  eFourierEvenlySpaced:
          integral = 0;
       break;
       default:
          integral = (long double)20.0/3.0;           
   }
   return integral;
}

long double integrandWeightFunction(long double x, PointsType type)
{
    long double weight = 1;

    switch(type)
    {
        case eGaussGaussChebyshev:
        case eGaussRadauMChebyshev:
        case eGaussRadauPChebyshev:
        case eGaussLobattoChebyshev: 
            weight = 1.0 / sqrt(1.0 - x*x);
        break;

        case eGaussRadauMAlpha0Beta1:
            // weight = 1.0 + x; // ?
        break;

        case eGaussRadauMAlpha0Beta2: 
            // weight = (1.0 + x)*(1.0 + x); // ?
        break;
                

        default:
            weight = 1.0;
    }
    return weight;
}
// This routine projects a polynomial or trigonmetric functions which
// has energy in all modes of the expansions and report an error.

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

    // Argument check: Display a help message if the count is wrong
    if(argc != 3)
    {
        cerr << "Usage: FoundationDemo Points1D-Type nPts" << endl;

        cerr << "Where type is an integer value which dictates the basis as:\n";
        for(int i=0; i<SIZE_PointsType; ++i) {
            cerr << setw(30) << kPointsTypeStr[i] << " = " << i << endl;
        }

        cerr << "Note type = 18, 19, and 20 are for two dimensional bases" << endl;
        cerr << "\nExample: FoundationDemo 5 6" << endl;
        cerr << "\n\t Tests GaussGaussChebyshev on 6 points" << endl;

        return 1; // Aborts main() function
    }

    // Read in the type for the points from the caller
    PointsType pointsType = (PointsType) atoi(argv[1]);
    if(pointsType == eNoPointsType)
    {
        cerr << "pointsType = " << pointsType << endl;
        cerr << "kPointsTypeStr["<<pointsType<<"] = " << kPointsTypeStr[pointsType] << endl;
        ErrorUtil::Error(ErrorUtil::efatal,__FILE__, __LINE__,
                  "No Points Type requested",0);
    }

    // Read in the number of points at which the function will be evaluated
    int nPts = atoi(argv[2]);

    // Show the set up to the user
    cout << "Points type:               " << kPointsTypeStr[pointsType] << endl;
    cout << "Number of points:          " << nPts << endl;
    
    // Display the example test function to the user
    if( pointsType == eFourierEvenlySpaced )
    {
        cout << "Trigonometric function:    ";
        cout << "f(x) = (cos(N/2.0*z) + sin((N/2.0 - 2.0)*z))/M_PI, where z = M_PI*(x + 1.0)" << endl;
    }
    else
    {
        cout << "Quintic polynomial:        ";
        cout << "p(x) = (((3.0*x*x - 5.0)*x + 1.0)*x - 2.0)*x + 3.0" << endl;
    }

      // Obtain a reference to a Points object via an appropriate PointsKey object
    PointsKey key(nPts, pointsType);
    
    PointsSharedPtr points = PointsManager()[key];
    //boost::shared_ptr<Points<NekDouble> > points = PointsManager()[key];
    //const ptr<Points<NekDouble> > points = PointsManager()[key];
    
    
    // Get the abscissas and their matching quadrature weights
   //    SharedArray<const NekDouble> z, w;
    Array<OneD, const NekDouble> z, w;
    points->GetZW(z,w);

    // Evaluate the example function at the z[i] points in the interval [-1,1].
    // This generates the data samples, which we store in the y vector and use later
    // during interpolation/integration/differentiation
    //    SharedArray<NekDouble> y(nPts);
    Array<OneD, NekDouble> y(nPts);
    for(int i = 0; i < nPts; ++i)
    {
        y[i] = function( z[i], nPts, pointsType );
{'fraction_non_alphanumeric': 0.12793116490166415, 'fraction_numerical': 0.019288956127080183, 'mean_word_length': 2.411935483870968, 'pattern_counts': {'":': 0, '<': 173, '<?xml version=': 0, '>': 35, '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': '815942', 'n_tokens_mistral': 3731, 'n_tokens_neox': 3543, 'n_words': 1014}