{"id":47756220,"url":"https://github.com/gnu-octave/pkg-apa","last_synced_at":"2026-04-03T04:22:25.085Z","repository":{"id":73412859,"uuid":"381619426","full_name":"gnu-octave/pkg-apa","owner":"gnu-octave","description":"Octave/Matlab arbitrary precision arithmetic","archived":false,"fork":false,"pushed_at":"2026-03-07T12:45:28.000Z","size":818,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-07T19:08:27.570Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"MATLAB","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gnu-octave.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-06-30T07:51:29.000Z","updated_at":"2026-03-07T12:42:46.000Z","dependencies_parsed_at":"2023-02-25T16:15:10.839Z","dependency_job_id":null,"html_url":"https://github.com/gnu-octave/pkg-apa","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":"gnu-octave/pkg-example","purl":"pkg:github/gnu-octave/pkg-apa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnu-octave%2Fpkg-apa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnu-octave%2Fpkg-apa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnu-octave%2Fpkg-apa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnu-octave%2Fpkg-apa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gnu-octave","download_url":"https://codeload.github.com/gnu-octave/pkg-apa/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnu-octave%2Fpkg-apa/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31333234,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T03:20:36.090Z","status":"ssl_error","status_checked_at":"2026-04-03T03:20:35.133Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-04-03T04:22:24.552Z","updated_at":"2026-04-03T04:22:25.072Z","avatar_url":"https://github.com/gnu-octave.png","language":"MATLAB","funding_links":[],"categories":[],"sub_categories":[],"readme":"# APA - Arbitrary Precision Arithmetic via MPFR interface for Octave/Matlab.\n\n## Installation\n\nFrom the Octave command-line run:\n```octave\npkg install apa\npkg load apa\npkg test apa\n```\n\nFrom the Matlab* command-line run:\n```octave\nurlwrite ('https://github.com/gnu-octave/pkg-apa/archive/refs/heads/main.zip', 'pkg-apa-main.zip');\nunzip ('pkg-apa-main.zip');\ncd (fullfile ('pkg-apa-main', 'inst'))\ninstall_apa\ntest_apa\n```\n\n\u003e The installation in Matlab requires a proper MEX-compiler setup, please see for details\n\u003e [`doc/MEX_INTERFACE.md`](https://github.com/gnu-octave/apa/blob/main/doc/MEX_INTERFACE.md).\n\n\n\n## High-level MPFR Interface\n\nThe high-level MPFR interface is given through the `@mpfr_t` class.\nA variable of that type \"behaves\" like a \"normal\" built-in Octave/Matlab\ndata type.\n\n\n```octave\nop1 = mpfr_t (eye (3) * 4);\n\nrop = op1 + 1\n```\n\n    rop =\n\n       5   1   1\n       1   5   1\n       1   1   5\n\n\n\nHowever, you can adjust the binary precision.\n\nThe default Octave/Matlab data type **(double)** has a precision of 53 binary digits.\nThus the following calculation exceeds the given precision:\n\n\n```octave\nformat long\ntoo_small = (2 ^ (-60))\nA = ones (3);\nA(3,3) = A(3,3) + too_small\n```\n\n    too_small = 8.673617379884035e-19\n    A =\n\n       1   1   1\n       1   1   1\n       1   1   1\n\n\n\n\n```octave\nB = A - ones (3)\n```\n\n    B =\n\n       0   0   0\n       0   0   0\n       0   0   0\n\n\n\nThe same calculation using APA and quadruple precision (113 binary digits):\n\n\n```octave\nA = mpfr_t (ones (3), 113);\nA(3,3) = A(3,3) + too_small\n```\n\n    A =\n\n       1   1                                       1\n       1   1                                       1\n       1   1   1.00000000000000000086736173798840355\n\n\n\n\n```octave\napa ('format.fmt', 'scientific')\napa ('format.base', 2)\nB = A - ones (3)\n```\n\n    B =\n\n       0 * 2^(0)   0 * 2^(0)     0 * 2^(0)\n       0 * 2^(0)   0 * 2^(0)     0 * 2^(0)\n       0 * 2^(0)   0 * 2^(0)   1 * 2^(-60)\n\n\n\nThe high-level MPFR interface is the preferred choice for quick numerical\nexperiments.\n\nHowever, if performance is more critical, please use the low-level MPFR\ninterface (explained below) and vectorization wherever possible.\n\n\u003e Please note that an interface from an interpreted high-level programming\n\u003e language like Octave/Matlab is most likely slower than a pre-compiled C\n\u003e program.\n\u003e\n\u003e If performance is highly-critical, use this tool for initial experiments\n\u003e and translate the developed algorithm to native MPFR C-code.\n\n## Low-level MPFR Interface\n\n\u003e For information how to compile/develop the interface, see\n\u003e [`doc/MEX_INTERFACE.md`](https://github.com/gnu-octave/apa/blob/main/doc/MEX_INTERFACE.md).\n\nThe low-level MPFR interface permits efficient access to almost all functions\nspecified by MPFR 4.1.0 \u003chttps://www.mpfr.org/mpfr-4.1.0/mpfr.html\u003e.\n\nAll supported functions are [listed in the `inst` folder](inst)\nand can be called from Octave/Matlab like in the C programming language.\n\nFor example, the C function:\n\n```c\nint mpfr_add (mpfr_t rop, mpfr_t op1, mpfr_t op2, mpfr_rnd_t rnd)\n```\n\ncan be called from Octave/Matlab with scalar, vector, or matrix quantities:\n\n\n```octave\n% Reset to default APA output.\nclear apa\n\n% Prepare input and output variables.\nrop = mpfr_t (zeros (3));\nop1 = mpfr_t (eye (3) * 4);\nop2 = mpfr_t (2);\nrnd = mpfr_get_default_rounding_mode ();\n\n% Call mpfr_add.  Note unlike Octave/Matlab the\n% left-hand side does NOT contain the result.\nret = mpfr_add (rop, op1, op2, rnd);\n\nrop  % Note rop vs. ret!\n```\n\n    rop =\n\n       6   2   2\n       2   6   2\n       2   2   6\n\n\n\nIn the low-level interface the type checks are stricter,\nbut scalar and matrix quantities can still be mixed.\n\nAnother benefit of using the low-level MPFR interface is that **in-place**\noperations are permitted, which do not create new (temporary) variables:\n\n\n```octave\nret = mpfr_add (op1, op1, op1, rnd);  % op1 += op1\n```\n\n## Presentations\n\n- [NVR workshop (Nov) 2021](https://github.com/siko1056/slides_nvr2021/blob/main/slides.pdf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnu-octave%2Fpkg-apa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgnu-octave%2Fpkg-apa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnu-octave%2Fpkg-apa/lists"}