vermotr/php-matrix 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vermotr/php-matrix

Composer 安装命令:

composer require vermotr/php-matrix

包简介

Matrix basic implementation.

README 文档

README

Matrix basic implementation.

Installation

composer require vermotr/php-matrix:0.1.0

Alternatively you can add the following to the require section of your composer.json manually:

"vermotr/php-matrix": "0.1.0"

Usage

There are three ways to instantiate a matrix:

use vermotr\Math\Matrix;

// Create a Matrix with its size
$matrix = new Matrix(4, 2);

// With a bi-dimensional array
$matrix = new Matrix([
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8]
]);

// With another Matrix
$matrix = new Matrix($anotherMatrix);

You can access each element like a bi-dimensional array and display the matrix like so:

$matrix[4][2] = 42;

echo $matrix;

To know the matrix' size, you have access to two getters:

$matrix->getRows();
$matrix->getCols();

In this class, you will find basic operations: add, subtract and multiply (by scalars and Matrices):

$addedScalar = $matrix->add(4);
$addedMatrix = $matrix->add($anotherMatrix);
$subtractedScalar = $matrix->subtract(2);
$subtractedMatrix = $matrix->subtract($anotherMatrix);
$multipliedByScalar = $matrix->multiply(2);
$multipliedByMatrix = $matrix->multiply($anotherMatrix);

You can also compare two matrices with the equals method:

if ($matrix1->equals($matrix2)) {
    // Do something!
}

There are some useful methods implemented in this class:

$matrix->adjugate();
$matrix->cofactor();
$matrix->determinant();
$matrix->inverse();
$matrix->subMatrix();
$matrix->transpose();

Changelog

  • 0.1.0
    • Created the Matrix type
    • Scalar Addition
    • Matrix Addition
    • Scalar Subtraction
    • Matrix Subtraction
    • Scalar Multiplication
    • Matrix Multiplication
    • Adjugate
    • Cofactor
    • Determinant
    • Inverse
    • Submatrix
    • Transpose

统计信息

  • 总下载量: 455
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固