Hmm.. that makes sens.. But I'm stuck with the same error in a different part of the code.
ofstream doesn't exist in Linux I beleive
Code:
#include "stdafx.h"
#include "include.h"
#include "extreal.h"
#include "newran.h"
#ifdef use_namespace
using namespace NEWRAN;
#endif
using namespace std;
#define al_trace printf
void Histogram(Random* rx, int n) // draw histogram with n obsv
{
int i,j; int count[20];
Real* a = new Real[n];
for (i = 0; i < n; i++) a[i] = rx->Next();
Real amax = a[0]; Real amin = a[0]; Real mean = a[0]; Real sd = 0;
for (i = 1; i < n; i++)
{
if (amin > a[i]) amin = a[i]; else if (amax < a[i]) amax = a[i];
mean += a[i];
}
mean /= n;
for (i = 0; i < 20; i++) count[i]=0;
for (i = 0; i < n; i++)
{
Real rat= (amax != amin) ? (a[i] - amin)/(amax - amin) : 1.0;
j = (int)( 19.999 * rat ); count[j]++;
Real diff = a[i] - mean; sd += diff*diff;
}
sd = sqrt(sd/(n-1));
j = 0;
for (i = 0; i < 20; i++) { if (j < count[i]) j = count[i]; }
if (j > 70) { for (i = 0; i < 20; i++) count[i] = (int)((70L*count[i])/j); }
al_trace( "\n" );
for (i = 0; i < 20; i++)
{
al_trace( "\n|" );
for (j = 1; j < count[i]; j = j+1)
al_trace( "*" );
}
al_trace( "\n%s\np. mean = %9f, p. var = %9f\ns. mean = %9f, s. var = %9f\n" ,
rx->Name() , rx->Mean() , rx->Variance() , mean , sd * sd ); //LINE 50
delete a;
}
void Hist(Random* rx, int n , const int cnt ) // draw histogram with n obsv
{
int i,j; int *count = new int[cnt];
Real* a = new Real[n];
for (i = 0; i < n; i++) a[i] = rx->Next();
Real amax = a[0]; Real amin = a[0]; Real mean = a[0]; Real sd = 0;
for (i = 1; i < n; i++)
{
if (amin > a[i]) amin = a[i]; else if (amax < a[i]) amax = a[i];
mean += a[i];
}
mean /= n;
for (i = 0; i < cnt ; i++) count[i]=0;
for (i = 0; i < n; i++)
{
Real rat= (amax != amin) ? (a[i] - amin)/(amax - amin) : 1.0;
j = (int)( (cnt - 0.001) * rat ); count[j]++;
Real diff = a[i] - mean; sd += diff*diff;
}
sd = sqrt(sd/(n-1));
j = 0;
for (i = 0; i < cnt; i++) { if (j < count[i]) j = count[i]; }
if (j > 70) { for (i = 0; i < cnt; i++) if( count[i] ) count[i] = (int)((70L*count[i])/j); }
al_trace( "\n" );
for (i = 0; i < cnt; i++)
{
al_trace( "\n%02d|" , i );
for (j = 1; j < count[i] ; j = j+1)
al_trace( "*" );
}
al_trace( "\n%s\np. mean = %9f, p. var = %9f\ns. mean = %9f, s. var = %9f\n" ,
rx->Name() , rx->Mean() , rx->Variance() , mean , sd * sd );//LINE 87
delete count;
delete a;
}
The code that makes the ExtReal class is
Code:
// extreal.h ----------------------------------------------------------
#ifndef EXTREAL_LIB
#define EXTREAL_LIB 0
#ifdef use_namespace
namespace NEWRAN { using namespace RBD_COMMON; }
namespace RBD_LIBRARIES { using namespace NEWRAN; }
namespace NEWRAN {
#endif
/************************ extended real class ***************************/
enum EXT_REAL_CODE
{ Finite, PlusInfinity, MinusInfinity, Indefinite, Missing };
class ExtReal {
Real value;
EXT_REAL_CODE c;
public:
ExtReal operator+(const ExtReal&) const;
ExtReal operator-(const ExtReal&) const;
ExtReal operator*(const ExtReal&) const;
ExtReal operator-() const;
friend ostream& operator<<( ostream&, const ExtReal& );
ExtReal(Real v) { c=Finite; value=v; }
ExtReal(const EXT_REAL_CODE& cx) { c = cx; }
ExtReal() { c = Missing; }
Real Value() const { return value; }
bool IsReal() const { return c==Finite; }
EXT_REAL_CODE Code() const { return c; }
};
#ifdef use_namespace
}
#endif
#endif
That's the header tell me if you want the source too
The errors I get are
Code:
../Source/Distribution/hist.cpp: In function `void Histogram(Random*, int)':
../Source/Distribution/hist.cpp:50: warning: cannot pass objects of non-POD
type `class ExtReal' through `...'; call will abort at runtime
../Source/Distribution/hist.cpp:50: warning: cannot pass objects of non-POD
type `class ExtReal' through `...'; call will abort at runtime
../Source/Distribution/hist.cpp: In function `void Hist(Random*, int, int)':
../Source/Distribution/hist.cpp:87: warning: cannot pass objects of non-POD
type `class ExtReal' through `...'; call will abort at runtime
../Source/Distribution/hist.cpp:87: warning: cannot pass objects of non-POD
type `class ExtReal' through `...'; call will abort at runtime
No clue what to do with that
Thanks