bjoernffm/step-functions
Composer 安装命令:
composer require bjoernffm/step-functions
包简介
Step Functions for php
关键字:
README 文档
README
Step Functions is a library which offers implementation of step functions. Define one or multiple functions, define the bounds where they are in use and this library will interpolate between the functions.
Installation
This library is provided as Composer package. To install it, simply execute the folowing command:
composer require bjoernffm/step-functions
Note: This library requires PHP 7.2.
Usage
The simplest usage that will mostly fulfill your needs is to define one or more functions and add them to an interpolator instance:
<?php use bjoernffm\stepFunctions\StepFunction; use bjoernffm\stepFunctions\Interpolator; require 'vendor/autoload.php'; $first = new StepFunction(0, 1, function($input) { return $input; }); $second = new StepFunction(1, 2, function($input) { return -1*$input+2; }); $interpolator = new Interpolator(); $interpolator->add($first); $interpolator->add($second); echo $interpolator->getValue(0); // output 0 echo $interpolator->getValue(0.5); // output 0.5 echo $interpolator->getValue(1); // output 1 echo $interpolator->getValue(1.5); // output 0.5 echo $interpolator->getValue(2); // output 0
Contributing
Do you want to help improving this project? Simply fork it and post a pull request. You can do everything on your own, you don't need to ask if you can, just do all the awesome things you want!
This project is published under Apache-2.0 license.
统计信息
- 总下载量: 811
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2019-11-04