0
|
1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32\euser\maths\um_utl.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include "um_std.h"
|
|
19 |
|
|
20 |
#if defined(__USE_VFP_MATH) && !defined(__CPU_HAS_VFP)
|
|
21 |
#error __USE_VFP_MATH was defined but not __CPU_HAS_VFP - impossible combination, check variant.mmh
|
|
22 |
#endif
|
|
23 |
|
|
24 |
GLDEF_C void Panic(TMathPanic aPanic)
|
|
25 |
//
|
|
26 |
// Panic the process with USER-Math as the category.
|
|
27 |
//
|
|
28 |
{
|
|
29 |
|
|
30 |
User::Panic(_L("USER-Math"),aPanic);
|
|
31 |
}
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
#ifdef __USE_VFP_MATH
|
|
36 |
extern "C" void __set_errno(TInt errno)
|
|
37 |
{
|
|
38 |
// Do nothing, we don't have an errno to set as we use
|
|
39 |
// return values instead - return values are recosntructed
|
|
40 |
// from the results/inputs, not from this
|
|
41 |
}
|
|
42 |
|
|
43 |
extern "C" IMPORT_C TReal __ARM_scalbn(TReal,TInt);
|
|
44 |
extern "C" TReal scalbn(TReal x,TInt n)
|
|
45 |
{
|
|
46 |
return __ARM_scalbn(x,n);
|
|
47 |
}
|
|
48 |
#endif
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
#ifndef __REALS_MACHINE_CODED__
|
|
53 |
EXPORT_C TReal Math::Poly(TReal aX,const SPoly *aPoly)
|
|
54 |
/**
|
|
55 |
Evaluates the polynomial:
|
|
56 |
{a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a[0]}.
|
|
57 |
|
|
58 |
|
|
59 |
@param aX The value of the x-variable
|
|
60 |
@param aPoly A pointer to the structure containing the set of coefficients
|
|
61 |
in the order: a[0], a[1], ..., a[n-1], a[n].
|
|
62 |
|
|
63 |
@return The result of the evaluation.
|
|
64 |
*/
|
|
65 |
//
|
|
66 |
// Evaluate a power series in x for a P_POLY coefficient table.
|
|
67 |
// Changed to use TRealX throughout the calculation
|
|
68 |
//
|
|
69 |
{
|
|
70 |
|
|
71 |
const TReal *pR=(&aPoly->c[aPoly->num-1]);
|
|
72 |
TRealX r(*pR);
|
|
73 |
TRealX x(aX);
|
|
74 |
while (pR>&aPoly->c[0])
|
|
75 |
{
|
|
76 |
r*=x;
|
|
77 |
r+=*--pR;
|
|
78 |
}
|
|
79 |
return(TReal(r));
|
|
80 |
}
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
EXPORT_C void Math::PolyX(TRealX& aY, const TRealX& aX, TInt aDegree, const TRealX *aCoeff)
|
|
86 |
/**
|
|
87 |
Evaluates the polynomial:
|
|
88 |
{a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a[0]}.
|
|
89 |
|
|
90 |
@param aY A reference containing the result.
|
|
91 |
@param aX The value of the x-variable.
|
|
92 |
@param aDegree The degree of the polynomial (the highest power of x
|
|
93 |
which is present).
|
|
94 |
@param aCoeff A pointer to a contiguous set of TRealX values containing
|
|
95 |
the coefficients.
|
|
96 |
They must be in the order: a[0], a[1], ..., a[n-1], a[n].
|
|
97 |
*/
|
|
98 |
{
|
|
99 |
// Evaluate a polynomial with TRealX argument and TRealX coefficients.
|
|
100 |
// Return a TRealX result.
|
|
101 |
|
|
102 |
const TRealX *pC=aCoeff+aDegree;
|
|
103 |
aY=*pC;
|
|
104 |
while(aDegree--)
|
|
105 |
{
|
|
106 |
aY*=aX;
|
|
107 |
aY+=*--pC;
|
|
108 |
}
|
|
109 |
}
|
|
110 |
#endif
|