-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor CSRMatrix #359
Refactor CSRMatrix #359
Conversation
cd5ad55
to
d573b43
Compare
b45faa6
to
db7ba88
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now. I did not review the algorithm; I assume that they did not change except for changing double
-> ValueType
(?).
f11c992
to
8be5f46
Compare
Why does the code break with an earlier version of Clang? We should not increase the version of Clang without a good reason. People who want run NetworKit on clusters that they do not control might not have the option to upgrade Clang. |
The build fails with clang 3.8 because of this error:
I searched for this error and did not find much apart this page. It could be a bug in clang 3.8 but I am not sure about that. Do you have some other solutions in mind? |
Moving |
7421696
to
1e247b0
Compare
1e247b0
to
69ae7bc
Compare
dca2088
to
ede57c6
Compare
Now that we raised the minimum supported clang version to 3.9 this PR can be reviewed. |
10efc2b
to
89744e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
We also need approval from @avdgrinten. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one comment below.
As a side note: a few algorithms are really inefficient here, for example setValue(). There is no way to implement setValue() well for CSR, so why does the class provide it at all?
I agree that there are several inefficiencies in this class that should be fixed, I already fixed a trivial one in the last commit. However, I think that fixing those inefficiencies is out of the scope of this PR and it should be done on a separate PR. |
Not sure that setValue() is really obsolete. But the docs should be clear about the inherent inefficiency. Other -- unnecessary -- inefficiencies should be addressed. This is rather old code that has not been touched for quite some time, I believe. |
But I leave it up to you guys if they are addressed in this PR or separately. |
It's not necessarily the case that the code is inefficient due to the implementation but it just provides tons of operations that you really would not use if you want your code to be fast (setting values, getting individual values, extracting columns, etc.). These operations are simply not fast because CSR cannot implement them in a fast way. |
I know @avdgrinten. Such operations should not be the preferred way to do things, I completely agree. But there may be cases where they are simply necessary. We can make a decision, though, that we do not want to support such cases. But that's a decision I'd like to be involved in and should follow from a comprehensive discussion of use cases. |
It might be a good idea to open a new issue/discussion about that. |
Are there any other issues that need to be addressed in this PR? |
da33d2a
to
07b16b6
Compare
|
||
Triplet() = default; | ||
|
||
Triplet(index row, index column, double value) : row(row), column(column), value(value) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change done?
/** Default destructor */ | ||
virtual ~CSRGeneralMatrix() = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this destructor virtual? Does the class have any virtual methods?
} | ||
} | ||
|
||
#ifndef NDEBUG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be gated behind the sanity check macros, right?. Seems to be an expensive check.
/** | ||
* @return Number of rows. | ||
*/ | ||
inline count numberOfRows() const noexcept { return nRows; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline
is redundant if a method is defined within class { ... }
or struct { ... }
.
triplets.push_back({i, j, result}); | ||
triplets.emplace_back(i, j, result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do not change this then the clang-tidy build fails due to modernize-use-emplace
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't clang-tidy fail right now?
triples.push_back({k, coarseIndex[j], w}); | ||
triples.emplace_back(k, coarseIndex[j], w); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change?
triplets.push_back({i, j, value}); | ||
triplets.emplace_back(i, j, value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change?
triplets.push_back({i,j,val}); | ||
triplets.emplace_back(i,j,val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change?
triplets.push_back({i,j,value}); | ||
triplets.emplace_back(i,j,value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change?
networkit/cpp/viz/PivotMDS.cpp
Outdated
triplets.push_back({v, j, dist[v]}); | ||
triplets.emplace_back(v, j, dist[v]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change?
26e5a2b
to
b5cd845
Compare
I addressed the comments, the |
b5cd845
to
ca9dd75
Compare
ca9dd75
to
752ad34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now.
This adds a template parameter to the
CSRMatrix
class allowing to store generic data types. The class is renamed toCSRGeneralMatrix
. Additional minor changes:std::lower_bound
noexcept
operator where applicablepush_back
withemplace_back
where applicable (and addition of two new constructors forTriplet
)