LCOV - code coverage report
Current view: top level - svtools/source/dialogs - mcvmath.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 26 0.0 %
Date: 2014-04-14 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <mcvmath.hxx>
      22             : 
      23             : 
      24             : // die folgenden Tabellen enthalten     sin(phi) * 2**14
      25             : // fuer phi= 360Grad*2**-32 bis 360 Grad
      26             : // def. fuer x: phi=360Grad * 2**(x-16)
      27             : //           d.h. x =  16 -> 360 Grad
      28             : //                x = -16 -> (2**-16) * 360 Grad
      29             : //         x:         -16 ... 0 ... 15
      30             : //x=    0,     1,     2,     3,     4,     5,     6,      7,
      31             : //      8,     9,    10,    11,    12,    13,    14,     15
      32             : 
      33             : static const short CosTab[16] =
      34             : {
      35             :     16384, 16384, 16384, 16384, 16384, 16384, 16384,  16383,
      36             :     16379, 16364, 16305, 16069, 15137, 11585,     0, -16383
      37             : };
      38             : static const short SinTab[16]=
      39             : {
      40             :         2,     3,      6,    13,    25,     50,   101,  201,
      41             :       402,   804,   1606,  3196,  6270,  11585, 16384,    0
      42             : };
      43             : 
      44             : /**************************************************************************
      45             : |*
      46             : |*    ImpMultBig2()
      47             : |*
      48             : |*    Description       Multiplier for FixPoint-calculations
      49             : |*
      50             : **************************************************************************/
      51             : 
      52             : //  first parameter should be the larger one
      53             : 
      54           0 : Fix ImpMultBig2( const Fix& a, const Fix& b )
      55             : {
      56           0 :     Fix f;
      57           0 :     f.x = (((b.x+FIX_A2)>>FIX_P2)*a.x+FIX_A3)>>FIX_P3;
      58           0 :     return f;
      59             : }
      60             : 
      61             : /**************************************************************************
      62             : |*
      63             : |*    ImpSqrt()
      64             : |*
      65             : |*    Description       SquareRoot function for FixPoint-calculations
      66             : |*
      67             : **************************************************************************/
      68             : 
      69           0 : sal_uInt16 ImpSqrt( sal_uLong nRadi )
      70             : {
      71           0 :     sal_uLong  inf = 1;
      72           0 :     sal_uLong  sup = nRadi;
      73             :     sal_uLong sqr;
      74             : 
      75           0 :     if ( !nRadi )
      76           0 :         return 0;
      77             : 
      78           0 :     while ( (inf<<1) <= sup )
      79             :     {
      80           0 :         sup >>= 1;
      81           0 :         inf <<= 1;
      82             :     }
      83           0 :     sqr = (sup+inf) >> 1;               // startvalue for iteration
      84             : 
      85           0 :     sqr = (nRadi/sqr + sqr) >> 1;       // 2 Newton-Iterations suffice for
      86           0 :     sqr = (nRadi/sqr + sqr) >> 1;       // +- 1 Digit
      87             : 
      88           0 :     return sal::static_int_cast< sal_uInt16 >(sqr);
      89             : }
      90             : 
      91             : /**************************************************************************
      92             : |*
      93             : |*    ImpExPI()
      94             : |*
      95             : |*    Description       EXPI funktion or FixPoint-calculations
      96             : |*
      97             : **************************************************************************/
      98             : 
      99             : // e**(i*nPhi), unit nPhi: 2**16 == 360 degrees
     100             : 
     101           0 : FixCpx ImpExPI( sal_uInt16 nPhi )
     102             : {
     103             :     short i;
     104           0 :     FixCpx aIter(1L);                   // e**(0*i)
     105           0 :     FixCpx Mul;
     106           0 :     const char Sft=14-FIX_POST;
     107             : 
     108           0 :     for ( i = 15; i >= 0; i-- )
     109             :     {
     110           0 :         if ( (1L<<i) & nPhi )
     111             :         {
     112           0 :             Mul.r.x = CosTab[i]>>Sft;   // e**(i(phi1+phi2)) =
     113           0 :             Mul.i.x = SinTab[i]>>Sft;   // e**(i*phi1)) * e**(i*phi2))
     114           0 :             aIter  *= Mul;
     115             :         }
     116             :     }
     117             : 
     118           0 :     return aIter;
     119             : }
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10