Skip to content

Commit 19c9d36

Browse files
committed
feat: add exact Hessian methods (RR, FR, RF) for mono and multi
Add exact second-order automatic differentiation using Reverse-over-Reverse, Forward-over-Reverse, and Reverse-over-Forward methods for both univariate and multivariate functions.
1 parent 9b677f6 commit 19c9d36

49 files changed

Lines changed: 26556 additions & 920 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Cargo configuration for petite-ad.
2+
#
3+
# The mold linker flag below speeds up local builds substantially.
4+
# If mold is not installed, the flag is silently ignored by the linker.
5+
# Remove or adjust the rustflags if needed for your machine.
6+
7+
[target.x86_64-unknown-linux-gnu]
8+
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
9+
10+
[registries.crates-io]
11+
protocol = "sparse" # Faster crate downloads

.github/workflows/ci.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master, develop]
6+
pull_request:
7+
branches: [main, master]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
rust: [stable, nightly]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Setup mold linker
24+
uses: rui314/setup-mold@v1
25+
26+
- name: Install Rust
27+
uses: dtolnay/rust-toolchain@master
28+
with:
29+
toolchain: ${{ matrix.rust }}
30+
components: rustfmt, clippy
31+
32+
- name: Setup Rust cache
33+
uses: Swatinem/rust-cache@v2
34+
with:
35+
key: ${{ matrix.rust }}
36+
37+
- name: Check formatting
38+
run: cargo fmt -- --check
39+
40+
- name: Run clippy
41+
run: cargo clippy --all-targets --all-features -- -D warnings
42+
43+
- name: Run tests
44+
run: cargo test --verbose --all-features
45+
46+
- name: Run examples
47+
run: cargo test --examples --all-features
48+
49+
- name: Run benchmarks (check only)
50+
run: cargo bench --no-run
51+
52+
coverage:
53+
name: Code Coverage
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- uses: actions/checkout@v4
58+
59+
- name: Setup mold linker
60+
uses: rui314/setup-mold@v1
61+
62+
- name: Install Rust
63+
uses: dtolnay/rust-toolchain@master
64+
with:
65+
toolchain: stable
66+
67+
- name: Setup Rust cache
68+
uses: Swatinem/rust-cache@v2
69+
70+
- name: Install cargo-tarpaulin
71+
run: cargo install cargo-tarpaulin
72+
73+
- name: Generate coverage report
74+
run: cargo tarpaulin --lib --out Xml
75+
76+
- name: Upload coverage to Codecov
77+
uses: codecov/codecov-action@v4
78+
with:
79+
file: ./cobertura.xml
80+
fail_ci_if_error: false
81+
82+
security:
83+
name: Security audit
84+
runs-on: ubuntu-latest
85+
86+
steps:
87+
- uses: actions/checkout@v4
88+
89+
- name: Setup mold linker
90+
uses: rui314/setup-mold@v1
91+
92+
- name: Install Rust
93+
uses: dtolnay/rust-toolchain@master
94+
with:
95+
toolchain: stable
96+
97+
- name: Install cargo-audit
98+
run: cargo install cargo-audit
99+
100+
- name: Generate temporary lockfile
101+
run: cargo generate-lockfile
102+
103+
- name: Run security audit
104+
run: cargo audit

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ target
1919
# and can be added to the global gitignore or merged into this file. For a more nuclear
2020
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
2121
#.idea/
22+
23+
Cargo.lock

.pre-commit-config.yaml

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,61 @@
1-
# Pre-commit hooks for Rust project
1+
# Pre-commit hooks for petite-ad
22
# See https://pre-commit.com for more information
3-
# Run `pre-commit install` to install these hooks
3+
# Install: pip install pre-commit
4+
# Setup: pre-commit install
5+
# Run manually: prek run --all-files # alias for: pre-commit run --all-files
46

57
repos:
6-
# General hooks
7-
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v5.0.0
9-
hooks:
10-
- id: trailing-whitespace
11-
- id: end-of-file-fixer
12-
- id: check-yaml
13-
- id: check-toml
14-
- id: check-added-large-files
15-
args: ['--maxkb=1000']
16-
- id: check-merge-conflict
17-
- id: check-case-conflict
18-
- id: mixed-line-ending
19-
args: ['--fix=lf']
20-
21-
# Rust specific hooks using local cargo commands
228
- repo: local
239
hooks:
10+
# Run cargo fmt to automatically format Rust files.
2411
- id: cargo-fmt
2512
name: cargo fmt
2613
entry: cargo fmt
2714
language: system
15+
types: [rust]
2816
pass_filenames: false
2917

30-
- id: cargo-check
31-
name: cargo check
32-
entry: cargo check
33-
language: system
34-
args: ['--all-targets', '--all-features']
35-
pass_filenames: false
36-
37-
# Clippy linting
38-
- repo: local
39-
hooks:
40-
- id: clippy
18+
# Run cargo clippy to catch common mistakes.
19+
- id: cargo-clippy
4120
name: cargo clippy
42-
entry: cargo clippy
21+
entry: cargo clippy --all-targets --all-features -- -D warnings
4322
language: system
44-
args: ['--all-targets', '--all-features', '--', '-D', 'warnings']
23+
types: [rust]
4524
pass_filenames: false
4625

47-
# Run tests
48-
- repo: local
49-
hooks:
26+
# Run cargo test to ensure all tests pass.
5027
- id: cargo-test
5128
name: cargo test
52-
entry: cargo test
29+
entry: cargo test --all-features
5330
language: system
54-
args: ['--all-features']
31+
types: [rust]
5532
pass_filenames: false
5633

57-
# Check documentation
58-
- repo: local
34+
# Generic pre-commit hooks for non-Rust files.
35+
- repo: https://github.com/pre-commit/pre-commit-hooks
36+
rev: v6.0.0
5937
hooks:
60-
- id: cargo-doc
61-
name: cargo doc
62-
entry: cargo doc
63-
language: system
64-
args: ['--no-deps', '--all-features']
65-
pass_filenames: false
38+
# Check for accidentally committed large files.
39+
- id: check-added-large-files
40+
args: ["--maxkb=10000"]
41+
42+
# Check config file syntax.
43+
- id: check-yaml
44+
- id: check-json
45+
- id: check-toml
46+
47+
# Fix whitespace-only file hygiene issues.
48+
- id: trailing-whitespace
49+
exclude: ^(tests/|fixtures/)
50+
- id: end-of-file-fixer
51+
52+
# Detect conflict markers and case-insensitive path collisions.
53+
- id: check-merge-conflict
54+
- id: check-case-conflict
55+
56+
# Normalize line endings.
57+
- id: mixed-line-ending
58+
args: ["--fix=lf"]
59+
60+
# Check that scripts with shebangs are executable.
61+
- id: check-executables-have-shebangs

0 commit comments

Comments
 (0)