I am trying to debug a piece of code, but the more I try to isolate the error, the more confused I get. The program bellow produces SIGSEGV 11, but if I rewrite the method at the bottom to;
void Iteration::Initiate(){
using namespace std;
cout << beta ;
}
i.e., skip the space in the output, then it works. There is no sanity in this. If it is of any use, I am using xcode 3.0 on osx 10.5 ppc. Also note, that since I have removed some pieces of the program before posting it here, some methods are prototyped, but the behavior of the whole program is no different...
//----------------
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <stdio.h>
#include <math.h>
class Session
{
public:
void Go();
};
class Iteration
{
public:
Iteration(double ibeta, double isigma, double iepsilon, double ikappa, int ino, double iquanta);
void Iteration::Initiate();
void run(int sweeps);
void write(char *target);
double eval(int x, int y);
double subeval(int x, int y);
double totalEnergy();
static const int Nmax=500;
double kappa, beta, sigma, epsilon; //<n>/<p>=sqrt(20)
double RF[Nmax][Nmax];
double IF[Nmax][Nmax];
double RG[Nmax][Nmax];
double IG[Nmax][Nmax];
double AX[Nmax][Nmax];
double AY[Nmax][Nmax];
int N;
double Xmesh[Nmax][Nmax];
double Ymesh[Nmax][Nmax];
double n;
};
int main(int argc, char* argv[])
{
using namespace std;
Session S1;
S1.Go();
return 0;
}
void Session::Go(){
using namespace std;
using std::ifstream;
using std::cerr;
using std::cout;
using std::endl;
int No=200;
double Beta=0.5; double Sigma=0; double Epsilon=sqrt(20); double Kappa=3; double Quanta=1;
//interpolate(fin, gin, ain, meshin, Xmesh, Nin, Fin, Gin, Ain, N);
Iteration sim=Iteration(Beta, Sigma, Epsilon, Kappa, No, Quanta);
sim.Initiate();
//sim.run(10);
//sim.write("file1.txt");
cout << " Completed ";
}
Iteration::Iteration(double ibeta, double isigma, double iepsilon, double ikappa, int ino, double iquanta){
// initiate mesh...
using namespace std;
beta=ibeta; kappa=ikappa; sigma=isigma; epsilon=iepsilon; n=iquanta;
N=ino;
}
void Iteration::Initiate(){
using namespace std;
cout << beta <<" ";
}
void Iteration::Initiate(){
using namespace std;
cout << beta ;
}
i.e., skip the space in the output, then it works. There is no sanity in this. If it is of any use, I am using xcode 3.0 on osx 10.5 ppc. Also note, that since I have removed some pieces of the program before posting it here, some methods are prototyped, but the behavior of the whole program is no different...
//----------------
#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <stdio.h>
#include <math.h>
class Session
{
public:
void Go();
};
class Iteration
{
public:
Iteration(double ibeta, double isigma, double iepsilon, double ikappa, int ino, double iquanta);
void Iteration::Initiate();
void run(int sweeps);
void write(char *target);
double eval(int x, int y);
double subeval(int x, int y);
double totalEnergy();
static const int Nmax=500;
double kappa, beta, sigma, epsilon; //<n>/<p>=sqrt(20)
double RF[Nmax][Nmax];
double IF[Nmax][Nmax];
double RG[Nmax][Nmax];
double IG[Nmax][Nmax];
double AX[Nmax][Nmax];
double AY[Nmax][Nmax];
int N;
double Xmesh[Nmax][Nmax];
double Ymesh[Nmax][Nmax];
double n;
};
int main(int argc, char* argv[])
{
using namespace std;
Session S1;
S1.Go();
return 0;
}
void Session::Go(){
using namespace std;
using std::ifstream;
using std::cerr;
using std::cout;
using std::endl;
int No=200;
double Beta=0.5; double Sigma=0; double Epsilon=sqrt(20); double Kappa=3; double Quanta=1;
//interpolate(fin, gin, ain, meshin, Xmesh, Nin, Fin, Gin, Ain, N);
Iteration sim=Iteration(Beta, Sigma, Epsilon, Kappa, No, Quanta);
sim.Initiate();
//sim.run(10);
//sim.write("file1.txt");
cout << " Completed ";
}
Iteration::Iteration(double ibeta, double isigma, double iepsilon, double ikappa, int ino, double iquanta){
// initiate mesh...
using namespace std;
beta=ibeta; kappa=ikappa; sigma=isigma; epsilon=iepsilon; n=iquanta;
N=ino;
}
void Iteration::Initiate(){
using namespace std;
cout << beta <<" ";
}