Verified Commit 17f19bc0 authored by Tim Gymnich's avatar Tim Gymnich
Browse files

added reshapeColumns and changed return type of toVector()

parent 4f5f49b9
......@@ -136,13 +136,13 @@ public:
}
/// Converts the matrix to a 1D Vector by stacking the column vectors
Matrix<T> toVector() const {
std::vector<T> toVector() const {
vector<T> result;
result.reserve(getWidth() * getHeight());
for (vector<T> vector: vectors) {
result.insert(result.end(), vector.begin(), vector.end());
}
return Matrix(result);
return result;
}
/// Converts a 1D Vector to a Matrix with given dimensions
......@@ -161,6 +161,13 @@ public:
}
return Matrix(result);
}
vector<Matrix<T>> reshapeColumns(int height, int width) const {
vector<Matrix<T>> result;
for (int c = 0; c < width; c++) {
result.push_back(column(c).reshape(height, width));
}
}
/// Returns the value at row i and column j
/// @param row
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment