Serving the Quantitative Finance Community

 
User avatar
liefje
Topic Author
Posts: 0
Joined: September 26th, 2002, 2:11 pm

Numerical recipes in VBA

November 24th, 2003, 3:14 pm

Just to be curious, has someone ever tried to translate the numerical recipes into VBA codes???For instance the optimization function???Thx
 
User avatar
DavidJN
Posts: 267
Joined: July 14th, 2002, 3:00 am

Numerical recipes in VBA

November 24th, 2003, 5:36 pm

Try "Numerical Recipes in BASIC," by Julien C. Sprott, Cambridge University PressISBN 0-521-40689-7 (Book)ISBN 0-521-40688-9 (Diskette)Its an old book, so maybe try a library.
 
User avatar
cryptic26
Posts: 0
Joined: February 18th, 2002, 9:39 am

Numerical recipes in VBA

November 24th, 2003, 11:26 pm

As far as I think and know, all the optimization works are better done in C/C++ because they are lot more faster. If you still want to use an excel as interface, then probably you could also make a DLL (that links excel with C++). That is what I do and there is enough information on this web site about that.
Last edited by cryptic26 on November 24th, 2003, 11:00 pm, edited 1 time in total.
 
User avatar
liefje
Topic Author
Posts: 0
Joined: September 26th, 2002, 2:11 pm

Numerical recipes in VBA

November 25th, 2003, 6:34 am

Yeah I was thinking about Matlab Excel builder since I need Excel as an interface oas well as dll...But you know just to know if there was something readily available (it's for a mock-up so I need to present it shortly )
 
User avatar
Graeme
Posts: 7
Joined: April 25th, 2003, 5:47 pm

Numerical recipes in VBA

November 25th, 2003, 4:50 pm

I am currently contracting an IT consultant (also ex student of mine) to write a translator from fortran to vb, to apply to the book 'Numerical Recipes in Fortran'. The idea is that it will cover most cases, not be absolutely bullet proof - this would take too much time i.t.o. familarising with every Fortran feature. She, however, won't be done before Xmas - I am in a queue.
 
User avatar
spv205
Posts: 1
Joined: July 14th, 2002, 3:00 am

Numerical recipes in VBA

December 3rd, 2003, 8:35 am

As mentioned by other people you generally wouldn't want to use VBA for speed considerations.A halfway house for the optimisation etc is to use VBA callbacks- that is presumably the only reason to implement in VBA, so you can do your optimisation on an arbitrary function written in VBA rather than having to code it in C/Fortran etc.NAG have instructions on how to implement VBA call backs that are called from a DLLThis would be a lot faster (in speed and programming time) than doing everything in VBAhttp://www.nag.co.uk/numeric/MSVB.asp
 
User avatar
daveangel
Posts: 5
Joined: October 20th, 2003, 4:05 pm

Numerical recipes in VBA

December 3rd, 2003, 12:07 pm

An alternative would be to use the Excel SDK function Excel4. You can call a excel macro4 function which then calls a VBA function. If you have the SDK book look at page 194/195
knowledge comes, wisdom lingers
 
User avatar
Graeme
Posts: 7
Joined: April 25th, 2003, 5:47 pm

Numerical recipes in VBA

December 3rd, 2003, 6:26 pm

Just to be sure we are on the same page - I'm talking vb, not vba. When vb is compiled into a dll, it isn't bad speed wise. (Not great, but not bad at all.) It also has a lot of functionality that vba doen't have.
 
User avatar
daveangel
Posts: 5
Joined: October 20th, 2003, 4:05 pm

Numerical recipes in VBA

December 3rd, 2003, 7:21 pm

It might be intellectually interesting to translate FORTRAN to VB but I cant see the point myself. First of all "Numerical Recipes" is also available in C, secondly if you compile FORTAN code and build a library, u can link your VB code into it. There is little to be gained from translating FORTRAN to VB, except for some legacy code. I did a google and found this website www.fortran2vb.com. As a digression, I used to program in FORTRAN and I tinkered with RATFOR (Rational FORTRAN) which was developed by Kerninghan and built a translator for it. FORTRAN is such a horrible langauge (I am talking about IV and 77 as I am not upto speed on later FORTRANs) For example, the following is valid FORTRAN (IV and 77) do 110 i = 1 10 ...... some code110 continuethe programmer probably meant to write a do loop but ended up assigning 110 to a variable called do110i ...it is really appalling.
Last edited by daveangel on December 2nd, 2003, 11:00 pm, edited 1 time in total.
knowledge comes, wisdom lingers
 
User avatar
Graeme
Posts: 7
Joined: April 25th, 2003, 5:47 pm

Numerical recipes in VBA

December 4th, 2003, 5:40 pm

A lot of clients want to understand the actual mathematics of the code I have built. They don't believe documentation, even when it is well written. In fact, they don't even seem to look at the stuff. So, vb is my language of choice when this is the case. Of course, I am not - and have not, in this thread - advocating it as the language of choice. I agree with your comments about fortran. It is a terrible language. It's a lot easier to translate numerical recipes from fortran than c++ into vb, though. Perhaps it is because the fortran there is well written. Thanks for the website. I guess I just got lucky and a consultant I had lined up for this unlucky.
 
User avatar
daveangel
Posts: 5
Joined: October 20th, 2003, 4:05 pm

Numerical recipes in VBA

December 5th, 2003, 11:47 am

I wish I had clients who were willing to pay me to translate FORTRAN to VB .. sigh
knowledge comes, wisdom lingers
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

Numerical recipes in VBA

December 6th, 2003, 3:02 pm

Basic stated off life as a teaching language as a first step towards Fortran. Basic, like Fortran is an old language, so I'm not surprised that Fortan to VB is easier than C++ to VB.