<commit_before>// Simple example file for the auto-differentiation module
// (c) 2014 by <NAME>
// =======================================================

// $CXX -o autodiff autodiff.cc `$LIBMESH_DIR/bin/libmesh-config --cppflags --cxxflags --include --libs` -I $LIBMESH_DIR/include/libmesh

#include "libmesh/fparser_ad.hh"

#include <fstream>
#include <iostream>
#include <string>

void write(const char *fname, FunctionParserAD & F)
{
  std::ofstream file;
  file.open(fname);
  for (double x = -1.0; x <= 1.0; x+=0.01)
    file << x << ' ' << F.Eval(&x) << '\n';
  file.close();
}

int main()
{
#ifndef FUNCTIONPARSER_SUPPORT_DEBUGGING
  std::cout << "Please configure libMesh with --enable-fparser-debugging and rebuild to enable bytecode output.\n";
#endif

  std::string function;
  FunctionParserAD fparser;

  std::string func = "2 + 4*x + 8*x^2 + 16*x^3 + 32*x^4";

  // Parse the input expression into bytecode
  fparser.Parse(func, "x,a");
  std::cout << "Input Expression:\n" << func << std::endl;
#ifdef FUNCTIONPARSER_SUPPORT_DEBUGGING
  fparser.PrintByteCode(std::cout);
#endif
  std::cout << std::endl;
  write("input_orig.dat", fparser);

  // output optimized version
  fparser.Optimize();
  std::cout << "Optimized Input Expression:\n" << func << std::endl;
#ifdef FUNCTIONPARSER_SUPPORT_DEBUGGING
  fparser.PrintByteCode(std::cout);
#endif
  std::cout << std::endl;
  write("input_opt.dat", fparser);
<commit_msg>Testing erf. Function output good. Derivative output symmetric which it should be but it's wrong (calculate offset tomorrow)<commit_after>// Simple example file for the auto-differentiation module
// (c) 2014 by <NAME>
// =======================================================

// $CXX -o autodiff autodiff.cc `$LIBMESH_DIR/bin/libmesh-config --cppflags --cxxflags --include --libs` -I $LIBMESH_DIR/include/libmesh

#include "libmesh/fparser_ad.hh"

#include <fstream>
#include <iostream>
#include <string>

void write(const char *fname, FunctionParserAD & F)
{
  std::ofstream file;
  file.open(fname);
  for (double x = -1.0; x <= 1.0; x+=0.01)
    file << x << ' ' << F.Eval(&x) << '\n';
  file.close();
}

int main()
{
#ifndef FUNCTIONPARSER_SUPPORT_DEBUGGING
  std::cout << "Please configure libMesh with --enable-fparser-debugging and rebuild to enable bytecode output.\n";
#endif

  std::string function;
  FunctionParserAD fparser;

  // std::string func = "2 + 4*x + 8*x^2 + 16*x^3 + 32*x^4";
  std::string func = "erf(x)";

  // Parse the input expression into bytecode
  fparser.Parse(func, "x,a");
  std::cout << "Input Expression:\n" << func << std::endl;
#ifdef FUNCTIONPARSER_SUPPORT_DEBUGGING
  fparser.PrintByteCode(std::cout);
#endif
  std::cout << std::endl;
  write("input_orig.dat", fparser);

  // output optimized version
  fparser.Optimize();
  std::cout << "Optimized Input Expression:\n" << func << std::endl;
#ifdef FUNCTIONPARSER_SUPPORT_DEBUGGING
  fparser.PrintByteCode(std::cout);
#endif
  std::cout << std::endl;
  write("input_opt.dat", fparser);

{'fraction_non_alphanumeric': 0.1932383162081538, 'fraction_numerical': 0.013921113689095127, 'mean_word_length': 4.558011049723757, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 11, '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': '5432834', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1042, 'n_words': 258}