Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nikhedonia/3389bf64cc6bd7c2218c1c96f62fa203 to your computer and use it in GitHub Desktop.
Save nikhedonia/3389bf64cc6bd7c2218c1c96f62fa203 to your computer and use it in GitHub Desktop.
Gist created by https://fiddle.jyt.io
#include<vector>
#include<iostream>
template<class T>
struct Matrix {
Matrix(std::size_t n=1, std::size_t m=1)
: n{n}, m{m}, data(n*m)
{}
Matrix(std::size_t n, std::size_t m, std::vector<T> const& data)
: n{n}, m{m}, data{data}
{}
T const& operator()(size_t i, size_t j) const {
return data[i*m + j];
}
T& operator()(size_t i, size_t j) {
return data[i*m + j];
}
size_t n;
size_t m;
std::vector<T> data;
using ScalarType = T;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment