1 /*
2  * Copyright (C) 2004-2010 NXP Software
3  * Copyright (C) 2010 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include "LVM_Types.h"
19 #include "LVM_Macros.h"
20 #include "ScalarArithmetic.h"
21 #include "Filter.h"
22 
23 /*-------------------------------------------------------------------------*/
24 /* FUNCTION:                                                               */
25 /*   LVM_Power10                                                           */
26 /*                                                                         */
27 /* DESCRIPTION:                                                            */
28 /*   This function calculates 10X using an 11th order polynomial. It uses  */
29 /*   the following table of 32-bit integer polynomial coefficients:        */
30 /*                                                                         */
31 /*   Coefficient    Value                                                  */
32 /*   A0             67102543                                               */
33 /*   A1             309032995                                              */
34 /*   A2             712096127                                              */
35 /*   A3             1092797331                                             */
36 /*   A4             1251625137                                             */
37 /*   A5             1154649460                                             */
38 /*   A6             915654800                                              */
39 /*   A7             597883683                                              */
40 /*   A8             284378230                                              */
41 /*   A9             150262097                                              */
42 /*   A10            124894471                                              */
43 /*   A11            50477244                                               */
44 /*   A12            -2                                                     */
45 /*                                                                         */
46 /*  Y = (A0 + A1*X + A2*X2 + A3*X3 + �.. + AN*xN) << AN+1                  */
47 /*                                                                         */
48 /*                                                                         */
49 /* PARAMETERS:                                                             */
50 /*                                                                         */
51 /*  X               is the input variable in Q2.30 format                  */
52 /*                                                                         */
53 /* RETURNS:                                                                */
54 /*   The result of the 10x expansion in Q8.24 format                       */
55 /*-------------------------------------------------------------------------*/
LVM_Power10(LVM_FLOAT X)56 LVM_FLOAT LVM_Power10(LVM_FLOAT X) {
57     LVM_FLOAT Y, Coefficients[13] = {0.999906f, 2.302475f, 2.652765f, 2.035494f, 1.165667f,
58                                      0.537676f, 0.213192f, 0.069603f, 0.016553f, 0.004373f,
59                                      0.001817f, 0.000367f, 0};
60     Y = LVM_Polynomial((LVM_UINT16)11, Coefficients, X);
61     return Y;
62 }
63