LibreOffice Module sc (master) 1
op_financial.cxx
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#include "op_financial.hxx"
11
13#include <sstream>
14
15using namespace formula;
16
17namespace sc::opencl {
18// Definitions of inline functions
20#include "op_math_helpers.hxx"
21
23 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
24{
26 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
27 ss << "{\n";
28 ss << " double tmp;\n";
29 ss << " int gid0 = get_global_id(0);\n";
30 GenerateArg( "nper", 0, vSubArguments, ss );
31 GenerateArg( "pv", 1, vSubArguments, ss );
32 GenerateArg( "fv", 2, vSubArguments, ss );
33 ss << " if ( nper <= 0.0 || pv == 0 )\n";
34 ss << " return CreateDoubleError(IllegalArgument);\n";
35 ss << " tmp = pow(fv/pv,1.0/nper)-1;\n";
36 ss << " return tmp;\n";
37 ss << "}";
38}
39
41 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
42{
44 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
45 ss << "{\n\t";
46 ss << "int gid0 = get_global_id(0);\n\t";
47 GenerateArg( "tmp0", 0, vSubArguments, ss );
48 GenerateArg( "tmp1", 1, vSubArguments, ss );
49 ss << "double tmp = 0;\n\t";
50 ss<<"if(tmp1==0)\n\t";
51 ss<<"\treturn 0;\n\t";
52 ss<<"tmp= 1.0 / tmp1;\n\t";
53 ss<<"tmp=( pow( tmp0+ 1.0, tmp ) - 1.0 ) *";
54 ss<<"tmp1;\n\t";
55 ss << "return tmp;\n";
56 ss << "}";
57}
58
60 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
61{
63 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
64 ss << "{\n\t";
65 ss << "double tmp = " << GetBottom() <<";\n\t";
66 ss << "int gid0 = get_global_id(0);\n\t";
67 ss << "double fInt = " << GetBottom() <<";\n\t";
68 GenerateArg( "dollar", 0, vSubArguments, ss );
69 GenerateArg( "fFrac", 1, vSubArguments, ss );
70 ss <<"fFrac = (int)fFrac;\n\t";
71 ss << "tmp = modf( dollar , &fInt );\n\t";
72 ss << "tmp /= fFrac;\n\t";
73 ss << "tmp *= pow( 10.0 , ceil( log10(fFrac ) ) );\n\t";
74 ss << "tmp += fInt;\t";
75 ss << "\n\treturn tmp;\n";
76 ss << "}";
77}
78
80 const std::string &sSymName, SubArguments &vSubArguments)
81{
83 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
84 ss << "{\n\t";
85 ss << "double tmp = " << GetBottom() <<";\n\t";
86 ss << "int gid0 = get_global_id(0);\n\t";
87 ss << "double fInt = " << GetBottom() <<";\n\t";
88 GenerateArg( "dollar", 0, vSubArguments, ss );
89 GenerateArg( "fFrac", 1, vSubArguments, ss );
90 ss <<"fFrac = (int)fFrac;\n\t";
91 ss << "tmp = modf( dollar , &fInt );\n\t";
92 ss << "tmp *= fFrac;\n\t";
93 ss << "tmp *= pow( 10.0 , -ceil( log10(fFrac ) ) );\n\t";
94 ss << "tmp += fInt;\t";
95 ss << "\n\treturn tmp;\n";
96 ss << "}";
97}
98
99void OpDISC::BinInlineFun(std::set<std::string>& decls,
100 std::set<std::string>& funs)
101{
102 decls.insert(GetYearFracDecl);decls.insert(DaysToDateDecl);
103 decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl);
104 funs.insert(GetYearFrac);funs.insert(DaysToDate);
105 funs.insert(DaysInMonth);funs.insert(IsLeapYear);
106}
107
109 const std::string &sSymName, SubArguments& vSubArguments)
110{
111 CHECK_PARAMETER_COUNT( 5, 5 );
112 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
113 ss << "{\n\t";
114 ss << " double tmp = " << GetBottom() << ";\n";
115 ss << " int gid0 = get_global_id(0);\n";
116 GenerateArg( 0, vSubArguments, ss );
117 GenerateArg( 1, vSubArguments, ss );
118 GenerateArg( 2, vSubArguments, ss );
119 GenerateArg( 3, vSubArguments, ss );
120 GenerateArg( 4, vSubArguments, ss );
121 ss << " int nNullDate = 693594;\n";
122 ss << " tmp = 1.0 - arg2 / arg3;\n";
123 ss << " tmp /=";
124 ss << " GetYearFrac(nNullDate, (int)arg0, (int)arg1, (int)arg4);\n";
125 ss << " return tmp;\n";
126 ss << "}";
127}
128
129void OpINTRATE::BinInlineFun(std::set<std::string>& decls,
130 std::set<std::string>& funs)
131{
132 decls.insert(GetYearDiffDecl);decls.insert(GetDiffDateDecl);
133 decls.insert(DaysToDateDecl);decls.insert(GetNullDateDecl);
134 decls.insert(DateToDaysDecl);decls.insert(DaysInMonthDecl);
135 decls.insert(IsLeapYearDecl);
136 funs.insert(GetYearDiff);funs.insert(GetDiffDate);
137 funs.insert(DaysToDate);funs.insert(GetNullDate);
138 funs.insert(DateToDays);funs.insert(DaysInMonth);
139 funs.insert(IsLeapYear);
140}
141
143 const std::string &sSymName, SubArguments& vSubArguments)
144{
145 CHECK_PARAMETER_COUNT( 5, 5 );
146 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
147 ss << "{\n";
148 ss << " double tmp = " << GetBottom() << ";\n";
149 ss << " int gid0 = get_global_id(0);\n";
150 GenerateArg( 0, vSubArguments, ss );
151 GenerateArg( 1, vSubArguments, ss );
152 GenerateArg( 2, vSubArguments, ss );
153 GenerateArg( 3, vSubArguments, ss );
154 GenerateArg( 4, vSubArguments, ss );
155 ss << " int nNullDate = GetNullDate();\n";
156 ss << " tmp = ((arg3 / arg2) - 1) / GetYearDiff(nNullDate, (int)arg0,";
157 ss << " (int)arg1,(int)arg4);\n";
158 ss << " return tmp;\n";
159 ss << "}";
160}
161
162void OpFV::BinInlineFun(std::set<std::string>& decls,
163 std::set<std::string>& funs)
164{
165 decls.insert(GetFVDecl);
166 funs.insert(GetFV);
167}
168
170 const std::string &sSymName, SubArguments& vSubArguments)
171{
172 CHECK_PARAMETER_COUNT( 5, 5 );
173 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
174 ss << "{\n";
175 ss << " double tmp = " << GetBottom() << ";\n";
176 ss << " int gid0 = get_global_id(0);\n";
177 GenerateArg( 0, vSubArguments, ss );
178 GenerateArg( 1, vSubArguments, ss );
179 GenerateArg( 2, vSubArguments, ss );
180 GenerateArg( 3, vSubArguments, ss );
181 GenerateArg( 4, vSubArguments, ss );
182 ss << " tmp = GetFV(arg0, arg1, arg2, arg3, arg4);\n";
183 ss << " return tmp;\n";
184 ss << "}";
185}
186
187void OpIPMT::BinInlineFun(std::set<std::string>& decls,
188 std::set<std::string>& funs)
189{
190 decls.insert(GetFVDecl);
191 funs.insert(GetFV);
192 decls.insert(GetPMTDecl);
193 funs.insert(GetPMT);
194 decls.insert(GetIpmtDecl);
195 funs.insert(GetIpmt);
196}
197
199 const std::string &sSymName, SubArguments& vSubArguments)
200{
201 CHECK_PARAMETER_COUNT( 4, 6 );
202 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
203 ss << "{\n";
204 ss << " double tmp = " << GetBottom() << ";\n";
205 ss << " int gid0 = get_global_id(0);\n";
206 GenerateArg( "fRate", 0, vSubArguments, ss );
207 GenerateArg( "fPer", 1, vSubArguments, ss );
208 GenerateArg( "fNper", 2, vSubArguments, ss );
209 GenerateArg( "fPv", 3, vSubArguments, ss );
210 GenerateArgWithDefault( "fFv", 4, 0, vSubArguments, ss );
211 GenerateArgWithDefault( "fPayInAdvance", 5, 0, vSubArguments, ss );
212 ss << " if (fPer < 1.0 || fPer > fNper)\n";
213 ss << " return CreateDoubleError(IllegalArgument);\n";
214 ss << " else\n";
215 ss << " {\n";
216 ss << " double fPmt;\n";
217 ss << " return GetIpmt(fRate, fPer, fNper, fPv, fFv, fPayInAdvance != 0, &fPmt);\n";
218 ss << " }\n";
219 ss << "}\n";
220}
222 const std::string &sSymName, SubArguments& vSubArguments)
223{
224 CHECK_PARAMETER_COUNT( 4, 4 );
225 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
226 ss << "{\n";
227 ss << " double tmp = " << GetBottom() << ";\n";
228 ss << " int gid0 = get_global_id(0);\n";
229 GenerateArg( 0, vSubArguments, ss );
230 GenerateArg( 1, vSubArguments, ss );
231 GenerateArg( 2, vSubArguments, ss );
232 GenerateArg( 3, vSubArguments, ss );
233 ss << " tmp = arg3 * arg0 * ( arg1 - arg2) / arg2;\n";
234 ss << " return tmp;\n";
235 ss << "}";
236}
237
239 const std::string &sSymName, SubArguments& vSubArguments)
240{
241 CHECK_PARAMETER_COUNT( 3, 3 );
242 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
243 ss << "{\n";
244 ss << " double tmp = " << GetBottom() << ";\n";
245 ss << " int gid0 = get_global_id(0);\n";
246 GenerateArg( 0, vSubArguments, ss );
247 GenerateArg( 1, vSubArguments, ss );
248 GenerateArg( 2, vSubArguments, ss );
249 ss << " if ( arg0 <= 0.0 || arg1 <= 0.0 || arg2 <= 0.0 )\n";
250 ss << " return CreateDoubleError(IllegalArgument);\n";
251 ss << " tmp = log(arg2 / arg1) / log1p(arg0);\n";
252 ss << " return tmp;\n";
253 ss << "}";
254}
255
256void OpDuration_ADD::BinInlineFun(std::set<std::string>& decls,
257 std::set<std::string>& funs)
258{
259 decls.insert(GetDurationDecl);decls.insert(lcl_GetcoupnumDecl);
260 decls.insert(GetYearFracDecl);decls.insert(DaysToDateDecl);
261 decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl);
262 decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl);
263 funs.insert(GetDuration);funs.insert(lcl_Getcoupnum);
264 funs.insert(GetYearFrac);funs.insert(DaysToDate);
265 funs.insert(GetNullDate);funs.insert(DateToDays);
266 funs.insert(DaysInMonth);funs.insert(IsLeapYear);
267}
268
270 const std::string &sSymName, SubArguments& vSubArguments)
271{
272 CHECK_PARAMETER_COUNT( 6, 6 );
273 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
274 ss << "{\n";
275 ss << " double tmp = " << GetBottom() << ";\n";
276 ss << " int gid0 = get_global_id(0);\n";
277 GenerateArg( 0, vSubArguments, ss );
278 GenerateArg( 1, vSubArguments, ss );
279 GenerateArg( 2, vSubArguments, ss );
280 GenerateArg( 3, vSubArguments, ss );
281 GenerateArg( 4, vSubArguments, ss );
282 GenerateArg( 5, vSubArguments, ss );
283 ss << " int nNullDate = GetNullDate();\n";
284 ss << " tmp = GetDuration( nNullDate, (int)arg0, (int)arg1, arg2,";
285 ss << " arg3, (int)arg4, (int)arg5);\n";
286 ss << " return tmp;\n";
287 ss << "}";
288}
289void OpMDuration::BinInlineFun(std::set<std::string>& decls,
290 std::set<std::string>& funs)
291{
292 decls.insert(GetDurationDecl);decls.insert(lcl_GetcoupnumDecl);
293 decls.insert(addMonthsDecl);decls.insert(checklessthanDecl);
294 decls.insert(setDayDecl);decls.insert(ScaDateDecl);
295 decls.insert(GetYearFracDecl);decls.insert(DaysToDateDecl);
296 decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl);
297 funs.insert(GetDuration);funs.insert(lcl_Getcoupnum);
298 funs.insert(addMonths);funs.insert(checklessthan);
299 funs.insert(setDay);funs.insert(ScaDate);
300 funs.insert(GetYearFrac);funs.insert(DaysToDate);
301 funs.insert(DaysInMonth);funs.insert(IsLeapYear);
302}
303
305 const std::string &sSymName, SubArguments& vSubArguments)
306{
307 CHECK_PARAMETER_COUNT( 6, 6 );
308 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
309 ss << "{\n";
310 ss << " double tmp = " << GetBottom() << ";\n";
311 ss << " int gid0 = get_global_id(0);\n";
312 GenerateArg( 0, vSubArguments, ss );
313 GenerateArg( 1, vSubArguments, ss );
314 GenerateArg( 2, vSubArguments, ss );
315 GenerateArg( 3, vSubArguments, ss );
316 GenerateArg( 4, vSubArguments, ss );
317 GenerateArg( 5, vSubArguments, ss );
318 ss << " int nNullDate = 693594;\n";
319 ss << " tmp = GetDuration( nNullDate, (int)arg0, (int)arg1, arg2,";
320 ss << " arg3, (int)arg4, (int)arg5);\n";
321 ss << " tmp = tmp * pow(1.0 + arg3 * pow((int)arg4, -1.0), -1);\n";
322 ss << " return tmp;\n";
323 ss << "}";
324}
326 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
327{
328 CHECK_PARAMETER_COUNT( 2, 2 );
329 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
330 ss << "{\n\t";
331 ss << "double tmp = 1.0;\n\t";
332 ss << "int gid0 = get_global_id(0);\n";
333 GenerateArg( 0, vSubArguments, ss );
334 ss << "\t";
335 GenerateRangeArg( 1, vSubArguments, ss, SkipEmpty,
336 " tmp *= arg + 1;\n"
337 );
338 ss << "\t";
339 ss << "return (double)tmp * arg0";
340 ss << ";\n}";
341}
342void Cumipmt::BinInlineFun(std::set<std::string>& decls,
343 std::set<std::string>& funs)
344{
345 decls.insert(GetPMTDecl); decls.insert(GetFV);
346 funs.insert(GetPMT);funs.insert(GetFV);
347}
349 outputstream &ss, const std::string &sSymName, SubArguments &
350vSubArguments)
351{
352 CHECK_PARAMETER_COUNT( 6, 6 );
353 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
354 ss << "{\n";
355 ss << " int gid0 = get_global_id(0);\n";
356 GenerateArg( "fRate", 0, vSubArguments, ss );
357 GenerateArg( "fNumPeriouds", 1, vSubArguments, ss );
358 GenerateArg( "fVal", 2, vSubArguments, ss );
359 GenerateArg( "fStartPer", 3, vSubArguments, ss );
360 GenerateArg( "fEndPer", 4, vSubArguments, ss );
361 GenerateArg( "fPayType", 5, vSubArguments, ss );
362 ss << " int nNumPeriods = (int)fNumPeriods;\n";
363 ss << " int nStartPer = (int)fStartPer;\n";
364 ss << " int nEndPer = (int)fEndPer;\n";
365 ss << " int nPayType = (int)fPayType;\n";
366 ss <<" double fPmt;\n";
367 ss <<" fPmt = GetPMT( fRate, nNumPeriods, fVal, 0.0, nPayType != 0 );\n";
368 ss <<" double tmp = 0.0;\n";
369 ss <<" if( nStartPer == 1 )\n";
370 ss <<" {\n";
371 ss <<" if( nPayType <= 0 )\n";
372 ss <<" tmp = -fVal;\n";
373 ss <<" nStartPer++;\n";
374 ss <<" }\n";
375 ss <<" for( ; nStartPer<= nEndPer ; nStartPer++ )\n";
376 ss <<" {\n";
377 ss <<" if( nPayType > 0 )\n";
378 ss <<" tmp += GetFV( fRate, nStartPer - 2 , ";
379 ss <<"fPmt, fVal, 1 ) - fPmt;\n";
380 ss <<" else\n";
381 ss <<" tmp += GetFV( fRate, nStartPer - 1 , ";
382 ss <<"fPmt, fVal, 0 );\n";
383 ss <<" }\n";
384 ss <<" tmp *= fRate;\n";
385 ss <<" return tmp;\n";
386 ss <<"}";
387}
388
390 const std::string &sSymName, SubArguments &vSubArguments)
391{
392 CHECK_PARAMETER_COUNT( 2, 2 );
394 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
395 ss << "{\n";
396 ss << " #define Epsilon 1.0E-7\n";
397 ss << " int gid0 = get_global_id(0);\n";
398 GenerateArgWithDefault( "fEstimated", 1, 0.1, vSubArguments, ss );
399 ss << " double fEps = 1.0;\n";
400 ss << " double xNew = 0.0, fNumerator = 0.0, fDenominator = 0.0;\n";
401 ss << " double nCount = 0.0;\n";
402 ss << " unsigned short nItCount = 0;\n";
403 ss << " double x = fEstimated;\n";
404 ss << " while (fEps > Epsilon && nItCount < 20)\n";
405 ss << " {\n";
406 ss << " nCount = 0.0; fNumerator = 0.0; fDenominator = 0.0;\n";
407 GenerateRangeArg( 0, vSubArguments, ss, SkipEmpty,
408 " fNumerator += arg / pow(1.0 + x, nCount);\n"
409 " fDenominator+=-1*nCount*arg/pow(1.0+x,nCount+1.0);\n"
410 " nCount += 1;\n"
411 );
412 ss << " xNew = x - fNumerator / fDenominator;\n";
413 ss << " fEps = fabs(xNew - x);\n";
414 ss << " x = xNew;\n";
415 ss << " nItCount++;\n";
416 ss << " }\n";
417 ss << " if (fEstimated == 0.0 && fabs(x) < Epsilon)\n";
418 ss << " x = 0.0;\n";
419 ss << " if (fEps < Epsilon)\n";
420 ss << " return x;\n";
421 ss << " else\n";
422 ss << " return CreateDoubleError(NoConvergence);\n";
423 ss << "}\n";
424}
425
427 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
428{
429 CHECK_PARAMETER_COUNT( 3, 3 );
432 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
433 ss << "{\n";
434 ss << " double result = 0.0;\n";
435 ss << " int gid0 = get_global_id(0);\n";
436 GenerateArg( "rate", 0, vSubArguments, ss );
437 GenerateRangeArgElement( "dateNull", 2, "0", vSubArguments, ss, EmptyIsZero );
438 GenerateRangeArgPair( 1, 2, vSubArguments, ss, SkipEmpty,
439 " result += arg1/(pow((rate+1),(arg2-dateNull)/365));\n"
440 );
441 ss << " return result;\n";
442 ss << "}";
443}
444
445void PriceMat::BinInlineFun(std::set<std::string>& decls,
446 std::set<std::string>& funs)
447{
448 decls.insert(GetYearFracDecl);decls.insert(GetNullDateDecl);
449 decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl);
450 decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl);
451
452 funs.insert(GetYearFrac);funs.insert(GetNullDate);
453 funs.insert(DateToDays);funs.insert(DaysToDate);
454 funs.insert(DaysInMonth);funs.insert(IsLeapYear);
455}
457 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
458{
459 CHECK_PARAMETER_COUNT( 5, 6 );
460 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
461 ss << "{\n\t";
462 ss << "int gid0 = get_global_id(0);\n\t";
463 ss << "double result=0;\n\t";
464 ss<< "int nNullDate = GetNullDate( );\n";
465 GenerateArg( "fSettle", 0, vSubArguments, ss );
466 GenerateArg( "fMat", 1, vSubArguments, ss );
467 GenerateArg( "fIssue", 2, vSubArguments, ss );
468 GenerateArg( "rate", 3, vSubArguments, ss );
469 GenerateArg( "yield", 4, vSubArguments, ss );
470 GenerateArgWithDefault( "fBase", 5, 0, vSubArguments, ss );
471 ss << "\t";
472 ss <<"int settle = fSettle;\n\t";
473 ss <<"int mat = fMat;\n\t";
474 ss <<"int issue = fIssue;\n\t";
475 ss <<"int nBase = fBase;\n\t";
476 ss<< "double fIssMat = GetYearFrac( nNullDate, issue, mat, nBase);\n";
477 ss<<"double fIssSet = GetYearFrac( nNullDate, issue, settle,nBase);\n";
478 ss<<"double fSetMat = GetYearFrac( nNullDate, settle, mat, nBase);\n";
479 ss<<"result = 1.0 + fIssMat * rate;\n\t";
480 ss<<"result /= 1.0 + fSetMat * yield;\n\t";
481 ss<<"result -= fIssSet * rate;\n\t";
482 ss<<"result*= 100.0;\n\t";
483 ss<<"return result;\n\t";
484 ss<<"}\n";
485}
486
488 const std::string &sSymName, SubArguments &vSubArguments)
489{
490 CHECK_PARAMETER_COUNT( 4, 4 );
491 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
492 ss << "{\n";
493 ss << " int gid0 = get_global_id(0);\n";
494 GenerateArg( "cost", 0, vSubArguments, ss );
495 GenerateArg( "salvage", 1, vSubArguments, ss );
496 GenerateArg( "life", 2, vSubArguments, ss );
497 GenerateArg( "period", 3, vSubArguments, ss );
498 ss << " double result=0;\n";
499 ss <<" double tmpvalue = ((life*(life+1))/2.0);\n";
500 ss <<" result = ((cost-salvage)*(life-period+1)/tmpvalue);\n";
501 ss <<" return result;\n";
502 ss <<"}\n";
503}
504
506 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
507{
508 CHECK_PARAMETER_COUNT( 3, 3 );
509 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
510 ss << "{\n\t";
511 ss << "double tmp;\n\t";
512 ss << "int gid0 = get_global_id(0);\n\t";
513 GenerateArg( 1, vSubArguments, ss );
514 GenerateArg( 2, vSubArguments, ss );
515 ss << "double invest = arg1 + 1.0;\n\t";
516 ss << "double reinvest = arg2 + 1.0;\n\t";
517 ss << "double NPV_invest = 0.0;\n\t";
518 ss << "double Pow_invest = 1.0;\n\t";
519 ss << "double NPV_reinvest = 0.0;\n\t";
520 ss << "double Pow_reinvest = 1.0;\n\t";
521 ss << "int nCount = 0;\n\t";
522 ss << "bool bHasPosValue = false;\n";
523 ss << "bool bHasNegValue = false;\n";
524 GenerateRangeArg( 0, vSubArguments, ss, SkipEmpty,
525 " if (arg > 0.0)\n"
526 " {\n"
527 " NPV_reinvest += arg * Pow_reinvest;\n"
528 " bHasPosValue = true;\n"
529 " }\n"
530 " else if (arg < 0.0)\n"
531 " {\n"
532 " NPV_invest += arg * Pow_invest;\n"
533 " bHasNegValue = true;\n"
534 " }\n"
535 " Pow_reinvest /= reinvest;\n"
536 " Pow_invest /= invest;\n"
537 " nCount++;\n"
538 );
539 ss << "if ( !( bHasPosValue && bHasNegValue ) )\n";
540 ss << " return CreateDoubleError(IllegalArgument);\n";
541 ss << "tmp = ";
542 ss << "-NPV_reinvest /NPV_invest * pow(reinvest,(double)nCount-1);\n\t";
543 ss << "tmp = pow(tmp, 1.0 / (nCount - 1)) - 1.0;\n\t";
544 ss << "return (double)tmp;\n";
545 ss << "}";
546}
547
549 const std::string &sSymName, SubArguments& vSubArguments)
550{
551 CHECK_PARAMETER_COUNT( 2, 2 );
552 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
553 ss << "{\n";
554 ss << " double tmp = " << GetBottom() <<";\n";
555 ss << " int gid0 = get_global_id(0);\n\t";
556 GenerateArg( 0, vSubArguments, ss );
557 GenerateArg( 1, vSubArguments, ss );
558 ss << " tmp = pow(1.0 + arg0 / arg1, arg1)-1.0;\n";
559 ss << " return tmp;\n";
560 ss << "}";
561}
562
563 void OpTbilleq::BinInlineFun(std::set<std::string>& decls,
564 std::set<std::string>& funs)
565{
566 decls.insert(GetDiffDate360_Decl);decls.insert(GetDiffDate360Decl);
567 decls.insert(DateToDaysDecl);decls.insert(DaysToDate_LocalBarrierDecl);
568 decls.insert(DaysInMonthDecl);decls.insert(GetNullDateDecl);
569 decls.insert(IsLeapYearDecl);
570 funs.insert(GetDiffDate360_);funs.insert(GetDiffDate360);
571 funs.insert(DateToDays);funs.insert(DaysToDate_LocalBarrier);
572 funs.insert(DaysInMonth);funs.insert(GetNullDate);
573 funs.insert(IsLeapYear);
574}
576 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
577{
578 CHECK_PARAMETER_COUNT( 3, 3 );
579 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
580 ss << "{\n\t";
581 ss << " int gid0 = get_global_id(0);\n";
582 ss << "double tmp = 0;\n\t";
583 GenerateArg( "tmp000", 0, vSubArguments, ss );
584 GenerateArg( "tmp001", 1, vSubArguments, ss );
585 GenerateArg( "tmp002", 2, vSubArguments, ss );
586 ss<<"tmp001+=1.0;\n";
587 ss<<"int nDiff =GetDiffDate360(GetNullDate(),tmp000,tmp001,true);\n";
588 ss<<"tmp =( 365 * tmp002 ) / ( 360 - ( tmp002 * ( nDiff ) ) );\n";
589 ss << "return tmp;\n";
590 ss << "}";
591}
592void OpCumprinc::BinInlineFun(std::set<std::string>& decls,
593 std::set<std::string>& funs)
594{
595 decls.insert(GetPMTDecl); decls.insert(GetFVDecl);
596 funs.insert(GetPMT);funs.insert(GetFV);
597}
599 const std::string &sSymName, SubArguments &vSubArguments)
600{
601 CHECK_PARAMETER_COUNT( 6, 6 );
602 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
603 ss << "{\n";
604 ss << " double tmp = " << GetBottom() <<";\n";
605 ss << " int gid0 = get_global_id(0);\n";
606 GenerateArg( "fRate", 0, vSubArguments, ss );
607 GenerateArg( "fNumPeriouds", 1, vSubArguments, ss );
608 GenerateArg( "fVal", 2, vSubArguments, ss );
609 GenerateArg( "fStartPer", 3, vSubArguments, ss );
610 GenerateArg( "fEndPer", 4, vSubArguments, ss );
611 GenerateArg( "fPayType", 5, vSubArguments, ss );
612 ss << " int nNumPeriods = (int)fNumPeriods;\n";
613 ss << " int nStartPer = (int)fStartPer;\n";
614 ss << " int nEndPer = (int)fEndPer;\n";
615 ss << " int nPayType = (int)fPayType;\n";
616 ss <<" double fPmt;\n";
617 ss <<" fPmt = GetPMT( fRate, nNumPeriods,fVal,0.0,nPayType != 0 );\n";
618 ss <<" if(nStartPer == 1)\n";
619 ss <<" {\n";
620 ss <<" if( nPayType <= 0 )\n";
621 ss <<" tmp = fPmt + fVal * fRate;\n";
622 ss <<" else\n";
623 ss <<" tmp = fPmt;\n";
624 ss <<" nStartPer=nStartPer+1;\n";
625 ss <<" }\n";
626 ss <<" for( int i = nStartPer ; i <= nEndPer ; i++ )\n";
627 ss <<" {\n";
628 ss <<" if( nPayType > 0 )\n";
629 ss <<" tmp += fPmt - ( GetFV( fRate,i - 2,";
630 ss <<"fPmt,fVal,1)- fPmt ) * fRate;\n";
631 ss <<" else\n";
632 ss <<" tmp += fPmt - GetFV( fRate, i - 1,";
633 ss <<"fPmt,fVal,0 ) * fRate;\n";
634 ss <<" }\n";
635 ss <<" return tmp;\n";
636 ss <<"}";
637}
638void OpAccrint::BinInlineFun(std::set<std::string>& decls,
639 std::set<std::string>& funs)
640{
641 decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl);
642 decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
643 decls.insert(GetNullDateDecl); decls.insert(GetDiffDateDecl);
644 funs.insert(IsLeapYear);funs.insert(DaysInMonth);
645 funs.insert(DaysToDate);funs.insert(DateToDays);
646 funs.insert(GetNullDate);funs.insert(GetDiffDate);
647}
649 outputstream &ss, const std::string &sSymName,
650 SubArguments &vSubArguments)
651{
652 CHECK_PARAMETER_COUNT( 7, 7 );
653 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
654 ss << "{\n";
655 ss << " int gid0 = get_global_id(0);\n";
656 ss << " double tmp = 0;\n";
657 GenerateArg( "fStartDate", 0, vSubArguments, ss );
658 // 1 is ignored
659 GenerateArg( "fEndDate", 2, vSubArguments, ss );
660 GenerateArg( "fRate", 3, vSubArguments, ss );
661 GenerateArg( "fVal", 4, vSubArguments, ss );
662 GenerateArg( "fFreq", 5, vSubArguments, ss );
663 GenerateArg( "fMode", 6, vSubArguments, ss );
664 ss << " int nStartDate = fStartDate;\n";
665 ss << " int nEndDate = fEndDate;\n";
666 ss << " int mode = fMode;\n";
667 ss << " int freq = fFreq;\n";
668 ss << " int nDays1stYear=0;\n";
669 ss <<" int nNullDate=GetNullDate();\n";
670 ss <<" int nTotalDays = GetDiffDate(nNullDate,nStartDate,";
671 ss <<"nEndDate, mode,&nDays1stYear);\n";
672 ss <<" tmp = fVal*fRate*convert_double(nTotalDays)";
673 ss <<"/convert_double(nDays1stYear);\n";
674 ss <<" return tmp;\n";
675 ss <<"}";
676}
677
678void OpAccrintm::BinInlineFun(std::set<std::string>& decls,
679 std::set<std::string>& funs)
680{
681 decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl);
682 decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
683 decls.insert(GetNullDateDecl); decls.insert(GetDiffDateDecl);
684 funs.insert(IsLeapYear);funs.insert(DaysInMonth);
685 funs.insert(DaysToDate);funs.insert(DateToDays);
686 funs.insert(GetNullDate);funs.insert(GetDiffDate);
687}
689 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
690{
691 CHECK_PARAMETER_COUNT( 5, 5 );
692 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
693 ss << "{\n\t";
694 ss << "int gid0 = get_global_id(0);\n\t";
695 ss << "double tmp = " << GetBottom() <<";\n\t";
696
697 GenerateArg( "fStartDate", 0, vSubArguments, ss );
698 GenerateArg( "fEndDate", 1, vSubArguments, ss );
699 GenerateArg( "fRate", 2, vSubArguments, ss );
700 GenerateArg( "fVal", 3, vSubArguments, ss );
701 GenerateArg( "fMode", 4, vSubArguments, ss );
702 ss << " int nStartDate = fStartDate;\n";
703 ss << " int nEndDate = fEndDate;\n";
704 ss << " int mode = fMode;\n";
705 ss <<"int nDays1stYear=0;\n\t";
706 ss <<"int nNullDate=GetNullDate();\n\t";
707 ss <<"int nTotalDays = GetDiffDate(nNullDate,nStartDate,";
708 ss <<"nEndDate, mode,&nDays1stYear);\n\t";
709 ss <<"tmp = fVal*fRate*convert_double(nTotalDays)";
710 ss <<"/convert_double(nDays1stYear);\n\t";
711 ss << "return tmp;\n";
712 ss << "}";
713}
714
715void OpYield::BinInlineFun(std::set<std::string>& decls,
716 std::set<std::string>& funs)
717{
718 decls.insert(getYield_Decl);decls.insert(getPriceDecl);
719 decls.insert(coupnumDecl);decls.insert(coupdaysncDecl);
720 decls.insert(coupdaybsDecl);decls.insert(coupdaysDecl);
721 decls.insert(lcl_GetcoupnumDecl);decls.insert(lcl_GetcoupdaysDecl);
722 decls.insert(lcl_GetcoupdaybsDecl);decls.insert(getDiffDecl);
723 decls.insert(getDaysInYearRangeDecl);decls.insert(GetDaysInYearDecl);
724 decls.insert(GetDaysInYearsDecl);decls.insert(getDaysInMonthRangeDecl);
725 decls.insert(addMonthsDecl);decls.insert(ScaDateDecl);
726 decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl);
727 decls.insert(DaysToDateDecl);decls.insert(DaysInMonthDecl);
728 decls.insert(IsLeapYearDecl);decls.insert(setDayDecl);
729 decls.insert(checklessthanDecl);
730
731 funs.insert(getYield_);funs.insert(getPrice);
732 funs.insert(coupnum);funs.insert(coupdaysnc);
733 funs.insert(coupdaybs);funs.insert(coupdays);
734 funs.insert(lcl_Getcoupnum);funs.insert(lcl_Getcoupdays);
735 funs.insert(lcl_Getcoupdaybs);funs.insert(getDiff);
736 funs.insert(getDaysInYearRange);funs.insert(GetDaysInYear);
737 funs.insert(GetDaysInYears);funs.insert(getDaysInMonthRange);
738 funs.insert(addMonths);funs.insert(ScaDate);
739 funs.insert(GetNullDate);funs.insert(DateToDays);
740 funs.insert(DaysToDate);funs.insert(DaysInMonth);
741 funs.insert(IsLeapYear);decls.insert(setDay);
742 funs.insert(checklessthan);
743}
744
746 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
747{
748 CHECK_PARAMETER_COUNT( 7, 7 );
749 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
750 ss << "{\n\t";
751 ss << "double tmp = 0;\n\t";
752 ss << "int gid0 = get_global_id(0);\n\t";
753 GenerateArg( "tmp000", 0, vSubArguments, ss );
754 GenerateArg( "tmp001", 1, vSubArguments, ss );
755 GenerateArg( "tmp002", 2, vSubArguments, ss );
756 GenerateArg( "tmp003", 3, vSubArguments, ss );
757 GenerateArg( "tmp004", 4, vSubArguments, ss );
758 GenerateArg( "tmp005", 5, vSubArguments, ss );
759 GenerateArg( "tmp006", 6, vSubArguments, ss );
760 ss << "tmp = getYield_(";
761 ss << "GetNullDate(),tmp000,tmp001,tmp002,tmp003,tmp004,tmp005,tmp006);\n\t ";
762 ss << "return tmp;\n";
763 ss << "}";
764}
765
767 const std::string &sSymName, SubArguments &vSubArguments)
768{
769 CHECK_PARAMETER_COUNT( 3, 3 );
770 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
771 ss << "{\n";
772 ss << " double tmp = 0;\n";
773 ss << " int gid0 = get_global_id(0);\n";
774 GenerateArg( "cost", 0, vSubArguments, ss );
775 GenerateArg( "salvage", 1, vSubArguments, ss );
776 GenerateArg( "life", 2, vSubArguments, ss );
777 ss << " tmp = (cost-salvage)/life;\n";
778 ss << " return tmp;\n";
779 ss << "}";
780}
781
782 void OpYieldmat::BinInlineFun(std::set<std::string>& decls,
783 std::set<std::string>& funs)
784{
785 decls.insert(GetYearFracDecl);decls.insert(GetNullDateDecl);
786 decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl);
787 decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl);
788 decls.insert(GetYieldmatDecl);
789
790 funs.insert(GetYearFrac);funs.insert(GetNullDate);
791 funs.insert(DateToDays);funs.insert(DaysToDate);
792 funs.insert(DaysInMonth);funs.insert(IsLeapYear);
793 funs.insert(GetYieldmat);
794}
795
797 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
798{
799 CHECK_PARAMETER_COUNT( 6, 6 );
800 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
801 ss << "{\n\t";
802 ss << "double tmp = 0;\n\t";
803 ss << "int gid0 = get_global_id(0);\n\t";
804 GenerateArg( "tmp000", 0, vSubArguments, ss );
805 GenerateArg( "tmp001", 1, vSubArguments, ss );
806 GenerateArg( "tmp002", 2, vSubArguments, ss );
807 GenerateArg( "tmp003", 3, vSubArguments, ss );
808 GenerateArg( "tmp004", 4, vSubArguments, ss );
809 GenerateArg( "tmp005", 5, vSubArguments, ss );
810 ss << "tmp = GetYieldmat(";
811 ss<<"GetNullDate(),tmp000,tmp001,tmp002,tmp003,tmp004,tmp005);\n\t";
812 ss << "return tmp;\n";
813 ss << "}";
814}
815
816void OpPMT::BinInlineFun(std::set<std::string>& decls,
817 std::set<std::string>& funs)
818{
819 decls.insert(GetPMTDecl);
820 funs.insert(GetPMT);
821}
822
824 const std::string &sSymName, SubArguments &vSubArguments)
825{
826 CHECK_PARAMETER_COUNT( 3, 5 );
827 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
828 ss << "{\n";
829 ss<< " double tmp = 0;\n";
830 ss<< " int gid0 = get_global_id(0);\n";
831 GenerateArg( "fRate", 0, vSubArguments, ss );
832 GenerateArg( "fNper", 1, vSubArguments, ss );
833 GenerateArg( "fPv", 2, vSubArguments, ss );
834 GenerateArgWithDefault( "fFv", 3, 0, vSubArguments, ss );
835 GenerateArgWithDefault( "fPayInAdvance", 4, 0, vSubArguments, ss );
836 ss << " return GetPMT( fRate, fNper, fPv, fFv, fPayInAdvance != 0 );\n";
837 ss << "}";
838}
839
841 const std::string &sSymName, SubArguments &vSubArguments)
842{
843 CHECK_PARAMETER_COUNT( 2, 31 );
844 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
845 ss << "{\n";
846 ss << " double tmp = 0.0;\n";
847 ss << " int gid0 = get_global_id(0);\n";
848 ss << " int nCount = 1;\n";
849 GenerateArg( 0, vSubArguments, ss );
850 GenerateRangeArgs( 1, vSubArguments.size() - 1, vSubArguments, ss, SkipEmpty,
851 " tmp += arg / pow( 1 + arg0, nCount );\n"
852 " nCount += 1;\n"
853 );
854 ss << " return tmp;\n";
855 ss << "}";
856}
857
858 void OpPrice::BinInlineFun(std::set<std::string>& decls,
859 std::set<std::string>& funs)
860 {
861 decls.insert(getPriceDecl);
862 decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
863 decls.insert(DaysToDateDecl);
864 decls.insert(DateToDaysDecl);
865 decls.insert(ScaDateDecl);
866 decls.insert(setDayDecl);decls.insert(checklessthanDecl);
867 decls.insert(addMonthsDecl);decls.insert(lcl_GetcoupnumDecl);
868 decls.insert(coupnumDecl);
869 decls.insert(DateToDaysDecl);
870 decls.insert(getDaysInMonthRangeDecl);
871 decls.insert(GetDaysInYearsDecl); decls.insert(GetDaysInYearDecl);
872 decls.insert(getDaysInYearRangeDecl); decls.insert(getDiffDecl);
873 decls.insert(coupdaybsDecl);
874 decls.insert(lcl_GetcoupdaysDecl);
875 decls.insert(lcl_GetcoupdaybsDecl);
876 decls.insert(coupdaysDecl);
877 decls.insert(coupdaysncDecl);
878 funs.insert(IsLeapYear);funs.insert(DaysInMonth);
879 funs.insert(DaysToDate);funs.insert(DateToDays);
880 funs.insert(DateToDays);
881 funs.insert(ScaDate);
882 funs.insert(addMonths);funs.insert(getDaysInMonthRange);
883 funs.insert(GetDaysInYears);funs.insert(GetDaysInYear);
884 funs.insert(getDaysInYearRange);funs.insert(getDiff);
885 funs.insert(setDay);funs.insert(checklessthan);
886 funs.insert(lcl_Getcoupdaybs);
887 funs.insert(coupdaybs);
888 funs.insert(lcl_Getcoupdays);
889 funs.insert(coupdaysnc);
890 funs.insert(coupdays);
891 funs.insert(setDay);funs.insert(checklessthan);
892 funs.insert(lcl_Getcoupnum);
893 funs.insert(coupnum);funs.insert(getPrice);
894 }
896 const std::string &sSymName, SubArguments &vSubArguments)
897{
898 CHECK_PARAMETER_COUNT( 6, 7 );
899 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
900 ss << "{\n";
901 ss<<" double tmp = 0;\n";
902 ss<<" int gid0 = get_global_id(0);\n";
903 GenerateArg( "tmp0", 0, vSubArguments, ss );
904 GenerateArg( "tmp1", 1, vSubArguments, ss );
905 GenerateArg( "tmp2", 2, vSubArguments, ss );
906 GenerateArg( "tmp3", 3, vSubArguments, ss );
907 GenerateArg( "tmp4", 4, vSubArguments, ss );
908 GenerateArg( "tmp5", 5, vSubArguments, ss );
909 GenerateArgWithDefault( "tmp6", 6, 0, vSubArguments, ss );
910 ss << " if(tmp4*tmp5 == 0) return NAN;\n";
911 ss << " tmp = getPrice(tmp0,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6);\n";
912 ss << " return tmp;\n";
913 ss << "}";
914}
915
916void OpOddlprice::BinInlineFun(std::set<std::string>& decls,
917 std::set<std::string>& funs)
918{
919 decls.insert(GetOddlpriceDecl);decls.insert(GetDiffDateDecl);
920 decls.insert(GetYearDiffDecl);decls.insert(IsLeapYearDecl);
921 decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl);
922 decls.insert(DaysToDateDecl);decls.insert(DaysInMonthDecl);
923 decls.insert(GetYearFracDecl);
924 funs.insert(GetOddlprice);funs.insert(GetDiffDate);
925 funs.insert(GetYearDiff);funs.insert(IsLeapYear);
926 funs.insert(GetNullDate);funs.insert(DaysInMonth);
927 funs.insert(DaysToDate);funs.insert(DateToDays);
928 funs.insert(GetYearFrac);
929}
931 const std::string &sSymName, SubArguments &vSubArguments)
932{
933 CHECK_PARAMETER_COUNT( 7, 8 );
934 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
935 ss << "{\n";
936 ss <<" double tmp = 0;\n";
937 ss <<" int gid0 = get_global_id(0);\n";
938 GenerateArg( "tmp0", 0, vSubArguments, ss );
939 GenerateArg( "tmp1", 1, vSubArguments, ss );
940 GenerateArg( "tmp2", 2, vSubArguments, ss );
941 GenerateArg( "tmp3", 3, vSubArguments, ss );
942 GenerateArg( "tmp4", 4, vSubArguments, ss );
943 GenerateArg( "tmp5", 5, vSubArguments, ss );
944 GenerateArg( "tmp6", 6, vSubArguments, ss );
945 GenerateArgWithDefault( "tmp7", 7, 0, vSubArguments, ss );
946 ss <<" int nNullDate = GetNullDate();\n";
947 ss <<" tmp = GetOddlprice(nNullDate,tmp0,tmp1,";
948 ss <<"tmp2,tmp3,tmp4,tmp5,tmp6,tmp7);\n";
949 ss <<" return tmp;\n";
950 ss <<"}";
951}
952void OpOddlyield::BinInlineFun(std::set<std::string>& decls,
953 std::set<std::string>& funs)
954{
955 decls.insert(GetDiffDateDecl);decls.insert(DaysToDateDecl);
956 decls.insert(GetYearDiffDecl);decls.insert(IsLeapYearDecl);
957 decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl);
958 decls.insert(DaysInMonthDecl);
959 decls.insert(GetYearFracDecl);decls.insert(GetOddlyieldDecl);
960 funs.insert(GetDiffDate);funs.insert(DaysToDate);
961 funs.insert(GetYearDiff);funs.insert(IsLeapYear);
962 funs.insert(GetNullDate);funs.insert(DaysInMonth);
963 funs.insert(DateToDays);
964 funs.insert(GetYearFrac);funs.insert(GetOddlyield);
965}
967 const std::string &sSymName, SubArguments &vSubArguments)
968{
969 CHECK_PARAMETER_COUNT( 7, 8 );
970 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
971 ss << "{\n";
972 ss <<" double tmp = 0;\n";
973 ss <<" int gid0 = get_global_id(0);\n";
974 GenerateArg( "tmp0", 0, vSubArguments, ss );
975 GenerateArg( "tmp1", 1, vSubArguments, ss );
976 GenerateArg( "tmp2", 2, vSubArguments, ss );
977 GenerateArg( "tmp3", 3, vSubArguments, ss );
978 GenerateArg( "tmp4", 4, vSubArguments, ss );
979 GenerateArg( "tmp5", 5, vSubArguments, ss );
980 GenerateArg( "tmp6", 6, vSubArguments, ss );
981 GenerateArgWithDefault( "tmp7", 7, 0, vSubArguments, ss );
982 ss <<" int nNullDate = GetNullDate();\n";
983 ss <<" tmp = GetOddlyield(nNullDate,tmp0,tmp1";
984 ss <<",tmp2,tmp3,tmp4,tmp5,tmp6,tmp7);\n";
985 ss <<" return tmp;\n";
986 ss <<"}";
987}
988void OpPriceDisc::BinInlineFun(std::set<std::string>& decls,
989 std::set<std::string>& funs)
990{
991 decls.insert(GetYearDiffDecl);decls.insert(getDiffDecl);
992 decls.insert(getDaysInYearRangeDecl);decls.insert(GetDaysInYearDecl);
993 decls.insert(GetDaysInYearsDecl);decls.insert(getDaysInMonthRangeDecl);
994 decls.insert(addMonthsDecl);decls.insert(ScaDateDecl);
995 decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl);
996 decls.insert(DaysToDateDecl);decls.insert(DaysInMonthDecl);
997 decls.insert(IsLeapYearDecl);decls.insert(GetDiffDateDecl);
998 funs.insert(GetYearDiff);funs.insert(getDiff);
999 funs.insert(getDaysInYearRange);funs.insert(GetDaysInYear);
1000 funs.insert(GetDaysInYears);funs.insert(getDaysInMonthRange);
1001 funs.insert(addMonths);funs.insert(ScaDate);
1002 funs.insert(GetNullDate);funs.insert(DateToDays);
1003 funs.insert(DaysToDate);funs.insert(DaysInMonth);
1004 funs.insert(IsLeapYear);funs.insert(GetDiffDate);
1005}
1007 const std::string &sSymName, SubArguments &vSubArguments)
1008{
1009 CHECK_PARAMETER_COUNT( 4, 5 );
1010 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1011 ss << "{\n";
1012 ss << " double tmp = 0;\n";
1013 ss << " int gid0 = get_global_id(0);\n";
1014 GenerateArg( "tmp0", 0, vSubArguments, ss );
1015 GenerateArg( "tmp1", 1, vSubArguments, ss );
1016 GenerateArg( "tmp2", 2, vSubArguments, ss );
1017 GenerateArg( "tmp3", 3, vSubArguments, ss );
1018 GenerateArgWithDefault( "tmp4", 4, 0, vSubArguments, ss );
1019 ss <<" int nNullDate = GetNullDate();\n";
1020 ss <<" tmp=tmp3* ( 1.0 -tmp2*GetYearDiff( nNullDate, ";
1021 ss <<"tmp0,tmp1,tmp4));\n";
1022 ss <<" return tmp;\n";
1023 ss <<"}";
1024}
1026 const std::string &sSymName, SubArguments &vSubArguments)
1027{
1028 CHECK_PARAMETER_COUNT( 3, 5 );
1029 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1030 ss << "{\n";
1031 ss << " double tmp = 0;\n";
1032 ss << " int gid0 = get_global_id(0);\n";
1033 GenerateArg( "fRate", 0, vSubArguments, ss );
1034 GenerateArg( "fPmt", 1, vSubArguments, ss );
1035 GenerateArg( "fPV", 2, vSubArguments, ss );
1036 GenerateArgWithDefault( "fFV", 3, 0, vSubArguments, ss );
1037 GenerateArgWithDefault( "fPayInAdvance", 4, 0, vSubArguments, ss );
1038 ss << " if ( fPV + fFV == 0.0 )\n";
1039 ss << " return 0.0;\n";
1040 ss << " else if (fRate == 0.0)\n";
1041 ss << " return -(fPV + fFV)/fPmt;\n";
1042 ss << " else if (fPayInAdvance != 0)\n";
1043 ss << " return log(-(fRate*fFV-fPmt*(1.0+fRate))/(fRate*fPV+fPmt*(1.0+fRate)))\n";
1044 ss << " / log1p(fRate);\n";
1045 ss << " else\n";
1046 ss << " return log(-(fRate*fFV-fPmt)/(fRate*fPV+fPmt)) / log1p(fRate);\n";
1047 ss << "}\n";
1048 }
1049
1050void OpPPMT::BinInlineFun(std::set<std::string>& decls,
1051 std::set<std::string>& funs)
1052{
1053 decls.insert(GetFVDecl);
1054 funs.insert(GetFV);
1055 decls.insert(GetPMTDecl);
1056 funs.insert(GetPMT);
1057 decls.insert(GetIpmtDecl);
1058 funs.insert(GetIpmt);
1059}
1060
1062 const std::string &sSymName, SubArguments &vSubArguments)
1063{
1064 CHECK_PARAMETER_COUNT( 4, 6 );
1065 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1066 ss << "{\n";
1067 ss << " double tmp = 0;\n";
1068 ss << " int gid0 = get_global_id(0);\n";
1069 ss << " double arg=0;\n";
1070 GenerateArg( "fRate", 0, vSubArguments, ss );
1071 GenerateArg( "fPer", 1, vSubArguments, ss );
1072 GenerateArg( "fNper", 2, vSubArguments, ss );
1073 GenerateArg( "fPv", 3, vSubArguments, ss );
1074 GenerateArgWithDefault( "fFv", 4, 0, vSubArguments, ss );
1075 GenerateArgWithDefault( "fPayInAdvance", 5, 0, vSubArguments, ss );
1076 ss << " if (fPer < 1.0 || fPer > fNper)\n";
1077 ss << " return CreateDoubleError(IllegalArgument);\n";
1078 ss << " else\n";
1079 ss << " {\n";
1080 ss << " double fPmt;\n";
1081 ss << " double fInterestPer = GetIpmt(fRate, fPer, fNper, fPv, fFv, fPayInAdvance != 0, &fPmt);\n";
1082 ss << " return fPmt - fInterestPer;\n";
1083 ss << " }\n";
1084 ss << "}\n";
1085}
1086
1087void OpCoupdaybs::BinInlineFun(std::set<std::string>& decls,
1088 std::set<std::string>& funs)
1089{
1090 decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl);
1091 decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
1092 decls.insert(GetNullDateDecl); decls.insert(ScaDateDecl);
1093 decls.insert(addMonthsDecl); decls.insert(getDaysInMonthRangeDecl);
1094 decls.insert(GetDaysInYearsDecl);
1095 decls.insert(getDaysInYearRangeDecl); decls.insert(getDiffDecl);
1096 decls.insert(setDayDecl);decls.insert(checklessthanDecl);
1097 decls.insert(lcl_GetcoupdaybsDecl);
1098 decls.insert(coupdaybsDecl);
1099 funs.insert(IsLeapYear);funs.insert(DaysInMonth);
1100 funs.insert(DaysToDate);funs.insert(DateToDays);
1101 funs.insert(GetNullDate);funs.insert(ScaDate);
1102 funs.insert(addMonths);funs.insert(getDaysInMonthRange);
1103 funs.insert(GetDaysInYears);
1104 funs.insert(getDaysInYearRange);funs.insert(getDiff);
1105 funs.insert(setDay);funs.insert(checklessthan);
1106 funs.insert(lcl_Getcoupdaybs);
1107 funs.insert(coupdaybs);
1108}
1110 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
1111{
1112 CHECK_PARAMETER_COUNT( 3, 4 );
1113 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1114 ss << "{\n";
1115 ss << " double tmp = 0;\n";
1116 ss << " int gid0 = get_global_id(0);\n";
1117 GenerateArg( "fSettle", 0, vSubArguments, ss );
1118 GenerateArg( "fMat", 1, vSubArguments, ss );
1119 GenerateArg( "fFreq", 2, vSubArguments, ss );
1120 GenerateArgWithDefault( "fBase", 3, 0, vSubArguments, ss );
1121 ss << " int nSettle = fSettle;\n";
1122 ss << " int nMat = fMat;\n";
1123 ss << " int nFreq = fFreq;\n";
1124 ss << " int nBase = fBase;\n";
1125 ss <<" tmp = coupdaybs(nSettle,nMat,nFreq,nBase);\n";
1126 ss <<" return tmp;\n";
1127 ss <<"}";
1128}
1129
1130void OpCoupdays::BinInlineFun(std::set<std::string>& decls,
1131 std::set<std::string>& funs)
1132{
1133 decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl);
1134 decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
1135 decls.insert(GetNullDateDecl); decls.insert(ScaDateDecl);
1136 decls.insert(addMonthsDecl); decls.insert(getDaysInMonthRangeDecl);
1137 decls.insert(GetDaysInYearsDecl); decls.insert(GetDaysInYearDecl);
1138 decls.insert(getDaysInYearRangeDecl); decls.insert(getDiffDecl);
1139 decls.insert(setDayDecl);decls.insert(checklessthanDecl);
1140 decls.insert(lcl_GetcoupdaysDecl);
1141 decls.insert(coupdaysDecl);
1142 funs.insert(IsLeapYear);funs.insert(DaysInMonth);
1143 funs.insert(DaysToDate);funs.insert(DateToDays);
1144 funs.insert(GetNullDate);funs.insert(ScaDate);
1145 funs.insert(addMonths);funs.insert(getDaysInMonthRange);
1146 funs.insert(GetDaysInYears);funs.insert(GetDaysInYear);
1147 funs.insert(getDaysInYearRange);funs.insert(getDiff);
1148 funs.insert(lcl_Getcoupdays);
1149 funs.insert(setDay);funs.insert(checklessthan);
1150 funs.insert(coupdays);
1151}
1153 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
1154{
1155 CHECK_PARAMETER_COUNT( 3, 4 );
1156 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1157 ss << "{\n";
1158 ss << " double tmp = 0;\n";
1159 ss << " int gid0 = get_global_id(0);\n";
1160 GenerateArg( "fSettle", 0, vSubArguments, ss );
1161 GenerateArg( "fMat", 1, vSubArguments, ss );
1162 GenerateArg( "fFreq", 2, vSubArguments, ss );
1163 GenerateArgWithDefault( "fBase", 3, 0, vSubArguments, ss );
1164 ss << " int nSettle = fSettle;\n";
1165 ss << " int nMat = fMat;\n";
1166 ss << " int nFreq = fFreq;\n";
1167 ss << " int nBase = fBase;\n";
1168 ss <<" tmp = coupdays(nSettle,nMat,nFreq,nBase);\n";
1169 ss <<" return tmp;\n";
1170 ss << "}";
1171}
1172void OpCouppcd::BinInlineFun(std::set<std::string>& decls,
1173 std::set<std::string>& funs)
1174{
1175 decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl);
1176 decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
1177 decls.insert(GetNullDateDecl);
1178 decls.insert(ScaDateDecl);
1179 decls.insert(addMonthsDecl);
1180 decls.insert(setDayDecl);decls.insert(checklessthanDecl);
1181 decls.insert(lcl_GetCouppcdDecl);
1182 funs.insert(IsLeapYear);funs.insert(DaysInMonth);
1183 funs.insert(DaysToDate);funs.insert(DateToDays);
1184 funs.insert(GetNullDate);
1185 funs.insert(ScaDate);
1186 funs.insert(addMonths);
1187 funs.insert(setDay);funs.insert(checklessthan);
1188 funs.insert(lcl_GetCouppcd);
1189}
1191 outputstream &ss, const std::string &sSymName,
1192 SubArguments &vSubArguments)
1193{
1194 CHECK_PARAMETER_COUNT( 3, 4 );
1195 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1196 ss << "{\n";
1197 ss << " double tmp = 0;\n";
1198 ss << " int gid0 = get_global_id(0);\n";
1199 GenerateArg( "fSettle", 0, vSubArguments, ss );
1200 GenerateArg( "fMat", 1, vSubArguments, ss );
1201 GenerateArg( "fFreq", 2, vSubArguments, ss );
1202 GenerateArgWithDefault( "fBase", 3, 0, vSubArguments, ss );
1203 ss << " int nSettle = fSettle;\n";
1204 ss << " int nMat = fMat;\n";
1205 ss << " int nFreq = fFreq;\n";
1206 ss << " int nBase = fBase;\n";
1207 ss <<" int nNullDate=693594;\n";
1208 ss <<" tmp = lcl_GetCouppcd(nNullDate,nSettle,nMat,nFreq,nBase);\n";
1209 ss <<" return tmp;\n";
1210 ss <<"}";
1211}
1212void OpCoupncd::BinInlineFun(std::set<std::string>& decls,
1213 std::set<std::string>& funs)
1214{
1215 decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl);
1216 decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
1217 decls.insert(GetNullDateDecl);
1218 decls.insert(ScaDateDecl);
1219 decls.insert(addMonthsDecl);
1220 decls.insert(setDayDecl);decls.insert(checklessthanDecl);
1221 decls.insert(lcl_GetCoupncdDecl);
1222 funs.insert(IsLeapYear);funs.insert(DaysInMonth);
1223 funs.insert(DaysToDate);funs.insert(DateToDays);
1224 funs.insert(GetNullDate);
1225 funs.insert(ScaDate);
1226 funs.insert(addMonths);
1227 funs.insert(setDay);funs.insert(checklessthan);
1228 funs.insert(lcl_GetCoupncd);
1229}
1231 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
1232{
1233 CHECK_PARAMETER_COUNT( 3, 4 );
1234 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1235 ss << "{\n";
1236 ss << " double tmp = 0;\n";
1237 ss << " int gid0 = get_global_id(0);\n";
1238 GenerateArg( "fSettle", 0, vSubArguments, ss );
1239 GenerateArg( "fMat", 1, vSubArguments, ss );
1240 GenerateArg( "fFreq", 2, vSubArguments, ss );
1241 GenerateArgWithDefault( "fBase", 3, 0, vSubArguments, ss );
1242 ss << " int nSettle = fSettle;\n";
1243 ss << " int nMat = fMat;\n";
1244 ss << " int nFreq = fFreq;\n";
1245 ss << " int nBase = fBase;\n";
1246 ss <<" int nNullDate=693594;\n";
1247 ss <<" tmp = lcl_GetCoupncd(nNullDate,nSettle,nMat,nFreq,nBase);\n";
1248 ss <<" return tmp;\n";
1249 ss <<"}";
1250}
1251
1252void OpCoupdaysnc::BinInlineFun(std::set<std::string>& decls,
1253 std::set<std::string>& funs)
1254{
1255 decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl);
1256 decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
1257 decls.insert(DateToDaysDecl);
1258 decls.insert(ScaDateDecl);
1259 decls.insert(addMonthsDecl); decls.insert(getDaysInMonthRangeDecl);
1260 decls.insert(GetDaysInYearsDecl); decls.insert(GetDaysInYearDecl);
1261 decls.insert(getDaysInYearRangeDecl); decls.insert(getDiffDecl);
1262 decls.insert(setDayDecl);decls.insert(checklessthanDecl);
1263 decls.insert(coupdaybsDecl);
1264 decls.insert(lcl_GetcoupdaysDecl);
1265 decls.insert(lcl_GetcoupdaybsDecl);
1266 decls.insert(coupdaysDecl);
1267 decls.insert(coupdaysncDecl);
1268 funs.insert(IsLeapYear);funs.insert(DaysInMonth);
1269 funs.insert(DaysToDate);funs.insert(DateToDays);
1270 funs.insert(DateToDays);
1271 funs.insert(ScaDate);
1272 funs.insert(addMonths);funs.insert(getDaysInMonthRange);
1273 funs.insert(GetDaysInYears);funs.insert(GetDaysInYear);
1274 funs.insert(getDaysInYearRange);funs.insert(getDiff);
1275 funs.insert(setDay);funs.insert(checklessthan);
1276 funs.insert(lcl_Getcoupdaybs);
1277 funs.insert(coupdaybs);
1278 funs.insert(lcl_Getcoupdays);
1279 funs.insert(coupdaysnc);
1280 funs.insert(coupdays);
1281}
1283 outputstream &ss, const std::string &sSymName,
1284 SubArguments &vSubArguments)
1285{
1286 CHECK_PARAMETER_COUNT( 3, 4 );
1287 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1288 ss << "{\n";
1289 ss << " double tmp = 0;\n";
1290 ss << " int gid0 = get_global_id(0);\n";
1291 GenerateArg( "fSettle", 0, vSubArguments, ss );
1292 GenerateArg( "fMat", 1, vSubArguments, ss );
1293 GenerateArg( "fFreq", 2, vSubArguments, ss );
1294 GenerateArgWithDefault( "fBase", 3, 0, vSubArguments, ss );
1295 ss << " int nSettle = fSettle;\n";
1296 ss << " int nMat = fMat;\n";
1297 ss << " int nFreq = fFreq;\n";
1298 ss << " int nBase = fBase;\n";
1299 ss <<" tmp = coupdaysnc(nSettle,nMat,nFreq,nBase);\n";
1300 ss <<" return tmp;\n";
1301 ss << "}";
1302}
1303
1304void OpCoupnum::BinInlineFun(std::set<std::string>& decls,
1305 std::set<std::string>& funs)
1306{
1307 decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
1308 decls.insert(DaysToDateDecl);
1309 decls.insert(DateToDaysDecl);
1310 decls.insert(ScaDateDecl);
1311 decls.insert(setDayDecl);decls.insert(checklessthanDecl);
1312 decls.insert(addMonthsDecl);decls.insert(lcl_GetcoupnumDecl);
1313 decls.insert(coupnumDecl);
1314 funs.insert(IsLeapYear);funs.insert(DaysInMonth);
1315 funs.insert(DaysToDate);
1316 funs.insert(DateToDays);
1317 funs.insert(ScaDate);
1318 funs.insert(setDay);funs.insert(checklessthan);
1319 funs.insert(addMonths);funs.insert(lcl_Getcoupnum);
1320 funs.insert(coupnum);
1321}
1323 const std::string &sSymName, SubArguments &vSubArguments)
1324{
1325 CHECK_PARAMETER_COUNT( 3, 4 );
1326 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1327 ss << "{\n";
1328 ss << " double tmp = 0;\n";
1329 ss << " int gid0 = get_global_id(0);\n";
1330 GenerateArg( "fSettle", 0, vSubArguments, ss );
1331 GenerateArg( "fMat", 1, vSubArguments, ss );
1332 GenerateArg( "fFreq", 2, vSubArguments, ss );
1333 GenerateArgWithDefault( "fBase", 3, 0, vSubArguments, ss );
1334 ss << " int nSettle = fSettle;\n";
1335 ss << " int nMat = fMat;\n";
1336 ss << " int nFreq = fFreq;\n";
1337 ss << " int nBase = fBase;\n";
1338 ss <<" tmp = coupnum(nSettle,nMat,nFreq,nBase);\n";
1339 ss <<" return tmp;\n";
1340 ss << "}";
1341}
1342void OpAmordegrc::BinInlineFun(std::set<std::string>& decls,
1343 std::set<std::string>& funs)
1344{
1345 decls.insert(nCorrValDecl); decls.insert(RoundDecl);
1346 decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
1347 decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
1348 decls.insert(GetNullDateDecl); decls.insert(GetYearFracDecl);
1349 funs.insert(Round);
1350 funs.insert(IsLeapYear);funs.insert(DaysInMonth);
1351 funs.insert(DaysToDate);funs.insert(DateToDays);
1352 funs.insert(GetNullDate);funs.insert(GetYearFrac);
1353}
1355 const std::string &sSymName, SubArguments &vSubArguments)
1356{
1357 CHECK_PARAMETER_COUNT( 6, 7 );
1358 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1359 ss << "{\n";
1360 ss << " int gid0 = get_global_id(0);\n";
1361 ss << " double tmp = " << GetBottom() <<";\n";
1362 GenerateArg( "fCost", 0, vSubArguments, ss );
1363 GenerateArg( "fDate", 1, vSubArguments, ss );
1364 GenerateArg( "fFirstPer", 2, vSubArguments, ss );
1365 GenerateArg( "fRestVal", 3, vSubArguments, ss );
1366 GenerateArg( "fPer", 4, vSubArguments, ss );
1367 GenerateArg( "fRate", 5, vSubArguments, ss );
1368 GenerateArgWithDefault( "fBase", 6, 0, vSubArguments, ss );
1369 ss << " int nDate = fDate;\n";
1370 ss << " int nFirstPer = fFirstPer;\n";
1371 ss << " int nBase = fBase;\n";
1372 ss <<" uint nPer = convert_int( fPer );\n";
1373 ss <<" double fUsePer = 1.0 / fRate;\n";
1374 ss <<" double fAmorCoeff;\n";
1375 ss <<" if( fUsePer < 3.0 )\n";
1376 ss <<" fAmorCoeff = 1.0;\n";
1377 ss <<" else if( fUsePer < 5.0 )\n";
1378 ss <<" fAmorCoeff = 1.5;\n";
1379 ss <<" else if( fUsePer <= 6.0 )\n";
1380 ss <<" fAmorCoeff = 2.0;\n";
1381 ss <<" else\n";
1382 ss <<" fAmorCoeff = 2.5;\n";
1383 ss <<" fRate *= fAmorCoeff;\n";
1384 ss <<" tmp = Round( GetYearFrac( 693594,";
1385 ss <<"nDate, nFirstPer, nBase ) * fRate * fCost);\n";
1386 ss <<" fCost = fCost-tmp;\n";
1387 ss <<" double fRest = fCost - fRestVal;\n";
1388 ss <<" for( uint n = 0 ; n < nPer ; n++ )\n";
1389 ss <<" {\n";
1390 ss <<" tmp = Round( fRate * fCost);\n";
1391 ss <<" fRest -= tmp;\n";
1392 ss <<" if( fRest < 0.0 )\n";
1393 ss <<" {\n";
1394 ss <<" switch( nPer - n )\n";
1395 ss <<" {\n";
1396 ss <<" case 0:\n";
1397 ss <<" case 1:\n";
1398 ss <<" tmp = Round( fCost * 0.5);\n";
1399 ss <<" default:\n";
1400 ss <<" tmp = 0.0;\n";
1401 ss <<" }\n";
1402 ss <<" }\n";
1403 ss <<" fCost -= tmp;\n";
1404 ss <<" }\n";
1405 ss <<" return tmp;\n";
1406 ss <<"}";
1407}
1408void OpAmorlinc::BinInlineFun(std::set<std::string>& decls,
1409 std::set<std::string>& funs)
1410{
1411 decls.insert(nCorrValDecl); decls.insert(RoundDecl);
1412 decls.insert(IsLeapYearDecl);decls.insert(DaysInMonthDecl);
1413 decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl);
1414 decls.insert(GetYearFracDecl);
1415 funs.insert(Round);
1416 funs.insert(IsLeapYear);funs.insert(DaysInMonth);
1417 funs.insert(DaysToDate);funs.insert(DateToDays);
1418 funs.insert(GetYearFrac);
1419}
1421 const std::string &sSymName, SubArguments &vSubArguments)
1422{
1423 CHECK_PARAMETER_COUNT( 6, 7 );
1424 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1425 ss << "{\n";
1426 ss << " int gid0 = get_global_id(0);\n";
1427 ss << " double tmp = 0;\n";
1428 GenerateArg( "fCost", 0, vSubArguments, ss );
1429 GenerateArg( "fDate", 1, vSubArguments, ss );
1430 GenerateArg( "fFirstPer", 2, vSubArguments, ss );
1431 GenerateArg( "fRestVal", 3, vSubArguments, ss );
1432 GenerateArg( "fPer", 4, vSubArguments, ss );
1433 GenerateArg( "fRate", 5, vSubArguments, ss );
1434 GenerateArgWithDefault( "fBase", 6, 0, vSubArguments, ss );
1435 ss << " int nDate = fDate;\n";
1436 ss << " int nFirstPer = fFirstPer;\n";
1437 ss << " int nBase = fBase;\n";
1438 ss <<" int nPer = convert_int( fPer );\n";
1439 ss <<" double fOneRate = fCost * fRate;\n";
1440 ss <<" double fCostDelta = fCost - fRestVal;\n";
1441 ss <<" double f0Rate = GetYearFrac( 693594,";
1442 ss <<"nDate, nFirstPer, nBase )* fRate * fCost;\n";
1443 ss <<" int nNumOfFullPeriods = (int)";
1444 ss <<"( ( fCost - fRestVal - f0Rate) / fOneRate );\n";
1445 ss <<" if( nPer == 0 )\n";
1446 ss <<" tmp = f0Rate;\n";
1447 ss <<" else if( nPer <= nNumOfFullPeriods )\n";
1448 ss <<" tmp = fOneRate;\n";
1449 ss <<" else if( nPer == nNumOfFullPeriods + 1 )\n";
1450 ss <<" tmp = fCostDelta - fOneRate * nNumOfFullPeriods - f0Rate;\n";
1451 ss <<" else\n";
1452 ss <<" tmp = 0.0;\n";
1453 ss <<" return tmp;\n";
1454 ss <<"}";
1455}
1456void OpReceived::BinInlineFun(std::set<std::string>& decls,
1457 std::set<std::string>& funs)
1458{
1459 decls.insert(GetYearDiffDecl);decls.insert(GetDiffDateDecl);
1460 decls.insert(DaysToDateDecl);decls.insert(DaysInMonthDecl);
1461 decls.insert(GetNullDateDecl);decls.insert(IsLeapYearDecl);
1462 decls.insert(DateToDaysDecl);
1463 funs.insert(GetDiffDate);funs.insert(DaysToDate);
1464 funs.insert(DaysInMonth);funs.insert(GetNullDate);
1465 funs.insert(DateToDays);funs.insert(IsLeapYear);
1466 funs.insert(GetYearDiff);
1467}
1468
1470 const std::string &sSymName, SubArguments &vSubArguments)
1471{
1472 CHECK_PARAMETER_COUNT( 4, 5 );
1473 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1474 ss << "{\n";
1475 ss << " double tmp = " << GetBottom() <<";\n";
1476 ss << " int gid0 = get_global_id(0);\n";
1477 GenerateArg( "fSettle", 0, vSubArguments, ss );
1478 GenerateArg( "fMat", 1, vSubArguments, ss );
1479 GenerateArg( "fInvest", 2, vSubArguments, ss );
1480 GenerateArg( "fDisc", 3, vSubArguments, ss );
1481 GenerateArgWithDefault( "fOB", 4, 0, vSubArguments, ss );
1482 ss << " int nSettle = fSettle;\n";
1483 ss << " int nMat = fMat;\n";
1484 ss << " int rOB = fOB;\n";
1485 ss << " double tmpvalue = (1.0-(fDisc";
1486 ss <<" * GetYearDiff( GetNullDate()";
1487 ss <<",nSettle,nMat,rOB)));\n";
1488 ss << " tmp = fInvest/tmpvalue;\n";
1489 ss << " return tmp;\n";
1490 ss << "}";
1491}
1492
1493void OpYielddisc::BinInlineFun(std::set<std::string>& decls,
1494 std::set<std::string>& funs)
1495{
1496 decls.insert(GetYearFracDecl);decls.insert(GetNullDateDecl);
1497 decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl);
1498 decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl);
1499
1500 funs.insert(GetYearFrac);funs.insert(GetNullDate);
1501 funs.insert(DateToDays);funs.insert(DaysToDate);
1502 funs.insert(DaysInMonth);funs.insert(IsLeapYear);
1503}
1505 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
1506{
1508 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1509 ss << "{\n\t";
1510 ss << "double tmp = 0;\n\t";
1511 ss << "int gid0 = get_global_id(0);\n";
1512 GenerateArg( "tmp000", 0, vSubArguments, ss );
1513 GenerateArg( "tmp001", 1, vSubArguments, ss );
1514 GenerateArg( "tmp002", 2, vSubArguments, ss );
1515 GenerateArg( "tmp003", 3, vSubArguments, ss );
1516 GenerateArg( "tmp004", 4, vSubArguments, ss );
1517 ss<< "\t";
1518 ss<< "if(tmp002 <= 0 || tmp003 <= 0 || tmp000 >= tmp001 )\n\t";
1519 ss<< " return CreateDoubleError(IllegalArgument);\n\t";
1520 ss<< "tmp = (tmp003/tmp002)-1;\n\t";
1521 ss << "tmp /= GetYearFrac( GetNullDate(),tmp000,tmp001,tmp004);\n\t";
1522 ss << "return tmp;\n";
1523 ss << "}";
1524}
1525
1526void OpTbillprice::BinInlineFun(std::set<std::string>& decls,
1527 std::set<std::string>& funs)
1528{
1529 decls.insert(GetYearFracDecl);
1530 decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl);
1531 decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl);
1532
1533 funs.insert(GetYearFrac);
1534 funs.insert(DateToDays);funs.insert(DaysToDate);
1535 funs.insert(DaysInMonth);funs.insert(IsLeapYear);
1536}
1537
1539 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
1540{
1541 CHECK_PARAMETER_COUNT( 3, 3 );
1542 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1543 ss << "{\n";
1544 ss << " int gid0 = get_global_id(0);\n";
1545 ss << " double tmp = 0;\n";
1546
1547 ss << " int singleIndex = gid0;\n";
1548 ss << " int doubleIndex = gid0;\n";
1549 ss << " int i = gid0;\n";
1550 GenTmpVariables(ss,vSubArguments);
1551 CheckAllSubArgumentIsNan(ss,vSubArguments);
1552
1553 ss << " tmp1+=1.0;\n";
1554 ss << " double fFraction =GetYearFrac(693594,tmp0,tmp1,0);\n";
1555 ss << " tmp = 100.0 * ( 1.0 - tmp2 * fFraction );\n";
1556 ss << " return tmp;\n";
1557 ss << "}\n";
1558}
1559
1560void OpRate::BinInlineFun(std::set<std::string>& decls,
1561 std::set<std::string>& funs)
1562{
1563 decls.insert(RateIterationDecl);
1564 funs.insert(RateIteration);
1565}
1566
1568 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
1569{
1570 CHECK_PARAMETER_COUNT( 3, 6 );
1571 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1572 ss << "{\n";
1573 ss << " int gid0 = get_global_id(0);\n";
1574 GenerateArg( "fNper", 0, vSubArguments, ss );
1575 GenerateArg( "fPayment", 1, vSubArguments, ss );
1576 GenerateArg( "fPv", 2, vSubArguments, ss );
1577 GenerateArgWithDefault( "fFv", 3, 0, vSubArguments, ss );
1578 GenerateArgWithDefault( "fPayType", 4, 0, vSubArguments, ss );
1579 ss << " bool bPayType = fPayType != 0;\n";
1580 if( vSubArguments.size() == 6 )
1581 {
1582 GenerateArgWithDefault( "fGuess", 5, 0.1, vSubArguments, ss );
1583 ss << " double fOrigGuess = fGuess;\n";
1584 ss << " bool bDefaultGuess = false;\n";
1585 }
1586 else
1587 {
1588 ss << " double fGuess = 0.1, fOrigGuess = 0.1;\n";
1589 ss << " bool bDefaultGuess = true;\n";
1590 }
1591 ss << " if( fNper <= 0 )\n";
1592 ss << " return CreateDoubleError(IllegalArgument);\n";
1593 ss << " bool bValid = RateIteration(fNper, fPayment, fPv, fFv, bPayType, &fGuess);\n";
1594 ss << " if (!bValid)\n";
1595 ss << " {\n";
1596 ss << " if (bDefaultGuess)\n";
1597 ss << " {\n";
1598 ss << " double fX = fOrigGuess;\n";
1599 ss << " for (int nStep = 2; nStep <= 10 && !bValid; ++nStep)\n";
1600 ss << " {\n";
1601 ss << " fGuess = fX * nStep;\n";
1602 ss << " bValid = RateIteration( fNper, fPayment, fPv, fFv, bPayType, &fGuess);\n";
1603 ss << " if (!bValid)\n";
1604 ss << " {\n";
1605 ss << " fGuess = fX / nStep;\n";
1606 ss << " bValid = RateIteration( fNper, fPayment, fPv, fFv, bPayType, &fGuess);\n";
1607 ss << " }\n";
1608 ss << " }\n";
1609 ss << " }\n";
1610 ss << " if (!bValid)\n";
1611 ss << " return CreateDoubleError(NoConvergence);\n";
1612 ss << " }\n";
1613 ss << " return fGuess;\n";
1614 ss << "}\n";
1615}
1616
1617void OpTbillyield::BinInlineFun(std::set<std::string>& decls,
1618 std::set<std::string>& funs)
1619{
1620 decls.insert(GetDiffDate360Decl);decls.insert(IsLeapYearDecl);
1621 decls.insert(DateToDaysDecl);decls.insert(DaysToDate_LocalBarrierDecl);
1622 decls.insert(DaysInMonthDecl);decls.insert(GetNullDateDecl);
1623 decls.insert(GetDiffDate360_Decl);
1624 funs.insert(GetDiffDate360);funs.insert(DateToDays);
1625 funs.insert(DaysToDate_LocalBarrier);funs.insert(IsLeapYear);
1626 funs.insert(DaysInMonth);funs.insert(GetNullDate);
1627 funs.insert(GetDiffDate360_);
1628
1629}
1630
1632 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
1633{
1634 CHECK_PARAMETER_COUNT( 3, 3 );
1635 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1636 ss << "{\n";
1637 ss << " int gid0 = get_global_id(0);\n";
1638 ss << " double tmp = 0;\n";
1639 GenerateArg( "tmp000", 0, vSubArguments, ss );
1640 GenerateArg( "tmp001", 1, vSubArguments, ss );
1641 GenerateArg( "tmp002", 2, vSubArguments, ss );
1642 ss <<" int nDiff=GetDiffDate360(GetNullDate(),tmp000,tmp001,true);\n";
1643 ss <<" nDiff++;\n";
1644 ss <<" tmp=100.0;\n";
1645 ss <<" tmp = tmp / tmp002;\n";
1646 ss <<" tmp = tmp - 1.0;\n";
1647 ss <<" tmp = tmp / nDiff;\n";
1648 ss <<" tmp = tmp * 360.0;\n";
1649 ss <<" return tmp;\n";
1650 ss << "}\n";
1651}
1652
1653void OpDDB::BinInlineFun(std::set<std::string>& decls,
1654 std::set<std::string>& funs)
1655{
1656 decls.insert(ScGetDDBDecl);
1657 funs.insert(ScGetDDB);
1658}
1659
1661 const std::string &sSymName, SubArguments& vSubArguments)
1662{
1663 CHECK_PARAMETER_COUNT( 4, 5 );
1664 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1665 ss << "{\n";
1666 ss << " int gid0 = get_global_id(0);\n";
1667 ss << " double tmp = 0;\n";
1668 GenerateArg( "fCost", 0, vSubArguments, ss );
1669 GenerateArg( "fSalvage", 1, vSubArguments, ss );
1670 GenerateArg( "fLife", 2, vSubArguments, ss );
1671 GenerateArg( "fPeriod", 3, vSubArguments, ss );
1672 GenerateArgWithDefault( "fFactor", 4, 2, vSubArguments, ss );
1673 ss << " if (fCost < 0.0 || fSalvage < 0.0 || fFactor <= 0.0 || fSalvage > fCost\n";
1674 ss << " || fPeriod < 1.0 || fPeriod > fLife)\n";
1675 ss << " return CreateDoubleError(IllegalArgument);\n";
1676 ss << " return ScGetDDB( fCost, fSalvage, fLife, fPeriod, fFactor );\n";
1677 ss << "}\n";
1678}
1679
1681 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
1682{
1683 CHECK_PARAMETER_COUNT( 3, 5 );
1684 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1685 ss << "{\n";
1686 ss << " double result = 0;\n";
1687 ss << " int gid0 = get_global_id(0);\n";
1688 GenerateArg( "fRate", 0, vSubArguments, ss );
1689 GenerateArg( "fNper", 1, vSubArguments, ss );
1690 GenerateArg( "fPmt", 2, vSubArguments, ss );
1691 GenerateArgWithDefault( "fFv", 3, 0, vSubArguments, ss );
1692 GenerateArgWithDefault( "fPayInAdvance", 4, 0, vSubArguments, ss );
1693 ss << " double fPv;\n";
1694 ss << " if (fRate == 0.0)\n";
1695 ss << " fPv = fFv + fPmt * fNper;\n";
1696 ss << " else\n";
1697 ss << " {\n";
1698 ss << " if (fPayInAdvance != 0)\n";
1699 ss << " fPv = (fFv * pow(1.0 + fRate, -fNper))\n";
1700 ss << " + (fPmt * (1.0 - pow(1.0 + fRate, -fNper + 1.0)) / fRate)\n";
1701 ss << " + fPmt;\n";
1702 ss << " else\n";
1703 ss << " fPv = (fFv * pow(1.0 + fRate, -fNper))\n";
1704 ss << " + (fPmt * (1.0 - pow(1.0 + fRate, -fNper)) / fRate);\n";
1705 ss << " }\n";
1706 ss << " return -fPv;\n";
1707 ss << "}\n";
1708}
1709
1710void OpVDB::BinInlineFun(std::set<std::string>& decls,
1711 std::set<std::string>& funs)
1712{
1713 decls.insert(is_representable_integerDecl);
1714 decls.insert(ScGetDDBDecl);decls.insert(approx_equalDecl);
1715 decls.insert(ScInterVDBDecl);decls.insert(VDBImplementDecl);
1716 funs.insert(is_representable_integer);
1717 funs.insert(ScGetDDB);funs.insert(approx_equal);
1718 funs.insert(ScInterVDB);funs.insert(VDBImplement);
1719}
1720
1722 outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
1723{
1724 CHECK_PARAMETER_COUNT( 5, 7 );
1725 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1726 ss << "{\n";
1727 ss << " int gid0 = get_global_id(0);\n";
1728 ss << " int singleIndex = gid0;\n";
1729 ss << " double result = 0;\n";
1730 GenerateArg( "fCost", 0, vSubArguments, ss );
1731 GenerateArg( "fSalvage", 1, vSubArguments, ss );
1732 GenerateArg( "fLife", 2, vSubArguments, ss );
1733 GenerateArg( "fStart", 3, vSubArguments, ss );
1734 GenerateArg( "fEnd", 4, vSubArguments, ss );
1735 GenerateArgWithDefault( "fFactor", 5, 2, vSubArguments, ss );
1736 GenerateArgWithDefault( "fNoSwitch", 6, 0, vSubArguments, ss );
1737 ss << " if (fStart < 0.0 || fEnd < fStart || fEnd > fLife || fCost < 0.0\n";
1738 ss << " || fSalvage > fCost || fFactor <= 0.0)\n";
1739 ss << " return CreateDoubleError(IllegalArgument);\n";
1740 ss << " return VDBImplement(fCost, fSalvage, fLife, fStart, fEnd, fFactor, fNoSwitch != 0);\n";
1741 ss << "}";
1742}
1743
1745 const std::string &sSymName, SubArguments &vSubArguments)
1746{
1747 CHECK_PARAMETER_COUNT( 2, 3 );
1748 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1749 ss << "{\n";
1750 ss << " int gid0 = get_global_id(0);\n";
1751 GenerateArgWithDefault( "fResultRate", 2, 0.1, vSubArguments, ss );
1752 ss << " if(fResultRate<=-1)\n";
1753 ss << " return CreateDoubleError(IllegalArgument);\n";
1754 ss << " double fMaxEps = 1e-10;\n";
1755 ss << " int nMaxIter = 50;\n";
1756 ss << " int nIter = 0;\n";
1757 ss << " double fResultValue;\n";
1758 ss << " int nIterScan = 0;\n";
1759 ss << " bool bContLoop = false;\n";
1760 ss << " bool bResultRateScanEnd = false;\n";
1761 // Make 'V_0' and 'D_0' be the first elements of arguments 0 and 1.
1762 GenerateRangeArgElement( "V_0", 0, "0", vSubArguments, ss, EmptyIsZero );
1763 GenerateRangeArgElement( "D_0", 1, "0", vSubArguments, ss, EmptyIsZero );
1764 ss << " do\n";
1765 ss << " {\n";
1766 ss << " if (nIterScan >=1)\n";
1767 ss << " fResultRate = -0.99 + (nIterScan -1)* 0.01;\n";
1768 ss << " do\n";
1769 ss << " {\n";
1770 ss << " double r = fResultRate + 1;\n";
1771 ss << " fResultValue = V_0;\n";
1772 GenerateRangeArgPair( 0, 1, vSubArguments, ss, SkipEmpty,
1773 " fResultValue += arg1/pow(r,(arg2 - D_0)/365.0);\n"
1774 , "1" // start from 2nd element
1775 );
1776 ss << " double fResultValue2 = 0;\n";
1777 GenerateRangeArgPair( 0, 1, vSubArguments, ss, SkipEmpty,
1778 " double E_i = (arg2 - D_0)/365.0;\n"
1779 " fResultValue2 -= E_i * arg1 / pow(r,E_i + 1.0);\n"
1780 , "1" // start from 2nd element
1781 );
1782 ss << " double fNewRate = fResultRate - fResultValue / fResultValue2;\n";
1783 ss << " double fRateEps = fabs( fNewRate - fResultRate );\n";
1784 ss << " fResultRate = fNewRate;\n";
1785 ss << " bContLoop = (fRateEps > fMaxEps) && (fabs( fResultValue ) > fMaxEps);\n";
1786 ss << " } while( bContLoop && (++nIter < nMaxIter) );\n";
1787 ss << " nIter = 0;\n";
1788 ss << " if( isnan(fResultRate) || isinf(fResultRate) || isnan(fResultValue) || isinf(fResultValue))\n";
1789 ss << " bContLoop = true;\n";
1790 ss << " ++nIterScan;\n";
1791 ss << " bResultRateScanEnd = (nIterScan >= 200);\n";
1792 ss << " } while(bContLoop && !bResultRateScanEnd);\n";
1793 ss << " if( bContLoop )\n";
1794 ss << " return CreateDoubleError(IllegalArgument);\n";
1795 ss << " return fResultRate;\n";
1796 ss << "}";
1797}
1798
1800 const std::string &sSymName, SubArguments& vSubArguments)
1801{
1802 CHECK_PARAMETER_COUNT( 4, 5 );
1803 GenerateFunctionDeclaration( sSymName, vSubArguments, ss );
1804 ss << "{\n";
1805 ss << " int gid0 = get_global_id(0);\n";
1806 GenerateArg( "fCost", 0, vSubArguments, ss );
1807 GenerateArg( "fSalvage", 1, vSubArguments, ss );
1808 GenerateArg( "fLife", 2, vSubArguments, ss );
1809 GenerateArg( "fPeriod", 3, vSubArguments, ss );
1810 GenerateArgWithDefault( "fMonths", 4, 12, vSubArguments, ss );
1811 ss << " int nMonths = (int)fMonths;\n";
1812 ss << " if (fMonths < 1.0 || fMonths > 12.0 || fLife > 1200.0 || fSalvage < 0.0 ||\n";
1813 ss << " fPeriod > (fLife + 1.0) || fSalvage > fCost || fCost <= 0.0 ||\n";
1814 ss << " fLife <= 0 || fPeriod <= 0 )\n";
1815 ss << " return CreateDoubleError(IllegalArgument);\n";
1816 ss << " double tmp = 0;\n";
1817 ss <<" double fDeprRate = 1.0 - pow(fSalvage / fCost, 1.0 / fLife);\n";
1818 ss <<" fDeprRate = ((int)(fDeprRate * 1000.0 + 0.5)) / 1000.0;\n";
1819 ss <<" double fFirstDeprRate = fCost * fDeprRate * nMonths / 12.0;\n";
1820 ss <<" double fDb = 0.0;\n";
1821 ss <<" if ((int)(fPeriod) == 1)\n";
1822 ss <<" fDb = fFirstDeprRate;\n";
1823 ss <<" else\n";
1824 ss <<" {\n";
1825 ss <<" double fSumDeprRate = fFirstDeprRate;\n";
1826 ss <<" double fMin = fLife;\n";
1827 ss <<" if (fMin > fPeriod) fMin = fPeriod;\n";
1828 ss <<" int nMax = (int)fMin;\n";
1829 ss <<" for (int i = 2; i <= nMax; i++)\n";
1830 ss <<" {\n";
1831 ss <<" fDb = (fCost - fSumDeprRate) * fDeprRate;\n";
1832 ss <<" fSumDeprRate += fDb;\n";
1833 ss <<" }\n";
1834 ss <<" if (fPeriod > fLife)\n";
1835 ss <<" fDb = ((fCost - fSumDeprRate)";
1836 ss <<"* fDeprRate * (12.0 - nMonths)) / 12.0;\n";
1837 ss <<" }\n";
1838 ss <<" tmp = fDb;\n";
1839 ss <<" return tmp;\n";
1840 ss <<"}";
1841}
1842
1843}
1844
1845/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void GenTmpVariables(outputstream &ss, const SubArguments &vSubArguments)
Definition: opbase.cxx:597
static void CheckAllSubArgumentIsNan(outputstream &ss, SubArguments &vSubArguments)
Definition: opbase.cxx:699
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual std::string GetBottom() override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual std::string GetBottom() override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual std::string GetBottom() override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual std::string GetBottom() override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual std::string GetBottom() override
virtual std::string GetBottom() override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual std::string GetBottom() override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual std::string GetBottom() override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual std::string GetBottom() override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual std::string GetBottom() override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual std::string GetBottom() override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual std::string GetBottom() override
virtual std::string GetBottom() override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual std::string GetBottom() override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual std::string GetBottom() override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
virtual void BinInlineFun(std::set< std::string > &, std::set< std::string > &) override
void GenerateArg(const char *name, int arg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty=EmptyIsZero, GenerateArgTypeType generateType=DoNotGenerateArgType)
Definition: opbase.cxx:229
static void GenerateRangeArgElement(const char *name, int arg, const char *element, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty)
Definition: opbase.cxx:498
static void GenerateRangeArg(int arg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code)
Definition: opbase.cxx:417
void GenerateArgWithDefault(const char *name, int arg, double def, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty=EmptyIsZero)
Definition: opbase.cxx:307
void GenerateFunctionDeclaration(const std::string &sSymName, SubArguments &vSubArguments, outputstream &ss)
Definition: opbase.cxx:566
static void GenerateRangeArgPair(int arg1, int arg2, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code, const char *firstElementDiff=nullptr)
Definition: opbase.cxx:423
static void GenerateRangeArgs(int firstArg, int lastArg, SubArguments &vSubArguments, outputstream &ss, EmptyArgType empty, const char *code)
Definition: opbase.cxx:316
std::vector< DynamicKernelArgumentRef > SubArguments
Definition: opbase.hxx:347
virtual void GenSlidingWindowFunction(outputstream &ss, const std::string &sSymName, SubArguments &vSubArguments) override
const char ScInterVDBDecl[]
const char IsLeapYearDecl[]
const char DaysInMonthDecl[]
const char DaysToDateDecl[]
const char coupnumDecl[]
const char GetDuration[]
const char ScaDate[]
const char DaysToDate[]
const char coupdaysncDecl[]
const char GetOddlpriceDecl[]
const char GetNullDateDecl[]
const char lcl_GetcoupdaysDecl[]
const char VDBImplementDecl[]
const char DateToDays[]
const char DaysToDate_LocalBarrierDecl[]
const char GetYearDiff[]
const char GetYearFrac[]
const char checklessthan[]
const char RateIteration[]
const char GetDiffDate360_[]
const char getYield_[]
const char coupdaysnc[]
const char getYield_Decl[]
const char GetDiffDate360Decl[]
const char getPrice[]
const char GetYieldmat[]
const char checklessthanDecl[]
const char GetDiffDate360_Decl[]
const char GetOddlyieldDecl[]
const char addMonths[]
const char GetDurationDecl[]
const char GetDiffDateDecl[]
const char GetPMT[]
const char GetIpmtDecl[]
const char lcl_Getcoupdaybs[]
const char getDaysInMonthRange[]
const char getDiff[]
const char GetPMTDecl[]
const char IsLeapYear[]
const char GetDiffDate360[]
const char RateIterationDecl[]
const char DateToDaysDecl[]
const char lcl_Getcoupdays[]
const char ScaDateDecl[]
const char lcl_GetCoupncdDecl[]
const char getDaysInYearRange[]
const char addMonthsDecl[]
const char VDBImplement[]
const char lcl_GetCoupncd[]
const char GetDiffDate[]
const char GetDaysInYears[]
const char GetOddlyield[]
const char lcl_GetcoupnumDecl[]
const char GetYieldmatDecl[]
const char setDayDecl[]
const char coupdays[]
const char ScInterVDB[]
const char GetDaysInYearsDecl[]
const char GetFV[]
const char coupdaysDecl[]
const char lcl_GetcoupdaybsDecl[]
const char GetFVDecl[]
const char ScGetDDB[]
const char GetDaysInYearDecl[]
const char GetOddlprice[]
const char GetYearFracDecl[]
const char coupnum[]
const char lcl_GetCouppcd[]
const char getDiffDecl[]
const char getPriceDecl[]
const char setDay[]
const char coupdaybs[]
const char GetNullDate[]
const char getDaysInYearRangeDecl[]
const char getDaysInMonthRangeDecl[]
const char lcl_Getcoupnum[]
const char coupdaybsDecl[]
const char ScGetDDBDecl[]
const char DaysInMonth[]
const char GetIpmt[]
const char GetDaysInYear[]
const char lcl_GetCouppcdDecl[]
const char DaysToDate_LocalBarrier[]
const char GetYearDiffDecl[]
const char is_representable_integerDecl[]
const char Round[]
const char RoundDecl[]
const char approx_equalDecl[]
const char approx_equal[]
const char nCorrValDecl[]
const char is_representable_integer[]
#define CHECK_PARAMETER_DOUBLEVECTORREF(arg)
Definition: opbase.hxx:97
#define CHECK_PARAMETER_COUNT(min, max)
Definition: opbase.hxx:85