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