Hi Chaps,
I have some code already written in Java, using third party math libs and I'm evaluating the possibility of adopting QuantLib as far as possible. I've noticed that swig did an incomplete job, for instance: // // This is a Java code trying to use Matrix from QuantLib // // Create 2 matrices Matrix a = new Matrix(4, 4); Matrix b = new Matrix(4, 4); // SWIG did not converted C++: operator[] to something like // Java: Array get(int) a[0][3] = 5; // it does not compile in Java // SWIG did not converted C++: operator* to something like // Java: Matrix multiply(Matrix) Matrix c = a * b; // it does not compile in Java How it can be done? Thanks in advance. -- Richard Gomes ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Chaps,
I'd like to ear your experiences with the swig thing and who is using the Java bindings, either seriosly or still testing. Kind regards -- Richard Gomes ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Richard Gomes
On Mon, 2007-09-03 at 14:19 +0100, Richard Gomes wrote:
> I have some code already written in Java, using third party math libs and > I'm evaluating the possibility of adopting QuantLib as far as possible. > > I've noticed that swig did an incomplete job, for instance: > > // Create 2 matrices > Matrix a = new Matrix(4, 4); > Matrix b = new Matrix(4, 4); > > // SWIG did not converted C++: operator[] to something like > // Java: Array get(int) > a[0][3] = 5; // it does not compile in Java > > // SWIG did not converted C++: operator* to something like > // Java: Matrix multiply(Matrix) > Matrix c = a * b; // it does not compile in Java > > How it can be done? You'll have to edit the corresponding SWIG interface file, namely, linearalgebra.i, regenerate the wrappers, and recompile. As for the edit, you have to add the methods you want to the Matrix interface, e.g., class Matrix { ... #if defined(SWIGJAVA) Array get(int i) { Array a(self->columns()); std::copy(self->row_begin(i), self->row_end(i), a.begin()); return a; } Matrix multiply(Matrix m) { return *self * m; } ... #endif ... }; I'll be happy to include your patch in next release. And of course you can post here if you need a hand to make it work. Later, Luigi -- Hanlon's Razor: Never attribute to malice that which is adequately explained by stupidity. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Luigi Ballabio wrote:
> On Mon, 2007-09-03 at 14:19 +0100, Richard Gomes wrote: >> I have some code already written in Java, using third party math libs and >> I'm evaluating the possibility of adopting QuantLib as far as possible. >> >> I've noticed that swig did an incomplete job, for instance: >> >> // Create 2 matrices >> Matrix a = new Matrix(4, 4); >> Matrix b = new Matrix(4, 4); >> >> // SWIG did not converted C++: operator[] to something like >> // Java: Array get(int) >> a[0][3] = 5; // it does not compile in Java >> >> // SWIG did not converted C++: operator* to something like >> // Java: Matrix multiply(Matrix) >> Matrix c = a * b; // it does not compile in Java >> >> How it can be done? > > You'll have to edit the corresponding SWIG interface file, namely, > linearalgebra.i, regenerate the wrappers, and recompile. > As for the edit, you have to add the methods you want to the Matrix > interface, e.g., > > class Matrix { > ... > #if defined(SWIGJAVA) > Array get(int i) { > Array a(self->columns()); > std::copy(self->row_begin(i), self->row_end(i), a.begin()); > return a; > } > Matrix multiply(Matrix m) { > return *self * m; > } > ... > #endif > ... > }; > > I'll be happy to include your patch in next release. And of course you > can post here if you need a hand to make it work. > > Later, > Luigi > > Hi Luigi, Thank you for your directions. I'll send the patch for you soon. BTW... by 'patch! you mean a real patch produced by 'diff -uN' ? Thanks -- Richard Gomes ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Tue, 2007-09-04 at 15:41 +0100, Richard Gomes wrote:
> I'll send the patch for you soon. > BTW... by 'patch! you mean a real patch produced by 'diff -uN' ? Hi Richard, that would be nice. But a modified file is ok too, I can run diff myself. Later, Luigi -- Dealing with failure is easy: work hard to improve. Success is also easy to handle: you've solved the wrong problem. Work hard to improve. -- Alan Perlis ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |