diff --git a/examples/misc/combine_samples.cpp b/examples/misc/combine_samples.cpp index dc726acee..9a2ae2f3e 100644 --- a/examples/misc/combine_samples.cpp +++ b/examples/misc/combine_samples.cpp @@ -139,7 +139,7 @@ int main(int argc, char* argv[]) if (rank==0) std::cout << "Loading data from " << kind << std::endl; for(const auto& sample_name: sample_names) { - static_basis_generator->loadSampleRange(sample_name, kind, col_min, col_max); + static_basis_generator->loadSampleRange(sample_name, kind, col_min-1, col_max-1); } if (rank==0) std::cout << "Saving data uploaded as a snapshot matrix" << diff --git a/lib/linalg/BasisGenerator.cpp b/lib/linalg/BasisGenerator.cpp index 9a5e4fa12..c005132ca 100644 --- a/lib/linalg/BasisGenerator.cpp +++ b/lib/linalg/BasisGenerator.cpp @@ -22,6 +22,7 @@ #include "svd/IncrementalSVDBrand.h" #include +#include namespace CAROM { @@ -189,12 +190,12 @@ BasisGenerator::loadSampleRange(const std::string& base_file_name, int num_rows = mat->numRows(); int num_cols = mat->numColumns(); - if (col_min < 1) col_min = 1; - if (col_max > num_cols) col_max = num_cols; + if (col_min < 0) col_min = 0; + if (col_max > num_cols-1) col_max = num_cols-1; CAROM_VERIFY(col_max >= col_min); - for (int j = col_min-1; j < col_max; j++) { + for (int j = col_min; j <= col_max; j++) { double* u_in = new double[num_rows]; for (int i = 0; i < num_rows; i++) { if (kind == "basis") { @@ -215,7 +216,7 @@ BasisGenerator::loadSamples(const std::string& base_file_name, int cutoff, Database::formats db_format) { - loadSampleRange(base_file_name, kind, 1, cutoff, db_format); + loadSampleRange(base_file_name, kind, 0, cutoff-1, db_format); } double diff --git a/lib/linalg/BasisGenerator.h b/lib/linalg/BasisGenerator.h index 6baa7ebc5..4fbcfb1e6 100644 --- a/lib/linalg/BasisGenerator.h +++ b/lib/linalg/BasisGenerator.h @@ -23,7 +23,6 @@ #include "mpi.h" #include -#include /* Use C++11 built-in shared pointers if available; else fallback to Boost. */ #if __cplusplus >= 201103L @@ -158,7 +157,7 @@ class BasisGenerator void loadSampleRange(const std::string& base_file_name, const std::string& kind = "basis", - int col_min = 1, + int col_min = 0, int col_max = 1e9, Database::formats db_format = Database::HDF5);