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:
+16
-16
@@ -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
|
||||
|
||||
+15
-15
@@ -68,17 +68,17 @@ namespace panic{
|
||||
|
||||
template <typename T>
|
||||
struct vector{
|
||||
panic::uint_t length;
|
||||
panic::types::uint_t length;
|
||||
T* data;
|
||||
|
||||
// empty contructor
|
||||
vector();
|
||||
|
||||
// contructor with size allocation
|
||||
vector(panic::uint_t size);
|
||||
vector(panic::types::uint_t size);
|
||||
|
||||
// contructor with size allocation and sets it all to a value
|
||||
vector(panic::uint_t size, T value);
|
||||
vector(panic::types::uint_t size, T value);
|
||||
|
||||
// copy-contructor
|
||||
// vector a(3);
|
||||
@@ -96,25 +96,25 @@ struct vector{
|
||||
|
||||
// function returns size.
|
||||
// const tells compiler that the fuction don't edit the objert.
|
||||
panic::uint_t size() const;
|
||||
panic::types::uint_t size() const;
|
||||
|
||||
// function to resize data vector (I need a new that don't save the vlaues)
|
||||
bool resize(panic::uint_t new_size);
|
||||
bool resize(panic::types::uint_t new_size);
|
||||
|
||||
// fill data with value
|
||||
bool fill(T value);
|
||||
|
||||
// lets you read and write v[index]
|
||||
T& operator[](panic::uint_t index);
|
||||
T& operator[](panic::types::uint_t index);
|
||||
|
||||
// lets you read v[index] from a const vector
|
||||
const T& operator[](panic::uint_t index) const;
|
||||
const T& operator[](panic::types::uint_t index) const;
|
||||
|
||||
// lets you read and write v.at(index)
|
||||
T& at(panic::uint_t index);
|
||||
T& at(panic::types::uint_t index);
|
||||
|
||||
// lets you read v.at(index) from a const vector
|
||||
const T& at(panic::uint_t index) const;
|
||||
const T& at(panic::types::uint_t index) const;
|
||||
|
||||
};
|
||||
|
||||
@@ -123,17 +123,17 @@ struct vector{
|
||||
// TYPE ALIASES
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
typedef vector<panic::real_t> real_vector;
|
||||
typedef vector<panic::int_t> int_vector;
|
||||
typedef vector<panic::uint_t> uint_vector;
|
||||
typedef vector<panic::types::real_t> real_vector;
|
||||
typedef vector<panic::types::int_t> int_vector;
|
||||
typedef vector<panic::types::uint_t> uint_vector;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// EXPLICIT TEMPLATE DECLARATION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
extern template struct vector<panic::real_t>;
|
||||
extern template struct vector<panic::int_t>;
|
||||
extern template struct vector<panic::uint_t>;
|
||||
extern template struct vector<panic::types::real_t>;
|
||||
extern template struct vector<panic::types::int_t>;
|
||||
extern template struct vector<panic::types::uint_t>;
|
||||
|
||||
|
||||
} // namespace tensor
|
||||
|
||||
Reference in New Issue
Block a user