SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
katastrofa
Posts: 9221
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

cds - jpm to give away its model?

January 31st, 2009, 6:38 pm

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: katastrofaI've seen this code, I can say I've never seen such C code in my life before.Lots of '*', -> and &* ??And of course malloc GOTOs. Lots of them. Even in places where a conditional system would work just fine. I suppose it was heavily optimized for some particular compiler.QuoteYou mean, it's not OO?It is, in a C way. Lots of structs defined to store particular kinds of data. I can't really say it is bad. Just... different from what I've seen. Very modularized. Nicely commented. Easy to follow.
 
User avatar
diogenes
Posts: 137
Joined: November 1st, 2006, 4:58 pm

cds - jpm to give away its model?

January 31st, 2009, 10:38 pm

Odd...wonder why it is not in python?
 
User avatar
katastrofa
Posts: 9221
Joined: August 16th, 2007, 5:36 am
Location: Alpha Centauri

cds - jpm to give away its model?

February 3rd, 2009, 9:49 pm

Speed?
 
User avatar
quantspot
Posts: 23
Joined: February 4th, 2009, 2:48 am

cds - jpm to give away its model?

February 4th, 2009, 8:14 am

JPM's model is "public" in the industry for more than 10 years, they just promote their brand to public this time
 
User avatar
bojan
Posts: 347
Joined: August 8th, 2008, 5:35 am

cds - jpm to give away its model?

February 4th, 2009, 10:39 am

When you say "public" what do you mean? Does it mean: you're allowed to have a look; or, you're allowed to use it; or, you're allowed to change it; or, you're allowed to redistribute it?I know the industry has in the past been occasionally careless about copyright and license arrangements (i.e., employees leave and take the code with them) but surely this is one of the many aspects that will be changing....
 
User avatar
Cuchulainn
Posts: 62149
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

cds - jpm to give away its model?

February 4th, 2009, 7:04 pm

QuoteGOTOs. Lots of them. Even in places where a conditional system would work just fine. I suppose it was heavily optimized for some particular compiler.Goto => optimised code (these must be REAL programmers). These days however this is considered harmful. QuoteIt is, in a C way. Lots of structs defined to store particular kinds of data. I can't really say it is bad. Just... different from what I've seen. Very modularized. Nicely commented. Easy to follow. It sounds OK. No inheritance ==> easier to maintain.But not the way to program in the 21st century. I would not let novices use this style.
Last edited by Cuchulainn on February 3rd, 2009, 11:00 pm, edited 1 time in total.
 
User avatar
rmeenaks
Posts: 186
Joined: May 1st, 2006, 2:31 pm

cds - jpm to give away its model?

February 5th, 2009, 2:41 pm

It is funny when people consider "goto" harmful. Goto are helpful when you have to do:1) Break out of loops that are inside another loop. The old CS philosophy of having boolean variables to do this can be tedious and hamper readability. I wish C had the JAVA notion of labeled breaks which would remove this need2) Error handling, as C does not have try/catch blocks...If you do use gotos, in general, it should always be FORWARD goto and not BACKWARDS...Ram
Last edited by rmeenaks on February 4th, 2009, 11:00 pm, edited 1 time in total.
 
User avatar
daveangel
Posts: 17031
Joined: October 20th, 2003, 4:05 pm

cds - jpm to give away its model?

February 5th, 2009, 3:52 pm

I have not used a GOTO since I stopped programming with FORTRAN 77 back in 1990. I find it unneccessary. Also, I do not find I have much use for booleans when trying to breal out of a nested loop either and I think they look very clumsy. You can usually write your loops such that you know when you got to the end in the expected manner or whether you broke out.
knowledge comes, wisdom lingers
 
User avatar
Cuchulainn
Posts: 62149
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

cds - jpm to give away its model?

February 5th, 2009, 4:05 pm

