How does Visual C++ compare to old school C++?

foozball3000

Executive Member
Joined
Oct 28, 2008
Messages
5,828
What happened with this?

I also want to know. I think it could be pretty kickass. gf's a dietician, so could make things REALLY hectic :p

It's still in the pipeline. The last 3 months have been hectic. New job ect...


Back on topic:
I found this:
Code:
Algorithm 5
Standard Normal According to Marsaglia-Bray

generate U = random number
if U < 0.8638 then
generate U1 ,U2,U3 = random numbers
setZ =2(U, + U, + U3) —3
else if U < 0.9745 then
generate U1,U2 = random numbers
setZ = l.5(U, + U3 — 1)
else if U < 0.9973002039
repeat
generate U, = random number
set V = 6*U, — 3
generate U2 = random number
until 0.358*U2 ~ g(V) *
set Z = V
else
repeat
repeat
generate U1 ,U2 = random numbers
set V1 = 2*U1 — 1, V2 = 2*U2 — 1
until W = W + V~< 1
set A = sqrt((9_2*ln(W))/W)
set B = AV,, set C = AV2
until jBJ > 3 or id > 3
if IBI > 3 then Z = B else Z = C
endif
return Z
*g(v)ae2/22b(3v2)c(l.5~v~), vi < 1
ae_v2~’2_b(3_ivj)2_c(l.5_ivi), 1 lvi <1.5
ae~Z~’2_b(3_jvi)2, l.5 ivi<3
a = 17.49731196, b = 2.36785163, c = 2.15787544

Erm... :wtf:
 

sn3rd

Expert Member
Joined
Jan 18, 2008
Messages
4,305
It's still in the pipeline. The last 3 months have been hectic. New job ect...


Back on topic:
I found this:

Erm... :wtf:

Code:
#include <stdio.h>
#include <math.h>

void getNextGauss(int* curr1, int* curr2, int* curr3, double* temp, double* x1, double* x2)
{
	double L = 0.0;
	double s = 1.0;
	double v1 = 0.0;
	double v2 = 0.0;
	
	while (s >= 1.0)
	{
		getNextRand(curr1, curr2, curr3, temp);
		v1 = 2.0 * *temp - 1.0;
	
		getNextRand(curr1, curr2, curr3, temp);
		v2 = 2.0 * *temp - 1.0;
		
		s = v1*v1 + v2*v2;
	}
	
	L = sqrt((-2*log(s))/s);
	
	*x1 = v1 * L;
	*x2 = v2 * L;
}

Then all you need to implement is getNextRand(), which just gets a uniform number between 0 and 1.
 

sn3rd

Expert Member
Joined
Jan 18, 2008
Messages
4,305
Code:
void getNextRand(int* curr1, int* curr2, int* curr3, double* temp)
{
	*curr1 = (177 * (*curr1 % 177)) - 2 * (*curr1/177);// % PRIME1;
	if (*curr1 < 0)
		*curr1 = *curr1 + 30269.0;
	*temp = *curr1 / (double) 30269.0;
	
	
	*curr2 = (171 * (*curr2 % 176)) - 35 * (*curr2/176);// % PRIME2;
	if (*curr2 < 0)
		*curr2 = *curr2 + 30307.0;
	*temp += *curr2 / (double) 30307.0;
	
		
	*curr3 = (170 * (*curr3 % 178)) - 63 * (*curr3/178);// % PRIME3;
	if (*curr3 < 0)
		*curr3 = *curr3 + 30323.0;
	*temp += *curr3 / (double) 30323.0;
	
	*temp = *temp - (int)*temp;
}
There's a uniform PRNG.
 

foozball3000

Executive Member
Joined
Oct 28, 2008
Messages
5,828
you could just record the hbo logo and remote the text ? :)

That would defeat the purpose. ;)

But I quickly stumbled onto another problem. Getting the randomness just right is one quest on it's own, but actually rendering the stuff is a new ball game.

I'm still pondering on this one...
A given screen has about 198,000 pixels. And double that if it's dual screens.
That's a lot of calculations per second.

(If you haven't guessed by now, I have no idea how to accomplish this task)
A simple graphics.draw() approach doesn't work (I get to about 5 frames per second on a way lower resolution.)
 

Gnome

Executive Member
Joined
Sep 19, 2005
Messages
7,208
Just be careful with Visual Studio because you get managed C++ which won't run without .NET framework installed.

I personally just use C++ standard library and directly interface with Windows functions using #include windows.h to draw the GUI. Seriously tedious but that is the way of C++

Linux with QT is much better IMHO. Even OpenGL in Linux is really nice to work with.
 

dequadin

Expert Member
Joined
May 9, 2008
Messages
1,434
Just be careful with Visual Studio because you get managed C++ which won't run without .NET framework installed.

Not true! You can create unmanaged C++ code fine with Visual Studio. (Win32/ATL/MFC/Whatever). If you want C++/CLI you have to specify...

Linux with QT is much better IMHO. Even OpenGL in Linux is really nice to work with.

Boost?
 

Gnome

Executive Member
Joined
Sep 19, 2005
Messages
7,208
Not true! You can create unmanaged C++ code fine with Visual Studio.

Yes I actually forgot to say that you can still create unmanaged code, somehow that part got lost (rereading my post now :whistling: ). But the default action is to create managed code which I hate, why use C++ then :confused:

I still write the code using VC++ I just usually create a empty Win32 Project.

The compiler is awesome, setting optimization to full and enablng whole program optimization, makes a huge difference in file size & performance.


??
 

dequadin

Expert Member
Joined
May 9, 2008
Messages
1,434
But the default action is to create managed code which I hate, why use C++ then :confused:

C++/CLI has it's place. It's really useful for tricky COM Interop (for example).

There's a lot of discussion about this on StackOverflow...

I still write the code using VC++ I just usually create a empty Win32 Project.
The compiler is awesome, setting optimization to full and enablng whole program optimization, makes a huge difference in file size & performance.

I only use it to create ATL ActiveX controls. My skills are far from leet :whistling:

Boost, I've heard good things about it. I think they've used some fancy tricks to get stuff like lambda expressions working etc.
 
Top