/Cpp-Array2D

A C++ Library about 2D array template classes, grid and mathematical operations of matrices.

Primary LanguageC++MIT LicenseMIT

Cpp-Array2D

A C++ Library about 2D array template classes, grid and mathematical operations of matrices.

Support

This is a library about C++ 2 dimensional array templates, the latest support is C++17.

The library content which is valid to use is:

  • grid.h
  • matrix.h

About

Since 2D array is a common use case, and I myself also need this type of API, so I decided to create this library. Welcome all of you to improve this as you like. Cheers!

Content Overview

In this Library, A grid template class is considered:

template <typename T, typename measure_t>
class grid;

Same time, there is a mathematical matrix template for matrix operations:

template <typename T, typename measure_t, measure_t m, measure_t n>
class matrix;

Dev Direction

Make backward compatibility to C++14.

The grid class is pretty simple, just a encapsulation of a heap array with row pointers, the main problem is the matrix operations. Basically, I want to support addition, subtraction and multiplication of matrices, and the ability to reduce, to Row Echelon Form and Reduced Row Echelon Form; these are pretty simple to implement, but when I introduce a dyn_matrix(dynamic version of matrix) for runtime size decision, I need a way to reuse the code.

These are the things I don't want:

  • Virtual Function Table (vtbl)
  • Inheritance

Well actually, the reason I don't want inheritance is, the normal inheritance is useless to me, what I need is to inherit a base class with only pure virtual methods, as an interface. I soon realize NO WAY, why? I don't want to introduce vtbl, but NO WAY.

So I then trying to use inline function for the algorithms to be used in both matrix and dyn_matrix. But there's some ridiculous bugs struggling me, so I just paused it for a while.