定制 jstewmc/fx 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

jstewmc/fx

Composer 安装命令:

composer require jstewmc/fx

包简介

Simple math functions

README 文档

README

Simple math functions.

use Jstewmc\Fx;

(new Constant(1))(3);         // returns 1
(new Equality())(3);          // returns 3
(new Linear(1, 2))(3);        // returns 5 (1 * 3 + 2)
(new Quadratic(1, 2, 3))(4);  // returns 27 (1 * 4 ^ 2 + 2 * 4 + 3)
(new Power(1, 2))(3);         // returns 9 (1 * 3 ^ 2)
(new Exponential(1))(2);      // returns 1 (1 ^ 2)

This library supports the following functions:

  • constant, c = x
  • equality, y = x
  • linear, y = mx + b
  • quadratic, y = ax2 + bx + c
  • power, y = cxp
  • exponential, y = bx

Constant

A constant function where c = x:

use Jstewmc\Fx

$fx = new Constant(1);

$fx(1);  // returns 1
$fx(2);  // returns 1
$fx(3);  // returns 1

Equality

An equality where y = x:

use Jstewmc\Fx;

$fx = new Equality();

$fx(1);  // returns 1
$fx(2);  // returns 2
$fx(3);  // returns 3

Linear

A linear function is y = mx + b, where m is the slope and b is the y-intercept:

use Jstewmc\Fx;

$fx = new Linear(1, 2);

$fx(1);  // returns 3 (1 * 1 + 2)
$fx(2);  // returns 4 (1 * 2 + 2)
$fx(3);  // returns 5 (1 * 3 + 2)

Quadratic

A univariate, standard-form quadratic function is y = ax2 + bx + c, where a, b, and c are constants (aka, the quadratic coefficient, the linear coefficient, and the constant, respectively):

use Jstewmc\Fx;

$fx = new Quadratic(1, 2, 3);

$fx(1);  // returns 5 (1 * 1 ^ 2 + 2 * 1 + 3)
$fx(2);  // returns 11 (1 * 2 ^ 2 + 2 * 2 + 3)
$fx(3);  // returns 18 (1 * 3 ^ 2 + 2 * 3 + 3)

Power

A power function is y = cxp, where c is a constant, and p is the power:

use Jstewmc\Fx;

$fx = new Power(1, 2);

$fx(1);  // returns 1 (1 * 1 ^ 2)
$fx(2);  // returns 4 (1 * 2 ^ 2)
$fx(3);  // returns 9 (1 * 3 ^ 2)

Exponential

An exponential function is y = bx, where b is a constant:

use Jstewmc\Fx;

$fx = new Exponential(2);

$fx(1);  // returns 2 (2 ^ 1)
$fx(2);  // returns 4 (2 ^ 2)
$fx(3);  // returns 8 (2 ^ 3)

That's it!

License

MIT

Author

Jack Clayton

Version

1.0.0, August 13, 2016

  • Major release
  • Update composer.json

0.3.1, August 13, 2016

  • Update Fx parent class to be an interface

0.3.0, August 6, 2016

  • Add Fx parent class

0.2.0, August 6, 2016

  • Update README examples
  • Add Equality function
  • Add Constant function

0.1.0, July 30, 2016

  • Initial release

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固