Git Product home page Git Product logo

pe's Introduction

pe

Build status Build status Build status Github Releases project euler

baihacker's C++ library for solving problem on project euler.

Prerequirements:

C++ dev environment that supports

  • C++17 or above.
  • Building x86_64 targets.

Installation:

  • Make sure "#include <pe.hpp>" work.

    • Put all the files in an installation folder (directory).
    • Add the installation folder to the environment variable CPLUS_INCLUDE_PATH. Other approaches are also OK.
  • Configure this library

    • Execute gen_config.py in the installation folder to generate pe_config.
      • Static configuration. The values are always 1 in the generated config file. You can edit the values after generating the config file.
        • ENABLE_ASSERT whether to assert some inputs or conditions.
        • TRY_TO_USE_INT128 whether to check whether the compiler support int128 and use it. If it is 0, it int128 is disabled even if the compiler supports it.
      • Auto-deduced configuration for third party libraries. The script searches for the corresponding header file and set the value to 1 if found. See Build and use pe's dependent libraries for the pre-built third party binaries.
        • ENABLE_EIGEN whether to use Eigen library.
        • ENABLE_GMP whether to use gmp.
        • ENABLE_FLINT whether to use FLINT.
        • ENABLE_MPFR whether to use mpfr.
        • ENABLE_LIBBF wheter to use libbf.
        • ENABLE_NTL whether to use ntl.
    • Edit the pe_config by adding more configuration items manually.
      • ENABLE_OPENMP whether to use openmp. It is NOT generated by the script automatically becaused it's inferred at the compiling time. You can still define it in pe_config to prevernt the library from inferring the value from the compiling environment. If it is enabled but the environment doesn't support it, a warning message will show.
  • [optional, recommended] Generate precompile header "pe.hpp.gch".

    • Run "g++ -xc++-header pe.hpp" in the installation folder.
    • Add more compiling options if necessary. Usually, they are the same as the options used to build your binary. e.g. "g++ -xc++-header pe.hpp --std=c++17 -O3 -march=native -fopenmp".

Use:

See example.c for quick start.

File list:

  • pe: Including all the implementation files.
  • pe.hpp: The file for generating precompile header. It only includes pe.
  • pe_algo: Algorithms.
  • pe_array: An array implementation with compiling time dimension length. The element count can be more than the limit of int32 and you can specify customized allocator.
  • pe_base: Some pre-including headers. Some macros and typedef. Some basic inline functions.
  • pe_bi32: Big integer whose base is 1 << 32.
  • pe_bit: Bit operation tricks.
  • pe_config: a centralized place the configure pe.
  • pe_db: load and save pre-calculated result such as prime pi and prime sum.
  • pe_extended_int: The extended integer.
  • pe_extended_signed_int: Extended signed integer.
  • pe_extended_unsigned_int: Extended unsigned integer.
  • pe_fft: Fast fourier transform and polynomial multiplication.
  • pe_float128: Unified float number functions of __float128.
  • pe_fraction: Fraction arithmetic.
  • pe_gbi: general big integer. The content corresponds to pe_nt.
  • pe_geometry: Support Point2D and Point3D.
  • pe_initializer: The helper class and macros used to initialize the library.
  • pe_int: Basic integer utilities.
  • pe_int128: Support to output int128 and the corresponding type traits.
  • pe_internal: Include configurations, define necessary types/macros and include third party libraries.
  • pe_io: methods and macros that simplify or fasten reading from and writing std io.
  • pe_mat: Matrix operations.
  • pe_memory: Memory manipulation such as allocating large memory. (windows only)
  • pe_misc: misc codes.
  • pe_mma: support mma: helper method or class to generate mma codes.
  • pe_mod: Modular arithmetic.
  • pe_nt: Basic code of number theory.
  • pe_nt_base: Generate prime list, factorize integer, prime test, compute phi and mu.
  • pe_parallel: A simple framework to solve problem with multi-threads. (windows only)
  • pe_parallel_algo: Parallel algorithms.
  • pe_persistance: KVPersistance. (it may support linux if we change the generated cmdline and check the other codes)
  • pe_poly: Polynomial c++ wrapper.
  • pe_poly_algo: Polynomial algorithms.
  • pe_poly_base: Polynomial basic algorithms.
  • pe_poly_base_flint: Flint based polynomial basic algorithms.
  • pe_poly_base_libbf: Libbf based polynomial basic algorithms.
  • pe_poly_base_min25: Min_25's polynomial basic algorithms. The polynomial multiplication implementation is the fastest one among mod polynomials integrated into pe.
  • pe_poly_base_ntl: Ntl based polynomial basic algorithms.
  • pe_rand: Random number.
  • pe_range: generate an range of numbers, iterate a container with index.
  • pe_sym_poly: Symbolic polynomial.
  • pe_time: Support TimeDelta, TimeRecorder.
  • pe_tree: Some tree based data structures.
  • pe_type_traits: Type traits.

pe's People

Contributors

baihacker avatar

Stargazers

Xiaozhou Zhao avatar Israfil Gasim avatar Marcelo Fornet avatar Paolo avatar Jorge Luis Ibáñez avatar Jeongseop Lee avatar Hyunjae Lee avatar David Clyde avatar cgiosy avatar Mark Moretto avatar  avatar Darius avatar  avatar Abdul avatar  avatar  avatar  avatar Haoyang Li avatar  avatar  avatar palayutm avatar  avatar Gaurav Kumar avatar Zhusong Li avatar  avatar Timo Strating avatar Yung-Luen Lan avatar  avatar  avatar ysmull avatar Guangxi Liu avatar Bhavani Shankar avatar Dandiss Valjean avatar  avatar foreverbell avatar

Watchers

James Cloos avatar LG avatar Guangxi Liu avatar  avatar

pe's Issues

pe_ntt_min_25 might cause overflow in worst cases

Hello,

I noticed that my NTT function (which was submitted on yukicoder) may cause overflow in some worst cases.

The lines 166-170 should have been the following:

    for (int i = 0; i < size; ++i) (A[i] *= A[i]) *= inv; // not A[i] *= A[i] * inv;
  } else {
    fill(B + s2, B + size, 0);
    transform(B, size, roots, iroots);
    for (int i = 0; i < size; ++i) (A[i] *= B[i]) *= inv; // not A[i] *= B[i] * inv;

(And, recent NTL seems run faster than mine.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.