It seems that 'C++ For Dummies' requires me to know how to program in C, so I am officially too dumb to be a dummy. ![]()
I took it back and tried to find a book that would treat me like the utter fuckwit that I am. The book I came away with was 'Engineering Problem Solving with C++', which is clearly aimed at undergraduates in Engineering........I'm saying nothing more for fear of incriminating myself.
I learned C++ from SAMS "Teach Yourself C++ in 24 Hours"
This is a PDF of the TOC:
http://ptgmedia.pearsoncmg.com/images/9780672333316/samplepages/0672333317.pdf
From there, I went to SAMS "Teach Yourself C++ in 21 Days"
The first book was actually sufficient for what I needed. From their, I was mostly using library code.
Cheers,
--VS
I guess it would make it up into the list of "the 10 books that affected me the least"
![]()
I did a bit of C++ in the past and also have that book. tbh I think java is the way of the future.
Microsoft simply takes C++ out of the hands of normal people by making the good compilers (the ones with all the modules) expensive and publishing help which is almost indescribable.
I now know enough C to write my little bit of code. I now just need to read this
http://classes.soe.ucsc.edu/ee264/Fall11/cmex.pdf
to work out how to get MATLAB to call it. He claims I'll get a 10-20 times improvement in speed. We shall see.
C C C. Fml. I'm not grown up enough to use C++. I'm fully institutionalised in MATLAB. Worrying about the type of variables, passing parameters, pointers......MATLAB, no problemo, C++, ![]()
And not only that, the only free C compiler that MATLAB will talk to is the Microsoft version, which it took me ages to get installed on my work PC (just press 'install', oh no, no, no. How naive!), and which flat out refuses to install on my laptop. I'm installing a different compiler on my laptop so that I can at least write C++ there, but it's all very frustrating.
On a less hysterical note, I do have to work out exactly the most efficient way of extracting the data for given flop hand, turn hand, river hand, turn card and river card buckets from the big array with everything in it, modifying it, and putting it back in, or maybe just using pointers without making copies. I don't know, but I'll get there in the end. It's so tantalizing...and term starts on Monday ....
I didn't know MS had a free compiler. Link for the lazy?
We once had a subscription to MSDN at work -- that was sweet. All software MS produced right there to play with.
Programming is for people who like puzzles. They harder they are, the better.
The feeling you get when the $@#!# thing finally runs is second to none in this life.
You'll get there.
Cheers,
--VS
This blog is taking a disturbing direction. We should go back to talking about shaving pubic hair and other things important.
Originally posted by VorpalF2F
I didn't know MS had a free compiler. Link for the lazy?
We once had a subscription to MSDN at work -- that was sweet. All software MS produced right there to play with.
http://www.microsoft.com/en-us/download/details.aspx?id=8279
Programming is for people who like puzzles. They harder they are, the better.
The feeling you get when the $@#!# thing finally runs is second to none in this life.You'll get there.
Agreed, but the frustrating thing is that I have a working code, I just need to translate it, so it's really a manmade problem, not an intrinsically interesting one. I made a bit of progress yesterday by rewriting my MATLAB code in the style of C++, in MATLAB, basically devectorizing all the loops and indexing the arrays differently. Once I've finished doing that, I think I can get it working. Currently sat watching number two son sat at my computer playing some shooting game or other. If I was a lonely saddo sat around in my underpants all day I'd have finished this weeks ago. Those were the days.....
Originally posted by mineriva
This blog is taking a disturbing direction. We should go back to talking about shaving pubic hair and other things important.
Agreed. See underpants reference above, an article of clothing that I will eat if Spurs don't beat West Brom this afternoon.
OMFG. No more autorebuy. No more problem gambling for me!
Seems the plan is to cure the problem gamblers by shutting down auto-rebuy and tilt everyone else. I can see the logic there.
Originally posted by jbpatzer
http://www.pokerstrategy.com/news/world-of-poker/UK-players-face-regulatory-changes-at-PokerStars_86978/OMFG. No more autorebuy. No more problem gambling for me!
![]()
Autohotkey
Write a script that does the auto top up.Table Ninja will probably add it as a feature shortly anyway.
Peace.
yes I also saw the auto rebuy thing very well researched that was.
The interesting question will be what pokerstars will do if we did an opensource rebuy script. Will it become the first "UK - ONLY Prohibited software"?
Originally posted by jbpatzer
C C C. Fml. I'm not grown up enough to use C++. I'm fully institutionalised in MATLAB. Worrying about the type of variables, passing parameters, pointers......MATLAB, no problemo, C++,
And not only that, the only free C compiler that MATLAB will talk to is the Microsoft version, which it took me ages to get installed on my work PC (just press 'install', oh no, no, no. How naive!), and which flat out refuses to install on my laptop. I'm installing a different compiler on my laptop so that I can at least write C++ there, but it's all very frustrating.On a less hysterical note, I do have to work out exactly the most efficient way of extracting the data for given flop hand, turn hand, river hand, turn card and river card buckets from the big array with everything in it, modifying it, and putting it back in, or maybe just using pointers without making copies. I don't know, but I'll get there in the end. It's so tantalizing...and term starts on Monday ....
![]()
pft. gnumex
This is an announcement that there is a new version gnumex available. gnumex sets up Matlab to use the Mingw compilers (gcc on windows) to create mex files. In the new version we have included support for 64 Bit Matlab (using Mingw-64). gnumex can be found here: https://sourceforge.net/projects/gnumex/In addition, gnumex now allows gcc to appear in the list of installed compilers once it has been set up, so you can easily switch between gcc and other installed compilers.Why is this of interest?The only other free compiler on windows is currently that which is supplied with the windows sdk. This compiler does not yet support the C99 standard, and won't for some time. It also has a few other issues that make cross-platform coding more difficult than it need be. There is also the possibility of using a fortran compiler.Regards,gnumex team
And from sourceforge link
Gnumex is a package that allows Matlab mex and engine files written in C, C++, Fortran 77 or Fortran 95 to be compiled with MinGW ( MS Windows versions of gcc, gfortran, g77 or g95. Here are some of the features in gnumex: Compile Matlab mex files using gcc on Windows Compatible with 64 bit MATLAB using Mingw-w64 and 32 bit MATLAB using mingw-w32 or mingw Allows gcc to appear in the list of compilers shown by mex -setup, and easy switching C, C++, Fortran 77 or Fortran 95 mex files
Isn't fortran something math types get? - and get better when in their underpants?
Oooooo! Sounds good. I'll have to install that. I think C++ is meant to be faster than FORTRAN, so I should probably stick with that. I'm trying to do everything with pointers to avoid shunting around my great big regret matrices. I finally managed to get it to compile today, but it immediately crashed MATLAB. I think my pointers are meant to be pointing at my elbow, but they're currently pointing at my arse. C++ is very unforgiving compared to MATLAB. Now if Hamish can find me a free debuggerer, I'd really be happy. If not, I'll be needing a free trial of Microsoft Visual Studio, which I could do without.
Originally posted by jbpatzer
Oooooo! Sounds good. I'll have to install that. I think C++ is meant to be faster than FORTRAN, so I should probably stick with that. I'm trying to do everything with pointers to avoid shunting around my great big regret matrices. I finally managed to get it to compile today, but it immediately crashed MATLAB. I think my pointers are meant to be pointing at my elbow, but they're currently pointing at my arse. C++ is very unforgiving compared to MATLAB. Now if Hamish can find me a free debuggerer, I'd really be happy. If not, I'll be needing a free trial of Microsoft Visual Studio, which I could do without.
sigh. What is it with Maths professors today. C++ will be faster for some things. Slower for others. Not sure with what you are trying to do. But if it is array / matrix stuff then fortran may be faster. (though both C++ and fortran may be so much faster than Matlab the point may be moot anyway.)
One opinion re Fortan Vs C++ speed (and other features of the languages)
Executive Summary (2)
Portability: Fortran the best, by a mile
And over--elaborate C++ is by far the worst
Software engineering: Fortran best, then Python Reasons are complicated,
Performance: Fortran or C++ (no overall difference)
Python and Matlab IF good toolbox exists
Actually programming them is always slow
Parallelism: Fortran best for shared memory
Little to choose for distributed memory
Executive Summary (3)
Array handling: Fortran best, then Matlab and Python
Less clear for sparse matrices, or unusual ones
Text handling: Python best, then C++, then Fortran
Python definitely best for regular expressions
‘Computer science’: C++, then Python and Fortran
Includes data networks (a.k.a. graph structures)
‘System interfaces’: Python, then C++, then Fortran
Includes writing multi--program applicationsThere’s no universally best language, nor ever will be
Fortran
One of 3 remaining original high--level languages
Very strange to people used to C--derived languages
Fortran 90 much higher--level and more modern
Older code still works (even most of Fortran 66)
Standard is about 1/3 size of C++ and much simpler
Standard much most explicit and least ambiguous)
Comparable in power to C++ – just very different
Don’t design Fortran and C++ applications same way
Fortran Benefits
Can be easier to use than the others if
• you need to code in parallel, or
• you need serious portability, or
• you are using matrices, or
• you need high efficiency
Can do matrices with Matlab and Python
But operations on elements very slow if using them
C++ depends on library and what you need to do
I teach Fortran scientific programming in 3 days
Not everything, but all many/most programmers need
Re debuggery. If you are using gcc then gdb may be something you wish to acquaint yourself with. I've never programmed in C / C++ / fortran. Only perl and python.
Possibly useful link re using free software to debug
There appear to be a number of free IDEs for C++ such as eclipse, netbeans and others. Never used any of those.
Found a couple of links describing how to interface eclipse IDE to gdb. (even if you choose a different IDE I think the links pointed to would be worth a read for background info)
Plus there is a tutorial for debugging C++ using netbeans IDE
Pft. Off to lose some more money on pokerstars. (trying to have a token poker related item in this post.) While I did ponder on stripping to my underpants to post, the weather is still too inclement for my fat stores to keep my body at a sufficiently warm temperature. For some reason an image comes to mind from a Southpark show that featured a world of warcraft fat guy....
sigh. I would rather procrastitask on this, rather than do some poker study. Classic avoidance behavior
Have been looking for references to debugging Matlab/C++ with either netbeans or eclipse (there are probably a zillion other IDEs that are free/betterer but I have liimited my search. Procrastitasking will only take me so far)
Link on how to set up eclipse / matlab / C++ debugging on ubuntu (linux)
How to set up eclipse to use gdb for C/C++ debugging
Photran (fortran/eclipse IDE)
Discussion of differences in speed for number crunching and why fortran was faster than C (up until C99 standard allowed a change that would allow C programs to be as optimized as fortran with the right option)
However, language differences can account for some of the differences. The longevity of Fortran happens to be a good example of this. For a long time, equivalent programs in Fortran and C (or C++) would be faster in Fortran, because Fortran enabled better optimizations. This was true even when the C compiler used the same code generator and optimizer as the Fortran compiler. This difference wasn't because of a feature Fortran had. In fact, it was the reverse: it was because of a feature that Fortran didn't have.Number crunching apps typically do their work on large arrays of numbers: numbers packed in memory representing points in 3D space or forces or similar. The computations generally iterate over these arrays doing the same operation on each element of the array in turn. A function to add two arrays to each other element-by-element, for example, will take three inputs: the two arrays to add, and a third array to put the answers.Element-wise addition like this can be done in any order. This allows all kinds of optimizations. For instance, it can also vector instructions like SSE and AVX. Instead of adding each element one by one, four elements from one array can be added to four elements from the other array, simultaneously, using SSE or AVX, for an easy four-fold improvement in performance. This kind of function is also amenable to being made multithreaded: if you have four cores, then one core can add the first quarter of the array, the next the next quarter, and so on. These array-based functions afford some of the most powerful compiler optimizations, able to make the code run many times faster.C doesn't really let functions have arrays as inputs (or, for that matter, outputs). Instead, it has a thing called pointers. Pointers more or less represent memory addresses, and C has built-in features for reading and writing values stored at these memory addresses. In many regards, C uses pointers and arrays interchangeably; for an array, the pointer just represents the address of the first element of the array. The other elements of the array just have the next, sequential, memory addresses. C has built-in features for performing arithmetic on the memory addresses to access the arrays.Pointers are very flexible, and C developers use them to construct complex data structures, as well as tightly packed sequential arrays. But this flexibility can make them difficult for compilers to optimize. Consider again that function to add two arrays. In C, it would take not three arrays as its input, but three pointers; two for the inputs, one for the output.Here's the problem. Those pointers could represent any memory address. More to the point, they could overlap. The memory address of the output array could be the same as one of the input arrays. They might even overlap partially. The output array could lie over half of one of the input arrays.This is a problem for the optimizer, because it means that the assumptions that the array-based optimizer could make no longer hold true. Specifically, the order in which elements are added now matters; if the output overlaps with one of the input arrays then the result of the calculation will be different depending on whether each element of the input array is read before they get overwritten as output, or after.This means that those fancy optimizations—multithreading and vector instructions—aren't available. The compiler doesn't know if it's safe to do, so it has to conservatively do what the source code instructs, in the order it instructs, and no more. The compiler no longer has the freedom to rearrange the program to make it go faster.This problem is called aliasing, and it's something that traditional Fortran doesn't suffer from, because traditional Fortran doesn't have pointers; it just has non-overlapping arrays. For many years, it meant that Fortran compilers (and developers) could apply powerful optimizations that weren't available in C. This cemented Fortran's position as the fastest language for number crunching.Obviously for this kind of function, this flexibility that pointers offer isn't actually useful. If the arrays overlap then there's no right way to process the data, so it's bad luck that the optimizations can't be used. In the 1999 update to the C specification, known as C99, C was given an answer to this problem. In C99, pointers can be specified as not overlapping. When this is done, the compiler can make all the optimizations it wants, and with this feature, C99 (and C++, as most compiler vendors gave it a comparable capability) became as optimizable as Fortran.This aliasing problem shows how language features can be relevant to optimization, especially when it comes to making big, transformative optimizations that, for example, automatically convert single-threaded code to multithreaded. However, it also shows how such differences aren't necessarily permanent. Developers want to be able to use C and C++ for their number crunching code, and if it takes small changes to the language to make it as fast as Fortran, those changes will be made.
Hmmm... Wandered around a bit and have found Mc2For (which automatically translates Matlab to Fortran) and MiX10 (an open MATLAB compiler that ports MATLAB programs for efficient execution on high performance computing systems by translating them to IBM’s new-age high performance computing languge) - both of which look sort of interesting but are making me feel like I'm wandering off the procrastitasking task at hand and have been entranced by yet another shiny information bauble cast into my path by the internet search engine of choice. Especially as MiX10 looks like it might be a bit new. Although I'm guessing the guys who are developing it have brains the sizes of large planets so it just might work.
And I have yet to do any research on a netbeans/matlab/gdb debug environment.... (and may well never as I'm a fickle procrastitasker who is easily distracted)
Enough for now
gnumex info on gdb suggests gdb debugging is a tad painful
Suggested configuration from a while ago for MinGW and gdb for eclipse
That's top quality procrastinating for sure. Sounds like I should just have used FORTRAN in the first place. I used to code in FORTRAN years ago. Oh well. At least I understand C++ now. The main operation that's used in this algorithm is 'add something to a small subset of the elements in a huge array', so I suspect that C++ will be good at this. I'll look into the 'tell the compiler the matrices don't overlap and optimize accordingly' thing. Thanks.
[X] Install Microsoft Visual Studio
[X] Work out how to debug mex files
[X] Debug to the point that the code actually runs without crashing MATLAB (surprise, surprise, my pointers were indeed pointing up my arse)
[X] Note that code runs 20 times faster (yes 20 times faster.......wait......nerdgasm coming......ooooooh!)
[ ] Explain why results with C++ code are garbage
.....just a matter of time now... ♠_cool:
