Dense Layer, Add

added the dense layer with a forward functions. I also made the add functions for most cases.
This commit is contained in:
2026-06-25 19:43:07 +02:00
parent 9b20278395
commit 189d605bfa
27 changed files with 1657 additions and 902 deletions
+16 -16
View File
@@ -70,19 +70,19 @@ namespace panic{
template <typename T>
struct matrix{
panic::uint_t n;
panic::uint_t m;
panic::uint_t length;
panic::types::uint_t n;
panic::types::uint_t m;
panic::types::uint_t length;
T* data;
// empty contructor
matrix();
// contructor with size allocation
matrix(panic::uint_t rows, panic::uint_t cols);
matrix(panic::types::uint_t rows, panic::types::uint_t cols);
// contructor with size allocation and sets it all to a value
matrix(panic::uint_t rows, panic::uint_t cols, T value);
matrix(panic::types::uint_t rows, panic::types::uint_t cols, T value);
// copy-contructor
// matrix A(3,3);
@@ -100,14 +100,14 @@ struct matrix{
// function returns rows.
// const tells compiler that the fuction don't edit the objert.
panic::uint_t rows() const;
panic::types::uint_t rows() const;
// function returns columns.
// const tells compiler that the fuction don't edit the objert.
panic::uint_t cols() const;
panic::types::uint_t cols() const;
// function to resize data vector
bool resize(panic::uint_t new_n, panic::uint_t new_m);
bool resize(panic::types::uint_t new_n, panic::types::uint_t new_m);
// fill data with value
bool fill(T value);
@@ -116,10 +116,10 @@ struct matrix{
// Example:
// A(1, 2)
// This is unchecked and fast.
T& operator()(panic::uint_t index_n, panic::uint_t index_m);
T& operator()(panic::types::uint_t index_n, panic::types::uint_t index_m);
// lets you read matrix data using row and column from a const matrix
const T& operator()(panic::uint_t index_n, panic::uint_t index_m) const;
const T& operator()(panic::types::uint_t index_n, panic::types::uint_t index_m) const;
};
@@ -128,17 +128,17 @@ struct matrix{
// TYPE ALIASES
//---------------------------------------------------------------------------------------------------------------------------
typedef matrix<panic::real_t> real_matrix;
typedef matrix<panic::int_t> int_matrix;
typedef matrix<panic::uint_t> uint_matrix;
typedef matrix<panic::types::real_t> real_matrix;
typedef matrix<panic::types::int_t> int_matrix;
typedef matrix<panic::types::uint_t> uint_matrix;
//---------------------------------------------------------------------------------------------------------------------------
// EXPLICIT TEMPLATE DECLARATION
//---------------------------------------------------------------------------------------------------------------------------
extern template struct matrix<panic::real_t>;
extern template struct matrix<panic::int_t>;
extern template struct matrix<panic::uint_t>;
extern template struct matrix<panic::types::real_t>;
extern template struct matrix<panic::types::int_t>;
extern template struct matrix<panic::types::uint_t>;
} // namespace tensor