Update of /cvsroot/quantlibaddin/QuantLibAddin/Addins/Calc
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv31052/Addins/Calc
Modified Files:
Tag: R000313f0-branch
Makefile.am calcutils.hpp conversions.cpp conversions.hpp
Log Message:
extend support for calc
Index: conversions.cpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/Addins/Calc/conversions.cpp,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -C2 -d -r1.1 -r1.1.2.1
*** conversions.cpp 29 Jul 2006 15:32:31 -0000 1.1
--- conversions.cpp 6 Aug 2006 19:27:20 -0000 1.1.2.1
***************
*** 17,24 ****
#include <Addins/Calc/conversions.hpp>
- QuantLib::Date calcToLib(const sal_Int32 &date) {
- return QuantLib::Date(date);
}
--- 17,119 ----
#include <Addins/Calc/conversions.hpp>
+ #include <Addins/Calc/calcutils.hpp>
+ #include <qlo/calendar.hpp>
+ #include <qlo/typefactory.hpp>
+ #include <oh/objecthandler.hpp>
+
+ void calcToLib(QuantLib::Date &ret, const sal_Int32 &date) {
+ ret = QuantLib::Date(date);
+ }
+
+ void calcToLib(QuantLib::Calendar &ret, const STRING &id2) {
+ std::string id = ouStringToStlString(id2);
+ if (QuantLibAddin::Create<QuantLib::Calendar>().checkType(id)) {
+ ret = QuantLibAddin::Create<QuantLib::Calendar>()(id);
+ } else {
+ OH_GET_REFERENCE(calendarPointer, id,
+ QuantLibAddin::JointCalendar, QuantLib::Calendar)
+ ret = *calendarPointer.get();
+ }
+ }
+
+ void calcToLib(QuantLib::Period &ret, const STRING &id) {
+ }
+
+ void calcToVectorLib(std::vector<QuantLib::Date> &ret,
+ const SEQSEQ(sal_Int32) &in) {
+ for (int i=0; i<in.getLength(); i++)
+ for (int j=0; j<in[i].getLength(); j++)
+ ret.push_back(QuantLib::Date(in[i][j]));
}
+ void calcToVectorLib(QuantLib::Array &ret, const SEQSEQ(double) &in) {
+ }
+
+ void calcToVectorLib(std::vector<std::string> &ret, const SEQSEQ(ANY) &in) {
+ }
+
+ void calcToVectorLib(std::vector<long> &ret, const SEQSEQ(sal_Int32) &in) {
+ }
+
+ void calcToVectorLib(std::vector<bool> &ret, const SEQSEQ(sal_Int32) &in) {
+ }
+
+ void calcToVectorLib(std::vector<QuantLib::Period> &ret, const SEQSEQ(ANY) &in) {
+ }
+
+ QuantLib::Matrix calcToQlMatrix(const SEQSEQ(double) &in) {
+ int rows = in.getLength();
+ int cols;
+ if (rows)
+ cols = in[0].getLength();
+ else
+ cols = 0;
+ QuantLib::Matrix m(rows, cols);
+ for (int i=0; i<rows; i++) {
+ SEQ(double) row = in[i];
+ for (int j=0; j<cols; j++) {
+ m[i][j] = row[j];
+ }
+ }
+ return m;
+ }
+
+
+ void scalarToCalcLib(sal_Int32 &ret, const QuantLib::Date &in) {
+ ret = in.serialNumber();
+ }
+
+ void scalarToCalcLib(double &ret, const QuantLib::Real &in) {
+ ret = in;
+ }
+
+ void vectorToCalcLib(SEQSEQ(sal_Int32) &ret, const std::vector<QuantLib::Date> &v) {
+ ret.realloc(v.size());
+ for (unsigned int i=0; i<v.size(); i++) {
+ SEQ(sal_Int32) s(1);
+ s[0] = v[i].serialNumber();
+ ret[i] = s;
+ }
+ }
+
+ void vectorToCalcLib(SEQSEQ(double) &ret, const QuantLib::Array &in) {
+ ret.realloc(in.size());
+ for (unsigned int i=0; i<in.size(); i++) {
+ SEQ(double) s(1);
+ s[0] = in[i];
+ ret[i] = s;
+ }
+ }
+
+ void matrixToCalcLib(SEQSEQ(double) &ret, const QuantLib::Matrix &in) {
+ ret.realloc(in.rows());
+ for (unsigned int i=0; i<in.rows(); i++) {
+ SEQ(double) s(in.columns());
+ for (unsigned int j=0; j<in.columns(); j++) {
+ s[j] = in[i][j];
+ }
+ ret[i] = s;
+ }
+ }
Index: conversions.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/Addins/Calc/conversions.hpp,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -C2 -d -r1.1 -r1.1.2.1
*** conversions.hpp 29 Jul 2006 15:32:31 -0000 1.1
--- conversions.hpp 6 Aug 2006 19:27:20 -0000 1.1.2.1
***************
*** 20,26 ****
#include <ql/date.hpp>
#include <sal/types.h>
! QuantLib::Date calcToLib(const sal_Int32&);
#endif
--- 20,45 ----
#include <ql/date.hpp>
+ #include <ql/calendar.hpp>
+ #include <ql/Math/matrix.hpp>
+ #include <Addins/Calc/qldefs.hpp>
#include <sal/types.h>
+ #include <vector>
! void calcToLib(QuantLib::Date &, const sal_Int32&);
! void calcToLib(QuantLib::Calendar &, const STRING &id);
! void calcToLib(QuantLib::Period &, const STRING &id);
! void calcToVectorLib(std::vector<QuantLib::Date> &, const SEQSEQ(sal_Int32) &);
! void calcToVectorLib(QuantLib::Array &, const SEQSEQ(double) &);
! void calcToVectorLib(std::vector<std::string> &, const SEQSEQ(ANY) &);
! void calcToVectorLib(std::vector<long> &, const SEQSEQ(sal_Int32) &);
! void calcToVectorLib(std::vector<bool> &, const SEQSEQ(sal_Int32) &);
! void calcToVectorLib(std::vector<QuantLib::Period> &, const SEQSEQ(ANY) &);
! QuantLib::Matrix calcToQlMatrix(const SEQSEQ(double) &);
!
! void scalarToCalcLib(sal_Int32 &, const QuantLib::Date &);
! void scalarToCalcLib(double &, const QuantLib::Real &);
! void vectorToCalcLib(SEQSEQ(sal_Int32) &, const std::vector<QuantLib::Date> &);
! void vectorToCalcLib(SEQSEQ(double) &, const QuantLib::Array &);
! void matrixToCalcLib(SEQSEQ(double) &, const QuantLib::Matrix &);
#endif
Index: Makefile.am
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/Addins/Calc/Makefile.am,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** Makefile.am 5 Aug 2006 15:44:44 -0000 1.1.2.2
--- Makefile.am 6 Aug 2006 19:27:20 -0000 1.1.2.3
***************
*** 1,6 ****
- OFFICE_SDK_PATH=/opt/openoffice.org2.0_sdk
- OFFICE_PROGRAM_PATH=/usr/lib/openoffice.org2.0/program
- # -DCPPU_ENV=gcc3
AM_CPPFLAGS = -I${top_srcdir} -I$(OFFICE_SDK_PATH)/include \
-DUNX -DGCC -DLINUX -DCPPU_ENV=gcc3
--- 1,3 ----
***************
*** 64,72 ****
--- 61,81 ----
if BUILD_CALC
noinst_HEADERS = \
+ bonds.hpp \
calcutils.hpp \
+ calendar.hpp \
+ capfloor.hpp \
+ capletvolstructure.hpp \
conversions.hpp \
+ couponvectors.hpp \
+ date.hpp \
exercise.hpp \
+ forwardrateagreement.hpp \
+ instruments.hpp \
+ interpolation.hpp \
+ mathf.hpp \
+ optimization.hpp \
options.hpp \
payoffs.hpp \
+ prices.hpp \
pricingengines.hpp \
processes.hpp \
***************
*** 74,93 ****
--- 83,132 ----
qladdin.hpp \
qldefs.hpp \
+ randomsequencegenerator.hpp \
+ ratehelpers.hpp \
+ schedule.hpp \
+ shortratemodels.hpp \
+ swap.hpp \
+ swaption.hpp \
+ swaptionvolstructure.hpp \
+ termstructures.hpp \
utilities.hpp \
+ vanillaswap.hpp \
volatilities.hpp
endif
libQuantLibAddinCalc_la_SOURCES = \
+ bonds.cpp \
calcutils.cpp \
+ calendar.cpp \
+ capfloor.cpp \
+ capletvolstructure.cpp \
conversions.cpp \
+ couponvectors.cpp \
+ date.cpp \
exercise.cpp \
+ forwardrateagreement.cpp \
funcdef.cpp \
+ instruments.cpp \
+ interpolation.cpp \
+ mathf.cpp \
+ optimization.cpp \
options.cpp \
payoffs.cpp \
+ prices.cpp \
pricingengines.cpp \
processes.cpp \
qladdin.cpp \
+ randomsequencegenerator.cpp \
+ ratehelpers.cpp \
+ schedule.cpp \
session.cpp \
+ shortratemodels.cpp \
+ swap.cpp \
+ swaption.cpp \
+ swaptionvolstructure.cpp \
+ termstructures.cpp \
utilities.cpp \
+ vanillaswap.cpp \
volatilities.cpp
Index: calcutils.hpp
===================================================================
RCS file: /cvsroot/quantlibaddin/QuantLibAddin/Addins/Calc/calcutils.hpp,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -C2 -d -r1.1 -r1.1.2.1
*** calcutils.hpp 19 May 2006 16:56:16 -0000 1.1
--- calcutils.hpp 6 Aug 2006 19:27:20 -0000 1.1.2.1
***************
*** 19,22 ****
--- 19,24 ----
#define qla_calc_calcutils_hpp
+ #include <boost/any.hpp>
+
std::string ouStringToStlString(const STRING &s);
ANY stlStringToCalcAny(const std::string &s);
|