Skip to content

Commit

Permalink
Improved documentation after reviews.
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Dafarra committed Sep 22, 2020
1 parent 7e749a9 commit cfbc4eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
7 changes: 6 additions & 1 deletion include/matioCpp/MultiDimensionalArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ class matioCpp::MultiDimensionalArray : public matioCpp::Variable
* @brief Get the index in the vectorized array corresponding to the provided indices
* @param el The desider element
* @warning It checks if the element is in the bounds only in debug mode.
*
* Since the array is stored in column-major, an element (i,j,k,l,..) of an array
* of dimensions (n,m,p,k,...) corresponds to a row index
* equal to i + j*n + k*n*m + l*n*m*p +...
*
* @return the index in the vectorized array corresponding to the provided indices
*/
index_type rawIndexFromIndices(const std::vector<index_type>& el) const;
Expand Down Expand Up @@ -150,7 +155,7 @@ class matioCpp::MultiDimensionalArray : public matioCpp::Variable

/**
* @brief Resize the vector.
* @param newSize The new size.
* @param newDimensions The new dimensions.
*
* @warning This requires to allocate memory for twice the new size.
* @warning Previous data is lost.
Expand Down
11 changes: 4 additions & 7 deletions include/matioCpp/impl/MultiDimensionalArray.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,13 @@ matioCpp::MultiDimensionalArray<T>::MultiDimensionalArray(const std::string &nam
template<typename T>
matioCpp::MultiDimensionalArray<T>::MultiDimensionalArray(const std::string &name, const std::vector<matioCpp::MultiDimensionalArray<T>::index_type> &dimensions, matioCpp::MultiDimensionalArray<T>::const_pointer inputVector)
{
matioCpp::MultiDimensionalArray<T>::index_type totalElements = 1;
for (matioCpp::MultiDimensionalArray<T>::index_type dim : dimensions)
{
if (dim == 0)
{
std::cerr << "[ERROR][matioCpp::MultiDimensionalArray::MultiDimensionalArray] Zero dimension detected." << std::endl;
assert(false);
}

totalElements *= dim;
}

initializeVariable(name,
Expand Down Expand Up @@ -131,8 +128,8 @@ bool matioCpp::MultiDimensionalArray<T>::fromVectorizedArray(const std::vector<t
template<typename T>
typename matioCpp::MultiDimensionalArray<T>::index_type matioCpp::MultiDimensionalArray<T>::rawIndexFromIndices(const std::vector<typename matioCpp::MultiDimensionalArray<T>::index_type> &el) const
{
assert(dimensions().size() && numberOfElements() && "[matioCpp::MultiDimensionalArray::rawIndexFromIndices] The array is empty.");
assert(el.size() == dimensions().size() && "[matioCpp::MultiDimensionalArray::rawIndexFromIndices] The input vector el should have the same number of dimensions of the array.");
assert(dimensions().size() > 0 && numberOfElements() > 0 && "[matioCpp::MultiDimensionalArray::rawIndexFromIndices] The array is empty.");
assert(el.size() > 0 == dimensions().size() > 0 && "[matioCpp::MultiDimensionalArray::rawIndexFromIndices] The input vector el should have the same number of dimensions of the array.");
assert(el[0] < dimensions()[0] && "[matioCpp::MultiDimensionalArray::operator()] The required element is out of bounds.");

typename matioCpp::MultiDimensionalArray<T>::index_type index = 0;
Expand All @@ -159,7 +156,7 @@ bool matioCpp::MultiDimensionalArray<T>::fromOther(const matioCpp::Variable &oth

if (other.isComplex())
{
std::cerr << "[matioCpp::MultiDimensionalArray::fromOther] The input variable is complex, this is not." << std::endl;
std::cerr << "[matioCpp::MultiDimensionalArray::fromOther] Cannot copy a complex a variable to a non-complex one." << std::endl;
return false;
}

Expand All @@ -183,7 +180,7 @@ bool matioCpp::MultiDimensionalArray<T>::fromOther(matioCpp::Variable &&other)

if (other.isComplex())
{
std::cerr << "[matioCpp::MultiDimensionalArray::fromOther] The input variable is complex, this is not." << std::endl;
std::cerr << "[matioCpp::MultiDimensionalArray::fromOther] Cannot copy a complex a variable to a non-complex one." << std::endl;
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions include/matioCpp/impl/Vector.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ bool matioCpp::Vector<T>::fromOther(const matioCpp::Variable &other)

if (other.isComplex())
{
std::cerr << "[matioCpp::Vector::fromOther] The input variable is complex, this is not." << std::endl;
std::cerr << "[matioCpp::Vector::fromOther] Cannot copy a complex a variable to a non-complex one." << std::endl;
return false;
}

Expand All @@ -122,7 +122,7 @@ bool matioCpp::Vector<T>::fromOther(matioCpp::Variable &&other)

if (other.isComplex())
{
std::cerr << "[matioCpp::Vector::fromOther] The input variable is complex, this is not." << std::endl;
std::cerr << "[matioCpp::Vector::fromOther] Cannot copy a complex a variable to a non-complex one." << std::endl;
return false;
}

Expand Down

0 comments on commit cfbc4eb

Please sign in to comment.