diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8795ad9..5f78ee0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,8 +23,8 @@ jobs: submodules: recursive - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - - name: Build crates - run: cargo build --all + - name: Build main crate + run: cargo build -p integraal --all-features build_examples: name: Build examples for ${{ matrix.os }} strategy: diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 098be68..9b7d4ed 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -30,12 +30,12 @@ jobs: - uses: Swatinem/rust-cache@v2 # generate raw coverage data - name: Build code - run: cargo build --all-features + run: cargo build --all-features --workspace --exclude integraal-examples env: RUSTFLAGS: "-Cinstrument-coverage" LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw" - name: Run tests - run: cargo test --all-features + run: cargo test --all-features --workspace --exclude integraal-examples env: RUSTFLAGS: "-Cinstrument-coverage" LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8cecdfe..0678188 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,6 +24,6 @@ jobs: # Publish - name: Publish core - run: cargo publish --token ${CIO_TOKEN} + run: cargo publish --package integraal --token ${CIO_TOKEN} env: CIO_TOKEN: ${{ secrets.CRATESIO_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fc4ad6a..787d1a1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,4 +40,4 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - name: Run Tests - run: cargo test --all \ No newline at end of file + run: cargo test --all --all-features \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index c7cc297..be1a1b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,12 @@ -[package] -name = "integraal" +[workspace] + +resolver = "2" +members = [ + "integraal", + "examples" +] + +[workspace.package] version = "0.0.1" edition = "2021" license = "MIT OR Apache-2.0" @@ -11,47 +18,11 @@ categories = ["algorithms", "concurrency", "mathematics", "science"] keywords = ["algorithms", "analysis", "integration", "numerical-analysis", "numerical-method"] authors = ["Isaie Muron "] +[workspace.dependencies] +# members +integraal = { version = "0.0.1", path = "./integraal" } +integraal-examples = { version = "0.0.1", path = "./examples" } -# FEATURES - -[features] -montecarlo = ["dep:rand"] - -# DEPS - -[dependencies] -rand = { version = "0.9.0-alpha.1", features = ["small_rng"], optional = true } - -[build-dependencies] +# external +rand = "0.9.0-alpha.1" rustversion = "1.0.15" - -[dev-dependencies] -rand = { version = "0.9.0-alpha.1", features = ["small_rng"] } - -# EXAMPLES - -[[example]] -name = "rectangle_hardcoded" -path = "examples/rectangle/hardcoded.rs" - -[[example]] -name = "rectangle_integraal" -path = "examples/rectangle/integraal.rs" - -[[example]] -name = "trapezoid_hardcoded" -path = "examples/trapezoid/hardcoded.rs" - -[[example]] -name = "trapezoid_integraal" -path = "examples/trapezoid/integraal.rs" - -[[example]] -name = "montecarlo_hardcoded" -path = "examples/montecarlo/hardcoded.rs" -required-features = ["montecarlo"] # not necessary, but enabled for consistency - -[[example]] -name = "montecarlo_integraal" -path = "examples/montecarlo/integraal.rs" -required-features = ["montecarlo"] \ No newline at end of file diff --git a/examples/Cargo.toml b/examples/Cargo.toml new file mode 100644 index 0000000..be20ea3 --- /dev/null +++ b/examples/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "integraal-examples" +version = "0.0.1" +edition = "2021" +license = "MIT OR Apache-2.0" +homepage = "https://imrn99.github.io/integraal/" +repository = "https://github.com/imrn99/integraal" +readme = "../README.md" +description = "Example of the Integraal crate" +categories = ["algorithms", "concurrency", "mathematics", "science"] +keywords = ["algorithms", "analysis", "integration", "numerical-analysis", "numerical-method"] +authors = ["Isaie Muron "] + +[dependencies] +integraal = { workspace = true, features = ["montecarlo"] } +rand = { workspace = true, features = ["small_rng"] } + +# EXAMPLES + +[[example]] +name = "rectangle_hardcoded" +path = "examples/rectangle/hardcoded.rs" + +[[example]] +name = "rectangle_integraal" +path = "examples/rectangle/integraal.rs" + +[[example]] +name = "trapezoid_hardcoded" +path = "examples/trapezoid/hardcoded.rs" + +[[example]] +name = "trapezoid_integraal" +path = "examples/trapezoid/integraal.rs" + +[[example]] +name = "montecarlo_hardcoded" +path = "examples/montecarlo/hardcoded.rs" + +[[example]] +name = "montecarlo_integraal" +path = "examples/montecarlo/integraal.rs" diff --git a/examples/montecarlo/hardcoded.rs b/examples/examples/montecarlo/hardcoded.rs similarity index 100% rename from examples/montecarlo/hardcoded.rs rename to examples/examples/montecarlo/hardcoded.rs diff --git a/examples/montecarlo/integraal.rs b/examples/examples/montecarlo/integraal.rs similarity index 100% rename from examples/montecarlo/integraal.rs rename to examples/examples/montecarlo/integraal.rs diff --git a/examples/rectangle/hardcoded.rs b/examples/examples/rectangle/hardcoded.rs similarity index 100% rename from examples/rectangle/hardcoded.rs rename to examples/examples/rectangle/hardcoded.rs diff --git a/examples/rectangle/integraal.rs b/examples/examples/rectangle/integraal.rs similarity index 100% rename from examples/rectangle/integraal.rs rename to examples/examples/rectangle/integraal.rs diff --git a/examples/trapezoid/hardcoded.rs b/examples/examples/trapezoid/hardcoded.rs similarity index 100% rename from examples/trapezoid/hardcoded.rs rename to examples/examples/trapezoid/hardcoded.rs diff --git a/examples/trapezoid/integraal.rs b/examples/examples/trapezoid/integraal.rs similarity index 100% rename from examples/trapezoid/integraal.rs rename to examples/examples/trapezoid/integraal.rs diff --git a/integraal/Cargo.toml b/integraal/Cargo.toml new file mode 100644 index 0000000..2f57d98 --- /dev/null +++ b/integraal/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "integraal" +version = "0.0.1" +edition = "2021" +license = "MIT OR Apache-2.0" +homepage = "https://imrn99.github.io/integraal/" +repository = "https://github.com/imrn99/integraal" +readme = "../README.md" +description = "Integral computation, done in Rust! " +categories = ["algorithms", "concurrency", "mathematics", "science"] +keywords = ["algorithms", "analysis", "integration", "numerical-analysis", "numerical-method"] +authors = ["Isaie Muron "] + + +# FEATURES + +[features] +montecarlo = ["dep:rand"] + +# DEPS + +[dependencies] +rand = { workspace = true, features = ["small_rng"], optional = true } + +[build-dependencies] +rustversion.workspace = true + +[dev-dependencies] +rand = { workspace = true, features = ["small_rng"] } diff --git a/build.rs b/integraal/build.rs similarity index 100% rename from build.rs rename to integraal/build.rs diff --git a/src/lib.rs b/integraal/src/lib.rs similarity index 100% rename from src/lib.rs rename to integraal/src/lib.rs diff --git a/src/parameters.rs b/integraal/src/parameters.rs similarity index 88% rename from src/parameters.rs rename to integraal/src/parameters.rs index 396273c..f9eddbe 100644 --- a/src/parameters.rs +++ b/integraal/src/parameters.rs @@ -43,6 +43,9 @@ pub enum ComputeMethod { /// Trapezoid method [reference](https://en.wikipedia.org/wiki/Trapezoidal_rule) Trapezoid, #[cfg(feature = "montecarlo")] - /// MonteCarlo method [reference](https://en.wikipedia.org/wiki/Monte_Carlo_integration) - MonteCarlo { n_sample: usize }, + /// Monte-Carlo method [reference](https://en.wikipedia.org/wiki/Monte_Carlo_integration) + MonteCarlo { + /// Number of random number sample per step computation. + n_sample: usize, + }, } diff --git a/src/structure/definitions.rs b/integraal/src/structure/definitions.rs similarity index 100% rename from src/structure/definitions.rs rename to integraal/src/structure/definitions.rs diff --git a/src/structure/implementations.rs b/integraal/src/structure/implementations.rs similarity index 100% rename from src/structure/implementations.rs rename to integraal/src/structure/implementations.rs diff --git a/src/structure/mod.rs b/integraal/src/structure/mod.rs similarity index 100% rename from src/structure/mod.rs rename to integraal/src/structure/mod.rs diff --git a/src/structure/tests.rs b/integraal/src/structure/tests.rs similarity index 100% rename from src/structure/tests.rs rename to integraal/src/structure/tests.rs