SERVING THE QUANTITATIVE FINANCE COMMUNITY

  • 1
  • 2
  • 3
  • 4
  • 5
  • 11
 
User avatar
Cuchulainn
Topic Author
Posts: 61168
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Matlab for C++ Programmers

April 2nd, 2007, 6:18 pm

I am looking for a compact introduction to Matlab for someone with a background in C++. Basically, I would like to understand memory models in Matlabvariable and their lifecylesArrays and matricesA comparison would be nice. Any ideas?
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
abginfl
Posts: 38
Joined: February 2nd, 2005, 2:03 am

Matlab for C++ Programmers

April 2nd, 2007, 6:23 pm

How about this webinar I just googled...http://www.mathworks.com/cmspro/req1432 ... ntid=41327
 
User avatar
Cuchulainn
Topic Author
Posts: 61168
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Matlab for C++ Programmers

April 2nd, 2007, 6:41 pm

QuoteOriginally posted by: abginflHow about this webinar I just googled...http://www.mathworks.com/cmspro/req1432 ... 27Thanks.I am looking for 10.000 feet overview without gettting bogged down in the product itself. Maybe I should have said I am interested in the language issues and less with applications and syntax.For example, does Matlab do:stack and heap memorycall by value/referencefunctions, subsglobal, local datasupports OO? I reckon 2-3 A4s should do the job.
Last edited by Cuchulainn on April 1st, 2007, 10:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
abginfl
Posts: 38
Joined: February 2nd, 2005, 2:03 am

Matlab for C++ Programmers

April 2nd, 2007, 7:12 pm

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: abginflHow about this webinar I just googled...http://www.mathworks.com/cmspro/req1432 ... 27Thanks.I am looking for 10.000 feet overview without gettting bogged down in the product itself. Maybe I should have said I am interested in the language issues and less with applications and syntax.For example, does Matlab do:stack and heap memorycall by value/referencefunctions, subsglobal, local datasupports OO? I reckon 2-3 A4s should do the job.Memory issues in MatlabCall by value/referenceglobal, local data - yes and yes - use global to declare a variable global, otherwise it is local to the current workspace (either the current desktop workspace or within a function)functions - yes...initialize an m-file with the keyword "function" Supports OO
 
User avatar
ZmeiGorynych
Posts: 876
Joined: July 10th, 2005, 11:46 am

Matlab for C++ Programmers

April 3rd, 2007, 7:44 am

Quotestack and heap memoryNo. Matlab memory management is quite bad - my major gripe with it.Quotecall by value/referenceFrom the point of view of the syntax, all calls are by value; internally, it tries to optimize that as described in the link below.Quotefunctions, subsyes. Either you can define each function in a separate file, or you can define functions on the fly as eg.nonzero =@(x) x(x~=0);then nonzero(y) will return a vector of all non-zero entries of y, in the original order.Another difference to C++ is that matlab functions support multiple out-args (this corrects for the pass-by-value), and also a variable number of in- and outargs (a function can tell how many in- and outargs it was called with)Quoteglobal, local datayes. There is the 'workspace' scope which the scripts run in, and each function has its own scope; there are static vars in functions, too.Quotesupports OOapparently. Never played with it.Basically, matlab's only major flow is memory management, meaning don't try to work with datasets >200MB on a 32bit machine (never tried a x64 machine myself)I got a series of posts on matlab planned on compplusplus.com soon BTW
 
User avatar
alexv
Posts: 31
Joined: March 14th, 2005, 9:45 pm

Matlab for C++ Programmers

April 3rd, 2007, 2:26 pm

As far as arrays/matrices go, I really liked this one MATLAB array manipulation tips and tricks
 
User avatar
zeta
Posts: 1952
Joined: September 27th, 2005, 3:25 pm

Matlab for C++ Programmers

April 3rd, 2007, 5:18 pm

