GithubHelp home page GithubHelp logo

numphp / numphp Goto Github PK

View Code? Open in Web Editor NEW
135.0 135.0 17.0 324 KB

Mathematical PHP library for scientific computing

Home Page: https://numphp.org/

License: MIT License

PHP 100.00%
complex-numbers linear-algebra math matrix numeric vector

numphp's Introduction

NumPHP

Latest Version on Packagist Software License Build Status Coverage Status Total Downloads Dependencies

Note: The development of NumPHP 2 has started completely from scratch. NumPHP 1.1 can be found at branch 1.1.

NumPHP is a mathematical PHP library for scientific computing. Advanced matrix arithmetic for PHP. More information under numphp.org.

Install

Via Composer

$ composer require numphp/numphp

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

numphp's People

Contributors

gordonlesti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

numphp's Issues

[Insight] Usage of a function in loops should be avoided - in src/NumPHP/Core/NumArray/Map.php, line 50

in src/NumPHP/Core/NumArray/Map.php, line 50

This loop uses a function. To avoid the overhead of executing the function n times, you should precalculate it before the loop.

                }
                for ($i = 0; $i < count($data1); $i++) {
                    $data1[$i] = self::mapRecursive($data1[$i], $data2[$i], $callback);
                }
            } else {
                for ($i = 0; $i < count($data1); $i++) {
                    $data1[$i] = self::mapRecursive($data1[$i], $data2, $callback);
                }
            }
        } else {
            if (is_array($data2)) {

Posted from SensioLabsInsight

Performance

Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u1 x86_64
PHP 5.4.36-0+deb7u3
NumPHP 1.0.5
NumArray Create
    100: 0.016494
    200: 0.063374
    300: 0.165208
    400: 0.274017
    500: 0.430155
    600: 0.633364
    700: 0.918757
    800: 1.175534
    900: 1.506660
    1000: 1.792760
NumArray Add
    100: 0.053313
    200: 0.223531
    300: 0.456773
    400: 0.847988
    500: 1.311289
    600: 1.806092
    700: 2.462531
    800: 3.221318
    900: 4.070084
    1000: 5.039575
NumArray Sum
    100: 0.037804
    200: 0.134861
    300: 0.300540
    400: 0.538527
    500: 0.845408
    600: 1.202567
    700: 1.672970
    800: 2.203351
    900: 2.847183
    1000: 3.543713
NumArray Abs
    100: 0.031971
    200: 0.123737
    300: 0.290139
    400: 0.506395
    500: 0.781722
    600: 1.162238
    700: 1.509048
    800: 2.023560
    900: 2.515371
    1000: 3.117705
NumArray Dot
    100: 0.369425
    200: 2.968532
    300: 12.218522
    400: 28.709637
    500: 55.286791

Documentation

The current documentation is incomplete and part of the website numphp.org/docs. The website is under closed source at the moment.
There is also the NumPHP-docs repository that was integrated with readthedocs.org. I would like to improve the documentation. Here a list of possible ways.

  • The source code of the website should be public including the docs.
  • The NumPHP-docs will be refreshed and used as main doc.
  • ...

[Insight] Unused use statement should be avoided - in src/NumPHP/Core/NumArray.php, line 23

in src/NumPHP/Core/NumArray.php, line 23

The class NumPHP\Core\NumArray\Sum is declared but never used. You should remove the use statement.

use NumPHP\Core\NumArray\Map;
use NumPHP\Core\NumArray\Reduce;
use NumPHP\Core\NumArray\Set;
use NumPHP\Core\NumArray\Shape;
use NumPHP\Core\NumArray\String;
use NumPHP\Core\NumArray\Sum;
use NumPHP\Core\NumArray\Transpose;

/**
 * Class NumArray
 * @package NumPHP\Core

Posted from SensioLabsInsight

'String' is a special class name

NumArray throws a fatal error under PHP 7:

PHP Fatal error: Cannot use NumPHP\Core\NumArray\String as String because 'String' is a special class name in C:\Users\Nick\PhpstormProjects\PhLe\vendor\numphp\numphp\src\NumPHP\Core\NumArray.php on line 21

So you should rename your String class :)

Significant digits

I am using the library for matrix multiplication and system of linear equations. I am using php 7.1 with Debian. I have read the docs before but I couldn't find any information on the maximum number of significant digits. I know that in PHP this can be modified using php.ini but some of the results I got when using calculations with the functions of NumPHP had 20+ significant digits. I would like to know what is the maximum number and if there is a way to set a fixed number of significant digits for all computations. Thanks in advance.

manual installation does not work

I am trying to follow the manual installation guideline saying "Download the latest package, extract it and include the file vendor/autoload.php in your project.". But there is not such file autoload.php. Can you please assist me in setting this up. Cheers. Chris

[Insight] Unused use statement should be avoided - in src/NumPHP/Core/NumArray/Cache.php, line 14

in src/NumPHP/Core/NumArray/Cache.php, line 14

The class NumPHP\Core\Exception\CacheMissException is declared but never used. You should remove the use statement.

namespace NumPHP\Core\NumArray;

use NumPHP\Core\Exception\CacheException;
use NumPHP\Core\Exception\CacheKeyException;
use NumPHP\Core\Exception\CacheMissException;

/**
 * Class Cache
  * @package NumPHP\Core\NumArray
  */

Posted from SensioLabsInsight

[Insight] Usage of a function in loops should be avoided - in src/NumPHP/Core/NumArray/Map.php, line 46

in src/NumPHP/Core/NumArray/Map.php, line 46

This loop uses a function. To avoid the overhead of executing the function n times, you should precalculate it before the loop.

        if (is_array($data1)) {
            if (is_array($data2)) {
                if (count($data1) !== count($data2)) {
                    throw new InvalidArgumentException('Shape '.count($data1).' is different from '.count($data2));
                }
                for ($i = 0; $i < count($data1); $i++) {
                    $data1[$i] = self::mapRecursive($data1[$i], $data2[$i], $callback);
                }
            } else {
                for ($i = 0; $i < count($data1); $i++) {
                    $data1[$i] = self::mapRecursive($data1[$i], $data2, $callback);

Posted from SensioLabsInsight

[Insight] Usage of a function in loops should be avoided - in src/NumPHP/Core/NumArray/Dot.php, line 166

in src/NumPHP/Core/NumArray/Dot.php, line 166

This loop uses a function. To avoid the overhead of executing the function n times, you should precalculate it before the loop.

    protected static function dotMatrixMatrix(array $data1, array $data2)
    {
        $product = [];
        foreach ($data1 as $i => $rowI) {
            $row = [];
            for ($j = 0; $j < count($data2[0]); $j++) {
                $sum = 0;
                foreach ($rowI as $key => $value1) {
                    $sum += $value1 * $data2[$key][$j];
                }
                $row[$j] = $sum;

Posted from SensioLabsInsight

Most Efficient Internal Representation of Matrices

In an email with @GordonLesti , the topic of efficient internal representation of matrices was discussed. There were concerns about the current approach of using nested arrays. The other alternative is to store one single array, and store another variable for the shape of the matrix. Currently I am researching which would be optimal.

I know you had mentioned that in some cases the nested array performed better and in other cases the single array representation performed better. Do you happen to remember or have it documented which operations were most efficient with which representation? That would be helpful information. I can generate new benchmarks if needed, but trying to save that step.

As I gain more insight into this, I will update this thread with relevant information and proposals. Thanks.

Library status

Hello. Is this library under development or is it abandoned?

[Insight] Usage of a function in loops should be avoided - in src/NumPHP/Core/NumArray/Map.php, line 56

in src/NumPHP/Core/NumArray/Map.php, line 56

This loop uses a function. To avoid the overhead of executing the function n times, you should precalculate it before the loop.

                    $data1[$i] = self::mapRecursive($data1[$i], $data2, $callback);
                }
            }
        } else {
            if (is_array($data2)) {
                for ($i = 0; $i < count($data2); $i++) {
                    $data2[$i] = self::mapRecursive($data1, $data2[$i], $callback);
                }

                return $data2;
            }

Posted from SensioLabsInsight

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.