{"id":17654359,"url":"https://github.com/renggli/dart-data","last_synced_at":"2025-04-14T21:52:50.537Z","repository":{"id":53124302,"uuid":"143556866","full_name":"renggli/dart-data","owner":"renggli","description":"A fast and space efficient library to deal with data in Dart, Flutter and the web.","archived":false,"fork":false,"pushed_at":"2025-02-13T20:43:43.000Z","size":1440,"stargazers_count":21,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T10:01:54.949Z","etag":null,"topics":["algorithm","dart","flutter","matrix","tensor","vector"],"latest_commit_sha":null,"homepage":"","language":"Dart","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/renggli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-04T19:20:40.000Z","updated_at":"2025-02-13T20:43:48.000Z","dependencies_parsed_at":"2024-06-21T16:34:25.947Z","dependency_job_id":null,"html_url":"https://github.com/renggli/dart-data","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renggli%2Fdart-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renggli%2Fdart-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renggli%2Fdart-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/renggli%2Fdart-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/renggli","download_url":"https://codeload.github.com/renggli/dart-data/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968753,"owners_count":21191158,"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":["algorithm","dart","flutter","matrix","tensor","vector"],"created_at":"2024-10-23T12:13:58.451Z","updated_at":"2025-04-14T21:52:50.512Z","avatar_url":"https://github.com/renggli.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"Dart Data\n=========\n\n[![Pub Package](https://img.shields.io/pub/v/data.svg)](https://pub.dev/packages/data)\n[![Build Status](https://github.com/renggli/dart-data/actions/workflows/dart.yml/badge.svg?branch=main)](https://github.com/renggli/dart-data/actions/workflows/dart.yml)\n[![Code Coverage](https://codecov.io/gh/renggli/dart-data/branch/main/graph/badge.svg?token=G8EBSJSR17)](https://codecov.io/gh/renggli/dart-data)\n[![GitHub Issues](https://img.shields.io/github/issues/renggli/dart-data.svg)](https://github.com/renggli/dart-data/issues)\n[![GitHub Forks](https://img.shields.io/github/forks/renggli/dart-data.svg)](https://github.com/renggli/dart-data/network)\n[![GitHub Stars](https://img.shields.io/github/stars/renggli/dart-data.svg)](https://github.com/renggli/dart-data/stargazers)\n[![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/renggli/dart-data/main/LICENSE)\n\nDart Data is a fast and space efficient library to deal with data in Dart, Flutter and the web. As of today this mostly includes data structures and algorithms for vectors and matrices, but at some point might also include graphs and other mathematical structures.\n\nThis library is open source, stable and well tested. Development happens on [GitHub](https://github.com/renggli/dart-data). Feel free to report issues or create a pull-request there. General questions are best asked on [StackOverflow](https://stackoverflow.com/questions/tagged/data+dart).\n\nThe package is hosted on [dart packages](https://pub.dev/packages/data). Up-to-date [class documentation](https://pub.dev/documentation/data/latest/) is created with every release.\n\n\nTutorial\n--------\n\nBelow are step-by-step instructions of how to use this library. More elaborate examples are included with the [examples](https://github.com/renggli/dart-data/tree/main/example).\n\n### Installation\n\nFollow the installation instructions on [dart packages](https://pub.dev/packages/data/install).\n\nImport the core-package into your Dart code using:\n\n```dart\nimport 'package:data/data.dart';\n```\n\n### How to solve a linear equation?\n\nSolve 'A * x = b', where 'A' is a matrix and 'b' a vector:\n\n```dart\nfinal a = Matrix\u003cdouble\u003e.fromRows(DataType.float64, [\n  [2, 1, 1],\n  [1, 3, 2],\n  [1, 0, 0],\n]);\nfinal b = Vector\u003cdouble\u003e.fromList(DataType.float64, [4, 5, 6]);\nfinal x = a.solve(b.columnMatrix).column(0);\nprint(x.format(valuePrinter: Printer.fixed()); // prints '6 15 -23'\n```\n\n### How to find the eigenvalues of a matrix?\n\nFind the eigenvalues of a matrix 'A':\n\n```dart\nfinal a = Matrix\u003cdouble\u003e.fromRows(DataType.float64, [\n  [1, 0, 0, -1],\n  [0, -1, 0, 0],\n  [0, 0, 1, -1],\n  [-1, 0, -1, 0],\n]);\nfinal decomposition = a.eigenvalue;\nfinal eigenvalues = Vector\u003cdouble\u003e.fromList(\n    DataType.float64, decomposition.realEigenvalues);\nprint(eigenvalues.format(valuePrinter: Printer.fixed(precision: 1))); // prints '-1.0 -1.0 1.0 2.0'\n```\n\n### How to find all the roots of a polynomial?\n\nTo find the roots of `x^5 + -8x^4 + -72x^3 + 242x^2 + 1847x + 2310`:\n\n```dart\nfinal polynomial = Polynomial.fromCoefficients(DataType.int32, [1, -8, -72, 242, 1847, 2310]);\nfinal roots = polynomial.roots;\nprint(roots.map((root) =\u003e root.real)); // [-5, -3, -2, 7, 11]\nprint(roots.map((root) =\u003e root.imaginary)); // [0, 0, 0, 0, 0]\n```\n\n### How to do a polynomial regression?\n\nTo find the best fitting third degree polynomial through a list of points:\n\n```dart\nfinal height = [1.47, 1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, 1.68, 1.70, 1.73, 1.75, 1.78, 1.80, 1.83].toVector();\nfinal mass = [52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29, 63.11, 64.47, 66.28, 68.10, 69.92, 72.19, 74.46].toVector();\nfinal fitter = PolynomialRegression(degree: 2);\nfinal result = fitter.fit(xs: height, ys: mass);\nprint(result.polynomial.format(valuePrinter: FixedNumberPrinter(precision: 3))); // 61.960x^2 + -143.162x + 128.813\n```\n\n### How to numerically integrate a function?\n\nIn both examples we specify a custom depth, since these integrals are tricky at the upper bound (very steep for the first one, very flat for the second one).\n\n```dart\n// Compute the area of a circle by iterating over a quarter circle:\nfinal pi = 4 * integrate((x) =\u003e sqrt(1 - x * x), 0, 1, depth: 30);\nprint(pi); // 3.1415925673846368 ~ pi\n\n// Compute an improper integral:\nfinal one = integrate((x) =\u003e exp(-x), 0, double.infinity, depth: 30);\nprint(one); // 1.0000000904304227 ~ 1\n```\n\n\nMisc\n----\n\n### License\n\nThe MIT License, see [LICENSE](https://github.com/renggli/dart-data/raw/main/LICENSE).\n\nSome of the matrix decomposition algorithms are a port of the [JAMA: A Java Matrix Package](https://math.nist.gov/javanumerics/jama/) released under public domain.\n- In particular, the singular value decomposition algorithm comes from the [Math.Net Numerics](https://github.com/mathnet/mathnet-numerics) released under MIT.\n\nSome of the distributions and special functions are a port of the [JavaScript Statistical Library](https://github.com/jstat/jstat) released under MIT.\n\nThe Levenberg-Marquardt least squares curve fitting is a port of [levenberg-marquardt](https://github.com/mljs/levenberg-marquardt) released under MIT.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenggli%2Fdart-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frenggli%2Fdart-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenggli%2Fdart-data/lists"}