{"id":23978328,"url":"https://github.com/wrsturgeon/dxpr","last_synced_at":"2025-08-17T13:38:29.081Z","repository":{"id":148309828,"uuid":"620012330","full_name":"wrsturgeon/dxpr","owner":"wrsturgeon","description":"crates.io: Differentiable expression templates in Rust.","archived":false,"fork":false,"pushed_at":"2023-03-30T03:42:49.000Z","size":48,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-17T13:38:28.640Z","etag":null,"topics":["autodiff","crates-io","differentiable","differentiable-programming","expression-templates","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/dxpr","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wrsturgeon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-27T21:20:46.000Z","updated_at":"2024-01-12T12:20:41.000Z","dependencies_parsed_at":"2023-05-20T06:30:19.164Z","dependency_job_id":null,"html_url":"https://github.com/wrsturgeon/dxpr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wrsturgeon/dxpr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wrsturgeon%2Fdxpr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wrsturgeon%2Fdxpr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wrsturgeon%2Fdxpr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wrsturgeon%2Fdxpr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wrsturgeon","download_url":"https://codeload.github.com/wrsturgeon/dxpr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wrsturgeon%2Fdxpr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270856563,"owners_count":24657688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autodiff","crates-io","differentiable","differentiable-programming","expression-templates","rust"],"created_at":"2025-01-07T08:17:51.735Z","updated_at":"2025-08-17T13:38:29.072Z","avatar_url":"https://github.com/wrsturgeon.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dxpr\nDifferentiable expression templates in compile-time, dependency-free, no_std Rust.\n\n## Examples\n\nBasics:\n```rust\nuse dxpr::prelude::*;\nlet x = 4; // Any type works; no special wrappers\nlet expr = -var(\u0026x); // Unevaluated expression\nassert_eq!(-4, expr.eval()); // Evaluated (expr moved)\nlet dvdx = (-var(\u0026x)).grad(\u0026x); // Automatic differentiation!\n// ...into another differentiable expression!\nassert_eq!(-1, (\u0026dvdx).eval()); // dvdx NOT moved yet: reusable\nassert_eq!(0, dvdx.grad(\u0026x).grad(\u0026x).grad(\u0026x).grad(\u0026x).eval());\n```\n\nWant to implement differentiable expressions for your own types and functions?\n```rust\n#![feature(const_trait_impl)]\nuse dxpr::{prelude::*, eval::Eval};\nstruct Teleport { arg: u8 }; // Unevaluated Teleport operation\nconst fn tp(x: u8) -\u003e Teleport { Teleport { arg: x } } // Not yet!\ndxpr::implement_eval!( // Now define what the operation does:\n  Teleport \u003e-\u003e u16: // Op type \u003e-\u003e output type\n  |self| (self.arg as u16) \u003c\u003c 8); // Function definition\nlet _ = tp(1); // Unevaluated expression\nassert_eq!(256, tp(1).eval()); // Done!\n```\n\nAt compile time:\n```rust\n#![feature(const_trait_impl)]\nuse dxpr::{expr::Expr, ops::Neg, prelude::*};\nconst X: i32 = 4;\nconst A: Expr\u003c\u0026i32\u003e = var(\u0026X);\nconst EXPRESSION: Expr\u003cNeg\u003cNeg\u003cNeg\u003c\u0026i32\u003e\u003e\u003e\u003e = ---A;\nconst VALUE: i32 = EXPRESSION.eval();\nassert_eq!(-4, VALUE);\n// Rust currently can't compare pointers to constants at compile time, so no compile-time autodiff at the moment\n// Plans in the works to fix this with the ability to manually specify a \"variable ID.\"\n// Either way, your `build.rs` could easily evaluate an arbitrary expression and write it, unevaluated, to a file.\n```\n\n## To do:\n- Figure out why Rust doesn't like `+` in macro `:path` arguments\n- Interoperability with builtin constants\n- `Index` and `RangeBound` operators (i.e. `a[b]` and `a..b`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwrsturgeon%2Fdxpr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwrsturgeon%2Fdxpr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwrsturgeon%2Fdxpr/lists"}