LibreOffice Module sc (master)  1
opinlinefun_math.hxx
Go to the documentation of this file.
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 
10 #pragma once
11 
12 #include <string>
13 
14 std::string Math_Intg_Str=
15 "\ndouble Intg(double n)\n\
16 {\n\
17  if(trunc(n)==n )\n\
18  return n;\n\
19  else if(n<0)\n\
20  return trunc(n)-1;\n\
21  else\n\
22  return trunc(n)+1;\n\
23 }\n";
24 
25 std::string bikDecl = "double bik(double n,double k);\n";
26 std::string bik =
27 "double bik(double n,double k)\n"
28 "{\n"
29 " double nVal1 = n;\n"
30 " double nVal2 = k;\n"
31 " n = n - 1;\n"
32 " k = k - 1;\n"
33 " while (k > 0)\n"
34 " {\n"
35 " nVal1 = nVal1 * n;\n"
36 " nVal2 = nVal2 * k;\n"
37 " k = k - 1;\n"
38 " n = n - 1;\n"
39 " }\n"
40 " return (nVal1 / nVal2);\n"
41 "}\n";
42 
43 std::string local_cothDecl = "double local_coth(double n);\n";
44 std::string local_coth =
45 "double local_coth(double n)\n"
46 "{\n"
47 " double a = exp(n);\n"
48 " double b = exp(-n);\n"
49 " double nVal = (a + b) / (a - b);\n"
50 " return nVal;\n"
51 "}\n";
52 
53 std::string local_coshDecl = "double local_cosh(double n);\n";
54 std::string local_cosh =
55 "double local_cosh(double n)\n"
56 "{\n"
57 " double nVal = (exp(n) + exp(-n)) / 2;\n"
58 " return nVal;\n"
59 "}\n";
60 std::string atan2Decl = "double arctan2(double y, double x);\n";
61 std::string atan2Content =
62 "double arctan2(double y, double x)\n"
63 "{\n"
64 " if(y==0.0)\n"
65 " return 0.0;\n"
66 " double a,num,den,tmpPi;\n"
67 " int flag;\n"
68 " tmpPi = 0;\n"
69 " if (fabs(x) >= fabs(y))\n"
70 " {\n"
71 " num = y;\n"
72 " den = x;\n"
73 " flag = 1;\n"
74 " if (x < 0.0)\n"
75 " tmpPi = M_PI;\n"
76 " }\n"
77 " if(fabs(x) < fabs(y))\n"
78 " {\n"
79 " num = x;\n"
80 " den = y;\n"
81 " flag = -1;\n"
82 " tmpPi = M_PI_2;\n"
83 " }\n"
84 " a = atan(num/den);\n"
85 " a = flag==1?a:-a;\n"
86 " a = a + (y >= 0.0 ? tmpPi : -tmpPi);\n"
87 " return a;\n"
88 "}\n";
89 
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::string Math_Intg_Str
std::string local_coth
std::string atan2Content
std::string bik
std::string local_cosh
std::string atan2Decl
std::string local_cothDecl
std::string bikDecl
std::string local_coshDecl