GOTO is the best (safest) mechanism for iterative schemes in numerical analysis. I welcome you to propose a solution without GOTO ... I am almost sure you will have *initialisation* problems. (the factor 'hn' is calculated and THEN we test the tolerance). Think about it, there is no other way? double solve() { // Find the root double xPrevious = x0; double hn; n = 1;L1: hn = - myF(xPrevious) / derivative(xPrevious); xCurrent = xPrevious + hn; xPrevious = xCurrent; n++; if (fabs(hn) > tol) goto L1; return xCurrent; } // GOTO ==> bad design in general.
Last edited by Cuchulainn on February 4th, 2009, 11:00 pm, edited 1 time in total.
 
User avatar
daveangel
Posts: 17031
Joined: October 20th, 2003, 4:05 pm

cds - jpm to give away its model?

February 5th, 2009, 4:10 pm

Cuch - we have had this "discussion" before !double solve() { // Find the rootdouble xPrevious = x0;double hn = 100.0;long n = 1; while ( fabs(hn = -myF(xPrevious) / derivative(xPrevious) ) > tol && n <= MAX_ITER) {hn = - myF(xPrevious) / derivative(xPrevious);xCurrent = xPrevious + hn;xPrevious = xCurrent;n++;}return xCurrent;}
knowledge comes, wisdom lingers
 
User avatar
Cuchulainn
Posts: 62149
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

cds - jpm to give away its model?

February 5th, 2009, 4:13 pm

QuoteCuch - we have had this "discussion" before !Indeed, but these new guys brought it up //.
Last edited by Cuchulainn on February 4th, 2009, 11:00 pm, edited 1 time in total.
 
User avatar
daveangel
Posts: 17031
Joined: October 20th, 2003, 4:05 pm

cds - jpm to give away its model?

February 5th, 2009, 4:20 pm

QuoteOriginally posted by: CuchulainnQuoteCuch - we have had this "discussion" before !Indeed, but these new guys brought it up //.you like my solution or not ? also, I noticed you used (incremented) n without delaring it (naughty) but then didn't use it !
knowledge comes, wisdom lingers
 
User avatar
Cuchulainn
Posts: 62149
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

cds - jpm to give away its model?

February 5th, 2009, 4:26 pm

Dave,My 'n' is a redundant member data in a class Newton, so it is declared in .hpp file (BTW my code is always runnable!) and solve() is a member function in Newton.Sorry, I missed one line of your solution. The essential crux is: Quotedouble hn = 100.0;while ( fabs(hn = -myF(xPrevious) / derivative(xPrevious) ) > tol) So, I think your solution has almost exactly the same effec as goto. The check must be done immediately.BUT if the iteration converges at the first test, where is the xCurrent value? I think you must sayxCurrent = xPrevious, before the start of the while.otherwise you will get a run-time error (xCurrent defined but given no value!).yes?
Last edited by Cuchulainn on February 4th, 2009, 11:00 pm, edited 1 time in total.
 
User avatar
Cuchulainn
Posts: 62149
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

cds - jpm to give away its model?

February 5th, 2009, 4:40 pm

Corollarydo{// iteration} while ( fabs(hn = -myF(xPrevious) / derivative(xPrevious) ) > tol)is executed 1 or more timeswhilewhile ( while ( fabs(hn = -myF(xPrevious) / derivative(xPrevious) ) > tol)){//}is executed 0 or more times. 'Goto' is similar to a 'do while'.
Last edited by Cuchulainn on February 4th, 2009, 11:00 pm, edited 1 time in total.
 
User avatar
daveangel
Posts: 17031
Joined: October 20th, 2003, 4:05 pm

cds - jpm to give away its model?

February 5th, 2009, 4:44 pm

QuoteSo, I think your solution has almost exactly the same effec as goto. The check must be done immediately.well yes and no - my solution is more controlled. there is nothing stopping someone doing a goto L1 from any other point.you can just initialise xCurrent to xPrevious before the while()
knowledge comes, wisdom lingers
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On