-
Couldn't load subscription status.
- Fork 0
Assignment0 #1
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
base: main
Are you sure you want to change the base?
Assignment0 #1
Conversation
|
Reviewer: Zach Knowlan General Code Review for Assignment 0 Does the style match?
Is there documentation of the new code? Does it address what it does and how to use it?
Are there any obvious bugs, or performance issues?
Is the code easy to read and understand? Is it well organized? Are function names clear?
Can raw loops be replaced with standard library algorithms?
General questions or concerns.
Does the code compile?
Are there any compiler warnings?
Are there any runtime errors?
Does the code do what it is supposed to do?
Are there test cases for all new functionality?
Are there test cases that you think should be added?
Do all of the tests pass?
Are there any performance regressions?
Does the code scale to the expected problem size?
|
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.
normally we do not commit .vscode files because they are system dependent. Let's add this to the .gitignore.
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.
Code looks great! Thanks for letting us review in class.
| return result; | ||
| } | ||
|
|
||
| void printmat(const std::vector<std::vector<double>> & mat){ |
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 noticed that the first function was using snake_case? Do you have a style guide? We should make this consistent.
| } | ||
|
|
||
| void printmat(const std::vector<std::vector<double>> & mat){ | ||
| for (const std::vector<double> & row : mat){ |
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.
consider using auto& for range based for loop.
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.
Changing the variables in this file and following the provided instruction does not change the result in the result.mm file. Maybe the instruction is not clear for that.
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 think the .vscode file is hindering my vscode to understand what the provided executable is. Removing that might helpful for anyone else trying to run the codes and execute in VScode. The codes and executables run fine in the ubuntu system.
The overall code is consistent and easy to follow.
Adding header files and CMakeList files would help the compilation process.
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.
Few major issues that will need to be resolved before you merge your code. Another one not noted in the review comments is that none of your functions have documentation.
| #include <iostream> | ||
| #include <vector> | ||
|
|
||
| std::vector<std::vector<double>> mat_mat(const std::vector<std::vector<double>>&mat1,const std::vector<std::vector<double>>&mat2) { |
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.
Consider using an alias type to avoid writing vector<vector<double>> everywhere. i.e., using Matrix = std::vector<std::vector<double>>
It is fine for this assignment, however vector<vector>> will not tend to give good performance since each column is an independent allocation.
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.
make sure you are not commiting any binaries. You may need to add them to your .gitignore
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.
The assignment asks you to implement a separate driver file and library that contains the functions to compute the two inner products. This needs to be updated. Having instructions to build these on the command line rather than CMake or a makefile is fine for assignment 0.
| #include <iostream> | ||
| #include <vector> | ||
|
|
||
| std::vector<double> mat_vec(const std::vector<std::vector<double>>& mat, const std::vector<double>& vec) { |
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.
The naming of this function is not ideal. If you did not have the context of the assignment, you would not know what this function does without reading the code. Consider renaming it to matrix_vector_product, or inner_product, the latter you would use the same name for matrix-vector and matrix-matrix product but take advantage of function overloading.
| #include <fstream> | ||
| #include <sstream> | ||
|
|
||
| std::vector<double> readMMformat_vector(const std::string & filename){ |
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.
Screens are wide these days, I would suggest making your name more explanatory. Without context the user would have no idea that MM means matrix_market.
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 file contains a repeat of the functions implemented in the other files which needs to be fixed for this assignment. Please make sure to update to use a separate library. Any time you ever find yourself copy-pasting code your hackles should be raised as it points to a poor choice of abstration.
Pull request for code review