Comment rewrite
This commit is contained in:
+115
-57
@@ -37,88 +37,154 @@
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
#include <config/types.hpp> // panic::uint_t, panic::int_t, and panic::real_t
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// DEFINE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// TYPE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// Type Name : panic::tensor::matrix
|
||||
//
|
||||
// Description:
|
||||
// Dynamic matrix storing T values.
|
||||
// The matrix owns its memory and releases it in the destructor.
|
||||
//
|
||||
// Member Variables:
|
||||
// n panic::uint_t
|
||||
// Number of rows in the matrix.
|
||||
// m panic::uint_t
|
||||
// Number of columns in the matrix.
|
||||
//
|
||||
// data T*
|
||||
// Pointer to the allocated matrix data.
|
||||
//
|
||||
// Notes:
|
||||
// This matrix uses dynamic allocation with new[] and delete[].
|
||||
// Copying performs a deep copy.
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
namespace panic{
|
||||
namespace tensor{
|
||||
|
||||
/**
|
||||
* @brief struct for matrix object
|
||||
*
|
||||
* The struct is used for all PANIC libraries
|
||||
* It uses dynamic allocation with new[] nad delete[].
|
||||
* Copying performs a deep copy.
|
||||
*/
|
||||
template <typename T>
|
||||
struct matrix{
|
||||
// Variable for number of rows
|
||||
panic::types::uint_t n;
|
||||
// Variable for number of cols
|
||||
panic::types::uint_t m;
|
||||
// Variable for length of data array
|
||||
panic::types::uint_t length;
|
||||
// Pointer to data array
|
||||
T* data;
|
||||
|
||||
// empty contructor
|
||||
/**
|
||||
* @brief Empthy constructor
|
||||
*
|
||||
*/
|
||||
matrix();
|
||||
|
||||
// contructor with size allocation
|
||||
/**
|
||||
* @brief Contructor with size allocation.
|
||||
*
|
||||
* @param rows Number of rows in the matrix
|
||||
* @param cols Number of columns in the matrix
|
||||
*/
|
||||
matrix(panic::types::uint_t rows, panic::types::uint_t cols);
|
||||
|
||||
// contructor with size allocation and sets it all to a value
|
||||
/**
|
||||
* @brief Contructor with size allocation and sets it all to a value.
|
||||
*
|
||||
* @param rows Number of rows in the matrix
|
||||
* @param cols Number of columns in the matrix
|
||||
* @param value all the values in the matrix.
|
||||
*/
|
||||
matrix(panic::types::uint_t rows, panic::types::uint_t cols, T value);
|
||||
|
||||
// copy-contructor
|
||||
// matrix A(3,3);
|
||||
// matrix B = A;
|
||||
/**
|
||||
* @brief Copy-contructor.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* matrix A(3,3);
|
||||
* matrix B = A;
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
matrix(const matrix& other);
|
||||
|
||||
// de-contructor, releases memory
|
||||
/**
|
||||
* @brief De-contructor, releases memory.
|
||||
*
|
||||
* @note Releases memory.
|
||||
*/
|
||||
~matrix();
|
||||
|
||||
// copy-assignment
|
||||
//matrix A(5);
|
||||
//matrix B(3);
|
||||
//B = A;
|
||||
/**
|
||||
* @brief Copy-assignment.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* matrix A(3,3);
|
||||
* matrix B(5,8);
|
||||
* B = A;
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
matrix& operator=(const matrix& other);
|
||||
|
||||
// function returns rows.
|
||||
// const tells compiler that the fuction don't edit the objert.
|
||||
/**
|
||||
* @brief Returns number of rows.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* n = A.rows();
|
||||
* @endcode
|
||||
*
|
||||
* @note The const tells compiler that the fuction don't edit the objert.
|
||||
*/
|
||||
panic::types::uint_t rows() const;
|
||||
|
||||
// function returns columns.
|
||||
// const tells compiler that the fuction don't edit the objert.
|
||||
/**
|
||||
* @brief Returns number of columns.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* m = A.cols();
|
||||
* @endcode
|
||||
*
|
||||
* @note The const tells compiler that the fuction don't edit the objert.
|
||||
*/
|
||||
panic::types::uint_t cols() const;
|
||||
|
||||
// function to resize data vector
|
||||
/**
|
||||
* @brief Function to resize data matrix.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* A.resize(3,4);
|
||||
* @endcode
|
||||
*
|
||||
* @note It hold all the privious functions if avaliable.
|
||||
*/
|
||||
bool resize(panic::types::uint_t new_n, panic::types::uint_t new_m);
|
||||
|
||||
// fill data with value
|
||||
/**
|
||||
* @brief Fill data with value.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* A.fill(3.1415);
|
||||
* @endcode
|
||||
*
|
||||
* @note Sets all values in the matrix.
|
||||
*/
|
||||
bool fill(T value);
|
||||
|
||||
// lets you read and write matrix data using row and column
|
||||
// Example:
|
||||
// A(1, 2)
|
||||
// This is unchecked and fast.
|
||||
/**
|
||||
* @brief Read and write matrix data using row and column
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* n = A(1,2);
|
||||
* @endcode
|
||||
*
|
||||
* @note This is unchecked and fast.
|
||||
*/
|
||||
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
|
||||
|
||||
/**
|
||||
* @brief Read from const matrix data using row and column
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* n = const A(1,2);
|
||||
* @endcode
|
||||
*
|
||||
* @note This is unchecked and fast.
|
||||
*/
|
||||
const T& operator()(panic::types::uint_t index_n, panic::types::uint_t index_m) const;
|
||||
|
||||
};
|
||||
@@ -144,12 +210,4 @@ extern template struct matrix<panic::types::uint_t>;
|
||||
} // namespace tensor
|
||||
} // namespace panic
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// VARIABLE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// FUNCTION PROTOTYPE
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@@ -32,18 +32,9 @@
|
||||
*
|
||||
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
#pragma once
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// INCLUDE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include <config/types.hpp> // panic::uint_t, panic::int_t, and panic::real_t
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// DEFINE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// TYPE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// Type Name : panic::tensor::vector
|
||||
|
||||
Reference in New Issue
Block a user