{"id":16788368,"url":"https://github.com/sgssgene/d_rive","last_synced_at":"2025-08-02T20:33:46.384Z","repository":{"id":84765816,"uuid":"122678203","full_name":"SGSSGene/d_rive","owner":"SGSSGene","description":"c++20 compile time math(derivation/integration) library","archived":false,"fork":false,"pushed_at":"2023-03-04T17:51:20.000Z","size":43,"stargazers_count":17,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-10T23:13:01.693Z","etag":null,"topics":["compile-time","cpp","cpp-library","cpp20","derivation","forthebadge","header-only","integration","math"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SGSSGene.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}},"created_at":"2018-02-23T22:13:42.000Z","updated_at":"2024-02-04T03:56:15.000Z","dependencies_parsed_at":"2023-03-13T02:16:15.500Z","dependency_job_id":null,"html_url":"https://github.com/SGSSGene/d_rive","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SGSSGene/d_rive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SGSSGene%2Fd_rive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SGSSGene%2Fd_rive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SGSSGene%2Fd_rive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SGSSGene%2Fd_rive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SGSSGene","download_url":"https://codeload.github.com/SGSSGene/d_rive/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SGSSGene%2Fd_rive/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268448362,"owners_count":24252019,"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-02T02:00:12.353Z","response_time":74,"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":["compile-time","cpp","cpp-library","cpp20","derivation","forthebadge","header-only","integration","math"],"created_at":"2024-10-13T08:17:41.369Z","updated_at":"2025-08-02T20:33:46.347Z","avatar_url":"https://github.com/SGSSGene.png","language":"C++","readme":"# d_rive\n[![forthebadge](https://forthebadge.com/images/badges/you-didnt-ask-for-this.svg)](https://forthebadge.com)\n[![forthebadge](https://forthebadge.com/images/badges/uses-badges.svg)](https://forthebadge.com)\n\nCompile time math expressions with c++20.\n- standard math addition, subtraction, multiplication, division\n- sin, cos, pow, ln, sign, abs, max and min\n- derivation\n- integration\n\nCheck example1.cpp and exampleQuat.cpp for more exciting examples..\nTo try the examples use a modern compiler and compile the .cpp file `g++ -std=c++20 example1.cpp`.\n\n## Examples\n\n(Assume you have `using namespace d_rive` set)\n\nLets start with something simple, a constant. Constant have to be written\nwith the `_c` suffix. that allows us to do everything at compile time. (`f() = 5`)\n```\n    auto f = 5_c;\n    std::cout \u003c\u003c f \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c f() \u003c\u003c \"\\n\";\n```\n\nLets define a polynomial and print the polynomial (`f(x) = x² + 2x + 3`)\n```\n    auto f = x\u003c0\u003e*x\u003c0\u003e + 2_c * x\u003c0\u003e + 3_c;\n    std::cout \u003c\u003c f \u003c\u003c \"\\n\";\n```\nNow lets evaluate it with `5` as `x\u003c0\u003e` (`f(x) = x² + 2x + 3`):\n```\n    auto f = x\u003c0\u003e*x\u003c0\u003e + 2_c * x\u003c0\u003e + 3_c;\n    std::cout \u003c\u003c f(5) \u003c\u003c \"\\n\";\n```\nEasy, right? But what if we need the derivative? (`f2 = f'`)\n```\n    auto f2 = derive(f);\n    std::cout \u003c\u003c f2 \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c f2(5) \u003c\u003c \"\\n\";\n```\nDerivative of derivates is also possible (`f3 = f2'`)\n```\n    auto f3 = derive(f2);\n    std::cout \u003c\u003c f3 \u003c\u003c \"\\n\";\n```\n\nIntegrating? (`F' = f`)\n```\n    auto F = integrate(f);\n    std::cout \u003c\u003c F \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c F(5) \u003c\u003c \"\\n\";\n```\nCompile time roots? (`sqrt(2)`)\n```\n    std::cout \u003c\u003c (2_c^0.5_c) \u003c\u003c \"\\n\";\n```\nMultiple variables: (`f(x0, x1, x2) = x0*x1 + x2`)\n```\n    auto f = x\u003c0\u003e*x\u003c1\u003e + x\u003c2\u003e;\n    std::cout \u003c\u003c f(1, 2, 3) \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c f \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c derive(f, x\u003c1\u003e) \u003c\u003c \"\\n\"; // derives for x\u003c1\u003e instead x\u003c0\u003e\n```\n\nLets go crazy:\n```\n    auto f = 10_c + ((3_c * x\u003c0\u003e) ^ (0.5_c * x\u003c1\u003e * x\u003c2\u003e - x\u003c1\u003e));\n    std::cout \u003c\u003c derive(f, x\u003c0\u003e) \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c derive(f, x\u003c1\u003e) \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c derive(f, x\u003c2\u003e) \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c integrate(f, x\u003c0\u003e) \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c integrate(f, x\u003c1\u003e) \u003c\u003c \"\\n\";\n    std::cout \u003c\u003c integrate(f, x\u003c2\u003e) \u003c\u003c \"\\n\";\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgssgene%2Fd_rive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgssgene%2Fd_rive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgssgene%2Fd_rive/lists"}