{"id":18864318,"url":"https://github.com/devtronic/morpheus","last_synced_at":"2026-02-11T08:30:15.512Z","repository":{"id":56967107,"uuid":"95296611","full_name":"devtronic/morpheus","owner":"devtronic","description":"A PHP matrix calculation helper","archived":false,"fork":false,"pushed_at":"2018-07-08T08:45:50.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-30T21:29:11.374Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/devtronic.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}},"created_at":"2017-06-24T12:35:57.000Z","updated_at":"2018-07-08T08:45:51.000Z","dependencies_parsed_at":"2022-08-21T09:50:43.455Z","dependency_job_id":null,"html_url":"https://github.com/devtronic/morpheus","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Fmorpheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Fmorpheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Fmorpheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Fmorpheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devtronic","download_url":"https://codeload.github.com/devtronic/morpheus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239808525,"owners_count":19700451,"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":[],"created_at":"2024-11-08T04:40:52.103Z","updated_at":"2026-02-11T08:30:15.444Z","avatar_url":"https://github.com/devtronic.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GitHub tag](https://img.shields.io/packagist/v/devtronic/morpheus.svg)](https://github.com/Devtronic/morpheus)\n[![License](https://img.shields.io/packagist/l/Devtronic/morpheus.svg)](https://github.com/Devtronic/morpheus/blob/master/LICENSE)\n[![Travis](https://img.shields.io/travis/Devtronic/morpheus.svg)](https://travis-ci.org/Devtronic/morpheus)\n[![Packagist](https://img.shields.io/packagist/dt/Devtronic/morpheus.svg)](https://packagist.org/packages/devtronic/morpheus)\n\n# Morpheus\nMorpheus is a matrix calculation class for PHP\n\n## Installation\n```bash\n$ composer require devtronic/morpheus\n```\n\n## Usage\n### Create a Matrix\n```php\n\u003c?php\n\nuse Devtronic\\Morpheus\\Matrix;\n\n$matrix = new Matrix([\n    [1, 2, 3],\n    [4, 5, 6]\n]);\n\n// or\n\n$matrix = new Matrix();\n$matrix-\u003esetData([\n    [1, 2, 3],\n    [4, 5, 6]\n]);\n```\n\n### Simple Operations\n\n#### Add\n```php\n\u003c?php\n\nuse Devtronic\\Morpheus\\Matrix;\n\n$matrixA = new Matrix([\n    [1, 2, 3],\n]);\n\n$matrixB = new Matrix([\n    [4, 5, 6],\n]);\n\n$matrixA-\u003eadd($matrixB);\n\nprint_r($matrixA-\u003egetData());\n// [ [5, 7, 9] ]\n```\n\n#### Subtract\n```php\n\u003c?php\n\nuse Devtronic\\Morpheus\\Matrix;\n\n$matrixA = new Matrix([\n    [4, 5, 6],\n]);\n\n$matrixB = new Matrix([\n    [1, 2, 3],\n]);\n\n$matrixA-\u003esubtract($matrixB);\n\nprint_r($matrixA-\u003egetData());\n// [ [3, 3, 3] ]\n```\n\n#### Multiply\n```php\n\u003c?php\n\nuse Devtronic\\Morpheus\\Matrix;\n\n$matrixA = new Matrix([\n    [1, 2, 3],\n    [3, 2, 1],\n]);\n\n$matrixB = new Matrix([\n    [1, 2],\n    [10, 20],\n    [100, 200],\n]);\n\n$matrixA-\u003esubtract($matrixB);\n\nprint_r($matrixA-\u003egetData());\n// [\n//     [321, 642],\n//     [123, 246],\n// ]\n```\n\n### Scalar Operations\n\n#### Scalar Multiply\n```php\n\u003c?php\n\nuse Devtronic\\Morpheus\\Matrix;\n\n$matrix = new Matrix([\n    [1, 2, 3],\n    [3, 2, 1],\n]);\n\n$matrix-\u003escalarMultiply(5);\n\nprint_r($matrix-\u003egetData());\n// [\n//     [5, 10, 15],\n//     [15, 10, 5],\n// ]\n```\n\n#### Scalar Division\n```php\n\u003c?php\n\nuse Devtronic\\Morpheus\\Matrix;\n\n$matrix = new Matrix([\n    [10, 15, 30],\n    [30, 10, 15],\n]);\n\n$matrix-\u003escalarDivide(5);\n\nprint_r($matrix-\u003egetData());\n// [\n//     [2, 3, 10],\n//     [10, 2, 3],\n// ]\n```\n\n### Custom Operations\n\n\n#### Scalar Operations\n```php\n\u003c?php\n\nuse Devtronic\\Morpheus\\Matrix;\n\n$matrix = new Matrix([\n    [1, 0, 0],\n    [1, 1, 0],\n]);\n\n$matrix-\u003escalarMatrixOperation(function($element) {\n    return $element == 1 ? 0 : 1;\n});\n\nprint_r($matrix-\u003egetData());\n// [\n//     [0, 1, 1],\n//     [0, 0, 1],\n// ]\n```\n\n#### \"Synchronous\" Operations\n```php\n\u003c?php\n\nuse Devtronic\\Morpheus\\Matrix;\n\n$matrixA = new Matrix([\n    [1, 0, 0],\n    [1, 1, 0],\n]);\n\n$matrixB = new Matrix([\n    [1, 1, 0],\n    [0, 1, 0],\n]);\n\n// Simple XOR Operation\n$matrixA-\u003esynchronousMatrixOperation($matrixB, function($left, $right) {\n    return intval($left ^ $right);\n});\n\nprint_r($matrixA-\u003egetData());\n// [\n//     [0, 1, 0],\n//     [1, 0, 0],\n// ]\n```\n\n### Transformation\n\n#### Transpose\n```php\n\u003c?php\n\nuse Devtronic\\Morpheus\\Matrix;\n\n$matrix = new Matrix([\n    [1, 2],\n    [3, 4],\n    [5, 6],\n]);\n\n$matrix-\u003etranspose();\n\nprint_r($matrixA-\u003egetData());\n// [\n//     [1, 3, 5],\n//     [2, 4, 6],\n// ]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtronic%2Fmorpheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevtronic%2Fmorpheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtronic%2Fmorpheus/lists"}