Skip to content

v0.0.3 #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
results: ${{ steps.artifacts.outputs.artifact-id }}
url: ${{ steps.artifacts.outputs.artifact-url }}
permissions:
contents: write
checks: write
Expand All @@ -78,7 +79,7 @@ jobs:
cache-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
-
name: Benchmark (${{ matrix.target }})
run: cargo bench --locked --workspace --all-features --workspace --verbose --
run: cargo bench --locked --verbose --workspace --all-features --
-
name: Upload the benchmarks
id: artifacts
Expand Down
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 8 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
[workspace]
default-members = [
"rsdiff"
]

exclude = [
]

default-members = ["rsdiff"]
members = [
"rsdiff",
"core",
"derive",
"graphs",
"macros",
"math",

]
resolver = "3"

Expand All @@ -38,20 +31,18 @@ license = "Apache-2.0"
repository = "https://github.com/FL03/rsdiff.git"
readme = "README.md"
rust-version = "1.85.0"
version = "0.0.2"
# version = "0.3.2-nightly"
version = "0.0.3"

[workspace.dependencies]
# local
rsdiff = { default-features = false, path = "rsdiff", version = "0.0.2" }
rsdiff-core = { default-features = false, path = "core", version = "0.0.2" }
rsdiff-derive = { default-features = false, path = "derive", version = "0.0.2" }
rsdiff-graphs = { default-features = false, path = "graphs", version = "0.0.2" }
rsdiff-macros = { default-features = false, path = "macros", version = "0.0.2" }
rsdiff-math = { default-features = false, path = "math", version = "0.0.2" }
rsdiff = { default-features = false, path = "rsdiff", version = "0.0.3" }
rsdiff-core = { default-features = false, path = "core", version = "0.0.3" }
rsdiff-derive = { default-features = false, path = "derive", version = "0.0.3" }
rsdiff-graphs = { default-features = false, path = "graphs", version = "0.0.3" }
rsdiff-macros = { default-features = false, path = "macros", version = "0.0.3" }
rsdiff-math = { default-features = false, path = "math", version = "0.0.3" }
# custom
scsys = { default-features = false, features = ["derive"], version = "0.3.0" }

# benchmarking
criterion = { version = "0.6" }
# concurrency & parallelism
Expand Down
62 changes: 22 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Autodifferentiation is a powerful technique used in machine learning and optimiz

## Features

- [x] `hash_graph` - A hash-based hypergraph implementation.
- [x] `macros` - enables the `autodiff` macro for automatically differentiating in-place logic.

## Usage

Expand All @@ -25,10 +25,9 @@ Add this to your `Cargo.toml`:
```toml
[dependencies.rsdiff]
features = [
"hash_graph",
"macros",
]
version = "0.1.x"
version = "0.0.x"
```

### Examples
Expand All @@ -38,45 +37,28 @@ For more detailed examples, please refer to the [examples directory](https://git
#### _Example #1:_ Basic Usage

```rust
extern crate rsdiff;

fn main() -> rsdiff::Result<()> {
// initialize a new instance of a hypergraph
let mut graph: HashGraph<usize, usize> = HashGraph::new();
// use the macro to insert nodes into the graph
rsdiff::hypernode! {
graph {
let v0;
let v1 = 2;
let v2 = 3;
let v3 = 4;
}
}
// Add some hyperedges
let e1 = graph.insert_edge(vec![v0, v1, v2])?;
println!("Added hyperedge {e1}: {:?}", [v0, v1, v2]);

let e2 = graph.insert_edge(vec![v1, v2, v3])?;
println!("Added hyperedge {e2}: {:?}", [v1, v2, v3]);

// Get neighbors of vertex v1
let neighbors = graph.neighbors(&v1)?;
println!("Neighbors of {}: {:?}", v1, neighbors);

// Get degree of vertex v1
let degree = graph.get_degree_of_node(&v1);
println!("Degree of {v1}: {degree}");

// Remove a vertex
graph.remove_vertex(&v2)?;
println!("Removed vertex {v2}");

println!("---------\nFinal graph state: {:?}", graph);
Ok(())
}

use rsdiff::autodiff;

fn main() {
let x = 3f64;
let y = 4f64;
assert_eq!(y, autodiff!(x: x * y));
assert_eq!(x, autodiff!(y: x * y));
assert_eq!(1f64, autodiff!(x: x + y));
}
```

### _Example #2:_ Trigonometric functions

```rust
use rsdiff::autodiff;

fn main() {
let x = 2f64;
assert_eq!(autodiff!(x: x.cos()), -x.sin());
assert_eq!(autodiff!(x: x.sin()), x.cos());
assert_eq!(autodiff!(x: x.tan()), x.cos().powi(2).recip());
}
## Getting Started

### Prerequisites
Expand Down
10 changes: 5 additions & 5 deletions rsdiff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,24 @@ num = { workspace = true }

[features]
default = [
"core",
"std",
"macros",
"math",
"graph",
]

full = [
"default",
"derive",
"graph",
"json",
"serde",
"tracing",
]

# ************* [FF:Features] *************
core = []

derive = [
"dep:rsdiff-derive",
"macros"
"macros",
]

graph = ["dep:rsdiff-graphs"]
Expand All @@ -73,6 +72,7 @@ math = ["dep:rsdiff-math"]

# ************* [FF:Environments] *************
std = [
"alloc",
"rsdiff-core/std",
"rsdiff-graphs/std",
]
Expand Down