←back to thread

123 points mtantaoui | 5 comments | | HN request time: 1.33s | source

Integrate is a fast, small, lightweight Rust library for performing numerical integration of real-valued functions. It is designed to integrate functions, providing a simple and efficient way to approximate definite integrals using various numerical methods.

Integrate supports a variety of numerical integration techniques: - Newton-Cotes methods:

  - Rectangle Rule.
  - Trapezoidal Rule.
  - Simpson's Rule.
  - Newton's 3/8 Rule.
- Gauss quadrature methods:

  - Gauss-Legendre.
  - Gauss-Laguerre.
  - Gauss-Hermite.
  - Gauss-Chebyshev First Kind.
  - Gauss-Chebyshev Second Kind.
- Adaptive Methods:

  - Adaptive Simpson's method
- Romberg’s method.
Show context
JanisErdmanis ◴[] No.42183942[source]
It looks a bit sloppy to hardcode so many constants in a single file: `src/gauss_quadrature/legendre.rs`. Isn't it possible to generate them with the help of rust macros in the same way Julia uses metaprogramming?
replies(3): >>42184353 #>>42185117 #>>42185548 #
ok123456 ◴[] No.42184353[source]
Gaussian quadrature points are typically solved numerically. There's a good chance these ultimately came from a table.

Additionally, compile time floating-point evaluation is limited. When I looked around recently, I didn't see a rust equivalent of gcem; any kind of transcendental function evaluation (which finding Gaussian quadrature points absolutely would require) would not allow compile-time evaluation.

replies(2): >>42185264 #>>42186782 #
1. zokier ◴[] No.42186782[source]
I was under the impression that macros can execute arbitrary code, surely some FP would not be big problem. And if not macros then build.rs script certainly could do the trick.
replies(1): >>42187277 #
2. dhosek ◴[] No.42187277[source]
build.rs can definitely execute arbitrary code, which means that a lot of places (including, IIRC crates.io) will forbid crates that rely on build.rs. I ended up refactoring my build.rs into a separate sub-application in finl_unicode that built data tables which are then checked into git and used pre-built. I include the sub-app in the source code so that anyone with access to the repo could continue development if I were to die tomorrow.
replies(1): >>42188113 #
3. n_plus_1_acc ◴[] No.42188113[source]
There are many crates with build.rs scripts on crates.io, because they host just the source code with the Cargo.{toml,lock}.
replies(1): >>42188859 #
4. dhosek ◴[] No.42188859{3}[source]
I ran into some issues with crates.io and my build.rs when I first released the crate, although it’s long enough ago, that I don’t remember exactly what the issue was. It might also have been that the build.rs script downloaded raw data files from unicode.org
replies(1): >>42190262 #
5. Arnavion ◴[] No.42190262{4}[source]
crates.io doesn't care what your build.rs does because it doesn't try to compile your code, neither now or ever in the past. There would be no point in it trying to compile your code; there are lots of crates that are bindings to C libraries that crates.io's builders can't be expected to have, crates that target architectures which crates.io can't be expected to have builders for, etc.