Home | History | Annotate | Download | only in src
      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 #ifdef BUILD_FLOAT
     58 LVM_FLOAT LVM_Power10(LVM_FLOAT     X)
     59 {
     60     LVM_FLOAT Y,Coefficients[13]={0.999906f,
     61                                   2.302475f,
     62                                   2.652765f,
     63                                   2.035494f,
     64                                   1.165667f,
     65                                   0.537676f,
     66                                   0.213192f,
     67                                   0.069603f,
     68                                   0.016553f,
     69                                   0.004373f,
     70                                   0.001817f,
     71                                   0.000367f,
     72                                   0};
     73     Y=LVM_Polynomial((LVM_UINT16)11,
     74                      Coefficients,
     75                      X);
     76     return Y;
     77 }
     78 #else
     79 LVM_INT32 LVM_Power10(LVM_INT32     X)
     80 {
     81     LVM_INT32 Y,Coefficients[13]={  16775636,
     82                                         77258249,
     83                                        178024032,
     84                                        273199333,
     85                                        312906284,
     86                                        288662365,
     87                                        228913700,
     88                                        149470921,
     89                                         71094558,
     90                                         37565524,
     91                                         31223618,
     92                                         12619311,
     93                                      0};
     94     Y=LVM_Polynomial((LVM_UINT16)11,
     95                         Coefficients,
     96                         X);
     97     return Y;
     98 }
     99 #endif
    100