init versie

This commit is contained in:
bart
2026-11-08 11:22:15 +01:00
commit dfd497d728
45 changed files with 3041 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#ifndef MATRIX2D_H
#define MATRIX2D_H
template <typename T>
class Matrix2D {
std::vector<T> data;
unsigned int sizeX, sizeY;
public:
Matrix2D (unsigned int x, unsigned int y)
: sizeX (x), sizeY (y) {
data.resize (sizeX*sizeY);
}
T& operator()( int x, int y) {
if (x >= (int) sizeX )
x-= sizeX;
if (x < 0 )
x+= sizeX;
if (y<0) y=0;
if (y >= (int) sizeY )
y =sizeY-1;
//if (y>= sizeY || y<0)
// throw std::out_of_range("OOB access"); // Throw something more appropriate
return data[sizeX*y + x]; // Stride-aware access
}
T* row(unsigned int y) {
if (y >= sizeY) y = sizeY - 1;
return &data[sizeX * y];
}
};
#endif // MATRIX2D_H