Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 5717763e authored by hhakim's avatar hhakim
Browse files

Fix stack variable reference returned in MatBSR::operator(int,int).

parent a0231327
No related branches found
No related tags found
No related merge requests found
......@@ -123,8 +123,11 @@ class BSRMat
// \brief the number of blocks along the column dimension of the matrix (n/bn).
int b_per_coldim;// TODO: should be unsigned
// useful in operator()
T zero;
// private default constructor
BSRMat(): data(nullptr), bcolinds(nullptr), browptr(nullptr), bnnz(0), m(0), n(0), bm(0), bn(0), b_per_rowdim(0), b_per_coldim(0) {}
BSRMat(): data(nullptr), bcolinds(nullptr), browptr(nullptr), bnnz(0), m(0), n(0), bm(0), bn(0), b_per_rowdim(0), b_per_coldim(0), zero(T(0)) {}
public:
BSRMat(unsigned long int nrows, unsigned long int ncols, unsigned long int bnrows, unsigned long int bncols, unsigned long int nblocks, const T* data, const int *block_rowptr, const int *block_colinds);
/** Copy constructor */
......
......@@ -860,7 +860,7 @@ const T& BSRMat<T, BlockStorageOrder>::operator()(unsigned int i, unsigned int j
return data[k*bm*bn+j%bn*bm+i%bm];
}
// (i,j) is not in a nz block
return 0;
return zero;
}
throw std::runtime_error("BSRMat::operator() i or j is out of bounds.");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment