This commit is contained in:
2020-12-05 23:49:54 +02:00
parent a93414b105
commit 377d37d512
6 changed files with 19 additions and 18 deletions
+9 -9
View File
@@ -48,7 +48,7 @@ template<typename DataType, typename IndexType> struct SpMatRow;
template<typename DataType, typename IndexType> struct SpMatVal;
/*!
* 2D-array wrapper for v1 and v2 part of the exercise t use as RAII
* 2D-array wrapper for v1 and v2 part of the exercise used as RAII
* and copy-prevention.
*
* This is a very thin abstraction layer over a native array.
@@ -180,7 +180,7 @@ Matrix<DataType, IndexType, Type> make_Matrix(IndexType s) {
* A(3, 4) = 7;
* \endcode
*
* We also provide getCol() and getRow() functions witch return a viwer/iterator to rows and
* We also provide getCol() and getRow() functions witch return a viewer/iterator to rows and
* columns of the matrix. In the case of a symmetric matrix instead of a row we return the
* equivalent column. This way we gain speed due to CSC format nature.
*
@@ -290,15 +290,15 @@ struct SpMat {
}
/*!
* A read item functionality using binary search to find the correct row
* A read item functionality using linear search to find the correct row
*
* @param i The row number
* @param j The column number
* @return The value of the item or DataType{} if is not present.
*/
DataType get2(IndexType i, IndexType j) {
DataType get_lin(IndexType i, IndexType j) {
IndexType idx; bool found;
std::tie(idx, found) =find2_idx(rows, col_ptr[j], col_ptr[j+1], i);
std::tie(idx, found) =find_lin_idx(rows, col_ptr[j], col_ptr[j+1], i);
return (found) ? values[idx] : 0;
}
@@ -318,7 +318,7 @@ struct SpMat {
*/
DataType set(DataType v, IndexType i, IndexType j) {
IndexType idx; bool found;
std::tie(idx, found) = find2_idx(rows, col_ptr[j], col_ptr[j+1], i);
std::tie(idx, found) = find_lin_idx(rows, col_ptr[j], col_ptr[j+1], i);
if (found)
return values[idx] = v; // we don't change NNZ even if we write "0"
else {
@@ -402,10 +402,10 @@ private:
else if (b >= e) return std::make_pair(end, false);
else {
if (v[m] < match) b = m +1;
else e = m -1;
else e = m -1;
}
}
return std::make_pair(end, false);;
return std::make_pair(end, false);
}
/*!
* find helper for set using index for begin-end instead of iterators.
@@ -418,7 +418,7 @@ private:
* \param end The vector's index to end
* \param match What to search
*/
std::pair<IndexType, bool> find2_idx(const std::vector<IndexType>& v, IndexType begin, IndexType end, IndexType match) {
std::pair<IndexType, bool> find_lin_idx(const std::vector<IndexType>& v, IndexType begin, IndexType end, IndexType match) {
for ( ; begin < end ; ++begin) {
if (match == v[begin]) return std::make_pair(begin, true);
else if (match < v[begin]) return std::make_pair(begin, false);
+2 -2
View File
@@ -223,10 +223,10 @@ private:
};
/*!
* A Logger for entire programm.
* A Logger for entire program.
*/
struct Log {
struct Endl {} endl; //!< a tag objec to to use it as a new line request.
struct Endl {} endl; //!< a tag object to to use it as a new line request.
//! We provide logging via << operator
template<typename T>