diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:12:17 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:12:17 +0200 |
commit | f1ab2f022fdc780aca0944d90e9a0e844a0820d7 (patch) | |
tree | 79942a40514f5ab40c5901349c9fcd30c6c8dc0e /admin/survey/excel/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation.php | |
parent | 2024-02-19 upstream (diff) | |
download | 1ka-f1ab2f022fdc780aca0944d90e9a0e844a0820d7.tar 1ka-f1ab2f022fdc780aca0944d90e9a0e844a0820d7.tar.gz 1ka-f1ab2f022fdc780aca0944d90e9a0e844a0820d7.tar.bz2 1ka-f1ab2f022fdc780aca0944d90e9a0e844a0820d7.tar.lz 1ka-f1ab2f022fdc780aca0944d90e9a0e844a0820d7.tar.xz 1ka-f1ab2f022fdc780aca0944d90e9a0e844a0820d7.tar.zst 1ka-f1ab2f022fdc780aca0944d90e9a0e844a0820d7.zip |
Diffstat (limited to 'admin/survey/excel/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation.php')
-rw-r--r-- | admin/survey/excel/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation.php | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/admin/survey/excel/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation.php b/admin/survey/excel/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation.php deleted file mode 100644 index 27c8937..0000000 --- a/admin/survey/excel/PHPExcel/Shared/JAMA/examples/LagrangeInterpolation.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php
-
-require_once "../Matrix.php";
-
-/**
- * Given n points (x0,y0)...(xn-1,yn-1), the following methid computes
- * the polynomial factors of the n-1't degree polynomial passing through
- * the n points.
- *
- * Example: Passing in three points (2,3) (1,4) and (3,7) will produce
- * the results [2.5, -8.5, 10] which means that the points are on the
- * curve y = 2.5x² - 8.5x + 10.
- *
- * @see http://geosoft.no/software/lagrange/LagrangeInterpolation.java.html
- * @author Jacob Dreyer
- * @author Paul Meagher (port to PHP and minor changes)
- *
- * @param x[] float
- * @param y[] float
- */
-class LagrangeInterpolation {
-
- public function findPolynomialFactors($x, $y) {
- $n = count($x);
-
- $data = array(); // double[n][n];
- $rhs = array(); // double[n];
-
- for ($i = 0; $i < $n; ++$i) {
- $v = 1;
- for ($j = 0; $j < $n; ++$j) {
- $data[$i][$n-$j-1] = $v;
- $v *= $x[$i];
- }
- $rhs[$i] = $y[$i];
- }
-
- // Solve m * s = b
- $m = new Matrix($data);
- $b = new Matrix($rhs, $n);
-
- $s = $m->solve($b);
-
- return $s->getRowPackedCopy();
- } // function findPolynomialFactors()
-
-} // class LagrangeInterpolation
-
-
-$x = array(2.0, 1.0, 3.0);
-$y = array(3.0, 4.0, 7.0);
-
-$li = new LagrangeInterpolation;
-$f = $li->findPolynomialFactors($x, $y);
-
-
-for ($i = 0; $i < 3; ++$i) {
- echo $f[$i]."<br />";
-}
|