{"id":13507229,"url":"https://github.com/a115/exmatrix","last_synced_at":"2026-02-21T06:32:43.626Z","repository":{"id":32586255,"uuid":"36169503","full_name":"a115/exmatrix","owner":"a115","description":"Elixir library implementing a parallel matrix multiplication algorithm and other utilities for working with matrices. Used for benchmarking computationally intensive concurrent code. ","archived":false,"fork":false,"pushed_at":"2023-04-09T20:33:23.000Z","size":146,"stargazers_count":58,"open_issues_count":1,"forks_count":15,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-21T15:36:47.003Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://a115.co.uk/","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a115.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":null}},"created_at":"2015-05-24T11:35:49.000Z","updated_at":"2024-08-21T23:37:13.000Z","dependencies_parsed_at":"2024-01-05T21:52:59.205Z","dependency_job_id":"4baa7541-f587-4839-8104-9a86ffbaa2fc","html_url":"https://github.com/a115/exmatrix","commit_stats":{"total_commits":15,"total_committers":7,"mean_commits":2.142857142857143,"dds":0.5333333333333333,"last_synced_commit":"1be15402240eb942d5f4f684ec08d6c17e6c88c5"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/a115/exmatrix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a115%2Fexmatrix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a115%2Fexmatrix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a115%2Fexmatrix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a115%2Fexmatrix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a115","download_url":"https://codeload.github.com/a115/exmatrix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a115%2Fexmatrix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29675470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T06:23:40.028Z","status":"ssl_error","status_checked_at":"2026-02-21T06:23:39.222Z","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":"2024-08-01T02:00:28.257Z","updated_at":"2026-02-21T06:32:43.607Z","avatar_url":"https://github.com/a115.png","language":"Elixir","funding_links":[],"categories":["Algorithms and Data structures"],"sub_categories":[],"readme":"# ExMatrix\n\n\n[![Travis CI](https://travis-ci.org/a115/exmatrix.svg)](https://travis-ci.org/a115/exmatrix) [![hex.pm version](https://img.shields.io/hexpm/v/exmatrix.svg?style=flat)](https://hex.pm/packages/exmatrix)\n\n\nExMatrix is an Elixir library implementing a parallel matrix multiplication algorithm with other utilities for working with matrices.\n\n### Installation\n\nThe latest version is `0.0.1` and requires Elixir `~\u003e 1.0`.\n\nReleases are published through [hex.pm](https://hex.pm/packages/exmatrix). Add as a dependency in your `mix.exs` file:\n\n```elixir\ndefp deps do\n  [ { :exmatrix, \"~\u003e 0.0.1\" } ]\nend\n```\n\n### Matrices\n\nMatrices are expected to be lists of lists of numbers, so for example, a simple 2x2 matrix might look like\n\n```elixir\niex\u003e matrix = [[0, 0], [1,1]]\n[[0, 0], [1,1]]\n```\n\nTo get an empty matrix you can use ```new_matrix``` to generate a zero-filled matrix\n\n```elixir\niex\u003e ExMatrix.new_matrix(2,2)\n[[0, 0], [0,0]]\n```\n\nTo test out the library, you can generate a random matrix using ```random_cells``` by passing the number of rows, columns and a maximum value to be contained in each cell.\n\n```elixir\niex\u003e random_cells(2, 2, 10)\n[[3, 4], [9, 0]]\n```\n\n\n### Multiplication\n\nTo multiply two matrices together you can call either ```multiply``` or ```pmultiply``` if you wish to do the multiplication in parallel.\n\n```elixir\niex\u003e matrix_a = [[2,3], [3,5]]\n[[2,3], [3,5]]\niex\u003e matrix_b = [[1,2], [5,-1]]\n[[1,2], [5,-1]]\niex\u003e ExMatrix.multiply(matrix_a, matrix_b)\n[[17, 1], [28, 1]]\n```\n\n### Addition\n\nAddition of matrices happens as you might expect, with the ```add``` function\n\n```elixir\niex\u003e matrix_a = [[0, 1, 2], [9, 8, 7]]\n[[0, 1, 2], [9, 8, 7]]\niex\u003e matrix_b = [[6, 5, 4], [3, 4, 5]]\n[[6, 5, 4], [3, 4, 5]]\niex\u003e ExMatrix.add(matrix_a, matrix_b)\n[[6, 6, 6], [12, 12, 12]]\n```\nIf you provide two matrices where the number of rows or columns differs, then an ```ArgumentError``` is raised.\n\n\n### Subtraction\n\nSubtraction is performed on two matrices (which must have the same dimentions) by using the ```subtract``` function\n\n```elixir\niex\u003e matrix_a = [[0, 1, 2], [9, 8, 7]]\n[[0, 1, 2], [9, 8, 7]]\niex\u003e from_matrix = [[6, 5, 4], [3, 4, 5]]\n[[6, 5, 4], [3, 4, 5]]\niex\u003e ExMatrix.subtract(matrix_a, from_matrix)\n[[-6, -4, -2], [6, 4, 2]]\n```\n\n\nIf you provide two matrices where the number of rows or columns differs, then an ```ArgumentError``` is raised.\n\n\n### Utility functions\n\n#### Size\n\nThe ```size``` function will return the number of rows and columns in your matrix.\n\n```elixir\niex\u003e {rows, cols} = ExMatrix.size([[1,2,3], [4, 5, 6], [7, 8, 9]])\n{3, 3}\niex\u003e rows\n3\n```\n\n#### Transpose\n\nYou can transpose a matrix so that the columns become rows (rotating the matrix by 90 degrees).\n\n```elixir\niex\u003e ExMatrix.transpose([[1,2,3], [4, 5, 6], [7, 8, 9]])\n[[1, 4, 7], [2, 5, 8], [3, 6, 9]]\n```\n\n\n\n## Benchmarks\n\nThe initial aim of ExMatrix was to benchmark how well it performed when scaled across a differing number of CPU cores.  Rather than measure the number-crunching ability of Elixir, the benchmarks included measure how well it performs when large matrices are multiplied on 1, 2, 4 and 8 cores.  \n\nYou can run the benchmarks yourself using the mix bench command.\n\n\n```elixir\nMIX_ENV=prod mix bench\n```\n\nTo try the benchmark with differing numbers of cores, depends on your operating system.  \n\n* OSX - Use Instruments.app where in the Preferences pane you can change the number of active cores.\n* Linux - This [page on stackexchange](http://unix.stackexchange.com/questions/145645/diabling-cpu-cores-on-quad-core-processor-on-linux) describes how to turn off individual cores on linux.\n* Windows - You can turn off individual cores using the steps described [here]\n(http://en.kioskea.net/faq/616-multicore-cpu-how-to-disable-a-core#procedure-when-using-windows-vista-7-and-xp) \n\n\n### OSX - 8 cores, 16Gb RAM\n\nThe following results show the outcome of running the benchmarks on the author's machine (OSX, 8cores, 16Gb) using 1, 2, 4 and 8 cores.  The matrix sizes used were 50x50, 100x100, 200x200, 400x400.  There is a threshold (to be determined) below which the size of the computation on the matrix is  apparently outweighed by the time taken to spawn and wait for the processes.  The charts below show for the 50x50 and 100x100 matrices no better performance between 1 and 2 cores, and it maybe that the threshold is around this point.\n\n#### Total times\n\nThe table below shows the times (in ms) as reported by [benchfella](https://github.com/alco/benchfella).  \n\n|   | 50x50  |  100x100 | 200x200  | 400x400   |\n|---|---|---|---|---|\n| **1 core**   |  101  | 817   |  7881   |  74524  |\n| **2 cores**  | 105  |  795  |  6028  |  51493  |\n| **4 cores**  |  54  | 404  | 3340  | 27339   |\n| **8 cores**   | 31  |  240  |  1858 |  15179 |\n\n\n#### 50x50 Matrix\n\n![](doc/img/50x50.png)\n\n#### 100x100 Matrix\n\n![](doc/img/100x100.png)\n\n#### 200x200\n\n![](doc/img/200x200.png)\n\n#### 400x400\n\n![](doc/img/400x400.png)\n\n\n\n\n\n\n\n### License\n\n```\n   Copyright 2015 A115 Ltd\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa115%2Fexmatrix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa115%2Fexmatrix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa115%2Fexmatrix/lists"}