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