Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from markrogoyski:master #7

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
6981456
e Add PHP 8.1 to Github Actions CI builds.
markrogoyski Nov 22, 2021
f45dd51
e Add PHP 8.1 to Github Actions CI builds.
markrogoyski Nov 22, 2021
0739d69
R Make truncatedMean behavior at 50 percent trim consistent. Throw ex…
markrogoyski Dec 1, 2021
0d545da
d Update CHANGELOG for v2.6.0 changes.
markrogoyski Dec 1, 2021
ee7aea7
Update CHANGELOG.
markrogoyski Apr 9, 2022
f4c407d
Minor linting improvements.
markrogoyski Apr 9, 2022
5ecf4b7
Unit test updates.
markrogoyski Apr 9, 2022
4e529aa
R Minor PHP 8.1 compatibility improvements.
markrogoyski Apr 10, 2022
73ec2b6
R Minor changes for PHP 8.1 compatibility.
markrogoyski Apr 10, 2022
85d7d7f
d Update CHANGELOG.
markrogoyski Apr 10, 2022
cc8dc16
t Add additional quantile unit tests and update method description.
markrogoyski Apr 17, 2022
59571ba
Add withDelta to tests with floating point results.
markrogoyski Dec 31, 2022
83aaf6f
Add withDelta to tests with floating point results.
markrogoyski Dec 31, 2022
749876f
Add withDelta to tests with floating point results.
markrogoyski Dec 31, 2022
2b99ecd
Add withDelta to tests with floating point results.
markrogoyski Dec 31, 2022
7275502
Add PHP 8.2 to CI Github Actions.
markrogoyski Dec 31, 2022
8c248c9
Update README.
markrogoyski Dec 31, 2022
d40041b
Update README: Add Matrix row operations.
markrogoyski Dec 31, 2022
8abfa12
Fix issue #458 (#460)
robsheldon Dec 31, 2022
c293fcd
Minor refactor of regularizedIncompleteBeta and add additional unit t…
markrogoyski Dec 31, 2022
cab7510
Add regression test for issue 458.
markrogoyski Dec 31, 2022
75771ae
Minor formating improvements.
markrogoyski Dec 31, 2022
d347007
Change 'number' to int-float type hint in PHPDoc comments: Issue 456.
markrogoyski Dec 31, 2022
dbc2d1d
Update CHANGELOG for v.2.7.0.
markrogoyski Dec 31, 2022
c97386d
Add row/columnAddVector to NumericMatrix (#462)
Aweptimum Dec 31, 2022
a435498
Minor style fix.
markrogoyski Dec 31, 2022
21e217c
Fix precondition column count in rowAddVector. Add additional unit te…
markrogoyski Dec 31, 2022
cce6f6b
Minor refactorings.
markrogoyski Dec 31, 2022
e44a7f8
Change order of parameters in rowAddVector and columnAddVector to be …
markrogoyski Dec 31, 2022
e20d66b
Update README: Add rowAddVector and columnAddVector to Matrix.
markrogoyski Dec 31, 2022
b55d8d6
Update CHANGELOG for v2.8.0.
markrogoyski Dec 31, 2022
5fea15a
NonInteger::hyperharmonic(): bug fix (#463)
Smoren Feb 1, 2023
7795af2
Consolidate exception and error messages.
markrogoyski Feb 1, 2023
9ca5996
PHPdoc annotations added, phpstan works without errors now (#465)
Smoren Apr 26, 2023
309c628
Fix sample data column indexes.
markrogoyski Apr 26, 2023
d3e9845
Clean up Search.
markrogoyski Apr 26, 2023
18b8723
Clean up Advanced.
markrogoyski Apr 26, 2023
b183ba0
Clean up WLS.
markrogoyski Apr 26, 2023
e7e6927
Minor changes to PLS.
markrogoyski Apr 26, 2023
81bded0
Minor improvements.
markrogoyski Apr 26, 2023
b885553
Minor comment change.
markrogoyski Apr 26, 2023
4ce7092
Minor change.
markrogoyski Apr 26, 2023
48ca4bd
Minor static analysis comment.
markrogoyski May 2, 2023
460377d
Update CHANGELOG for v2.8.0.
markrogoyski May 7, 2023
fc5e16a
Rename methods to better indicate assertion and no return value.
markrogoyski May 7, 2023
b3872ef
Minor comment change.
markrogoyski May 7, 2023
64bc11a
Minor comment change.
markrogoyski May 7, 2023
3c13e5a
Minor comment change.
markrogoyski May 7, 2023
6fb5024
Update CHANGELOG for v2.8.0.
markrogoyski May 7, 2023
de15ba5
Github actions improvements for static analysis.
markrogoyski May 7, 2023
70d0111
Github actions changes for static analysis.
markrogoyski May 7, 2023
341013a
Changes for static anlaysis improvements, and various other internal …
markrogoyski May 19, 2023
ea4f212
Update CHANGELOG for v2.8.1.
markrogoyski May 19, 2023
da47751
Replace array_search with floating-point filter in `Eigenvector::eige…
Aweptimum Nov 8, 2023
5d13385
Update Github actions for PHP 8.3.
markrogoyski Mar 2, 2024
cc0d818
Add Chebyshev Distance.
markrogoyski Mar 2, 2024
ae967a3
Add Chebyshev distance to README.
markrogoyski Mar 2, 2024
20fd816
Add cast for legacy max behavior returning boolean.
markrogoyski Mar 2, 2024
9989b92
Update documentation.
markrogoyski Mar 3, 2024
4d4bfad
Update CHANGELOG for v2.9.0.
markrogoyski Mar 3, 2024
70def3f
Add Integer::isPrime.
markrogoyski Apr 16, 2024
5963799
Update README.
markrogoyski Apr 16, 2024
e587bfe
Update CHANGELOG for v2.10.0.
markrogoyski Apr 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 44 additions & 9 deletions .github/workflows/test_develop_and_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ on:

jobs:
test-and-static-analysis:
name: Test and Static Analysis
name: Test and Lint
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2', '7.3', '7.4', '8.0']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']

steps:
- name: Set up PHP
Expand All @@ -23,12 +23,12 @@ jobs:
tools: composer:v2

- name: Set up Node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '14.x'
node-version: '20.x'

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -54,7 +54,42 @@ jobs:
./vendor/bin/phpunit --configuration tests/phpunit.xml --testsuite=LinearAlgebra

- name: PHP Code Sniffer
run: ./vendor/bin/phpcs --ignore=vendor --standard=tests/coding_standard.xml -s .
run: |
./vendor/bin/phpcs --version
./vendor/bin/phpcs --ignore=vendor --standard=tests/coding_standard.xml -s .

static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2']

steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: composer:v2

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run Composer
run: composer install --no-interaction

- name: Static analysis
run: |
./vendor/bin/phpstan --version
./vendor/bin/phpstan analyze -c tests/phpstan.neon

code-coverage:
name: Code coverage
Expand All @@ -72,12 +107,12 @@ jobs:
tools: composer:v2

- name: Set up Node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '14.x'
node-version: '20.x'

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
49 changes: 42 additions & 7 deletions .github/workflows/test_other_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ on:
- master

jobs:
test-and-static-analysis:
name: Test and Static Analysis
test-and-lint:
name: Test and Lint
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2', '7.3', '7.4', '8.0']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']

steps:
- name: Set up PHP
Expand All @@ -22,12 +22,12 @@ jobs:
tools: composer:v2

- name: Set up Node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '14.x'
node-version: '20.x'

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -53,4 +53,39 @@ jobs:
./vendor/bin/phpunit --configuration tests/phpunit.xml --testsuite=LinearAlgebra

- name: PHP Code Sniffer
run: ./vendor/bin/phpcs --ignore=vendor --standard=tests/coding_standard.xml -s .
run: |
./vendor/bin/phpcs --version
./vendor/bin/phpcs --ignore=vendor --standard=tests/coding_standard.xml -s .

static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2']

steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: composer:v2

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run Composer
run: composer install --no-interaction

- name: Static analysis
run: |
./vendor/bin/phpstan --version
./vendor/bin/phpstan analyze -c tests/phpstan.neon
53 changes: 44 additions & 9 deletions .github/workflows/test_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on: pull_request

jobs:
test-and-static-analysis:
name: Test and Static Analysis
name: Test and Lint
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2', '7.3', '7.4', '8.0']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']

steps:
- name: Set up PHP
Expand All @@ -19,12 +19,12 @@ jobs:
tools: composer:v2

- name: Set up Node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '14.x'
node-version: '20.x'

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -50,7 +50,42 @@ jobs:
./vendor/bin/phpunit --configuration tests/phpunit.xml --testsuite=LinearAlgebra

- name: PHP Code Sniffer
run: ./vendor/bin/phpcs --ignore=vendor --standard=tests/coding_standard.xml -s .
run: |
./vendor/bin/phpcs --version
./vendor/bin/phpcs --ignore=vendor --standard=tests/coding_standard.xml -s .

static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2']

steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: composer:v2

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run Composer
run: composer install --no-interaction

- name: Static analysis
run: |
./vendor/bin/phpstan --version
./vendor/bin/phpstan analyze -c tests/phpstan.neon

code-coverage:
name: Code coverage
Expand All @@ -68,12 +103,12 @@ jobs:
tools: composer:v2

- name: Set up Node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '14.x'
node-version: '20.x'

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
# MathPHP Change Log

## v2.10.0 - 2024-04-16

### New Features
* NumberTheory\Integer `isPrime`

## v2.9.0 - 2024-03-02

### New Features
* Distance `chebyshev`

### Improvements
* Internal build CI/CD improvements

## v2.8.1 - 2023-05-18

### Improvements
* Internal improvements to improve conformance with static analysis tools

## v2.8.0 - 2023-05-07

### New Features
* Matrix `rowAddVector`
* Matrix `columnAddVector`

### Improvements
* Better error handling and exception message in `Sequence\NonIntenger::hyperharmonic`
* Internal code improvements to conform to static analysis checks

### Backwards Incompatible Changes
* Helper method names changed (public abstract methods but not part of published interface)
* `NumericalDifferentiation::isTargetInPoints` changed to `assertTargetInPoints`
* `NumericalDifferentiation::isSpacingConstant` changed to `assertSpacingConstant`

## v2.7.0 - 2022-12-31

### Improvements
* Improved algorithm for `regularizedIncompleteBeta`: Addresses issue 458
* Issue 456: Improved PHPDoc blocks: Changed "number" to "int|float"
* Added PHP 8.2 for CI test target

## v2.6.0 - 2022-04-10

### Improvements
* `Average::truncatedMean` behavior at 50% trim made consistent
* PHP 8.1 compatibility improvements

### Backwards Incompatible Changes
# `Average::truncatedMean` throws exception if trim percent greater than 50% rather than error or unpredictable results.

## v2.5.0 - 2021-11-21

### New Features
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ style :
vendor/bin/phpcs --standard=tests/coding_standard.xml --ignore=vendor -s .

phpstan :
vendor/bin/phpstan analyze --level max src/
vendor/bin/phpstan analyze -c tests/phpstan.neon

phpmd :
vendor/bin/phpmd src/ ansi cleancode,codesize,design,unusedcode,naming
Expand Down
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,16 +444,22 @@ $Aᵢⱼ = $A[2][2];
// Row operations
[$mᵢ, $mⱼ, $k] = [1, 2, 5];
$R = $A->rowInterchange($mᵢ, $mⱼ);
$R = $A->rowMultiply($mᵢ, $k); // Multiply row mᵢ by k
$R = $A->rowAdd($mᵢ, $mⱼ, $k); // Add k * row mᵢ to row mⱼ
$R = $A->rowExclude($mᵢ); // Exclude row $mᵢ
$R = $A->rowExclude($mᵢ); // Exclude row $mᵢ
$R = $A->rowMultiply($mᵢ, $k); // Multiply row mᵢ by k
$R = $A->rowDivide($mᵢ, $k); // Divide row mᵢ by k
$R = $A->rowAdd($mᵢ, $mⱼ, $k); // Add k * row mᵢ to row mⱼ
$R = $A->rowAddScalar($mᵢ, $k); // Add k to each item of row mᵢ
$R = $A->rowAddVector($mᵢ, $V); // Add Vector V to row mᵢ
$R = $A->rowSubtract($mᵢ, $mⱼ, $k); // Subtract k * row mᵢ from row mⱼ
$R = $A->rowSubtractScalar($mᵢ, $k); // Subtract k from each item of row mᵢ

// Column operations
[$nᵢ, $nⱼ, $k] = [1, 2, 5];
$R = $A->columnInterchange($nᵢ, $nⱼ);
$R = $A->columnExclude($nᵢ); // Exclude column $nᵢ
$R = $A->columnMultiply($nᵢ, $k); // Multiply column nᵢ by k
$R = $A->columnAdd($nᵢ, $nⱼ, $k); // Add k * column nᵢ to column nⱼ
$R = $A->columnExclude($nᵢ); // Exclude column $nᵢ
$R = $A->columnAddVector($nᵢ, $V); // Add Vector V to column nᵢ

// Matrix augmentations - return a new Matrix
$⟮A∣B⟯ = $A->augment($B); // Augment on the right - standard augmentation
Expand Down Expand Up @@ -859,7 +865,8 @@ use MathPHP\NumberTheory\Integer;

$n = 225;

// Prime factorization
// Prime numbers
$bool = Integer::isPrime($n);
$factors = Integer::primeFactorization($n);

// Divisor function
Expand Down Expand Up @@ -971,7 +978,7 @@ $f’⟮x⟯ = function ($x) {
};
[$start, $end, $n] = [0, 3, 4];

$p = Interpolation\ClampedCubicSpline::interpolate($points); // input as a set of points
$p = Interpolation\ClampedCubicSpline::interpolate($points); // input as a set of points
$p = Interpolation\ClampedCubicSpline::interpolate($f⟮x⟯, $f’⟮x⟯, $start, $end, $n); // input as a callback function

$p(0); // 1
Expand Down Expand Up @@ -1773,7 +1780,7 @@ $hexagons = Advanced::hexagonalNumber($n);
// [1, 6, 15, 28, 45, 66] - Indexed from 1

// Heptagonal numbers (figurate number)
$hexagons = Advanced::heptagonalNumber($n);
$heptagons = Advanced::heptagonalNumber($n);
// [1, 4, 7, 13, 18, 27] - Indexed from 1

// Look-and-say sequence (describe the previous term!)
Expand Down Expand Up @@ -2022,7 +2029,7 @@ $interquartile_mean = Average::iqm($numbers); // same as interqua
$cubic_mean = Average::cubicMean($numbers);

// Truncated mean (trimmed mean)
$trim_percent = 25;
$trim_percent = 25; // 25 percent of observations trimmed from each end of distribution
$truncated_mean = Average::truncatedMean($numbers, $trim_percent);

// Generalized mean (power mean)
Expand Down Expand Up @@ -2260,6 +2267,7 @@ $d⟮X、Y⟯ = Distance::canberra($X, Y);
brayCurtis = Distance::brayCurtis($X, $Y);
$cosine = Distance::cosine($X, $Y);
$cos⟮α⟯ = Distance::cosineSimilarity($X, $Y);
$D⟮X、Y⟯ = Distance::chebyshev($X, $Y);

// Mahalanobis distance
$x = new Matrix([[6], [5]]);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"phpunit/phpunit": "^8.5",
"php-coveralls/php-coveralls": "^2.0",
"squizlabs/php_codesniffer": "3.*",
"phpstan/phpstan": "*",
"phpstan/phpstan": "^1.10",
"phpmd/phpmd": "^2.6",
"phploc/phploc": "*",
"php-parallel-lint/php-parallel-lint": "^1.2"
Expand Down
Loading