I would start with the free "clone", octave. you can look under the hood, you also get the power of the hdf5 format for large sets. The main advantage over C++ is succinctness eg., compare the FFT function I posted in the other thread with simply doing a=fft(z,1024). Matrices are the native data type, and you can do multidimensional ones at thatIt's slower than compiled code, but you can convert loops (for eg.,) into MEX functions. Octave unfortunately doesn't do pass by reference which is another huge bottleneck. Octave does support c style structs eg., x.a="foo"; x.b=23; x.c=[1 2 3 4]; you don't need typedefs, declarations etc, you can switch seamlessly. we could make this a tutorial style thread, I have lots of examples I'd be happy to post/go over incl SDE, FDM stuff
 
User avatar
ZmeiGorynych
Posts: 876
Joined: July 10th, 2005, 11:46 am

Matlab for C++ Programmers

April 3rd, 2007, 5:38 pm

Is octave command-line only? One thing I love about matlab is the incredibly mature integration of command-line and GUI features (things like selecting some text in the editor and right click-evaluating it on the command line, double-clicking on workspace variables to display their contents, etc).
 
User avatar
zeta
Posts: 1952
Joined: September 27th, 2005, 3:25 pm

Matlab for C++ Programmers

April 3rd, 2007, 6:36 pm

yep, no IDE in octave but there was a rumor of something based Qt in the works; octave is built on C++/STL and uses gnuplot for plotting etc. I usually plot something by swtching the terminal type to emf and then you have an image you can edit in powerpoint, openoffice etc:gset terminal emfgset output 'foo.emf'replotgset terminal x11the last command is important so as not to overwrite the intended file every subsequent plot
 
User avatar
zeta
Posts: 1952
Joined: September 27th, 2005, 3:25 pm

Matlab for C++ Programmers

April 4th, 2007, 12:56 pm

thanks for the array tips and tricks *pdf alexv, that was really good
 
User avatar
talazigha
Posts: 6
Joined: July 14th, 2004, 9:35 pm

Matlab for C++ Programmers

April 4th, 2007, 2:12 pm

Deviating slightly, Would you know a quick and easy way to transform matlab code to C++ code.My aim is to use code developed in matlab to be callable in excel -Any help or pointers?ThanksBest
 
User avatar
zeta
Posts: 1952
Joined: September 27th, 2005, 3:25 pm

Matlab for C++ Programmers

April 4th, 2007, 2:14 pm

you might have to pony up the dough for this
 
User avatar
alexv
Posts: 31
Joined: March 14th, 2005, 9:45 pm

Matlab for C++ Programmers

April 4th, 2007, 2:25 pm

QuoteOriginally posted by: ZmeiGorynychIs octave command-line only? One thing I love about matlab is the incredibly mature integration of command-line and GUI features (things like selecting some text in the editor and right click-evaluating it on the command line, double-clicking on workspace variables to display their contents, etc).Whenever I had to use octave (I am Mathematica guy) I have always used very powerful octave-mode in (X)Emacs. See the extensive documentation. The mode will launch GNU Plot automatically.The QT interface is hereThis is slightly unrelated but there is also free clone of Matlab for PocketPC hereLong list of Octave links
 
User avatar
Cuchulainn
Topic Author
Posts: 61168
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Matlab for C++ Programmers

April 5th, 2007, 2:17 pm

QuoteOriginally posted by: alexvAs far as arrays/matrices go, I really liked this one MATLAB array manipulation tips and tricksThere's a lot of useful stuff here. I suppose the BLAS routines are extra and we need to use LAPACK or does Matlab have 'native' BLAS?In C++ we have the optionsvector<T>valarray<T>Boost multidimensional arraygrow your own structuresThere are a number of useful STL algorithms that correspond to Matlab while in other cases you have to write your own.
Last edited by Cuchulainn on April 4th, 2007, 10:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
zeta
Posts: 1952
Joined: September 27th, 2005, 3:25 pm

Matlab for C++ Programmers

April 5th, 2007, 3:27 pm

octave (at least) is built against blas/lapack and on my machine this means against the AMD acmlin matlab/octave, remember there's no std::vector<float> u.push_back(foo) it's just u(i)=foo, or u(i,j)=foo, or u(i,j,k)=foo... etc etc
Last edited by zeta on April 4th, 2007, 10:00 pm, edited 1 time in total.
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