sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\euser\maths\um_utl.cpp sl@0: // sl@0: // sl@0: sl@0: #include "um_std.h" sl@0: sl@0: #if defined(__USE_VFP_MATH) && !defined(__CPU_HAS_VFP) sl@0: #error __USE_VFP_MATH was defined but not __CPU_HAS_VFP - impossible combination, check variant.mmh sl@0: #endif sl@0: sl@0: GLDEF_C void Panic(TMathPanic aPanic) sl@0: // sl@0: // Panic the process with USER-Math as the category. sl@0: // sl@0: { sl@0: sl@0: User::Panic(_L("USER-Math"),aPanic); sl@0: } sl@0: sl@0: sl@0: sl@0: #ifdef __USE_VFP_MATH sl@0: extern "C" void __set_errno(TInt errno) sl@0: { sl@0: // Do nothing, we don't have an errno to set as we use sl@0: // return values instead - return values are recosntructed sl@0: // from the results/inputs, not from this sl@0: } sl@0: sl@0: extern "C" IMPORT_C TReal __ARM_scalbn(TReal,TInt); sl@0: extern "C" TReal scalbn(TReal x,TInt n) sl@0: { sl@0: return __ARM_scalbn(x,n); sl@0: } sl@0: #endif sl@0: sl@0: sl@0: sl@0: #ifndef __REALS_MACHINE_CODED__ sl@0: EXPORT_C TReal Math::Poly(TReal aX,const SPoly *aPoly) sl@0: /** sl@0: Evaluates the polynomial: sl@0: {a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a[0]}. sl@0: sl@0: sl@0: @param aX The value of the x-variable sl@0: @param aPoly A pointer to the structure containing the set of coefficients sl@0: in the order: a[0], a[1], ..., a[n-1], a[n]. sl@0: sl@0: @return The result of the evaluation. sl@0: */ sl@0: // sl@0: // Evaluate a power series in x for a P_POLY coefficient table. sl@0: // Changed to use TRealX throughout the calculation sl@0: // sl@0: { sl@0: sl@0: const TReal *pR=(&aPoly->c[aPoly->num-1]); sl@0: TRealX r(*pR); sl@0: TRealX x(aX); sl@0: while (pR>&aPoly->c[0]) sl@0: { sl@0: r*=x; sl@0: r+=*--pR; sl@0: } sl@0: return(TReal(r)); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: EXPORT_C void Math::PolyX(TRealX& aY, const TRealX& aX, TInt aDegree, const TRealX *aCoeff) sl@0: /** sl@0: Evaluates the polynomial: sl@0: {a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a[0]}. sl@0: sl@0: @param aY A reference containing the result. sl@0: @param aX The value of the x-variable. sl@0: @param aDegree The degree of the polynomial (the highest power of x sl@0: which is present). sl@0: @param aCoeff A pointer to a contiguous set of TRealX values containing sl@0: the coefficients. sl@0: They must be in the order: a[0], a[1], ..., a[n-1], a[n]. sl@0: */ sl@0: { sl@0: // Evaluate a polynomial with TRealX argument and TRealX coefficients. sl@0: // Return a TRealX result. sl@0: sl@0: const TRealX *pC=aCoeff+aDegree; sl@0: aY=*pC; sl@0: while(aDegree--) sl@0: { sl@0: aY*=aX; sl@0: aY+=*--pC; sl@0: } sl@0: } sl@0: #endif