Created
August 22, 2016 14:51
-
-
Save nikhedonia/3389bf64cc6bd7c2218c1c96f62fa203 to your computer and use it in GitHub Desktop.
Gist created by https://fiddle.jyt.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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