Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Sep 27, 2024
1 parent 2e35faf commit c5de496
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/sundials_matrix_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SUNMatrixWrapper::SUNMatrixWrapper(
sunindextype M, sunindextype N, sunindextype NNZ, int sparsetype,
SUNContext sunctx
)
: matrix_(SUNSparseMatrix(M, N, NNZ, sparsetype, sunctx))
: matrix_(M * N != 0 ? SUNSparseMatrix(M, N, NNZ, sparsetype, sunctx) : nullptr)
, id_(SUNMATRIX_SPARSE)
, sparsetype_(sparsetype) {

Expand All @@ -34,7 +34,7 @@ SUNMatrixWrapper::SUNMatrixWrapper(
SUNMatrixWrapper::SUNMatrixWrapper(
sunindextype M, sunindextype N, SUNContext sunctx_
)
: matrix_(SUNDenseMatrix(M, N, sunctx_))
: matrix_(M * N != 0 ? SUNDenseMatrix(M, N, sunctx_) : nullptr)
, id_(SUNMATRIX_DENSE) {
if (M && N && !matrix_)
throw std::bad_alloc();
Expand Down
2 changes: 1 addition & 1 deletion src/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void AmiVector::copy(AmiVector const& other) {
void AmiVector::synchroniseNVector() {
if (nvec_)
N_VDestroy_Serial(nvec_);
nvec_ = N_VMake_Serial(
nvec_ = vec_.empty() ? nullptr : N_VMake_Serial(
gsl::narrow<long int>(vec_.size()), vec_.data(), sunctx_
);
}
Expand Down

0 comments on commit c5de496

Please sign in to comment.