mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 15:10:46 +03:00
phobos 0.138
This commit is contained in:
parent
0db21d681e
commit
d53da65c02
2 changed files with 2 additions and 23 deletions
|
@ -50,6 +50,7 @@ module std.math;
|
||||||
|
|
||||||
//debug=math; // uncomment to turn on debugging printf's
|
//debug=math; // uncomment to turn on debugging printf's
|
||||||
|
|
||||||
|
private import std.stdio;
|
||||||
private import std.c.stdio;
|
private import std.c.stdio;
|
||||||
private import std.string;
|
private import std.string;
|
||||||
private import std.c.math;
|
private import std.c.math;
|
||||||
|
@ -1641,7 +1642,7 @@ body
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
i = A.length - 1;
|
int i = A.length - 1;
|
||||||
real r = A[i];
|
real r = A[i];
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
{
|
{
|
||||||
|
|
22
std/math2.d
22
std/math2.d
|
@ -114,28 +114,6 @@ unittest
|
||||||
assert(feq(frac(-123.456), -0.456L));
|
assert(feq(frac(-123.456), -0.456L));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************
|
|
||||||
* Polynomial of X
|
|
||||||
*/
|
|
||||||
|
|
||||||
real poly(real x, real[] coefficients)
|
|
||||||
{
|
|
||||||
debug (math2) printf("poly(), coefficients.length = %d\n", coefficients.length);
|
|
||||||
if (!coefficients.length)
|
|
||||||
return 0;
|
|
||||||
real result = coefficients[coefficients.length - 1];
|
|
||||||
for (int i = coefficients.length - 2; i >= 0; i--)
|
|
||||||
result = result * x + coefficients[i];
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
unittest
|
|
||||||
{
|
|
||||||
debug (math2) printf("unittest.poly()\n");
|
|
||||||
static real[4] k = [ 4, 3, 2, 1 ];
|
|
||||||
assert(feq(poly(2, k), cast(real) 8 * 1 + 4 * 2 + 2 * 3 + 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
* Sign
|
* Sign
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue