Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<unsigned int rows, unsigned int cols>
- class Matrix
- {
- // Protected/private means that you cannot access
- // this names from outside the class
- protected:
- //////////////////////////////////////////////////
- // Class fields
- //////////////////////////////////////////////////
- /// Matrix data as STATIC array
- double data[rows * cols];
- public:
- // Constructors are executed when you create
- // a new variable of type Matrix
- /**
- * Default constructor, doesn't do anything
- */
- Matrix()
- {
- //
- }
- /**
- * Returns number of columns
- */
- unsigned int numRows() const
- {
- return rows;
- }
- /**
- * Returns number of columns
- */
- unsigned int numCols() const
- {
- return cols;
- }
- /**
- * Custom subscript operator, returns address of
- * first element of i-th row
- */
- double * operator[](unsigned int i)
- {
- return data + (i * cols);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement