Skip to content
Snippets Groups Projects
Commit 70ddd5bd authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Ignore excess indices in IOG vector

parent 772eeb90
No related branches found
No related tags found
No related merge requests found
......@@ -197,6 +197,7 @@ ScattererConfiguration::~ScattererConfiguration() {
delete[] dc0_matrix[i][j];
}
}
delete[] dc0_matrix;
for (int i = 0; i < number_of_spheres; i++) {
delete[] rcf[i];
}
......@@ -222,7 +223,7 @@ ScattererConfiguration* ScattererConfiguration::from_binary(string file_name, st
input.open(file_name.c_str(), ios::in | ios::binary);
if (input.is_open()) {
input.read(reinterpret_cast<char *>(&nsph), sizeof(int));
iog = new int[nsph];
iog = new int[nsph]();
for (int i = 0; i < nsph; i++) {
input.read(reinterpret_cast<char *>(&(iog[i])), sizeof(int));
}
......@@ -232,15 +233,15 @@ ScattererConfiguration* ScattererConfiguration::from_binary(string file_name, st
input.read(reinterpret_cast<char *>(&_idfc), sizeof(int));
input.read(reinterpret_cast<char *>(&nxi), sizeof(int));
try {
xi_vec = new double[nxi];
xi_vec = new double[nxi]();
} catch (bad_alloc &ex) {
throw UnrecognizedConfigurationException("Wrong parameter set: invalid number of scales " + nxi);
}
for (int i = 0; i < nxi; i++) {
input.read(reinterpret_cast<char *>(&(xi_vec[i])), sizeof(double));
}
nshl_vector = new int[nsph];
ros_vector = new double[nsph];
nshl_vector = new int[nsph]();
ros_vector = new double[nsph]();
rcf_vector = new double*[nsph];
for (int i115 = 1; i115 <= nsph; i115++) {
if (iog[i115 - 1] < i115) continue;
......@@ -249,7 +250,7 @@ ScattererConfiguration* ScattererConfiguration::from_binary(string file_name, st
int nsh = nshl_vector[i115 - 1];
if (max_ici < (nsh + 1) / 2) max_ici = (nsh + 1) / 2;
try {
rcf_vector[i115 - 1] = new double[nsh];
rcf_vector[i115 - 1] = new double[nsh]();
} catch (bad_alloc &ex) {
throw UnrecognizedConfigurationException("Wrong parameter set: invalid number of layers " + nsh);
}
......@@ -261,7 +262,7 @@ ScattererConfiguration* ScattererConfiguration::from_binary(string file_name, st
for (int dim1 = 0; dim1 < max_ici; dim1++) {
dc0m[dim1] = new complex<double>*[nsph];
for (int dim2 = 0; dim2 < nsph; dim2++) {
dc0m[dim1][dim2] = new complex<double>[nxi];
dc0m[dim1][dim2] = new complex<double>[nxi]();
}
}
for (int jxi468 = 1; jxi468 <= nxi; jxi468++) {
......@@ -357,14 +358,14 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(string dedfb_file_nam
sscanf(file_lines[++last_read_line].c_str(), " %9lE D%d %9lE D%d", &xi, &xi_exp, &xi_step, &xi_step_exp);
xi *= pow(10.0, 1.0 * xi_exp);
xi_step *= pow(10.0, 1.0 * xi_step_exp);
variable_vector = new double[nxi];
variable_vector = new double[nxi]();
for (int jxi320 = 0; jxi320 < nxi; jxi320++) {
variable_vector[jxi320] = xi;
xi += xi_step;
}
}
} else { // idfc >= 0
variable_vector = new double[nxi];
variable_vector = new double[nxi]();
if (instpc == 0) { // The variable vector is explicitly defined
double vs;
int vs_exp;
......@@ -420,15 +421,22 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(string dedfb_file_nam
}
}
last_read_line++;
int *iog_vector = new int[nsph];
double *ros_vector = new double[nsph];
int *iog_vector = new int[nsph]();
double *ros_vector = new double[nsph]();
double **rcf_vector = new double*[nsph];
int *nshl_vector = new int[nsph];
int *nshl_vector = new int[nsph]();
//printf("\nDEBUG: reading IOG from %s", file_lines[last_read_line].c_str());
//fflush(stdout);
for (int i = 0; i < nsph; i++) {
string read_format = "";
for (int j = 0; j < i; j++) read_format += " %*d";
for (int j = 0; j < (i % 15); j++) read_format += " %*d";
read_format += " %d";
sscanf(file_lines[last_read_line].c_str(), read_format.c_str(), (iog_vector + i));
if (i > 0 && i % 15 == 0) {
last_read_line++;
//printf("DEBUG: reading IOG from %s", file_lines[last_read_line].c_str());
//fflush(stdout);
}
}
for (int i113 = 1; i113 <= nsph; i113++) {
int i_val, nsh;
......@@ -441,7 +449,7 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(string dedfb_file_nam
ros_vector[i113 - 1] = ros_val * pow(10.0, 1.0 * ros_val_exp);
nsh = nshl_vector[i113 - 1];
if (i113 == 1) nsh += ies;
rcf_vector[i113 - 1] = new double[nsh];
rcf_vector[i113 - 1] = new double[nsh]();
for (int ns = 0; ns < nsh; ns++) {
double ns_rcf;
int ns_rcf_exp;
......@@ -453,7 +461,7 @@ ScattererConfiguration* ScattererConfiguration::from_dedfb(string dedfb_file_nam
for (int dim1 = 0; dim1 < max_ici; dim1++) {
dc0m[dim1] = new complex<double>*[nsph];
for (int dim2 = 0; dim2 < nsph; dim2++) {
dc0m[dim1][dim2] = new complex<double>[nxi];
dc0m[dim1][dim2] = new complex<double>[nxi]();
}
}
for (int jxi468 = 1; jxi468 <= nxi; jxi468++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment