Initial comments done

This commit is contained in:
2026-07-27 08:52:23 +02:00
parent a30b410f89
commit 52684e6b8a
3 changed files with 134 additions and 59 deletions
+124 -44
View File
@@ -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
//---------------------------------------------------------------------------------------------------------------------------
+1 -1
View File
@@ -36,7 +36,7 @@
// INCLUDE DESCRIPTION
//---------------------------------------------------------------------------------------------------------------------------
#include <tensor/matrix.hpp>
#include <config/types.hpp> // panic::uint_t, panic::int_t, and panic::real_t
#include <config/types.hpp>
#include <config/omp.hpp>
//---------------------------------------------------------------------------------------------------------------------------
+9 -14
View File
@@ -36,19 +36,18 @@
// INCLUDE DESCRIPTION
//---------------------------------------------------------------------------------------------------------------------------
#include <tensor/vector.hpp>
#include <config/types.hpp>
#include <config/omp.hpp>
//---------------------------------------------------------------------------------------------------------------------------
// DEFINE DESCRIPTION
//---------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------
// TYPE DESCRIPTION
//---------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------
// VARIABLE DESCRIPTION
// PRIVATE CONSTANTS
//---------------------------------------------------------------------------------------------------------------------------
/**
* @brief Minimum number of element operations before using the OpenMP-enabled loop.
*
* Small vectors and matrices are kept serial because the overhead of starting
* worker threads can be larger than the work itself.
*/
static const panic::types::uint_t vector_omp_min_size = 10000;
//---------------------------------------------------------------------------------------------------------------------------
@@ -160,10 +159,7 @@ vector<T>::~vector(){
// Function Name : panic::tensor::vector::operator=
//
// Description:
// Copy-assignment. Copies from another vector like this:
// vector a(5);
// vector b(3);
// b = a;
// Copy-assignment. Copies from another vector.
//--------------------------------------------------------------------------------------------------------------------------
template <typename T>
vector<T>& vector<T>::operator=(const vector& other){
@@ -315,7 +311,6 @@ const T& vector<T>::at(panic::types::uint_t index) const{
}
//---------------------------------------------------------------------------------------------------------------------------
// EXPLICIT TEMPLATE INSTANTIATION
//---------------------------------------------------------------------------------------------------------------------------