Initial comments done
This commit is contained in:
+124
-44
@@ -32,79 +32,165 @@
|
||||
*
|
||||
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
#pragma once
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// INCLUDE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
#include <config/types.hpp> // panic::uint_t, panic::int_t, and panic::real_t
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// Type Name : panic::tensor::vector
|
||||
//
|
||||
// Description:
|
||||
// Dynamic vector storing panic::real_t values.
|
||||
// The vector owns its memory and releases it in the destructor.
|
||||
//
|
||||
// Member Variables:
|
||||
// length panic::uint_t
|
||||
// Number of elements in the vector.
|
||||
//
|
||||
// data panic::real_t*
|
||||
// Pointer to the allocated vector data.
|
||||
//
|
||||
// Notes:
|
||||
// This vector uses dynamic allocation with new[] and delete[].
|
||||
// Copying performs a deep copy.
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
namespace panic{
|
||||
namespace tensor{
|
||||
|
||||
|
||||
/**
|
||||
* @brief struct for vector 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 vector{
|
||||
// Variable to store the length of the data array
|
||||
panic::types::uint_t length;
|
||||
// Pointer to the data array
|
||||
T* data;
|
||||
|
||||
// empty contructor
|
||||
/**
|
||||
* @brief Empthy constructor
|
||||
*
|
||||
*/
|
||||
vector();
|
||||
|
||||
// contructor with size allocation
|
||||
/**
|
||||
* @brief Contructor with size allocation.
|
||||
*
|
||||
* @param size Number of elemets in the vector
|
||||
*/
|
||||
vector(panic::types::uint_t size);
|
||||
|
||||
// contructor with size allocation and sets it all to a value
|
||||
/**
|
||||
* @brief Contructor with size allocation and sets it all to a value.
|
||||
*
|
||||
* @param size Number of elemets in the vector
|
||||
* @param value all the values in the vactor.
|
||||
*/
|
||||
vector(panic::types::uint_t size, T value);
|
||||
|
||||
// copy-contructor
|
||||
// vector a(3);
|
||||
// vector b = a;
|
||||
/**
|
||||
* @brief Copy-contructor.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* vector a(3);
|
||||
* vector b = a;
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
vector(const vector& other);
|
||||
|
||||
// de-contructor, releases memory
|
||||
/**
|
||||
* @brief De-contructor, releases memory.
|
||||
*
|
||||
* @note Releases memory.
|
||||
*/
|
||||
~vector();
|
||||
|
||||
// copy-assignment
|
||||
//vector a(5);
|
||||
//vector b(3);
|
||||
//b = a;
|
||||
/**
|
||||
* @brief Copy-assignment.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* vector a(3);
|
||||
* vector b(5);
|
||||
* b = a;
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
vector& operator=(const vector& other);
|
||||
|
||||
// function returns size.
|
||||
// const tells compiler that the fuction don't edit the objert.
|
||||
/**
|
||||
* @brief Returns number of elements/size.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* m = a.size();
|
||||
* @endcode
|
||||
*
|
||||
* @note The const tells compiler that the fuction don't edit the objert.
|
||||
*/
|
||||
panic::types::uint_t size() const;
|
||||
|
||||
// function to resize data vector (I need a new that don't save the vlaues)
|
||||
/**
|
||||
* @brief Function to resize data vactor.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* a.resize(6);
|
||||
* @endcode
|
||||
*
|
||||
* @note It hold all the privious functions if avaliable.
|
||||
*/
|
||||
bool resize(panic::types::uint_t new_size);
|
||||
|
||||
// fill data with value
|
||||
/**
|
||||
* @brief Fill data with value.
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* a.fill(3.1415);
|
||||
* @endcode
|
||||
*
|
||||
* @note Sets all values in the vactor.
|
||||
*/
|
||||
bool fill(T value);
|
||||
|
||||
// lets you read and write v[index]
|
||||
/**
|
||||
* @brief Read and write vactor data using index
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* n = a[3];
|
||||
* @endcode
|
||||
*
|
||||
* @note This is unchecked and fast.
|
||||
*/
|
||||
T& operator[](panic::types::uint_t index);
|
||||
|
||||
// lets you read v[index] from a const vector
|
||||
/**
|
||||
* @brief Read from const vector data using index
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* n = const a[3];
|
||||
* @endcode
|
||||
*
|
||||
* @note This is unchecked and fast.
|
||||
*/
|
||||
const T& operator[](panic::types::uint_t index) const;
|
||||
|
||||
// lets you read and write v.at(index)
|
||||
/**
|
||||
* @brief Read and write vactor data using index
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* n = a.at(3);
|
||||
* @endcode
|
||||
*
|
||||
* @note This is checked and not fast.
|
||||
*/
|
||||
T& at(panic::types::uint_t index);
|
||||
|
||||
// lets you read v.at(index) from a const vector
|
||||
/**
|
||||
* @brief Read from const vector data using index
|
||||
*
|
||||
* Computes:
|
||||
* @code
|
||||
* n = const a.at(3);
|
||||
* @endcode
|
||||
*
|
||||
* @note This is checked and not fast.
|
||||
*/
|
||||
const T& at(panic::types::uint_t index) const;
|
||||
|
||||
};
|
||||
@@ -130,12 +216,6 @@ extern template struct vector<panic::types::uint_t>;
|
||||
} // namespace tensor
|
||||
} // namespace panic
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// VARIABLE DESCRIPTION
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
// FUNCTION PROTOTYPE
|
||||
//---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user