ILIAS
Release_4_0_x_branch Revision 61816
◀ ilDoc Overview
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Groups
Pages
LagrangeInterpolation.php
Go to the documentation of this file.
1
<?php
2
3
require_once
"../Matrix.php"
;
4
21
class
LagrangeInterpolation
{
22
23
public
function
findPolynomialFactors
(
$x
,
$y
) {
24
$n
= count(
$x
);
25
26
$data
= array();
// double[n][n];
27
$rhs = array();
// double[n];
28
29
for
($i = 0; $i <
$n
; ++$i) {
30
$v = 1;
31
for
($j = 0; $j <
$n
; ++$j) {
32
$data
[$i][$n-$j-1] = $v;
33
$v *=
$x
[$i];
34
}
35
$rhs[$i] =
$y
[$i];
36
}
37
38
// Solve m * s = b
39
$m =
new
Matrix
(
$data
);
40
$b =
new
Matrix
($rhs, $n);
41
42
$s = $m->solve($b);
43
44
return
$s->getRowPackedCopy();
45
}
// function findPolynomialFactors()
46
47
}
// class LagrangeInterpolation
48
49
50
$x
= array(2.0, 1.0, 3.0);
51
$y
= array(3.0, 4.0, 7.0);
52
53
$li
=
new
LagrangeInterpolation
;
54
$f
=
$li
->findPolynomialFactors(
$x
,
$y
);
55
56
57
for
($i = 0; $i < 3; ++$i) {
58
echo
$f
[$i].
"<br />"
;
59
}
Services
Excel
classes
PHPExcel
Shared
JAMA
examples
LagrangeInterpolation.php
Generated on Wed Apr 27 2016 19:01:36 for ILIAS by
1.8.1.2 (using
Doxyfile
)