diff --git a/src/equil/vcs_DoubleStarStar.cpp b/src/equil/vcs_DoubleStarStar.cpp index 308f10ece..174017c70 100644 --- a/src/equil/vcs_DoubleStarStar.cpp +++ b/src/equil/vcs_DoubleStarStar.cpp @@ -41,8 +41,10 @@ DoubleStarStar::DoubleStarStar(const DoubleStarStar& y) m_data.resize(m_nrows*m_ncols); m_data = y.m_data; m_colAddr.resize(m_ncols); - for (size_t jcol = 0; jcol < m_ncols; jcol++) { - m_colAddr[jcol] = &(m_data[jcol*m_nrows]); + if (!m_data.empty()) { + for (size_t jcol = 0; jcol < m_ncols; jcol++) { + m_colAddr[jcol] = &(m_data[jcol*m_nrows]); + } } } @@ -57,8 +59,10 @@ DoubleStarStar& DoubleStarStar::operator=(const DoubleStarStar& y) m_data.resize(m_nrows*m_ncols); m_data = y.m_data; m_colAddr.resize(m_ncols); - for (size_t jcol = 0; jcol < m_ncols; jcol++) { - m_colAddr[jcol] = &(m_data[jcol*m_nrows]); + if (!m_data.empty()) { + for (size_t jcol = 0; jcol < m_ncols; jcol++) { + m_colAddr[jcol] = &(m_data[jcol*m_nrows]); + } } return *this; } @@ -108,8 +112,10 @@ void DoubleStarStar::resize(size_t m, size_t n, double v) m_nrows = n; m_ncols = m; m_colAddr.resize(m_ncols); - for (size_t jcol = 0; jcol < m_ncols; jcol++) { - m_colAddr[jcol] = &(m_data[jcol*m_nrows]); + if (!m_data.empty()) { + for (size_t jcol = 0; jcol < m_ncols; jcol++) { + m_colAddr[jcol] = &(m_data[jcol*m_nrows]); + } } } diff --git a/src/equil/vcs_IntStarStar.cpp b/src/equil/vcs_IntStarStar.cpp index 82d93d830..582c7271e 100644 --- a/src/equil/vcs_IntStarStar.cpp +++ b/src/equil/vcs_IntStarStar.cpp @@ -28,8 +28,10 @@ IntStarStar::IntStarStar(size_t m, size_t n, int v) : m_data.resize(n*m); std::fill(m_data.begin(), m_data.end(), v); m_colAddr.resize(m); - for (size_t jcol = 0; jcol < m_ncols; jcol++) { - m_colAddr[jcol] = &(m_data[jcol*m_nrows]); + if (!m_data.empty()) { + for (size_t jcol = 0; jcol < m_ncols; jcol++) { + m_colAddr[jcol] = &(m_data[jcol*m_nrows]); + } } } @@ -41,8 +43,10 @@ IntStarStar::IntStarStar(const IntStarStar& y) m_data.resize(m_nrows*m_ncols); m_data = y.m_data; m_colAddr.resize(m_ncols); - for (size_t jcol = 0; jcol < m_ncols; jcol++) { - m_colAddr[jcol] = &(m_data[jcol*m_nrows]); + if (!m_data.empty()) { + for (size_t jcol = 0; jcol < m_ncols; jcol++) { + m_colAddr[jcol] = &(m_data[jcol*m_nrows]); + } } } @@ -57,8 +61,10 @@ IntStarStar& IntStarStar::operator=(const IntStarStar& y) m_data.resize(m_nrows*m_ncols); m_data = y.m_data; m_colAddr.resize(m_ncols); - for (size_t jcol = 0; jcol < m_ncols; jcol++) { - m_colAddr[jcol] = &(m_data[jcol*m_nrows]); + if (!m_data.empty()) { + for (size_t jcol = 0; jcol < m_ncols; jcol++) { + m_colAddr[jcol] = &(m_data[jcol*m_nrows]); + } } return *this; } diff --git a/src/numerics/DenseMatrix.cpp b/src/numerics/DenseMatrix.cpp index fe36e2501..ca28cdd8c 100644 --- a/src/numerics/DenseMatrix.cpp +++ b/src/numerics/DenseMatrix.cpp @@ -35,8 +35,10 @@ DenseMatrix::DenseMatrix(size_t n, size_t m, doublereal v) : { m_ipiv.resize(std::max(n, m)); m_colPts.resize(m); - for (size_t j = 0; j < m; j++) { - m_colPts[j] = &(m_data[m_nrows*j]); + if (!m_data.empty()) { + for (size_t j = 0; j < m; j++) { + m_colPts[j] = &(m_data[m_nrows*j]); + } } } //==================================================================================================================== @@ -52,8 +54,10 @@ DenseMatrix::DenseMatrix(const DenseMatrix& y) : { m_ipiv = y.ipiv(); m_colPts.resize(m_ncols); - for (size_t j = 0; j < m_ncols; j++) { - m_colPts[j] = &(m_data[m_nrows*j]); + if (!m_data.empty()) { + for (size_t j = 0; j < m_ncols; j++) { + m_colPts[j] = &(m_data[m_nrows*j]); + } } } //==================================================================================================================== @@ -84,8 +88,10 @@ void DenseMatrix::resize(size_t n, size_t m, doublereal v) Array2D::resize(n,m,v); m_ipiv.resize(std::max(n,m)); m_colPts.resize(m_ncols); - for (size_t j = 0; j < m_ncols; j++) { - m_colPts[j] = &(m_data[m_nrows*j]); + if (!m_data.empty()) { + for (size_t j = 0; j < m_ncols; j++) { + m_colPts[j] = &(m_data[m_nrows*j]); + } } } //====================================================================================================================