diff options
author | yiming ju <yiming@multicorewareinc.com> | 2013-11-01 16:54:56 +0800 |
---|---|---|
committer | I-Jui (Ray) Sung <ray@multicorewareinc.com> | 2013-11-01 12:56:14 -0500 |
commit | 8e88765cc67b42755b6950dccb24f771c1e1dc83 (patch) | |
tree | 5cf86c7081bc17294a168f759ef326579082af3b /sc/source | |
parent | 35f8d734dd54cafd1e9d07a1e67b63c366b93a9d (diff) |
GPU Calc: refactor code generation for inlined library routines
Refactored all library functions of now formule calc in GPU
Change-Id: Icf238c18cae5ca2b685a99204994f5d3211b3ac9
Signed-off-by: haochen <haochen@multicorewareinc.com>
Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/opencl/formulagroupcl_finacial.hxx | 727 | ||||
-rw-r--r-- | sc/source/core/opencl/op_financial.cxx | 230 | ||||
-rw-r--r-- | sc/source/core/opencl/op_financial.hxx | 17 | ||||
-rw-r--r-- | sc/source/core/opencl/opinlinefun_finacial.cxx | 879 |
5 files changed, 1121 insertions, 734 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 2dfc0cf65b59..d4dada657a4a 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -23,7 +23,6 @@ #include "op_math.hxx" #include "op_statistical.hxx" #include "formulagroupcl_public.hxx" -#include "formulagroupcl_finacial.hxx" #include <list> #include <map> @@ -1187,7 +1186,6 @@ public: } // preambles decl << publicFunc; - decl << finacialFunc; DK->DumpInlineFun(inlineDecl,inlineFun); for(std::set<std::string>::iterator set_iter=inlineDecl.begin(); set_iter!=inlineDecl.end();set_iter++) diff --git a/sc/source/core/opencl/formulagroupcl_finacial.hxx b/sc/source/core/opencl/formulagroupcl_finacial.hxx deleted file mode 100644 index da09168ff7f1..000000000000 --- a/sc/source/core/opencl/formulagroupcl_finacial.hxx +++ /dev/null @@ -1,727 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef SC_OPENCL_FORMULAGROUPCL_FINACIAL_HXX -#define SC_OPENCL_FORMULAGROUPCL_FINACIAL_HXX -const char* finacialFunc = -"double GetRmz( double fZins, double fZzr, double fBw, double fZw, int nF )\n" -"{\n" - "\tdouble fRmz;\n" - "\tif( fZins == 0.0 )\n" - "\t\tfRmz = ( fBw + fZw ) / fZzr;\n" - "\telse\n" - "\t\t{\n" - "\t\t\tdouble fTerm = pow( 1.0 + fZins, fZzr );\n" - "\t\t\tif( nF > 0 )\n" - "\t\t\t\tfRmz = ( fZw * fZins / ( fTerm - 1.0 ) + fBw" - " * fZins / ( 1.0 - 1.0 / fTerm ) ) / ( 1.0 + fZins );\n" - "\t\t\telse\n" - "\t\t\t\tfRmz = fZw * fZins / ( fTerm - 1.0 ) + fBw * fZins /" - "( 1.0 - 1.0 / fTerm );\n" - "\t\t}\n" - "\treturn -fRmz;\n" -"}\n\n" -"double GetZw( double fZins, double fZzr, double fRmz, double fBw, int nF )\n" -"{\n" -" double fZw;\n" -" if( fZins == 0.0 )\n" -" fZw = fBw + fRmz * fZzr;\n" -" else\n" -" {\n" -" double fTerm = pow( 1.0 + fZins, fZzr );\n" -" if( nF > 0 )\n" -" fZw = fBw * fTerm + fRmz * ( 1.0 + fZins ) *" -"( fTerm - 1.0 ) / fZins;\n" -" else\n" -" fZw = fBw * fTerm + fRmz * ( fTerm - 1.0 ) / fZins;\n" -" }\n" -" return -fZw;\n" -"}\n\n" -"bool IsLeapYear( int n )\n" -"{\n" - "return ( (( ( n % 4 ) == 0 ) && ( ( n % 100 ) != 0)) || ( ( n % 400 ) == 0 ) );\n" -"}\n" - -"int DaysInMonth( int nMonth, int nYear )\n" -"{\n" - " int aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30,\n" - " 31, 31, 30, 31, 30, 31 };\n" -"\n" -" if ( nMonth != 2 )\n" -" return aDaysInMonth[nMonth-1];\n" -" else\n" -" {\n" -" if ( IsLeapYear(nYear) )\n" -" return aDaysInMonth[nMonth-1] + 1;\n" -" else\n" -" return aDaysInMonth[nMonth-1];\n" -" }\n" -"}\n" - -"void DaysToDate( int nDays, int *rDay, int* rMonth, int* rYear )\n" -"{\n" -"\n" -" int nTempDays;\n" -" int i = 0;\n" -" bool bCalc;\n" - -" do\n" -" {\n" -" nTempDays = nDays;\n" -" *rYear = (int)((nTempDays / 365) - i);\n" -" nTempDays -= ((int) *rYear -1) * 365;\n" -" nTempDays -= (( *rYear -1) / 4) - (( *rYear -1) / 100) + ((*rYear -1) / 400);\n" -" bCalc = false;\n" -" if ( nTempDays < 1 )\n" -" {\n" -" i++;\n" -" bCalc = true;\n" -" }\n" -" else\n" -" {\n" -" if ( nTempDays > 365 )\n" -" {\n" -" if ( (nTempDays != 366) || !IsLeapYear( *rYear ) )\n" -" {\n" -" i--;\n" -" bCalc = true;\n" -" }\n" -" }\n" -" }\n" -" }\n" -" while ( bCalc );\n" - -" *rMonth = 1;\n" -" while ( (int)nTempDays > DaysInMonth( *rMonth, *rYear ) )\n" -" {\n" -" nTempDays -= DaysInMonth( *rMonth, *rYear );\n" -" *rMonth+=1;\n" -" }\n" -" *rDay = (int)nTempDays;\n" -"}\n" - -"int DateToDays( int nDay, int nMonth, int nYear )\n" -"{\n" -" int nDays = ((int)nYear-1) * 365;\n" -" nDays += ((nYear-1) / 4) - ((nYear-1) / 100) + ((nYear-1) / 400);\n" - -" for( int i = 1; i < nMonth; i++ )\n" -" nDays += DaysInMonth(i,nYear);\n" -" nDays += nDay;\n" -"\n" -" return nDays;\n" -"}\n" -"int GetNullDate()\n" -"{\n" -" return DateToDays(30,12,1899 );\n" -"}\n" - -"void ScaDate( int nNullDate, int nDate, int nBase,int *nOrigDay, int *nMonth,int *nYear,int *bLastDayMode,int *bLastDay,int *b30Days,int *bUSMode,int *nDay)\n" -"{\n" -"DaysToDate( nNullDate + nDate, nOrigDay, nMonth, nYear );\n" -"*bLastDayMode = (nBase != 5);\n" -"*bLastDay = (*nOrigDay >= DaysInMonth( *nMonth, *nYear ));\n" -"*b30Days = (nBase == 0) || (nBase == 4);\n" -"*bUSMode = (nBase == 0);\n" - "if( *b30Days)\n" - "{\n" - "*nDay = min( *nOrigDay, 30);\n" - "if( *bLastDay || (*nDay >=DaysInMonth( *nMonth, *nYear )) )\n" - "*nDay = 30;\n" - "}\n" - "else\n" - "{\n" - "int nLastDay = DaysInMonth( *nMonth, *nYear );\n" - "*nDay = *bLastDay ? nLastDay : min( *nOrigDay, nLastDay );\n" - "}\n" -"}\n" - -"void addMonths(int b30Days,int bLastDay,int *nDay,int nOrigDay,int *nMonth,int nMonthCount,int *year)\n" -"{\n" - "int nNewMonth = nMonthCount + *nMonth;\n" - "if( nNewMonth > 12 )\n" - "{\n" - "--nNewMonth;\n" - "*year+=nNewMonth / 12 ;\n" - "*nMonth = ( nNewMonth % 12 ) + 1;\n" - "}\n" - "else if( nNewMonth < 1 )\n" - "{\n" - "*year+= nNewMonth / 12 - 1 ;\n" - "*nMonth = nNewMonth % 12 + 12 ;\n" - "}\n" - "else\n" - "*nMonth = nNewMonth ;\n" - "if( b30Days )\n" - "{\n" - "*nDay = min( nOrigDay, 30);\n" - "if( bLastDay || (*nDay >= DaysInMonth( *nMonth, *year )) )\n" - "*nDay = 30;\n" - "}\n" - "else\n" - "{\n" - "int nLastDay = DaysInMonth( *nMonth, *year );\n" - "*nDay = bLastDay ? nLastDay : min( nOrigDay, nLastDay );\n" - "}\n" -"}\n" -"int getDaysInMonthRange( int nFrom, int nTo,int b30Days,int year)\n" -"{\n" - "if( nFrom > nTo )\n" - "return 0;\n" - "int nRet = 0;\n" - "if( b30Days )\n" - "nRet = (nTo - nFrom + 1) * 30;\n" - "else\n" - "{\n" - "for( int nMonthIx = nFrom; nMonthIx <= nTo; ++nMonthIx )\n" - "nRet += b30Days ? 30 : DaysInMonth( nMonthIx, year );\n" - "}\n" - "return nRet;\n" -"}\n" - -"int GetDaysInYears( int nYear1, int nYear2 )\n" -"{\n" - "int nLeaps = 0;\n" - "for( int n = nYear1 ; n <= nYear2 ; n++ )\n" - "{\n" - "if( IsLeapYear( n ) )\n" - "nLeaps++;\n" - "}\n" - "int nSum = 1;\n" - "nSum += nYear2;\n" - "nSum -= nYear1;\n" - "nSum *= 365;\n" - "nSum += nLeaps;\n" - "return nSum;\n" -"}\n" - -"int GetDaysInYear( int nNullDate, int nDate, int nMode )\n" -"{\n" -"switch( nMode )\n" -"{\n" -"case 0:\n" -"case 2:\n" -"case 4:\n" - "return 360;\n" -"case 1:\n" - "{\n" - "int nD=0, nM=0, nY=0;\n" - "nDate += nNullDate;\n" - "DaysToDate( nDate, &nD, &nM, &nY );\n" - "return IsLeapYear( nY )? 366 : 365;\n" - "}\n" -"case 3:\n" - "return 365;\n" -"}\n" -"}\n" -"int getDaysInYearRange( int nFrom, int nTo,int b30Days )\n" -"{\n" - "if( nFrom > nTo )\n" - "return 0;\n" - "return b30Days ? ((nTo - nFrom + 1) * 360) : GetDaysInYears( nFrom, nTo );\n" -"}\n" - -"int getDiff(int rFrom,int rTo,int fDay,int fMonth,int fYear,int fbLastDayMode,int fbLastDay,int fb30Days,int fbUSMode,int fnDay,\n" - "int tDay,int tMonth,int tYear,int tbLastDayMode,int tbLastDay,int tb30Days,int tbUSMode,int tnDay)\n" -"{\n" -"if(rFrom>rTo)\n" -"{\n" -"int d=fDay;fDay=tDay;tDay=d;\n" -"int m=fMonth;fMonth=tMonth;tMonth=m;\n" -"int y=fYear;fYear=tYear;tYear=y;\n" -"int a=fbLastDayMode;fbLastDayMode=tbLastDayMode;tbLastDayMode=a;\n" -"int b=fbLastDay;fbLastDay=tbLastDay;tbLastDay=b;\n" -"int c=fb30Days;fb30Days=tb30Days;tb30Days=c;\n" -"int e=fbUSMode;fbUSMode=tbUSMode;tbUSMode=e;\n" -"int f=fnDay;fnDay=tnDay;tnDay=f;\n" -"}\n" -"int nDiff=0;\n" -"if( tb30Days )\n" -"{\n" -"if( tbUSMode )\n" -"{\n" - "if( ((fMonth == 2) || (fnDay < 30)) && (tDay == 31) )\n" - "tnDay = 31;\n" - "else if( (tMonth == 2) && tbLastDay )\n" - "tnDay = DaysInMonth( 2, tYear );\n" -"}\n" -"else\n" -"{\n" - "if( (fMonth == 2) && (fnDay == 30) )\n" - "fnDay = DaysInMonth( 2, fYear );\n" - "if( (tMonth == 2) && (tnDay == 30) )\n" - "tnDay = DaysInMonth( 2, tYear );\n" -"}\n" -"}\n" -"if( (fYear < tYear) || ((fYear == tYear) && (fMonth < tMonth)) )\n" -"{\n" -"nDiff = (fb30Days? 30:DaysInMonth(fMonth,fYear) )- fnDay + 1;\n" -"fDay = fnDay = 1;\n" -"fbLastDay = 0;\n" -"addMonths(fb30Days,fbLastDay,&fnDay,fDay,&fMonth,1,&fYear);\n" -"if( fYear < tYear )\n" -"{\n" - "nDiff += getDaysInMonthRange( fMonth, 12,fb30Days,fYear);\n" - "addMonths(fb30Days,fbLastDay,&fnDay,fDay,&fMonth,13-fMonth,&fYear);\n" - "nDiff += getDaysInYearRange( fYear, tYear - 1,fb30Days);\n" - "fYear+=tYear - fYear;\n" -"}\n" -"nDiff += getDaysInMonthRange(fMonth, tMonth - 1,fb30Days ,fYear );\n" -"addMonths(fb30Days,fbLastDay,&fnDay,fDay,&fMonth,tMonth-fMonth,&fYear);\n" -"}\n" -"nDiff += tnDay - fnDay;\n" -"return nDiff > 0 ? nDiff : 0;\n" -"}\n" - -"int lcl_Getcoupdaybs(int nNullDate,int nSettle, int nMat,int nFreq,int nBase)\n" -"{\n" - "int aDate = nMat;\n" - "int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0, mYear=0;int sDay=0,sMonth=0, sYear=0;\n" - "int rbLastDayMode=0, rbLastDay=0,rb30Days=0,rbUSMode=0,rnDay=0;\n" - "int sbLastDayMode=0, sbLastDay=0,sb30Days=0,sbUSMode=0,snDay=0;\n" - "ScaDate( nNullDate,aDate,nBase,&rDay,&rMonth,&rYear,&rbLastDayMode,&rbLastDay,&rb30Days,&rbUSMode,&rnDay);\n" - "ScaDate( nNullDate,nSettle,nBase,&sDay,&sMonth,&sYear,&sbLastDayMode,&sbLastDay,&sb30Days,&sbUSMode,&snDay);\n" - "rYear= sYear;\n" - "nSettle=nSettle+nNullDate;\n" - "aDate=DateToDays( rDay,rMonth,rYear );\n" - "if( aDate < nSettle )\n" - "{\n" - "rYear+= 1;\n" - "aDate=DateToDays( rDay,rMonth,rYear );\n" - "}\n" - "while(aDate > nSettle )\n" - "{\n" - "addMonths(rb30Days,rbLastDay,&rnDay,rDay,&rMonth,-1*(12/nFreq),&rYear);\n" - "aDate=DateToDays( rDay,rMonth,rYear );\n" - "}\n" - "return getDiff( aDate, nSettle, rDay, rMonth, rYear, rbLastDayMode, rbLastDay, rb30Days, rbUSMode, rnDay,\n" - "sDay, sMonth, sYear, sbLastDayMode, sbLastDay, sb30Days, sbUSMode, snDay);\n" -"}\n" - -"int lcl_Getcoupdays(int nNullDate,int nSettle, int nMat,int nFreq,int nBase)\n" -"{\n" - "int aDate = nMat;\n" - "int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0, mYear=0;int sDay=0,sMonth=0, sYear=0;\n" - "int rbLastDayMode=0, rbLastDay=0,rb30Days=0,rbUSMode=0,rnDay=0;\n" - "int sbLastDayMode=0, sbLastDay=0,sb30Days=0,sbUSMode=0,snDay=0;\n" - "ScaDate( nNullDate,aDate,nBase,&rDay,&rMonth,&rYear,&rbLastDayMode,&rbLastDay,&rb30Days,&rbUSMode,&rnDay);\n" - "ScaDate( nNullDate,nSettle,nBase,&sDay,&sMonth,&sYear,&sbLastDayMode,&sbLastDay,&sb30Days,&sbUSMode,&snDay);\n" - "rYear= sYear;\n" - "nSettle=nSettle+nNullDate;\n" - "aDate=DateToDays( rDay,rMonth,rYear );\n" - "if( aDate < nSettle )\n" - "{ \n" - "rYear+= 1;\n" - "aDate=DateToDays( rDay,rMonth,rYear );\n" - "}\n" - "while(aDate > nSettle )\n" - "{\n" - "addMonths(rb30Days,rbLastDay,&rnDay,rDay,&rMonth,-1*(12/nFreq),&rYear);\n" - "aDate=DateToDays( rDay,rMonth,rYear );\n" - "}\n" - "int aNextDate=aDate;int aDay=rDay,aMonth=rMonth, aYear=rYear;\n" - "int abLastDayMode=rbLastDayMode, abLastDay=rbLastDay,ab30Days=rb30Days,abUSMode=rbUSMode,anDay=rnDay;\n" - "addMonths(ab30Days,abLastDay,&anDay,aDay,&aMonth,12/nFreq,&aYear);\n" - "return getDiff( aDate, aNextDate, rDay, rMonth, rYear, rbLastDayMode, rbLastDay, rb30Days, rbUSMode, rnDay,\n" - "aDay, aMonth, aYear, abLastDayMode, abLastDay, ab30Days, abUSMode, anDay);\n" -"}\n" - -"int lcl_Getcoupnum(int nNullDate,int nSettle, int nMat,int nFreq)\n" -"{\n" - "int aDate = nMat;int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0, mYear=0;\n" - "int sDay=0,sMonth=0, sYear=0;\n" - "DaysToDate(aDate+nNullDate,&rDay, &rMonth, &rYear );\n" - "DaysToDate(nMat+nNullDate,&mDay, &mMonth, &mYear );\n" - "DaysToDate(nSettle+nNullDate,&sDay, &sMonth, &sYear );\n" - "rYear= sYear;\n" - "nSettle=nSettle+nNullDate;\n" - "aDate=DateToDays( rDay,rMonth,rYear );\n" - "if( aDate < nSettle )\n" - "rYear+= 1;\n" - "int d=DateToDays( rDay,rMonth,rYear );\n" - "int nMonthCount=-1*(12 / nFreq);\n" - "while(d > nSettle )\n" - "{\n" - "int nNewMonth = nMonthCount + rMonth;\n" - "if( nNewMonth > 12 )\n" - "{\n" - "--nNewMonth;\n" - "rYear+=nNewMonth / 12;\n" - "rMonth = nNewMonth % 12 + 1;\n" - "}\n" - "else if( nNewMonth < 1 )\n" - "{\n" - "rYear+= nNewMonth / 12 - 1;\n" - "rMonth = nNewMonth % 12 + 12;\n" - "}\n" - "else\n" - "rMonth = nNewMonth;\n" - "d=DateToDays( rDay,rMonth,rYear );\n" - "}\n" - "int n=(mYear-rYear)*12+mMonth-rMonth;\n" - "n=n*nFreq/12;\n" - "return n;\n" -"}\n" - -"double coupdays(int nSettle,int nMat,int nFreq,int nBase)\n" -"{\n" - "int nNullDate=GetNullDate();\n" - "if( nBase == 1 )\n" - "return lcl_Getcoupdays(nNullDate, nSettle, nMat,nFreq, nBase);\n" - "else\n" - "return (double)GetDaysInYear(0,0,nBase)/nFreq;\n" -"}\n" - -"double coupdaybs( int nSettle,int nMat,int nFreq,int nBase)\n" -"{\n" - "int nNullDate=GetNullDate();\n" - "return lcl_Getcoupdaybs(nNullDate, nSettle, nMat,nFreq, nBase);\n" -"}\n" - -"double coupdaysnc( int nSettle,int nMat,int nFreq,int nBase)\n" -"{\n" -"int nNullDate=GetNullDate();\n" -"if((nBase != 0) && (nBase != 4))\n" -"{\n" - "int aDate = nMat;\n" - "int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0, mYear=0;int sDay=0,sMonth=0, sYear=0;\n" - "int rbLastDayMode=0, rbLastDay=0,rb30Days=0,rbUSMode=0,rnDay=0;\n" - "int sbLastDayMode=0, sbLastDay=0,sb30Days=0,sbUSMode=0,snDay=0;\n" - "ScaDate( nNullDate,aDate,nBase,&rDay,&rMonth,&rYear,&rbLastDayMode,&rbLastDay,&rb30Days,&rbUSMode,&rnDay);\n" - "ScaDate( nNullDate,nSettle,nBase,&sDay,&sMonth,&sYear,&sbLastDayMode,&sbLastDay,&sb30Days,&sbUSMode,&snDay);\n" - "rYear= sYear;\n" - "nSettle=nSettle+nNullDate;\n" - "aDate=DateToDays( rDay,rMonth,rYear );\n" - "if( aDate > nSettle )\n" - "{\n" - "rYear-= 1;\n" - "aDate=DateToDays( rDay,rMonth,rYear );\n" -"}\n" -"while(aDate <= nSettle )\n" -"{\n" - "addMonths(rb30Days,rbLastDay,&rnDay,rDay,&rMonth,12/nFreq,&rYear);\n" - "aDate=DateToDays( rDay,rMonth,rYear );\n" -"}\n" -"return getDiff( nSettle, aDate, sDay, sMonth, sYear, sbLastDayMode, sbLastDay, sb30Days, sbUSMode, snDay,\n" - "rDay, rMonth, rYear, rbLastDayMode, rbLastDay, rb30Days, rbUSMode, rnDay);\n" -"}\n" -"else\n" - "return coupdays(nSettle,nMat,nFreq,nBase)- coupdaybs( nSettle,nMat,nFreq,nBase);\n" -"}\n" - -"double coupnum( int nSettle,int nMat,int nFreq,int nBase)\n" -"{\n" - "int nNullDate=GetNullDate();\n" - "return lcl_Getcoupnum(nNullDate,nSettle,nMat,nFreq);\n" -"}\n" - -"double getPrice_(int nSettle, int nMat, double fRate, double fYield,\n" - "double fRedemp, int nFreq, int nBase )\n" -"{\n" - "double fFreq = nFreq;\n" - "double fE = coupdays( nSettle, nMat, nFreq, nBase );\n" - "double fDSC_E = coupdaysnc( nSettle, nMat, nFreq, nBase ) / fE;\n" - "double fN = coupnum( nSettle, nMat, nFreq, nBase );\n" - "double fA = coupdaybs( nSettle, nMat, nFreq, nBase );\n" - "double fRet = fRedemp / ( pow( 1.0 + fYield / fFreq, fN - 1.0 + fDSC_E ) );\n" - "fRet -= 100.0 * fRate / fFreq * fA / fE;\n" - "double fT1 = 100.0 * fRate / fFreq;\n" - "double fT2 = 1.0 + fYield / fFreq;\n" - "for( double fK = 0.0 ; fK < fN ; fK+=1.0 )\n" - "fRet += fT1 / pow( fT2, fK + fDSC_E );\n" -"return fRet;\n" -"}\n" - -"double getYield_( int nNullDate, int nSettle, int nMat, double fCoup, double fPrice,double fRedemp, int nFreq, int nBase )\n" -"{\n" - "double fRate = fCoup;\n" - "double fPriceN = 0.0;\n" - "double fYield1 = 0.0;\n" - "double fYield2 = 1.0;\n" - "double fPrice1 = getPrice_(nSettle, nMat, fRate, fYield1, fRedemp, nFreq, nBase );\n" - "double fPrice2 = getPrice_(nSettle, nMat, fRate, fYield2, fRedemp, nFreq, nBase );\n" - "double fYieldN = ( fYield2 - fYield1 ) * 0.5;\n" - "for( unsigned int nIter = 0 ; nIter < 100 && fPriceN != fPrice ; nIter++ )\n" - "{\n" - "fPriceN = getPrice_(nSettle, nMat, fRate, fYieldN, fRedemp, nFreq, nBase );\n" - "if( fPrice == fPrice1 )\n" - "return fYield1;\n" - "else if( fPrice == fPrice2 )\n" - "return fYield2;\n" - "else if( fPrice == fPriceN )\n" - "return fYieldN;\n" - "else if( fPrice < fPrice2 )\n" - "{\n" - "fYield2 *= 2.0;\n" - "fPrice2 = getPrice_(nSettle, nMat, fRate, fYield2, fRedemp, nFreq, nBase );\n" - "fYieldN = ( fYield2 - fYield1 ) * 0.5;\n" - "}\n" - "else\n" - "{\n" - "if( fPrice < fPriceN )\n" - "{\n" - "fYield1 = fYieldN;\n" - "fPrice1 = fPriceN;\n" - "}\n" - "else\n" - "{\n" - "fYield2 = fYieldN;\n" - "fPrice2 = fPriceN;\n" - "}\n" - "fYieldN = fYield2 - ( fYield2 - fYield1 ) * ( ( fPrice - fPrice2 ) / ( fPrice1 - fPrice2 ) );\n" - "}\n" - "}\n" - "return fYieldN;\n" -"}\n" - -"double GetYearFrac( int nNullDate, int nStartDate, int nEndDate, int nMode ) \n" -"{\n" -" if( nStartDate == nEndDate )\n" -" return 0.0; \n" - - " if( nStartDate > nEndDate )\n" - " {\n" - " int n = nEndDate;\n" - " nEndDate = nStartDate;\n" - " nStartDate = n;\n" - " }\n" - - " int nDate1 = nStartDate + nNullDate;\n" - " int nDate2 = nEndDate + nNullDate;\n" - - " int nDay1, nDay2;\n" - " int nMonth1, nMonth2;\n" - " int nYear1, nYear2;\n" - - " DaysToDate( nDate1, &nDay1, &nMonth1, &nYear1 );\n" - " DaysToDate( nDate2, &nDay2, &nMonth2, &nYear2 );\n" - - - " int nDayDiff;\n" - " switch( nMode )\n" - " {\n" - " case 0: \n" - " if ( nDay1 == 31 )\n" - " {\n" - " nDay1--;\n" - " }\n" - " if ( nDay1 == 30 && nDay2 == 31 )\n" - " {\n" - " nDay2--;\n" - " }\n" - " else\n" - " {\n" - " if ( nMonth1 == 2 && nDay1 == ( IsLeapYear( nYear1 ) ? 29 : 28 ) )\n" - " {\n" - " nDay1 = 30;\n" - " if ( nMonth2 == 2 && nDay2 == ( IsLeapYear( nYear2 ) ? 29 : 28 ) )\n" - " {\n" - " nDay2 = 30;\n" - " }\n" - " }\n" - " }\n" - " nDayDiff = ( nYear2 - nYear1 ) * 360 + ( nMonth2 - nMonth1 ) * 30 + ( nDay2 - nDay1 );\n" - " break;\n" - " case 1: \n" - " case 2: \n" - " case 3: \n" - " nDayDiff = nDate2 - nDate1;\n" - " break;\n" - " case 4: \n" - " if ( nDay1 == 31 )\n" - " {\n" - " nDay1--;\n" - " }\n" - " if ( nDay2 == 31 )\n" - " {\n" - " nDay2--;\n" - " }\n" - " nDayDiff = ( nYear2 - nYear1 ) * 360 + ( nMonth2 - nMonth1 ) * 30 + ( nDay2 - nDay1 );\n" - " break;\n" - " }\n" - - - " double nDaysInYear;\n" - " switch( nMode )\n" - " {\n" - " case 0: \n" - " case 2: \n" - " case 4: \n" - " nDaysInYear = 360;\n" - " break;\n" - " case 1: \n" - " {\n" - " bool isYearDifferent = ( nYear1 != nYear2 );\n" - " if ( isYearDifferent &&\n" - " ( ( nYear2 != nYear1 + 1 ) ||\n" - " ( nMonth1 < nMonth2 ) ||\n" - " ( nMonth1 == nMonth2 && nDay1 < nDay2 ) ) )\n" - " {\n" - - " int nDayCount = 0;\n" - " for ( int i = nYear1; i <= nYear2; i++ )\n" - " nDayCount += ( IsLeapYear( i ) ? 366 : 365 );\n" - - " nDaysInYear = ( double ) nDayCount / ( double ) ( nYear2 - nYear1 + 1 );\n" - " }\n" - " else\n" - " {\n" - " if ( isYearDifferent && IsLeapYear( nYear1 ) )\n" - " {\n" - " nDaysInYear = 366;\n" - " }\n" - " else\n" - " {\n" - - " if ( ( IsLeapYear( nYear1 ) && nMonth1 <= 2 && nDay1 <= 29 ) ||\n" - " ( IsLeapYear( nYear2 ) && ( nMonth2 > 3 || ( nMonth2 == 2 && nDay1 == 29 ) ) ) )\n" - " {\n" - " nDaysInYear = 366;\n" - " }\n" - " else\n" - " {\n" - " nDaysInYear = 365;\n" - " for ( int i = nYear1; i <= nYear2; i++ )\n" - " {\n" - " if ( IsLeapYear( i ) )\n" - " {\n" - " nDaysInYear = 366;\n" - " break;\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - " break;\n" - " case 3: \n" - " nDaysInYear = 365;\n" - " break;\n" - - " }\n" - - " return (double)( nDayDiff ) / (nDaysInYear);\n" -"}\n" - "double GetYieldmat( int nNullDate, int nSettle, int nMat, int nIssue,\n" - "double fRate, double fPrice, int nBase )\n" - "{\n" - "double fIssMat = GetYearFrac( nNullDate, nIssue, nMat, nBase );\n" - "double fIssSet = GetYearFrac( nNullDate, nIssue, nSettle, nBase );\n" - "double fSetMat = GetYearFrac( nNullDate, nSettle, nMat, nBase );\n" - "double y = 1.0 + fIssMat * fRate;\n" - "y /= fPrice / 100.0 + fIssSet * fRate;\n" - "y-=1.0;\n" - "y /= fSetMat;\n" - "return y;\n" - "}\n" - -"int GetDiffDate( int nNullDate, int nStartDate, int nEndDate, int nMode," -" int* pOptDaysIn1stYear )\n" -"{\n" -"\t bool bNeg = nStartDate > nEndDate;\n" - -"\t if( bNeg )\n" -"\t {\n" -"\t\t int n = nEndDate;\n" -"\t\t nEndDate = nStartDate;\n" -"\t\t nStartDate = n;\n" -"\t }\n" -"\t int nRet;\n" -"\t switch( nMode )\n" -"\t {\n" -"\t\t case 0: \n" -"\t\t case 4: \n" -"\t\t {\n" -"\t\t\t int nD1, nM1, nY1, nD2, nM2, nY2;\n" -"\t\t\t nStartDate += nNullDate;\n" -"\t\t\t nEndDate += nNullDate;\n" -"\t\t\t DaysToDate( nStartDate, &nD1, &nM1, &nY1 );\n" -"\t\t\t DaysToDate( nEndDate, &nD2, &nM2, &nY2 );\n" -"\t\t\t bool bLeap = IsLeapYear( nY1 );\n" -"\t\t\t int nDays, nMonths;\n" -"\t\t\t nMonths = nM2 - nM1;\n" -"\t\t\t nDays = nD2 - nD1;\n" -"\t\t\t nMonths += ( nY2 - nY1 ) * 12;\n" -"\t\t\t nRet = nMonths * 30 + nDays;\n" -"\t\t\t if( nMode == 0 && nM1 == 2 && nM2 != 2 && nY1 == nY2 )\n" -"\t\t\t\t nRet -= bLeap? 1 : 2;\n" -"\t\t\t if( pOptDaysIn1stYear )\n" -"\t\t\t\t *pOptDaysIn1stYear = 360;\n" -"\t\t }\n" -"\t\t\t break;\n" -"\t\t case 1: \n" -"\t\t\t if( pOptDaysIn1stYear )\n" -"\t\t\t {\n" -"\t\t\t\t int nD, nM, nY;\n" -"\t\t\t\t DaysToDate( nStartDate + nNullDate, &nD, &nM, &nY );\n" -"\t\t\t\t *pOptDaysIn1stYear = IsLeapYear( nY )? 366 : 365;\n" -"\t\t\t }\n" -"\t\t\t nRet = nEndDate - nStartDate;\n" -"\t\t\t break;\n" -"\t\t case 2: \n" -"\t\t\t nRet = nEndDate - nStartDate;\n" -"\t\t\t if( pOptDaysIn1stYear )\n" -"\t\t\t\t *pOptDaysIn1stYear = 360;\n" -"\t\t\t break;\n" -"\t\t case 3: \n" -"\t\t\t nRet = nEndDate - nStartDate;\n" -"\t\t\t if( pOptDaysIn1stYear )\n" -"\t\t\t\t *pOptDaysIn1stYear = 365;\n" -"\t\t\t break;\n" -"\t }\n" -"\t return bNeg? -nRet : nRet;\n" -"}\n" -"double GetYearDiff( int nNullDate, int nStartDate, int nEndDate, int nMode )\n" -"{\n" -"\t int nDays1stYear;\n" -"\t int nTotalDays = GetDiffDate( nNullDate, nStartDate, nEndDate, nMode, &nDays1stYear );\n" -"\t double result=(double)(nTotalDays)/(nDays1stYear);\n" -"\treturn result;\n" -"}\n" -"int GetDiffDate360_(\n" -" int nDay1, int nMonth1, int nYear1, bool bLeapYear1,\n" -" int nDay2, int nMonth2, int nYear2,\n" -" bool bUSAMethod )\n" -"{\n" -" if( nDay1 == 31 )\n" -" nDay1--;\n" -" else if( bUSAMethod && ( nMonth1 == 2 && ( nDay1 == 29 || ( nDay1 == 28 && !bLeapYear1 ) ) ) )\n" -" nDay1 = 30;\n" -" if( nDay2 == 31 )\n" -" {\n" -" if( bUSAMethod && nDay1 != 30 )\n" -" {\n" -" nDay2 = 1;\n" -" if( nMonth2 == 12 )\n" -" {\n" -" nYear2++;\n" -" nMonth2 = 1;\n" -" }\n" -" else\n" -" nMonth2++;\n" -" }\n" -" else\n" -" nDay2 = 30;\n" -" }\n" -" return nDay2 + nMonth2 * 30 + nYear2 * 360 - nDay1 - nMonth1 * 30 - nYear1 * 360;\n" -"}\n" - -"int GetDiffDate360( int nNullDate, int nDate1, int nDate2, bool bUSAMethod )\n" -"{\n" -" nDate1 += nNullDate;\n" -" nDate2 += nNullDate;\n" -" int nDay1, nMonth1, nYear1, nDay2, nMonth2, nYear2;\n" -" DaysToDate( nDate1, &nDay1, &nMonth1, &nYear1 );\n" -" DaysToDate( nDate2, &nDay2, &nMonth2, &nYear2 );\n" -" return GetDiffDate360_( nDay1, nMonth1, nYear1, IsLeapYear( nYear1 ), nDay2, nMonth2, nYear2, bUSAMethod );\n" -"}\n"; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx index 69f7d02bbccc..ff167e0f1675 100644 --- a/sc/source/core/opencl/op_financial.cxx +++ b/sc/source/core/opencl/op_financial.cxx @@ -258,6 +258,17 @@ void OpDollarfr::GenSlidingWindowFunction(std::stringstream &ss, ss << "}"; } +void OpDISC::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetYearFracDecl);decls.insert(DaysToDateDecl); + decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl); + decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl); + funs.insert(GetYearFrac);funs.insert(DaysToDate); + funs.insert(GetNullDate);funs.insert(DateToDays); + funs.insert(DaysInMonth);funs.insert(IsLeapYear); +} + void OpDISC::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -361,6 +372,19 @@ void OpDISC::GenSlidingWindowFunction( ss << "}"; } +void OpINTRATE::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetYearDiffDecl);decls.insert(GetDiffDateDecl); + decls.insert(DaysToDateDecl);decls.insert(GetNullDateDecl); + decls.insert(DateToDaysDecl);decls.insert(DaysInMonthDecl); + decls.insert(IsLeapYearDecl); + funs.insert(GetYearDiff);funs.insert(GetDiffDate); + funs.insert(DaysToDate);funs.insert(GetNullDate); + funs.insert(DateToDays);funs.insert(DaysInMonth); + funs.insert(IsLeapYear); +} + void OpINTRATE::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -507,7 +531,12 @@ void Fvschedule::GenSlidingWindowFunction( ss << "return (double)tmp * arg0"; ss << ";\n}"; } - +void Cumipmt::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetRmzDecl); decls.insert(GetZwDecl); + funs.insert(GetRmz);funs.insert(GetZw); +} void Cumipmt::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -803,6 +832,17 @@ void XNPV::GenSlidingWindowFunction( ss << "}"; } + void PriceMat::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetYearFracDecl);decls.insert(GetNullDateDecl); + decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl); + decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl); + + funs.insert(GetYearFrac);funs.insert(GetNullDate); + funs.insert(DateToDays);funs.insert(DaysToDate); + funs.insert(DaysInMonth);funs.insert(IsLeapYear); +} void PriceMat::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -1153,6 +1193,18 @@ void OpEffective::GenSlidingWindowFunction( ss << "}"; } + void OpTbilleq::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetDiffDate360_Decl);decls.insert(GetDiffDate360Decl); + decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl); + decls.insert(DaysInMonthDecl);decls.insert(GetNullDateDecl); + decls.insert(IsLeapYearDecl); + funs.insert(GetDiffDate360_);funs.insert(GetDiffDate360); + funs.insert(DateToDays);funs.insert(DaysToDate); + funs.insert(DaysInMonth);funs.insert(GetNullDate); + funs.insert(IsLeapYear); +} void OpTbilleq::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -1233,7 +1285,12 @@ void OpTbilleq::GenSlidingWindowFunction( ss << "return tmp;\n"; ss << "}"; } - +void OpCumprinc::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetRmzDecl); decls.insert(GetZwDecl); + funs.insert(GetRmz);funs.insert(GetZw); +} void OpCumprinc::GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -1361,6 +1418,16 @@ void OpCumprinc::GenSlidingWindowFunction(std::stringstream &ss, ss << "}"; } +void OpAccrintm::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl); + decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl); + decls.insert(GetNullDateDecl); decls.insert(GetDiffDateDecl); + funs.insert(IsLeapYear);funs.insert(DaysInMonth); + funs.insert(DaysToDate);funs.insert(DateToDays); + funs.insert(GetNullDate);funs.insert(GetDiffDate); +} void OpAccrintm::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -1472,6 +1539,35 @@ void OpAccrintm::GenSlidingWindowFunction( ss << "}"; } + void OpYield::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(getYield_Decl);decls.insert(getPrice_Decl); + decls.insert(coupnumDecl);decls.insert(coupdaysncDecl); + decls.insert(coupdaybsDecl);decls.insert(coupdaysDecl); + decls.insert(lcl_GetcoupnumDecl);decls.insert(lcl_GetcoupdaysDecl); + decls.insert(lcl_GetcoupdaybsDecl);decls.insert(getDiffDecl); + decls.insert(getDaysInYearRangeDecl);decls.insert(GetDaysInYearDecl); + decls.insert(GetDaysInYearsDecl);decls.insert(getDaysInMonthRangeDecl); + decls.insert(addMonthsDecl);decls.insert(ScaDateDecl); + decls.insert(GetNullDateDecl);decls.insert(DateToDaysDecl); + decls.insert(DaysToDateDecl);decls.insert(DaysInMonthDecl); + decls.insert(IsLeapYearDecl); + + funs.insert(getYield_);funs.insert(getPrice_); + funs.insert(coupnum);funs.insert(coupdaysnc); + funs.insert(coupdaybs);funs.insert(coupdays); + funs.insert(lcl_Getcoupnum);funs.insert(lcl_Getcoupdays); + funs.insert(lcl_Getcoupdaybs);funs.insert(getDiff); + funs.insert(getDaysInYearRange);funs.insert(GetDaysInYear); + funs.insert(GetDaysInYears);funs.insert(getDaysInMonthRange); + funs.insert(addMonths);funs.insert(ScaDate); + funs.insert(GetNullDate);funs.insert(DateToDays); + funs.insert(DaysToDate);funs.insert(DaysInMonth); + funs.insert(IsLeapYear); +} + + void OpYield::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -1699,6 +1795,20 @@ void OpSLN::GenSlidingWindowFunction(std::stringstream &ss, ss << "}"; } + void OpYieldmat::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetYearFracDecl);decls.insert(GetNullDateDecl); + decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl); + decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl); + decls.insert(GetYieldmatDecl); + + funs.insert(GetYearFrac);funs.insert(GetNullDate); + funs.insert(DateToDays);funs.insert(DaysToDate); + funs.insert(DaysInMonth);funs.insert(IsLeapYear); + funs.insert(GetYieldmat); +} + void OpYieldmat::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -1952,6 +2062,12 @@ void OpPMT::GenSlidingWindowFunction(std::stringstream &ss, ss << "return tmp;\n"; ss << "}"; } + void OpPPMT::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetZwDecl); + funs.insert(GetZw); +} void OpPPMT::GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) @@ -2036,7 +2152,24 @@ void OpPPMT::GenSlidingWindowFunction(std::stringstream &ss, ss << "return tmp;\n"; ss << "}"; } - +void OpCoupdaybs::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl); + decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl); + decls.insert(GetNullDateDecl); decls.insert(ScaDateDecl); + decls.insert(addMonthsDecl); decls.insert(getDaysInMonthRangeDecl); + decls.insert(GetDaysInYearsDecl); + decls.insert(getDaysInYearRangeDecl); decls.insert(getDiffDecl); + decls.insert(lcl_GetcoupdaybsDecl); + funs.insert(IsLeapYear);funs.insert(DaysInMonth); + funs.insert(DaysToDate);funs.insert(DateToDays); + funs.insert(GetNullDate);funs.insert(ScaDate); + funs.insert(addMonths);funs.insert(getDaysInMonthRange); + funs.insert(GetDaysInYears); + funs.insert(getDaysInYearRange);funs.insert(getDiff); + funs.insert(lcl_Getcoupdaybs); +} void OpCoupdaybs::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -2120,6 +2253,24 @@ void OpCoupdaybs::GenSlidingWindowFunction( ss << "return tmp;\n"; ss << "}"; } +void OpCoupdays::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl); + decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl); + decls.insert(GetNullDateDecl); decls.insert(ScaDateDecl); + decls.insert(addMonthsDecl); decls.insert(getDaysInMonthRangeDecl); + decls.insert(GetDaysInYearsDecl); decls.insert(GetDaysInYearDecl); + decls.insert(getDaysInYearRangeDecl); decls.insert(getDiffDecl); + decls.insert(lcl_GetcoupdaysDecl); + funs.insert(IsLeapYear);funs.insert(DaysInMonth); + funs.insert(DaysToDate);funs.insert(DateToDays); + funs.insert(GetNullDate);funs.insert(ScaDate); + funs.insert(addMonths);funs.insert(getDaysInMonthRange); + funs.insert(GetDaysInYears);funs.insert(GetDaysInYear); + funs.insert(getDaysInYearRange);funs.insert(getDiff); + funs.insert(lcl_Getcoupdays); +} void OpCoupdays::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) @@ -2207,7 +2358,28 @@ void OpCoupdays::GenSlidingWindowFunction( ss << "return tmp;\n"; ss << "}"; } - +void OpCoupdaysnc::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(IsLeapYearDecl); decls.insert(DaysInMonthDecl); + decls.insert(DaysToDateDecl); decls.insert(DateToDaysDecl); + decls.insert(GetNullDateDecl); decls.insert(ScaDateDecl); + decls.insert(addMonthsDecl); decls.insert(getDaysInMonthRangeDecl); + decls.insert(GetDaysInYearsDecl); decls.insert(GetDaysInYearDecl); + decls.insert(getDaysInYearRangeDecl); decls.insert(getDiffDecl); + decls.insert(lcl_GetcoupdaysDecl);decls.insert(lcl_GetcoupdaybsDecl); + decls.insert(coupdaysDecl);decls.insert(coupdaybsDecl); + decls.insert(coupdaysncDecl); + funs.insert(IsLeapYear);funs.insert(DaysInMonth); + funs.insert(DaysToDate);funs.insert(DateToDays); + funs.insert(GetNullDate);funs.insert(ScaDate); + funs.insert(addMonths);funs.insert(getDaysInMonthRange); + funs.insert(GetDaysInYears);funs.insert(GetDaysInYear); + funs.insert(getDaysInYearRange);funs.insert(getDiff); + funs.insert(lcl_Getcoupdays);funs.insert(lcl_Getcoupdaybs); + funs.insert(coupdaysnc);funs.insert(coupdaybs); + funs.insert(coupdays); +} void OpCoupdaysnc::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -2290,6 +2462,19 @@ void OpCoupdaysnc::GenSlidingWindowFunction( ss << "}"; } + void OpReceived::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetYearDiffDecl);decls.insert(GetDiffDateDecl); + decls.insert(DaysToDateDecl);decls.insert(DaysInMonthDecl); + decls.insert(GetNullDateDecl);decls.insert(IsLeapYearDecl); + decls.insert(DateToDaysDecl); + funs.insert(GetDiffDate);funs.insert(DaysToDate); + funs.insert(DaysInMonth);funs.insert(GetNullDate); + funs.insert(DateToDays);funs.insert(IsLeapYear); + funs.insert(GetYearDiff); +} + void OpReceived::GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -2387,6 +2572,17 @@ void OpReceived::GenSlidingWindowFunction(std::stringstream &ss, ss << "}"; } + void OpYielddisc::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetYearFracDecl);decls.insert(GetNullDateDecl); + decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl); + decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl); + + funs.insert(GetYearFrac);funs.insert(GetNullDate); + funs.insert(DateToDays);funs.insert(DaysToDate); + funs.insert(DaysInMonth);funs.insert(IsLeapYear); +} void OpYielddisc::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -2507,6 +2703,18 @@ void OpYielddisc::GenSlidingWindowFunction( ss << "}"; } + void OpTbillprice::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetYearFracDecl);decls.insert(GetNullDateDecl); + decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl); + decls.insert(DaysInMonthDecl);decls.insert(IsLeapYearDecl); + + funs.insert(GetYearFrac);funs.insert(GetNullDate); + funs.insert(DateToDays);funs.insert(DaysToDate); + funs.insert(DaysInMonth);funs.insert(IsLeapYear); +} + void OpTbillprice::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { @@ -2709,6 +2917,20 @@ void RATE::GenSlidingWindowFunction( ss << "}"; } + void OpTbillyield::BinInlineFun(std::set<std::string>& decls, + std::set<std::string>& funs) +{ + decls.insert(GetDiffDate360Decl);decls.insert(IsLeapYearDecl); + decls.insert(DateToDaysDecl);decls.insert(DaysToDateDecl); + decls.insert(DaysInMonthDecl);decls.insert(GetNullDateDecl); + decls.insert(GetDiffDate360_Decl); + funs.insert(GetDiffDate360);funs.insert(DateToDays); + funs.insert(DaysToDate);funs.insert(IsLeapYear); + funs.insert(DaysInMonth);funs.insert(GetNullDate); + funs.insert(GetDiffDate360_); + +} + void OpTbillyield::GenSlidingWindowFunction( std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { diff --git a/sc/source/core/opencl/op_financial.hxx b/sc/source/core/opencl/op_financial.hxx index 544d757c023f..7a79dde12393 100644 --- a/sc/source/core/opencl/op_financial.hxx +++ b/sc/source/core/opencl/op_financial.hxx @@ -69,6 +69,7 @@ public: virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); virtual std::string BinFuncName(void) const { return "DISC"; } }; @@ -80,6 +81,7 @@ public: virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); virtual std::string BinFuncName(void) const { return "INTRATE"; } }; @@ -96,6 +98,7 @@ class Cumipmt: public Normal public: virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); }; class IRR: public Normal @@ -124,6 +127,7 @@ class PriceMat: public Normal public: virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); }; class OpSYD: public Normal { @@ -174,6 +178,7 @@ public: const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "fTbilleq"; } + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); }; class OpCumprinc: public Normal @@ -182,6 +187,7 @@ public: virtual std::string GetBottom(void) { return "0"; } virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); virtual std::string BinFuncName(void) const { return "cumprinc"; } }; @@ -189,6 +195,7 @@ class OpAccrintm: public Normal { public: virtual std::string GetBottom(void) { return "0"; } + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "Accrintm"; } @@ -200,6 +207,7 @@ public: virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "Yield"; } + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); }; @@ -224,6 +232,7 @@ public: virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "Yieldmat"; } + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); }; class OpPMT: public Normal @@ -239,6 +248,7 @@ class OpPPMT: public Normal public: virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); virtual std::string BinFuncName(void) const { return "PPMT"; } }; @@ -248,6 +258,7 @@ public: virtual std::string GetBottom(void) { return "0";} virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); virtual std::string BinFuncName(void) const { return "Coupdaybs"; } }; @@ -258,6 +269,7 @@ public: virtual std::string GetBottom(void) { return "0";} virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); virtual std::string BinFuncName(void) const { return "Coupdays";} }; @@ -268,6 +280,7 @@ public: virtual std::string GetBottom(void) { return "0";} virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); virtual std::string BinFuncName(void) const { return "Coupdaysnc"; } }; @@ -279,6 +292,7 @@ public: virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "Received"; } + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); }; class OpYielddisc: public Normal @@ -287,6 +301,7 @@ public: virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "Yielddisc"; } + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); }; class OpTbillprice: public Normal @@ -295,6 +310,7 @@ public: virtual void GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "fTbillprice"; } + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); }; class OpPriceMat:public PriceMat @@ -324,6 +340,7 @@ public: const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "fTbillyield"; } + virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& ); }; class OpMIRR: public MIRR diff --git a/sc/source/core/opencl/opinlinefun_finacial.cxx b/sc/source/core/opencl/opinlinefun_finacial.cxx index bb5d3f2fccf6..05e6a5f0b1cf 100644 --- a/sc/source/core/opencl/opinlinefun_finacial.cxx +++ b/sc/source/core/opencl/opinlinefun_finacial.cxx @@ -13,7 +13,7 @@ std::string approxEqualDecl="bool approxEqual(double a, double b);\n"; std::string approxEqual = "bool approxEqual(double a, double b)\n" "{\n" - "\tif (a == b)\n" +" if (a == b)\n" "\t\treturn true;\n" "\tdouble x = a - b;\n" "\treturn (x < 0.0 ? -x : x) < ((a < 0.0 ? -a : a) * (1.0 / (16777216.0 *" @@ -48,6 +48,883 @@ std::string Round = "\tfValue = floor(fValue + 0.5 + nKorrVal[nIndex]);\n" "\treturn fValue;\n" "}\n"; + +std::string GetRmzDecl = +"double GetRmz( double fZins, double fZzr, double fBw, double fZw,int nF );\n"; + +std::string GetRmz= +"double GetRmz( double fZins, double fZzr, double fBw, double fZw, int nF )\n" +"{\n" + "\tdouble fRmz;\n" + "\tif( fZins == 0.0 )\n" + "\t\tfRmz = ( fBw + fZw ) / fZzr;\n" + "\telse\n" + "\t\t{\n" + "\t\t\tdouble fTerm = pow( 1.0 + fZins, fZzr );\n" + "\t\t\tif( nF > 0 )\n" + "\t\t\t\tfRmz = ( fZw * fZins / ( fTerm - 1.0 ) + fBw" + " * fZins / ( 1.0 - 1.0 / fTerm ) ) / ( 1.0 + fZins );\n" + "\t\t\telse\n" + "\t\t\t\tfRmz = fZw * fZins / ( fTerm - 1.0 ) + fBw * fZins /" + "( 1.0 - 1.0 / fTerm );\n" + "\t\t}\n" + "\treturn -fRmz;\n" +"}\n\n"; + +std::string GetZwDecl = +"double GetZw( double fZins, double fZzr, double fRmz, double fBw, int nF );\n"; + +std::string GetZw = +"double GetZw( double fZins, double fZzr, double fRmz, double fBw, int nF )\n" +"{\n" +" double fZw;\n" +" if( fZins == 0.0 )\n" +" fZw = fBw + fRmz * fZzr;\n" +" else\n" +" {\n" +" double fTerm = pow( 1.0 + fZins, fZzr );\n" +" if( nF > 0 )\n" +" fZw = fBw * fTerm + fRmz * ( 1.0 + fZins ) *" +"( fTerm - 1.0 ) / fZins;\n" +" else\n" +" fZw = fBw * fTerm + fRmz * ( fTerm - 1.0 ) / fZins;\n" +" }\n" +" return -fZw;\n" +"}\n\n"; + +std::string IsLeapYearDecl = +"bool IsLeapYear( int n );\n"; + +std::string IsLeapYear = +"bool IsLeapYear( int n )\n" +"{\n" + "return ( (( ( n % 4 ) == 0 ) && ( ( n % 100 ) != 0)) || ( ( n % 400 ) == 0 ) );\n" +"}\n"; + +std::string DaysInMonthDecl= +"int DaysInMonth( int nMonth, int nYear );\n"; + +std::string DaysInMonth = +"int DaysInMonth( int nMonth, int nYear )\n" +"{\n" + " int aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30,\n" + " 31, 31, 30, 31, 30, 31 };\n" +"\n" +" if ( nMonth != 2 )\n" +" return aDaysInMonth[nMonth-1];\n" +" else\n" +" {\n" +" if ( IsLeapYear(nYear) )\n" +" return aDaysInMonth[nMonth-1] + 1;\n" +" else\n" +" return aDaysInMonth[nMonth-1];\n" +" }\n" +"}\n"; + +std::string DaysToDateDecl = +"void DaysToDate( int nDays, int *rDay, int* rMonth, int* rYear );\n"; + +std::string DaysToDate = +"void DaysToDate( int nDays, int *rDay, int* rMonth, int* rYear )\n" +"{\n" +"\n" +" int nTempDays;\n" +" int i = 0;\n" +" bool bCalc;\n" + +" do\n" +" {\n" +" nTempDays = nDays;\n" +" *rYear = (int)((nTempDays / 365) - i);\n" +" nTempDays -= ((int) *rYear -1) * 365;\n" +" nTempDays -= (( *rYear -1) / 4) - (( *rYear -1) / 100) + ((*rYear -1) / 400);\n" +" bCalc = false;\n" +" if ( nTempDays < 1 )\n" +" {\n" +" i++;\n" +" bCalc = true;\n" +" }\n" +" else\n" +" {\n" +" if ( nTempDays > 365 )\n" +" {\n" +" if ( (nTempDays != 366) || !IsLeapYear( *rYear ) )\n" +" {\n" +" i--;\n" +" bCalc = true;\n" +" }\n" +" }\n" +" }\n" +" }\n" +" while ( bCalc );\n" + +" *rMonth = 1;\n" +" while ( (int)nTempDays > DaysInMonth( *rMonth, *rYear ) )\n" +" {\n" +" nTempDays -= DaysInMonth( *rMonth, *rYear );\n" +" *rMonth+=1;\n" +" }\n" +" *rDay = (int)nTempDays;\n" +"}\n"; + +std::string DateToDaysDecl= +"int DateToDays( int nDay, int nMonth, int nYear );\n"; + +std::string DateToDays= +"int DateToDays( int nDay, int nMonth, int nYear )\n" +"{\n" +" int nDays = ((int)nYear-1) * 365;\n" +" nDays += ((nYear-1) / 4) - ((nYear-1) / 100) + ((nYear-1) / 400);\n" + +" for( int i = 1; i < nMonth; i++ )\n" +" nDays += DaysInMonth(i,nYear);\n" +" nDays += nDay;\n" +"\n" +" return nDays;\n" +"}\n"; + +std::string GetNullDateDecl= +"int GetNullDate();\n"; + +std::string GetNullDate= +"int GetNullDate()\n" +"{\n" +" return DateToDays(30,12,1899 );\n" +"}\n"; + +std::string ScaDateDecl= +"void ScaDate( int nNullDate, int nDate, int nBase,int *nOrigDay, " +"int *nMonth,int *nYear,int *bLastDayMode,int *bLastDay," +"int *b30Days,int *bUSMode,int *nDay);\n"; + +std::string ScaDate= +"void ScaDate( int nNullDate, int nDate, int nBase,int *nOrigDay, " +"int *nMonth,int *nYear,int *bLastDayMode,int *bLastDay," +"int *b30Days,int *bUSMode,int *nDay)\n" +"{\n" +"DaysToDate( nNullDate + nDate, nOrigDay, nMonth, nYear );\n" +"*bLastDayMode = (nBase != 5);\n" +"*bLastDay = (*nOrigDay >= DaysInMonth( *nMonth, *nYear ));\n" +"*b30Days = (nBase == 0) || (nBase == 4);\n" +"*bUSMode = (nBase == 0);\n" + "if( *b30Days)\n" + "{\n" + "*nDay = min( *nOrigDay, 30);\n" + "if( *bLastDay || (*nDay >=DaysInMonth( *nMonth, *nYear )) )\n" + "*nDay = 30;\n" + "}\n" + "else\n" + "{\n" + "int nLastDay = DaysInMonth( *nMonth, *nYear );\n" + "*nDay = *bLastDay ? nLastDay : min( *nOrigDay, nLastDay );\n" + "}\n" +"}\n"; + +std::string addMonthsDecl= +"void addMonths(int b30Days,int bLastDay,int *nDay,int nOrigDay," +"int *nMonth,int nMonthCount,int *year);\n"; + +std::string addMonths= +"void addMonths(int b30Days,int bLastDay,int *nDay,int nOrigDay," +"int *nMonth,int nMonthCount,int *year)\n" +"{\n" + "int nNewMonth = nMonthCount + *nMonth;\n" + "if( nNewMonth > 12 )\n" + "{\n" + "--nNewMonth;\n" + "*year+=nNewMonth / 12 ;\n" + "*nMonth = ( nNewMonth % 12 ) + 1;\n" + "}\n" + "else if( nNewMonth < 1 )\n" + "{\n" + "*year+= nNewMonth / 12 - 1 ;\n" + "*nMonth = nNewMonth % 12 + 12 ;\n" + "}\n" + "else\n" + "*nMonth = nNewMonth ;\n" + "if( b30Days )\n" + "{\n" + "*nDay = min( nOrigDay, 30);\n" + "if( bLastDay || (*nDay >= DaysInMonth( *nMonth, *year )) )\n" + "*nDay = 30;\n" + "}\n" + "else\n" + "{\n" + "int nLastDay = DaysInMonth( *nMonth, *year );\n" + "*nDay = bLastDay ? nLastDay : min( nOrigDay, nLastDay );\n" + "}\n" +"}\n"; + +std::string getDaysInMonthRangeDecl= +"int getDaysInMonthRange( int nFrom, int nTo,int b30Days,int year);\n"; + +std::string getDaysInMonthRange= +"int getDaysInMonthRange( int nFrom, int nTo,int b30Days,int year)\n" +"{\n" + "if( nFrom > nTo )\n" + "return 0;\n" + "int nRet = 0;\n" + "if( b30Days )\n" + "nRet = (nTo - nFrom + 1) * 30;\n" + "else\n" + "{\n" + "for( int nMonthIx = nFrom; nMonthIx <= nTo; ++nMonthIx )\n" + "nRet += b30Days ? 30 : DaysInMonth( nMonthIx, year );\n" + "}\n" + "return nRet;\n" +"}\n"; + +std::string GetDaysInYearsDecl= +"int GetDaysInYears( int nYear1, int nYear2 );\n"; + +std::string GetDaysInYears= +"int GetDaysInYears( int nYear1, int nYear2 )\n" +"{\n" + "int nLeaps = 0;\n" + "for( int n = nYear1 ; n <= nYear2 ; n++ )\n" + "{\n" + "if( IsLeapYear( n ) )\n" + "nLeaps++;\n" + "}\n" + "int nSum = 1;\n" + "nSum += nYear2;\n" + "nSum -= nYear1;\n" + "nSum *= 365;\n" + "nSum += nLeaps;\n" + "return nSum;\n" +"}\n"; + +std::string GetDaysInYearDecl= +"int GetDaysInYear( int nNullDate, int nDate, int nMode );\n"; + +std::string GetDaysInYear= +"int GetDaysInYear( int nNullDate, int nDate, int nMode )\n" +"{\n" +"switch( nMode )\n" +"{\n" +"case 0:\n" +"case 2:\n" +"case 4:\n" + "return 360;\n" +"case 1:\n" + "{\n" + "int nD=0, nM=0, nY=0;\n" + "nDate += nNullDate;\n" + "DaysToDate( nDate, &nD, &nM, &nY );\n" + "return IsLeapYear( nY )? 366 : 365;\n" + "}\n" +"case 3:\n" + "return 365;\n" +"}\n" +"}\n"; + +std::string getDaysInYearRangeDecl = +"int getDaysInYearRange( int nFrom, int nTo,int b30Days );\n"; + +std::string getDaysInYearRange= +"int getDaysInYearRange( int nFrom, int nTo,int b30Days )\n" +"{\n" + "if( nFrom > nTo )\n" + "return 0;\n" + "return b30Days ? ((nTo - nFrom + 1) * 360) : GetDaysInYears( nFrom, nTo );\n" +"}\n"; + + +std::string getDiffDecl= +"int getDiff(int rFrom,int rTo,int fDay,int fMonth,int fYear,int fbLastDayMode,int fbLastDay," +"int fb30Days,int fbUSMode,int fnDay,""int tDay,int tMonth,int tYear,int tbLastDayMode," +"int tbLastDay,int tb30Days,int tbUSMode,int tnDay);\n"; + + +std::string getDiff= +"int getDiff(int rFrom,int rTo,int fDay,int fMonth,int fYear,int fbLastDayMode,int fbLastDay," +"int fb30Days,int fbUSMode,int fnDay,""int tDay,int tMonth,int tYear,int tbLastDayMode," +"int tbLastDay,int tb30Days,int tbUSMode,int tnDay)\n" +"{\n" +"if(rFrom>rTo)\n" +"{\n" +"int d=fDay;fDay=tDay;tDay=d;\n" +"int m=fMonth;fMonth=tMonth;tMonth=m;\n" +"int y=fYear;fYear=tYear;tYear=y;\n" +"int a=fbLastDayMode;fbLastDayMode=tbLastDayMode;tbLastDayMode=a;\n" +"int b=fbLastDay;fbLastDay=tbLastDay;tbLastDay=b;\n" +"int c=fb30Days;fb30Days=tb30Days;tb30Days=c;\n" +"int e=fbUSMode;fbUSMode=tbUSMode;tbUSMode=e;\n" +"int f=fnDay;fnDay=tnDay;tnDay=f;\n" +"}\n" +"int nDiff=0;\n" +"if( tb30Days )\n" +"{\n" +"if( tbUSMode )\n" +"{\n" + "if( ((fMonth == 2) || (fnDay < 30)) && (tDay == 31) )\n" + "tnDay = 31;\n" + "else if( (tMonth == 2) && tbLastDay )\n" + "tnDay = DaysInMonth( 2, tYear );\n" +"}\n" +"else\n" +"{\n" + "if( (fMonth == 2) && (fnDay == 30) )\n" + "fnDay = DaysInMonth( 2, fYear );\n" + "if( (tMonth == 2) && (tnDay == 30) )\n" + "tnDay = DaysInMonth( 2, tYear );\n" +"}\n" +"}\n" +"if( (fYear < tYear) || ((fYear == tYear) && (fMonth < tMonth)) )\n" +"{\n" +"nDiff = (fb30Days? 30:DaysInMonth(fMonth,fYear) )- fnDay + 1;\n" +"fDay = fnDay = 1;\n" +"fbLastDay = 0;\n" +"addMonths(fb30Days,fbLastDay,&fnDay,fDay,&fMonth,1,&fYear);\n" +"if( fYear < tYear )\n" +"{\n" + "nDiff += getDaysInMonthRange( fMonth, 12,fb30Days,fYear);\n" + "addMonths(fb30Days,fbLastDay,&fnDay,fDay,&fMonth,13-fMonth,&fYear);\n" + "nDiff += getDaysInYearRange( fYear, tYear - 1,fb30Days);\n" + "fYear+=tYear - fYear;\n" +"}\n" +"nDiff += getDaysInMonthRange(fMonth, tMonth - 1,fb30Days ,fYear );\n" +"addMonths(fb30Days,fbLastDay,&fnDay,fDay,&fMonth,tMonth-fMonth,&fYear);\n" +"}\n" +"nDiff += tnDay - fnDay;\n" +"return nDiff > 0 ? nDiff : 0;\n" +"}\n"; + + + +std::string lcl_GetcoupdaybsDecl= +"int lcl_Getcoupdaybs(int nNullDate,int nSettle, int nMat,int nFreq,int nBase);\n"; + + +std::string lcl_Getcoupdaybs= +"int lcl_Getcoupdaybs(int nNullDate,int nSettle, int nMat,int nFreq,int nBase)\n" +"{\n" + "int aDate = nMat;\n" + "int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0, mYear=0;int sDay=0,sMonth=0," + "sYear=0;\n" + "int rbLastDayMode=0, rbLastDay=0,rb30Days=0,rbUSMode=0,rnDay=0;\n" + "int sbLastDayMode=0, sbLastDay=0,sb30Days=0,sbUSMode=0,snDay=0;\n" + "ScaDate( nNullDate,aDate,nBase,&rDay,&rMonth,&rYear,&rbLastDayMode,&rbLastDay," + "&rb30Days,&rbUSMode,&rnDay);\n" + "ScaDate( nNullDate,nSettle,nBase,&sDay,&sMonth,&sYear,&sbLastDayMode,&sbLastDay," + "&sb30Days,&sbUSMode,&snDay);\n" + "rYear= sYear;\n" + "nSettle=nSettle+nNullDate;\n" + "aDate=DateToDays( rDay,rMonth,rYear );\n" + "if( aDate < nSettle )\n" + "{\n" + "rYear+= 1;\n" + "aDate=DateToDays( rDay,rMonth,rYear );\n" + "}\n" + "while(aDate > nSettle )\n" + "{\n" + "addMonths(rb30Days,rbLastDay,&rnDay,rDay,&rMonth,-1*(12/nFreq),&rYear);\n" + "aDate=DateToDays( rDay,rMonth,rYear );\n" + "}\n" + "return getDiff( aDate, nSettle, rDay, rMonth, rYear, rbLastDayMode, rbLastDay, rb30Days," + "rbUSMode, rnDay,\n" + "sDay, sMonth, sYear, sbLastDayMode, sbLastDay, sb30Days, sbUSMode, snDay);\n" +"}\n"; + +std::string lcl_GetcoupdaysDecl= +"int lcl_Getcoupdays(int nNullDate,int nSettle, int nMat,int nFreq,int nBase);\n"; + +std::string lcl_Getcoupdays= +"int lcl_Getcoupdays(int nNullDate,int nSettle, int nMat,int nFreq,int nBase)\n" +"{\n" + "int aDate = nMat;\n" + "int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0, mYear=0;int sDay=0," + "sMonth=0, sYear=0;\n" + "int rbLastDayMode=0, rbLastDay=0,rb30Days=0,rbUSMode=0,rnDay=0;\n" + "int sbLastDayMode=0, sbLastDay=0,sb30Days=0,sbUSMode=0,snDay=0;\n" + "ScaDate( nNullDate,aDate,nBase,&rDay,&rMonth,&rYear," + "&rbLastDayMode,&rbLastDay,&rb30Days,&rbUSMode,&rnDay);\n" + "ScaDate( nNullDate,nSettle,nBase,&sDay,&sMonth,&sYear," + "&sbLastDayMode,&sbLastDay,&sb30Days,&sbUSMode,&snDay);\n" + "rYear= sYear;\n" + "nSettle=nSettle+nNullDate;\n" + "aDate=DateToDays( rDay,rMonth,rYear );\n" + "if( aDate < nSettle )\n" + "{ \n" + "rYear+= 1;\n" + "aDate=DateToDays( rDay,rMonth,rYear );\n" + "}\n" + "while(aDate > nSettle )\n" + "{\n" + "addMonths(rb30Days,rbLastDay,&rnDay,rDay,&rMonth,-1*(12/nFreq),&rYear);\n" + "aDate=DateToDays( rDay,rMonth,rYear );\n" + "}\n" + "int aNextDate=aDate;int aDay=rDay,aMonth=rMonth, aYear=rYear;\n" + "int abLastDayMode=rbLastDayMode, abLastDay=rbLastDay," + "ab30Days=rb30Days,abUSMode=rbUSMode,anDay=rnDay;\n" + "addMonths(ab30Days,abLastDay,&anDay,aDay,&aMonth,12/nFreq,&aYear);\n" + "return getDiff( aDate, aNextDate, rDay, rMonth, rYear, rbLastDayMode," + "rbLastDay, rb30Days, rbUSMode, rnDay,\n" + "aDay, aMonth, aYear, abLastDayMode, abLastDay, ab30Days, abUSMode, anDay);\n" +"}\n"; + + +std::string lcl_GetcoupnumDecl= +"int lcl_Getcoupnum(int nNullDate,int nSettle, int nMat,int nFreq);\n"; + +std::string lcl_Getcoupnum= +"int lcl_Getcoupnum(int nNullDate,int nSettle, int nMat,int nFreq)\n" +"{\n" + "int aDate = nMat;int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0, mYear=0;\n" + "int sDay=0,sMonth=0, sYear=0;\n" + "DaysToDate(aDate+nNullDate,&rDay, &rMonth, &rYear );\n" + "DaysToDate(nMat+nNullDate,&mDay, &mMonth, &mYear );\n" + "DaysToDate(nSettle+nNullDate,&sDay, &sMonth, &sYear );\n" + "rYear= sYear;\n" + "nSettle=nSettle+nNullDate;\n" + "aDate=DateToDays( rDay,rMonth,rYear );\n" + "if( aDate < nSettle )\n" + "rYear+= 1;\n" + "int d=DateToDays( rDay,rMonth,rYear );\n" + "int nMonthCount=-1*(12 / nFreq);\n" + "while(d > nSettle )\n" + "{\n" + "int nNewMonth = nMonthCount + rMonth;\n" + "if( nNewMonth > 12 )\n" + "{\n" + "--nNewMonth;\n" + "rYear+=nNewMonth / 12;\n" + "rMonth = nNewMonth % 12 + 1;\n" + "}\n" + "else if( nNewMonth < 1 )\n" + "{\n" + "rYear+= nNewMonth / 12 - 1;\n" + "rMonth = nNewMonth % 12 + 12;\n" + "}\n" + "else\n" + "rMonth = nNewMonth;\n" + "d=DateToDays( rDay,rMonth,rYear );\n" + "}\n" + "int n=(mYear-rYear)*12+mMonth-rMonth;\n" + "n=n*nFreq/12;\n" + "return n;\n" +"}\n"; + +std::string coupdaysDecl= +"double coupdays(int nSettle,int nMat,int nFreq,int nBase);\n"; + + +std::string coupdays= +"double coupdays(int nSettle,int nMat,int nFreq,int nBase)\n" +"{\n" + "int nNullDate=GetNullDate();\n" + "if( nBase == 1 )\n" + "return lcl_Getcoupdays(nNullDate, nSettle, nMat,nFreq, nBase);\n" + "else\n" + "return (double)GetDaysInYear(0,0,nBase)/nFreq;\n" +"}\n"; + +std::string coupdaybsDecl= +"double coupdaybs( int nSettle,int nMat,int nFreq,int nBase);\n"; + +std::string coupdaybs= +"double coupdaybs( int nSettle,int nMat,int nFreq,int nBase)\n" +"{\n" + "int nNullDate=GetNullDate();\n" + "return lcl_Getcoupdaybs(nNullDate, nSettle, nMat,nFreq, nBase);\n" +"}\n"; + +std::string coupdaysncDecl= +"double coupdaysnc( int nSettle,int nMat,int nFreq,int nBase);\n"; + + +std::string coupdaysnc= +"double coupdaysnc( int nSettle,int nMat,int nFreq,int nBase)\n" +"{\n" +"int nNullDate=GetNullDate();\n" +"if((nBase != 0) && (nBase != 4))\n" +"{\n" + "int aDate = nMat;\n" + "int rDay=0,rMonth=0, rYear=0;int mDay=0,mMonth=0," + "mYear=0;int sDay=0,sMonth=0, sYear=0;\n" + "int rbLastDayMode=0, rbLastDay=0,rb30Days=0,rbUSMode=0,rnDay=0;\n" + "int sbLastDayMode=0, sbLastDay=0,sb30Days=0,sbUSMode=0,snDay=0;\n" + "ScaDate( nNullDate,aDate,nBase,&rDay,&rMonth,&rYear," + "&rbLastDayMode,&rbLastDay,&rb30Days,&rbUSMode,&rnDay);\n" + "ScaDate( nNullDate,nSettle,nBase,&sDay,&sMonth,&sYear," + "&sbLastDayMode,&sbLastDay,&sb30Days,&sbUSMode,&snDay);\n" + "rYear= sYear;\n" + "nSettle=nSettle+nNullDate;\n" + "aDate=DateToDays( rDay,rMonth,rYear );\n" + "if( aDate > nSettle )\n" + "{\n" + "rYear-= 1;\n" + "aDate=DateToDays( rDay,rMonth,rYear );\n" +"}\n" +"while(aDate <= nSettle )\n" +"{\n" + "addMonths(rb30Days,rbLastDay,&rnDay,rDay,&rMonth,12/nFreq,&rYear);\n" + "aDate=DateToDays( rDay,rMonth,rYear );\n" +"}\n" +"return getDiff( nSettle, aDate, sDay, sMonth, sYear, " +"sbLastDayMode, sbLastDay, sb30Days, sbUSMode, snDay,\n" + "rDay, rMonth, rYear, rbLastDayMode, rbLastDay, rb30Days, rbUSMode, rnDay);\n" +"}\n" +"else\n" + "return coupdays(nSettle,nMat,nFreq,nBase)- coupdaybs( nSettle,nMat,nFreq,nBase);\n" +"}\n"; + +std::string coupnumDecl= +"double coupnum( int nSettle,int nMat,int nFreq,int nBase);\n"; + +std::string coupnum= +"double coupnum( int nSettle,int nMat,int nFreq,int nBase)\n" +"{\n" + "int nNullDate=GetNullDate();\n" + "return lcl_Getcoupnum(nNullDate,nSettle,nMat,nFreq);\n" +"}\n"; + +std::string getPrice_Decl= +"double getPrice_(int nSettle, int nMat, double fRate, double fYield,\n" + "double fRedemp, int nFreq, int nBase );\n"; + + +std::string getPrice_= +"double getPrice_(int nSettle, int nMat, double fRate, double fYield,\n" + "double fRedemp, int nFreq, int nBase )\n" +"{\n" + "double fFreq = nFreq;\n" + "double fE = coupdays( nSettle, nMat, nFreq, nBase );\n" + "double fDSC_E = coupdaysnc( nSettle, nMat, nFreq, nBase ) / fE;\n" + "double fN = coupnum( nSettle, nMat, nFreq, nBase );\n" + "double fA = coupdaybs( nSettle, nMat, nFreq, nBase );\n" + "double fRet = fRedemp / ( pow( 1.0 + fYield / fFreq, fN - 1.0 + fDSC_E ) );\n" + "fRet -= 100.0 * fRate / fFreq * fA / fE;\n" + "double fT1 = 100.0 * fRate / fFreq;\n" + "double fT2 = 1.0 + fYield / fFreq;\n" + "for( double fK = 0.0 ; fK < fN ; fK+=1.0 )\n" + "fRet += fT1 / pow( fT2, fK + fDSC_E );\n" +"return fRet;\n" +"}\n"; + +std::string getYield_Decl= +"double getYield_( int nNullDate, int nSettle, int nMat, double fCoup," +"double fPrice,double fRedemp, int nFreq, int nBase);\n"; + +std::string getYield_= +"double getYield_( int nNullDate, int nSettle, int nMat, double fCoup," +"double fPrice,double fRedemp, int nFreq, int nBase )\n" +"{\n" + "double fRate = fCoup;\n" + "double fPriceN = 0.0;\n" + "double fYield1 = 0.0;\n" + "double fYield2 = 1.0;\n" + "double fPrice1 = getPrice_(nSettle, nMat, fRate, fYield1, fRedemp, nFreq, nBase );\n" + "double fPrice2 = getPrice_(nSettle, nMat, fRate, fYield2, fRedemp, nFreq, nBase );\n" + "double fYieldN = ( fYield2 - fYield1 ) * 0.5;\n" + "for( unsigned int nIter = 0 ; nIter < 100 && fPriceN != fPrice ; nIter++ )\n" + "{\n" + "fPriceN = getPrice_(nSettle, nMat, fRate, fYieldN, fRedemp, nFreq, nBase );\n" + "if( fPrice == fPrice1 )\n" + "return fYield1;\n" + "else if( fPrice == fPrice2 )\n" + "return fYield2;\n" + "else if( fPrice == fPriceN )\n" + "return fYieldN;\n" + "else if( fPrice < fPrice2 )\n" + "{\n" + "fYield2 *= 2.0;\n" + "fPrice2 = getPrice_(nSettle, nMat, fRate, fYield2, fRedemp, nFreq, nBase );\n" + "fYieldN = ( fYield2 - fYield1 ) * 0.5;\n" + "}\n" + "else\n" + "{\n" + "if( fPrice < fPriceN )\n" + "{\n" + "fYield1 = fYieldN;\n" + "fPrice1 = fPriceN;\n" + "}\n" + "else\n" + "{\n" + "fYield2 = fYieldN;\n" + "fPrice2 = fPriceN;\n" + "}\n" + "fYieldN = fYield2 - ( fYield2 - fYield1 ) * " + "( ( fPrice - fPrice2 ) / ( fPrice1 - fPrice2 ) );\n" + "}\n" + "}\n" + "return fYieldN;\n" +"}\n"; + +std::string GetYearFracDecl= +"double GetYearFrac( int nNullDate, int nStartDate, int nEndDate, int nMode );\n"; + +std::string GetYearFrac= +"double GetYearFrac( int nNullDate, int nStartDate, int nEndDate, int nMode ) \n" +"{\n" +" if( nStartDate == nEndDate )\n" +" return 0.0; \n" + + " if( nStartDate > nEndDate )\n" + " {\n" + " int n = nEndDate;\n" + " nEndDate = nStartDate;\n" + " nStartDate = n;\n" + " }\n" + + " int nDate1 = nStartDate + nNullDate;\n" + " int nDate2 = nEndDate + nNullDate;\n" + + " int nDay1, nDay2;\n" + " int nMonth1, nMonth2;\n" + " int nYear1, nYear2;\n" + " DaysToDate( nDate1, &nDay1, &nMonth1, &nYear1 );\n" + " DaysToDate( nDate2, &nDay2, &nMonth2, &nYear2 );\n" + " int nDayDiff;\n" + " switch( nMode )\n" + " {\n" + " case 0: \n" + " if ( nDay1 == 31 )\n" + " {\n" + " nDay1--;\n" + " }\n" + " if ( nDay1 == 30 && nDay2 == 31 )\n" + " {\n" + " nDay2--;\n" + " }\n" + " else\n" + " {\n" + " if ( nMonth1 == 2 && nDay1 == ( IsLeapYear( nYear1 ) ? 29 : 28 ) )\n" + " {\n" + " nDay1 = 30;\n" + " if ( nMonth2 == 2 && nDay2 == ( IsLeapYear( nYear2 ) ? 29 : 28 ) )\n" + " {\n" + " nDay2 = 30;\n" + " }\n" + " }\n" + " }\n" + " nDayDiff = ( nYear2 - nYear1 ) * 360 + " + "( nMonth2 - nMonth1 ) * 30 + ( nDay2 - nDay1 );\n" + " break;\n" + " case 1: \n" + " case 2: \n" + " case 3: \n" + " nDayDiff = nDate2 - nDate1;\n" + " break;\n" + " case 4: \n" + " if ( nDay1 == 31 )\n" + " {\n" + " nDay1--;\n" + " }\n" + " if ( nDay2 == 31 )\n" + " {\n" + " nDay2--;\n" + " }\n" + " nDayDiff = ( nYear2 - nYear1 ) * 360 + " + "( nMonth2 - nMonth1 ) * 30 + ( nDay2 - nDay1 );\n" + " break;\n" + " }\n" + + " double nDaysInYear;\n" + " switch( nMode )\n" + " {\n" + " case 0: \n" + " case 2: \n" + " case 4: \n" + " nDaysInYear = 360;\n" + " break;\n" + " case 1: \n" + " {\n" + " bool isYearDifferent = ( nYear1 != nYear2 );\n" + " if ( isYearDifferent &&\n" + " ( ( nYear2 != nYear1 + 1 ) ||\n" + " ( nMonth1 < nMonth2 ) ||\n" + " ( nMonth1 == nMonth2 && nDay1 < nDay2 ) ) )\n" + " {\n" + " int nDayCount = 0;\n" + " for ( int i = nYear1; i <= nYear2; i++ )\n" + " nDayCount += ( IsLeapYear( i ) ? 366 : 365 );\n" + " nDaysInYear = ( double ) nDayCount / ( double ) ( nYear2 - nYear1 + 1 );\n" + " }\n" + " else\n" + " {\n" + " if ( isYearDifferent && IsLeapYear( nYear1 ) )\n" + " {\n" + " nDaysInYear = 366;\n" + " }\n" + " else\n" + " {\n" + " if ( ( IsLeapYear( nYear1 ) && nMonth1 <= 2 && nDay1 <= 29 ) ||\n" + " ( IsLeapYear( nYear2 ) && ( nMonth2 > 3 || " + "( nMonth2 == 2 && nDay1 == 29 ) ) ) )\n" + " {\n" + " nDaysInYear = 366;\n" + " }\n" + " else\n" + " {\n" + " nDaysInYear = 365;\n" + " for ( int i = nYear1; i <= nYear2; i++ )\n" + " {\n" + " if ( IsLeapYear( i ) )\n" + " {\n" + " nDaysInYear = 366;\n" + " break;\n" + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + " break;\n" + " case 3: \n" + " nDaysInYear = 365;\n" + " break;\n" + " }\n" + " return (double)( nDayDiff ) / (nDaysInYear);\n" +"}\n"; + + +std::string GetYieldmatDecl= + "double GetYieldmat( int nNullDate, int nSettle, int nMat, int nIssue,\n" + "double fRate, double fPrice, int nBase );\n"; + + +std::string GetYieldmat= + "double GetYieldmat( int nNullDate, int nSettle, int nMat, int nIssue,\n" + "double fRate, double fPrice, int nBase )\n" + "{\n" + "double fIssMat = GetYearFrac( nNullDate, nIssue, nMat, nBase );\n" + "double fIssSet = GetYearFrac( nNullDate, nIssue, nSettle, nBase );\n" + "double fSetMat = GetYearFrac( nNullDate, nSettle, nMat, nBase );\n" + "double y = 1.0 + fIssMat * fRate;\n" + "y /= fPrice / 100.0 + fIssSet * fRate;\n" + "y-=1.0;\n" + "y /= fSetMat;\n" + "return y;\n" + "}\n"; + +std::string GetDiffDateDecl= +"int GetDiffDate( int nNullDate, int nStartDate, int nEndDate, int nMode," +" int* pOptDaysIn1stYear );\n"; + +std::string GetDiffDate= +"int GetDiffDate( int nNullDate, int nStartDate, int nEndDate, int nMode," +" int* pOptDaysIn1stYear )\n" +"{\n" +"\t bool bNeg = nStartDate > nEndDate;\n" + +"\t if( bNeg )\n" +"\t {\n" +"\t\t int n = nEndDate;\n" +"\t\t nEndDate = nStartDate;\n" +"\t\t nStartDate = n;\n" +"\t }\n" +"\t int nRet;\n" +"\t switch( nMode )\n" +"\t {\n" +"\t\t case 0: \n" +"\t\t case 4: \n" +"\t\t {\n" +"\t\t\t int nD1, nM1, nY1, nD2, nM2, nY2;\n" +"\t\t\t nStartDate += nNullDate;\n" +"\t\t\t nEndDate += nNullDate;\n" +"\t\t\t DaysToDate( nStartDate, &nD1, &nM1, &nY1 );\n" +"\t\t\t DaysToDate( nEndDate, &nD2, &nM2, &nY2 );\n" +"\t\t\t bool bLeap = IsLeapYear( nY1 );\n" +"\t\t\t int nDays, nMonths;\n" +"\t\t\t nMonths = nM2 - nM1;\n" +"\t\t\t nDays = nD2 - nD1;\n" +"\t\t\t nMonths += ( nY2 - nY1 ) * 12;\n" +"\t\t\t nRet = nMonths * 30 + nDays;\n" +"\t\t\t if( nMode == 0 && nM1 == 2 && nM2 != 2 && nY1 == nY2 )\n" +"\t\t\t\t nRet -= bLeap? 1 : 2;\n" +"\t\t\t if( pOptDaysIn1stYear )\n" +"\t\t\t\t *pOptDaysIn1stYear = 360;\n" +"\t\t }\n" +"\t\t\t break;\n" +"\t\t case 1: \n" +"\t\t\t if( pOptDaysIn1stYear )\n" +"\t\t\t {\n" +"\t\t\t\t int nD, nM, nY;\n" +"\t\t\t\t DaysToDate( nStartDate + nNullDate, &nD, &nM, &nY );\n" +"\t\t\t\t *pOptDaysIn1stYear = IsLeapYear( nY )? 366 : 365;\n" +"\t\t\t }\n" +"\t\t\t nRet = nEndDate - nStartDate;\n" +"\t\t\t break;\n" +"\t\t case 2: \n" +"\t\t\t nRet = nEndDate - nStartDate;\n" +"\t\t\t if( pOptDaysIn1stYear )\n" +"\t\t\t\t *pOptDaysIn1stYear = 360;\n" +"\t\t\t break;\n" +"\t\t case 3: \n" +"\t\t\t nRet = nEndDate - nStartDate;\n" +"\t\t\t if( pOptDaysIn1stYear )\n" +"\t\t\t\t *pOptDaysIn1stYear = 365;\n" +"\t\t\t break;\n" +"\t }\n" +"\t return bNeg? -nRet : nRet;\n" +"}\n"; + +std::string GetYearDiffDecl= +"double GetYearDiff( int nNullDate, int nStartDate, int nEndDate, int nMode);\n"; + +std::string GetYearDiff= +"double GetYearDiff( int nNullDate, int nStartDate, int nEndDate, int nMode )\n" +"{\n" +"\t int nDays1stYear;\n" +"\t int nTotalDays = GetDiffDate( nNullDate, nStartDate," +"nEndDate, nMode, &nDays1stYear );\n" +"\t double result=(double)(nTotalDays)/(nDays1stYear);\n" +"\treturn result;\n" +"}\n"; + +std::string GetDiffDate360_Decl= +"int GetDiffDate360_(\n" +" int nDay1, int nMonth1, int nYear1, bool bLeapYear1,\n" +" int nDay2, int nMonth2, int nYear2,\n" +" bool bUSAMethod );\n"; + +std::string GetDiffDate360_= +"int GetDiffDate360_(\n" +" int nDay1, int nMonth1, int nYear1, bool bLeapYear1,\n" +" int nDay2, int nMonth2, int nYear2,\n" +" bool bUSAMethod )\n" +"{\n" +" if( nDay1 == 31 )\n" +" nDay1--;\n" +" else if( bUSAMethod && ( nMonth1 == 2 && ( nDay1 == 29 ||" +"( nDay1 == 28 && !bLeapYear1 ) ) ) )\n" +" nDay1 = 30;\n" +" if( nDay2 == 31 )\n" +" {\n" +" if( bUSAMethod && nDay1 != 30 )\n" +" {\n" +" nDay2 = 1;\n" +" if( nMonth2 == 12 )\n" +" {\n" +" nYear2++;\n" +" nMonth2 = 1;\n" +" }\n" +" else\n" +" nMonth2++;\n" +" }\n" +" else\n" +" nDay2 = 30;\n" +" }\n" +" return nDay2 + nMonth2 * 30 + nYear2 * 360 - nDay1 - nMonth1 * 30 - nYear1 * 360;\n" +"}\n"; + +std::string GetDiffDate360Decl= +"int GetDiffDate360( int nNullDate, int nDate1, int nDate2, bool bUSAMethod);\n"; + + +std::string GetDiffDate360= +"int GetDiffDate360( int nNullDate, int nDate1, int nDate2, bool bUSAMethod )\n" +"{\n" +" nDate1 += nNullDate;\n" +" nDate2 += nNullDate;\n" +" int nDay1, nMonth1, nYear1, nDay2, nMonth2, nYear2;\n" +" DaysToDate( nDate1, &nDay1, &nMonth1, &nYear1 );\n" +" DaysToDate( nDate2, &nDay2, &nMonth2, &nYear2 );\n" +" return GetDiffDate360_( nDay1, nMonth1, nYear1, " +"IsLeapYear( nYear1 ), nDay2, nMonth2, nYear2, bUSAMethod );\n" +"}\n"; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |