{"id":20098269,"url":"https://github.com/trick-17/fmath","last_synced_at":"2026-06-08T19:32:02.388Z","repository":{"id":93811365,"uuid":"115876063","full_name":"Trick-17/FMath","owner":"Trick-17","description":"Math library for operations on fields","archived":false,"fork":false,"pushed_at":"2022-04-01T20:33:52.000Z","size":1375,"stargazers_count":3,"open_issues_count":10,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-02T16:36:53.903Z","etag":null,"topics":["c-plus-plus","c-plus-plus-17","etl","expression-template","header-only","math-library","openmp-backend","parallelisation"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Trick-17.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2017-12-31T17:14:43.000Z","updated_at":"2020-06-13T12:27:25.000Z","dependencies_parsed_at":"2023-03-23T17:49:09.357Z","dependency_job_id":null,"html_url":"https://github.com/Trick-17/FMath","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Trick-17/FMath","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trick-17%2FFMath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trick-17%2FFMath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trick-17%2FFMath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trick-17%2FFMath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Trick-17","download_url":"https://codeload.github.com/Trick-17/FMath/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trick-17%2FFMath/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34078019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"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":["c-plus-plus","c-plus-plus-17","etl","expression-template","header-only","math-library","openmp-backend","parallelisation"],"created_at":"2024-11-13T17:02:24.069Z","updated_at":"2026-06-08T19:32:02.372Z","avatar_url":"https://github.com/Trick-17.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"FMath: Field Math library\n=========================\n**Efficient and expressive use of abstract Fields**\u003cbr /\u003e\n\n\u0026nbsp;\n\n[![Build Status](https://api.travis-ci.com/Trick-17/FMath.svg?branch=master)](https://travis-ci.com/github/Trick-17/FMath)\n[![Coverage Status](https://codecov.io/gh/trick-17/fmath/branch/master/graph/badge.svg)](https://codecov.io/gh/trick-17/fmath/branch/master)\n[![Documentation](https://readthedocs.org/projects/fmath/badge/?version=latest)](https://fmath.readthedocs.io)\n\n\u0026nbsp;\n\n**Requirements:**\n- C++17\n- OpenMP 4.5 (optional)\n- (later maybe a CUDA version which supports C++17 features)\n\n\nGeneral Ideas\n-------------\n\nThe library revolves around the `Field` template class, which is a convenience\nwrapper around `std::vector` with added operators and functions. The Eigen library\nis used for vector operations.\n\nExpression templates ensure that mathematical operations are used efficiently,\navoiding temporaries.\n\nThe library provides convenience `typedef`s:\n- `FMath::scalar`      = default is `double`, can be defined differently by `FMATH_SCALAR_TYPE`\n- `FMath::ScalarField` = `FMath::Field\u003cFMath::scalar\u003e`\n- `FMath::Vector3`     = `Eigen::Vector3\u003cFMath::scalar\u003e`\n- `FMath::VectorX`     = `Eigen::VectorX\u003cFMath::scalar\u003e`\n- `FMath::VectorField` = `FMath::Field\u003cFMath::Vector3\u003e`\n\n\nParallelisation\n---------------\n\nSince almost all operations on `Field`s, defined in this library, are either trivially parallelizable\nor typical reductions, both CPU and GPU could and should be used to speed up operations.\n\nOpenMP 4.5 can easily be used to parallelize everything on CPU and also supports usage of devices.\nHowever, due to the lack of unified memory abstractions, GPU parallelisation does not yet come as\nnaturally.\n\n\nIncorporation into your project\n-------------------------------\n\nAdding this library to your project should be trivial.\nYou can do it manually:\n- copy the `FMath` folder into your directory of choice\n- copy the `thirdparty/Eigen` folder or provide your own\n- make sure the `FMath` and `Eigen` folders are in your include-directories\n- optionally define `FMATH_SCALAR_TYPE`\n- optionally add OpenMP compiler flags to activate parallelisation\n\nor using CMake:\n- copy the entire repository folder into your directory of choice\n- TODO...\n\n\nUsage Examples\n--------------\n\n### Reductions\n```C++\n#include \u003cFMath/Core\u003e\n\n// Single field reduction\nFMath::VectorField vf(N);\nFMath::scalar mean = vf.mean();\n\n// N-dimensional dot-product\nFMath::ScalarField sf1(N), sf2(N);\nsf1 *= sf2;\nFMath::scalar dot = sf1.sum();\n```\n\n### Operators\n```C++\n#include \u003cFMath/Core\u003e\n\nFMath::VectorField vf1(N), vf2(N);\nFMath::ScalarField sf1(N);\n\n// This will produce an expression object, due to auto\nauto vf = vf1 + vf2*vf2;\n// This will actually evaluate the expression\nFMath::ScalarField sf_result = vf.dot(vf1);\n```\n\n### Convenience math functions\n```C++\n#include \u003cFMath/Core\u003e\n\nFMath::VectorField vf1(N), vf2(N);\n\n// Element-wise dot product\nFMath::ScalarField sf_dot = vf1.dot(vf2);\n// Element-wise cross product\nFMath::VectorField vf_cross = vf1.cross(vf2);\n```\n\n### Other convenience functions\nCopying or re-interpreting a `Field` as an `Eigen::VectorX`\n```C++\n#include \u003cFMath/Core\u003e\n\nFMath::ScalarField sf(N);\nFMath::VectorField vf(N);\n\n// Copy a scalar field to a new N-dimensional vector\nFMath::VectorX vec1 = sf.asRef\u003cVectorX\u003e();\n// Copy a vector field to a new 3N-dimensional vector\nFMath::VectorX vec2 = vf.asRef\u003cVectorX\u003e();\n\n// Interpret a scalar field as a N-dimensional vector without copying\nEigen::Ref\u003cVectorX\u003e vecRef1 = sf.asRef\u003cVectorX\u003e();\n// Interpret a vector field as a 3N-dimensional vector without copying\nEigen::Ref\u003cVectorX\u003e vecRef2 = vf.asRef\u003cVectorX\u003e();\n```\n\nExtracting and operating on an indexed subset of a `Field`\n```C++\n#include \u003cFMath/Core\u003e\n\n// A Field of size N1 and an index list of size N2\u003cN1\nFMath::ScalarField sf1(N1);\nFMath::IntField    index_list1(N2);\n\n// Set the indices of the Field entries you wish to extract...\n// (this can also be used to re-order a Field)\n\n// Extract the indexed set\nFMath::ScalarField sf_subset1 = sf1[index_list1];\n\n// Extract a small set via an initializer list\nFMath::ScalarField sf_subset2 = sf1[{0,3,22}];\n\n// Operate on subsets, combining different index lists\nFMath::ScalarField sf2(N1);\nFMath::ScalarField sf3(N3);\nFMath::IntField    index_list2(N2);\nsf1[index_list1] = sf2[index_list1] + sf3[index_list2];\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrick-17%2Ffmath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrick-17%2Ffmath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrick-17%2Ffmath/lists"}