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