Initial comments done
This commit is contained in:
+124
-44
@@ -32,79 +32,165 @@
|
|||||||
*
|
*
|
||||||
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// INCLUDE DESCRIPTION
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
#include <config/types.hpp> // panic::uint_t, panic::int_t, and panic::real_t
|
#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 panic{
|
||||||
namespace tensor{
|
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>
|
template <typename T>
|
||||||
struct vector{
|
struct vector{
|
||||||
|
// Variable to store the length of the data array
|
||||||
panic::types::uint_t length;
|
panic::types::uint_t length;
|
||||||
|
// Pointer to the data array
|
||||||
T* data;
|
T* data;
|
||||||
|
|
||||||
// empty contructor
|
/**
|
||||||
|
* @brief Empthy constructor
|
||||||
|
*
|
||||||
|
*/
|
||||||
vector();
|
vector();
|
||||||
|
|
||||||
// contructor with size allocation
|
/**
|
||||||
|
* @brief Contructor with size allocation.
|
||||||
|
*
|
||||||
|
* @param size Number of elemets in the vector
|
||||||
|
*/
|
||||||
vector(panic::types::uint_t size);
|
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);
|
vector(panic::types::uint_t size, T value);
|
||||||
|
|
||||||
// copy-contructor
|
/**
|
||||||
// vector a(3);
|
* @brief Copy-contructor.
|
||||||
// vector b = a;
|
*
|
||||||
|
* Computes:
|
||||||
|
* @code
|
||||||
|
* vector a(3);
|
||||||
|
* vector b = a;
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
*/
|
||||||
vector(const vector& other);
|
vector(const vector& other);
|
||||||
|
|
||||||
// de-contructor, releases memory
|
/**
|
||||||
|
* @brief De-contructor, releases memory.
|
||||||
|
*
|
||||||
|
* @note Releases memory.
|
||||||
|
*/
|
||||||
~vector();
|
~vector();
|
||||||
|
|
||||||
// copy-assignment
|
/**
|
||||||
//vector a(5);
|
* @brief Copy-assignment.
|
||||||
//vector b(3);
|
*
|
||||||
//b = a;
|
* Computes:
|
||||||
|
* @code
|
||||||
|
* vector a(3);
|
||||||
|
* vector b(5);
|
||||||
|
* b = a;
|
||||||
|
* @endcode
|
||||||
|
*
|
||||||
|
*/
|
||||||
vector& operator=(const vector& other);
|
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;
|
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);
|
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);
|
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);
|
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;
|
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);
|
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;
|
const T& at(panic::types::uint_t index) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -130,12 +216,6 @@ extern template struct vector<panic::types::uint_t>;
|
|||||||
} // namespace tensor
|
} // namespace tensor
|
||||||
} // namespace panic
|
} // namespace panic
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
|
||||||
// VARIABLE DESCRIPTION
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
|
||||||
// FUNCTION PROTOTYPE
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
// INCLUDE DESCRIPTION
|
// INCLUDE DESCRIPTION
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
#include <tensor/matrix.hpp>
|
#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>
|
#include <config/omp.hpp>
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
+9
-14
@@ -36,19 +36,18 @@
|
|||||||
// INCLUDE DESCRIPTION
|
// INCLUDE DESCRIPTION
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
#include <tensor/vector.hpp>
|
#include <tensor/vector.hpp>
|
||||||
|
#include <config/types.hpp>
|
||||||
#include <config/omp.hpp>
|
#include <config/omp.hpp>
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
// DEFINE DESCRIPTION
|
// PRIVATE CONSTANTS
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
|
||||||
// TYPE DESCRIPTION
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
|
||||||
// VARIABLE DESCRIPTION
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @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;
|
static const panic::types::uint_t vector_omp_min_size = 10000;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -160,10 +159,7 @@ vector<T>::~vector(){
|
|||||||
// Function Name : panic::tensor::vector::operator=
|
// Function Name : panic::tensor::vector::operator=
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
// Copy-assignment. Copies from another vector like this:
|
// Copy-assignment. Copies from another vector.
|
||||||
// vector a(5);
|
|
||||||
// vector b(3);
|
|
||||||
// b = a;
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
vector<T>& vector<T>::operator=(const vector& other){
|
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
|
// EXPLICIT TEMPLATE INSTANTIATION
|
||||||
//---------------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user