{"id":15008714,"url":"https://github.com/n4ze3m/matrix2d","last_synced_at":"2025-10-02T20:31:39.703Z","repository":{"id":40682284,"uuid":"282433976","full_name":"n4ze3m/matrix2d","owner":"n4ze3m","description":"A package for mathematical 2D array functions and manipulations in Dart, similar to NumPy","archived":false,"fork":false,"pushed_at":"2023-04-29T07:07:10.000Z","size":95,"stargazers_count":16,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-29T19:58:14.507Z","etag":null,"topics":["dart","dartlang","matrix","numpy"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/matrix2d","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/n4ze3m.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-07-25T11:53:15.000Z","updated_at":"2023-01-09T05:50:20.000Z","dependencies_parsed_at":"2024-06-21T19:21:47.386Z","dependency_job_id":null,"html_url":"https://github.com/n4ze3m/matrix2d","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n4ze3m%2Fmatrix2d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n4ze3m%2Fmatrix2d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n4ze3m%2Fmatrix2d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n4ze3m%2Fmatrix2d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/n4ze3m","download_url":"https://codeload.github.com/n4ze3m/matrix2d/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235040209,"owners_count":18926464,"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":["dart","dartlang","matrix","numpy"],"created_at":"2024-09-24T19:20:14.832Z","updated_at":"2025-10-02T20:31:34.434Z","avatar_url":"https://github.com/n4ze3m.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Matrix 2D 🧮\n\n[![pub version](https://img.shields.io/pub/v/matrix2d.svg)](https://pub.dev/packages/matrix2d)\n[![Build Status](https://github.com/n4ze3m/matrix2d/actions/workflows/ci.yml/badge.svg)](https://github.com/n4ze3m/matrix2d/actions/workflows/ci.yml)\n[![License: MIT](https://img.shields.io/github/license/n4ze3m/matrix2d)](https://github.com/n4ze3m/matrix2d/blob/master/LICENSE)\n\nWith Matrix 2D, you can perform matrix operations such as addition, subtraction, and multiplication in Dart. It is a simple and easy-to-use library inspired by Python's NumPy library.\n\n## Operations\n\n- `addition(listA,listB)` returns array of sums of corresponding elements of listA and listB of any dimensions.\n\n- `subtraction(listA,listB)` returns array of differences of corresponding elements of listA and listB of any dimensions.\n\n- `division(listA,listB)` divides listA by listB and returns new array\n\n- `dot(listA,listB)` Function returns the dot product of two arrays. For 2-D vectors, it is the equivalent to matrix multiplication. For 1-D arrays, it is the inner product of the vectors. For N-dimensional arrays, it is a sum product over the last axis of a and the second-last axis of b.\n\n- `shape(list)` returns dimensions of input array if the array is uniform or error otherwise.\n\n- `flatten(list)` returns 1-D representation of any shape and any levels of nesting of list array.\n\n- `transpose(list)` Reverse the axes of an array and returns the modified array\n\n- `arange(start, stop, steps)` returns evenly spaced values within the half-open interval `[start, stop)` with optional steps argument.\n\n- `zeros(row,cols)` Return a new array of given shape and type, with zeros\n\n- `ones(row,cols)` Return a new array of given shape and type, with ones\n\n- `sum(list)` Function returns the sum of array elements\n\n- `reshape(list)`Reshaping means changing the shape of an array.\n\n- `diagonal(list)` To find a diagonal element from a given matrix and gives output as one dimensional matrix.\n- `fill(row,cols,object)` Just like `zeros()` and `ones` this function will return a new array of given shape, with given object(anything btw strings too)\n\n* `compareobject(list,operation,obj)` compare values inside an array with given object and operations. function will return a new boolen array (this function is deprecated in favor of `compare`)\n\n* `concatenate(listA,listB,{axis})` Concatenation refers to joining. This function is used to join two arrays of the same shape along a specified axis. The function takes the following parameters.Axis along which arrays have to be joined. Default is 0\n\n* `min(list,{axis})` Functions, used to find the minimum value for any given array\n\n* `max(list,{axis})` Functions, used to find the maximum value for any given array\n\n* `slice(list (List\u003cList\u003e), row_index [start, stop*], column_index [start, stop*]*)` Function used to slice two-dimensional arrays . (_column_index_ and _stop_ not required )\n\n* `reverse(list,{axis})` Function used to reverse the array along the given axis. The function takes the following parameters.Axis along which the array is to be flipped. Default is 0\n\n\n## Examples\n\n\u003ch2\u003eshape\u003c/h2\u003e\n\n```dart\nList list = [[1, 2],[1, 2]];\nprint(list.shape);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[2,2]\n```\n\n\u003chr\u003e\n\n\u003ch2\u003eflatten\u003c/h2\u003e\n\n```dart\nList list = [[1, 2],[1, 2]];\nprint(list.flatten);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[1,2,1,2]\n```\n\n\u003chr\u003e\n\u003ch2\u003etranspose\u003c/h2\u003e\n\n```dart\nList list = [[1, 2],[1, 2]];\nprint(list.transpose);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[[1,1],[2,2]]\n```\n\n\u003chr\u003e\n\u003ch2\u003eaddition\u003c/h2\u003e\n\n```dart\nList list1 = [[1, 1],[1, 1]];\nList list2 = [[2, 2],[2, 2]];\nvar addition = m2d.addition(list1,list2);\nprint(addition);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[[3,3],[3,3]]\n```\n\n\u003chr\u003e\n\u003ch2\u003esubtraction\u003c/h2\u003e\n\n```dart\nList list1 = [[1, 1],[1, 1]];\nList list2 = [[2, 2],[2, 2]];\nvar subtraction = m2d.subtraction(list1,list2);\nprint(subtraction);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[[-1,-1],[-1,-1]]\n```\n\n\u003chr\u003e\n\u003ch2\u003edivision\u003c/h2\u003e\n\n```dart\nList list1 = [[1, 1],[1, 1]];\nList list2 = [[2, 2],[0, 2]];\nvar division = m2d.subtraction(division,list2);\nprint(division);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[[0.5,Infinity],[0.5,0.5]]\n```\n\n\u003chr\u003e\n\u003ch2\u003edot operation\u003c/h2\u003e\n\n```dart\nList list1 = [[1,2],[3,4]];\nList list2 = [[11,12],[13,14]];\nvar dot = m2d.dot(division,list2);\nprint(dot);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[[37, 40], [85, 92]]\n```\n\n\u003chr\u003e\n\u003ch2\u003earange\u003c/h2\u003e\n\n```dart\nvar arange = m2d.arange(8);\nprint(arange);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[[0,1,2,3,4,5,6,7,8]]\n```\n\n\u003chr\u003e\n\n\u003ch2\u003esum\u003c/h2\u003e\n\n```dart\nvar list = [[2,2],[2,2]];\nvar sum = m2d.sum(list);\nprint(sum);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n8\n```\n\n\u003chr\u003e\n\u003ch2\u003ereshape\u003c/h2\u003e\n\n```dart\nList list = [[0, 1, 2, 3, 4, 5, 6, 7]];\nlist = list.reshape(2,4);\nprint(list);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[[0, 1, 2, 3], [4, 5, 6, 7]]\n```\n\n\u003chr\u003e\n\u003ch2\u003elinspace\u003c/h2\u003e\n\n```dart\nvar linspace = m2d.linspace(2, 3, 5);\nprint(linspace);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[2.0, 2.25, 2.5, 2.75, 3.0]\n```\n\n\u003chr\u003e\n\u003ch2\u003ediagonal\u003c/h2\u003e\n\n```dart\nList list = [[1,1,1],[2,2,2],[3,3,3]];\nprint(list.diagonal);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[1,2,3]\n```\n\n\u003chr\u003e\n\u003ch2\u003ecompare\u003c/h2\u003e\n\n```dart\nvar list = [[1,1,1],[2,2,2],[3,3,3]];\nvar compare = m2d.compare(list,'\u003e',2);\nprint(compare);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[[false, false, false], [false, false, false], [true, true, true]]\n```\n\n\u003chr\u003e\n\u003ch2\u003econcatenate\u003c/h2\u003e\n\n\u003ch5\u003eaxis 0\u003c/h5\u003e\n\n```dart\nfinal l1 = [\n    [1, 1, 1],\n    [1, 1, 1],\n    [1, 1, 1]\n  ];\n  final l2 = [\n    [0, 0, 0],\n    [0, 0, 0],\n    [0, 0, 0],\n    [0, 0, 0],\n  ];\n  final l3 = m2d.concatenate(l1, l2);\n  print(l3);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[[1, 1, 1],\n[1, 1, 1],\n[1, 1, 1],\n[0, 0, 0],\n[0, 0, 0],\n[0, 0, 0],\n[0, 0, 0]]\n```\n\n\u003ch5\u003eaxis 1\u003c/h5\u003e\n\n```dart\nfinal a1 = [\n    [1, 1, 1, 1],\n    [1, 1, 1, 1],\n    [1, 1, 1, 1]\n  ];\n  final a2 = [\n    [0, 0, 0, 0, 0,0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0,0, 0, 0, 0, 0],\n    [0, 0, 0, 0, 0,0, 0, 0, 0, 0]\n  ];\n\n  final a3 = m2d.concatenate(a2, a1, axis: 1);\n  print(a3);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1],\n[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1],\n[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]]\n```\n\n\u003chr\u003e\n\u003ch2\u003ezeros,ones and fill\u003c/h2\u003e\n\n```dart\nvar zeros = m2d.zeros(2,2);\nprint(zeros);\n\nvar ones = m2d.ones(2,2);\nprint(ones);\n\nvar anything = m2d.fill(2,2,'i love dart');\nprint(anything);\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[[0,0],[1,1]]\n\n[[1,1],[1,1]]\n\n[['i love dart','i love dart'],['i love dart','i love dart']]\n```\n\n\u003chr\u003e\n\n\u003ch2\u003emin max\u003c/h2\u003e\n\n```dart\n final numbers = [\n    [1, 2, 3],\n    [4, 5, 6],\n    [7, 8, 9]\n  ];\n  print(numbers.min());\n  print(numbers.min(axis: 1));\n  print(numbers.min(axis: 0));\n  print(numbers.max());\n  print(numbers.max(axis: 1));\n  print(numbers.max(axis: 0));\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[1]\n\n[1, 4, 7]\n\n[1, 2, 3]\n\n[9]\n\n[3, 6, 9]\n\n[7, 8, 9]\n```\n\n\u003ch2\u003eslice\u003c/h2\u003e\n\n```dart\n\n var sliceArray = [\n    [1, 2, 3, 4, 5],\n    [6, 7, 8, 9, 10]\n  ];\n\n  var newArray = m2d.slice(sliceArray, [0, 2], [1, 4]);\n  print(newArray);\n\n```\n\n\u003cb\u003eouput\u003c/b\u003e:\n\n```cmd\n[[2, 3, 4],[7, 8, 9]]\n```\n\n## Contribution\n\nIf you want to contribute to this project, you are always welcome! Just make a pull request and I will review it as soon as possible.\n\n## Features and bugs\n\nIf you have any problems or suggestions, please open an issue [here](https://github.com/n4ze3m/matrix2d/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn4ze3m%2Fmatrix2d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fn4ze3m%2Fmatrix2d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn4ze3m%2Fmatrix2d/lists"}