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 /*-------------------------------------------------------------------------*/
25 /* FUNCTION: */
26 /* LVM_Power10 */
27 /* */
28 /* DESCRIPTION: */
29 /* This function calculates 10X using an 11th order polynomial. It uses */
30 /* the following table of 32-bit integer polynomial coefficients: */
31 /* */
32 /* Coefficient Value */
33 /* A0 67102543 */
34 /* A1 309032995 */
35 /* A2 712096127 */
36 /* A3 1092797331 */
37 /* A4 1251625137 */
38 /* A5 1154649460 */
39 /* A6 915654800 */
40 /* A7 597883683 */
41 /* A8 284378230 */
42 /* A9 150262097 */
43 /* A10 124894471 */
44 /* A11 50477244 */
45 /* A12 -2 */
46 /* */
47 /* Y = (A0 + A1*X + A2*X2 + A3*X3 + �.. + AN*xN) << AN+1 */
48 /* */
49 /* */
50 /* PARAMETERS: */
51 /* */
52 /* X is the input variable in Q2.30 format */
53 /* */
54 /* RETURNS: */
55 /* The result of the 10x expansion in Q8.24 format */
56 /*-------------------------------------------------------------------------*/
57
LVM_Power10(LVM_INT32 X)58 LVM_INT32 LVM_Power10(LVM_INT32 X)
59 {
60 LVM_INT32 Y,Coefficients[13]={ 16775636,
61 77258249,
62 178024032,
63 273199333,
64 312906284,
65 288662365,
66 228913700,
67 149470921,
68 71094558,
69 37565524,
70 31223618,
71 12619311,
72 0};
73 Y=LVM_Polynomial((LVM_UINT16)11,
74 Coefficients,
75 X);
76 return Y;
77 }
78
79