{"id":16985661,"url":"https://github.com/sinshu/openblassharp","last_synced_at":"2025-04-12T03:32:15.439Z","repository":{"id":218349567,"uuid":"746127195","full_name":"sinshu/OpenBlasSharp","owner":"sinshu","description":"An OpenBLAS wrapper for .NET","archived":false,"fork":false,"pushed_at":"2025-01-13T03:33:55.000Z","size":124,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T13:38:28.643Z","etag":null,"topics":["blas","lapack","linear-algebra","math","numerics","openblas"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sinshu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2024-01-21T06:06:49.000Z","updated_at":"2025-01-13T03:33:59.000Z","dependencies_parsed_at":"2024-04-13T07:40:31.763Z","dependency_job_id":"5a850925-faff-4d35-ad88-4b625815ca64","html_url":"https://github.com/sinshu/OpenBlasSharp","commit_stats":null,"previous_names":["sinshu/openblassharp"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinshu%2FOpenBlasSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinshu%2FOpenBlasSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinshu%2FOpenBlasSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinshu%2FOpenBlasSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinshu","download_url":"https://codeload.github.com/sinshu/OpenBlasSharp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248512478,"owners_count":21116610,"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","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":["blas","lapack","linear-algebra","math","numerics","openblas"],"created_at":"2024-10-14T02:43:56.797Z","updated_at":"2025-04-12T03:32:15.421Z","avatar_url":"https://github.com/sinshu.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenBlasSharp\n\nThe purpose of this project is to provide a .NET wrapper for [OpenBLAS](https://github.com/OpenMathLib/OpenBLAS).\n\n\n\n## Features\n\n* Auto-generated thin wrapper for C# with no special marshalling.\n* Covers BLAS, LAPACK, and OpenBLAS-specific functions.\n* Most functions and arguments are annotated with doc comments taken from the original FORTRAN code.\nThis is very helpful when working with the BLAS and LAPACK functions, which often require a large number of arguments.\n\n![An example screenshot shows the doc comment of a BLAS function.](screenshot.png)\n\n\n\n## Installation\n\n[The NuGet package](https://www.nuget.org/packages/OpenBlasSharp) is available.\n\n```ps1\nInstall-Package OpenBlasSharp\n```\n\nThis package does not include the native binary.\n[The `OpenBlasSharp.Windows` package](https://www.nuget.org/packages/OpenBlasSharp.Windows) provides the native binary for Windows.\n\n```ps1\nInstall-Package OpenBlasSharp.Windows\n```\n\nOr, [download the compiled binary](https://github.com/OpenMathLib/OpenBLAS/releases) and put `libopenblas.dll` in the same directory as the executable file.\nBinaries for both x86 and x64 architectures are supported, but [the ILP64 build with the `x64-64` suffix](https://github.com/OpenMathLib/OpenBLAS/blob/develop/docs/distributing.md#ilp64-interface-builds) is not supported.\n\nAll the classes are in the `OpenBlasSharp` namespace.\n\n```cs\nusing OpenBlasSharp;\n```\n\n\n\n## BLAS Examples\n\nBLAS functions are provided as static methods of the `Blas` class.\n\n### Dot Product\n\n```cs\nvar len = 3;\n\nvar rnd = new Random(42);\nvar x = Enumerable.Range(0, len).Select(i =\u003e rnd.NextDouble()).ToArray();\nvar y = Enumerable.Range(0, len).Select(i =\u003e rnd.NextDouble()).ToArray();\n\nfixed (double* px = x)\nfixed (double* py = y)\n{\n    // Calculate x^T * y.\n    var result = Blas.Ddot(len, px, 1, py, 1);\n}\n```\n\n### Matrix Multiplication\n\n```cs\nvar m = 3;\nvar n = 5;\nvar k = 4;\n\nvar rnd = new Random(42);\nvar a = Enumerable.Range(0, m * k).Select(i =\u003e rnd.NextDouble()).ToArray();\nvar b = Enumerable.Range(0, k * n).Select(i =\u003e rnd.NextDouble()).ToArray();\nvar c = new double[m * n];\n\nfixed (double* pa = a)\nfixed (double* pb = b)\nfixed (double* pc = c)\n{\n    // Calculate c = a * b.\n    Blas.Dgemm(\n        Order.ColMajor,\n        Transpose.NoTrans,\n        Transpose.NoTrans,\n        m, n, k,\n        1.0,\n        pa, m,\n        pb, k,\n        0.0,\n        pc, m);\n}\n```\n\n\n\n## LAPACK Examples\n\nLAPACK functions are provided as static methods of the `Lapack` class.\n\n### Inverse Matrix using LU Decomposition\n\n```cs\nvar n = 3;\n\nvar random = new Random(42);\nvar a = Enumerable.Range(0, n * n).Select(i =\u003e random.NextDouble()).ToArray();\nvar piv = new int[n];\n\nfixed (double* pa = a)\nfixed (int* ppiv = piv)\n{\n    Lapack.Dgetrf(\n        MatrixLayout.ColMajor,\n        n, n,\n        pa, n,\n        ppiv);\n\n    Lapack.Dgetri(\n        MatrixLayout.ColMajor,\n        n,\n        pa, n, // pa will be the inverse matrix.\n        ppiv);\n}\n```\n\n### Singular Value Decomposition\n\n```cs\nvar m = 4;\nvar n = 3;\n\nvar rnd = new Random(42);\nvar a = Enumerable.Range(0, m * n).Select(i =\u003e rnd.NextDouble()).ToArray();\nvar s = new double[Math.Min(m, n)];\nvar u = new double[m * m];\nvar vt = new double[n * n];\nvar work = new double[Math.Min(m, n) - 1];\n\nfixed (double* pa = a)\nfixed (double* ps = s)\nfixed (double* pu = u)\nfixed (double* pvt = vt)\nfixed (double* pwork = work)\n{\n    Lapack.Dgesvd(\n        MatrixLayout.ColMajor,\n        'A', 'A',\n        m, n,\n        pa, m, // Note that pa will be destroyed.\n        ps,\n        pu, m,\n        pvt, n,\n        pwork);\n}\n```\n\n\n\n## OpenBLAS-specific functions\n\nOpenBLAS-specific functions are provided as static methods of the `OpenBlas` class.\n\n```cs\nvar numThreads = OpenBlas.GetNumThreads();\nvar numProcs = OpenBlas.GetNumProcs();\nvar config = OpenBlas.GetConfig();\n```\n\n\n\n## Limitations\n\n* There are no plans to support low-level LAPACK functions with the `work` suffix.\n* LAPACK functions that require function pointers are currently not supported, but support is planned for the future.\n* The doc comments in the original FORTRAN code do not completely align with the C API of OpenBLAS, so the annotations for some APIs are incomplete.\n\n\n\n## License\nOpenBlasSharp is available under [the BSD-3-Clause license](LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinshu%2Fopenblassharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinshu%2Fopenblassharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinshu%2Fopenblassharp/lists"}