Skip to content

Commit

Permalink
small fixes and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
thelfer committed May 13, 2024
1 parent d145ba8 commit 91890c6
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 57 deletions.
53 changes: 34 additions & 19 deletions include/TFEL/Math/Array/GenericFixedSizeArray.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ namespace tfel::math {
template <typename ValueType>
TFEL_HOST_DEVICE constexpr explicit GenericFixedSizeArray(
const ValueType&) noexcept requires(isAssignableTo<ValueType,
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
typename GenericFixedSizeArray<
Child,
ArrayPolicy,
N>::
value_type>());
/*!
* \brief constructor from an initializer list
Expand All @@ -133,8 +136,10 @@ namespace tfel::math {
template <typename ValueType2>
TFEL_HOST_DEVICE constexpr GenericFixedSizeArray(
const std::initializer_list<ValueType2>& values) noexcept //
requires(isAssignableTo<ValueType2,
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::value_type>());
requires(isAssignableTo<
ValueType2,
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
value_type>());
/*!
* \brief default donstructor.
* \param p pointer to an array used to initialise the components
Expand All @@ -145,7 +150,9 @@ namespace tfel::math {
const InputIterator) noexcept //
requires(std::is_same_v<
typename std::iterator_traits<InputIterator>::value_type,
base_type<typename GenericFixedSizeArray::value_type>>);
base_type<typename GenericFixedSizeArray<Child,
ArrayPolicy,
N>::value_type>>);
/*!
* \brief copy constructor from an object assignable to the `Child` class.
* \param[in] src: source
Expand All @@ -162,8 +169,9 @@ namespace tfel::math {
* be greater than than the logical number of elements contained in the
* array which is returned by `IndexingPolicy::size`.
*/
TFEL_HOST_DEVICE constexpr typename GenericFixedSizeArray<Child, ArrayPolicy, N>::size_type
getContainerSize() const noexcept;
TFEL_HOST_DEVICE constexpr
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::size_type
getContainerSize() const noexcept;
// inheriting MutableFixedSizeArrayBase' assignement operator
using MutableFixedSizeArrayBase<
GenericFixedSizeArray<Child, ArrayPolicy, N>,
Expand All @@ -190,26 +198,33 @@ namespace tfel::math {
//
template <typename ValueType2>
TFEL_HOST_DEVICE constexpr Child& operator*=(const ValueType2&) noexcept //
requires(isAssignableTo<BinaryOperationResult<
ValueType2,
typename GenericFixedSizeArray::value_type,
OpMult>,
typename GenericFixedSizeArray::value_type>());
requires(isAssignableTo<
BinaryOperationResult<
ValueType2,
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
value_type,
OpMult>,
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
value_type>());
//
template <typename ValueType2>
TFEL_HOST_DEVICE constexpr Child& operator/=(const ValueType2&) noexcept //
requires(isAssignableTo<BinaryOperationResult<
typename GenericFixedSizeArray::value_type,
ValueType2,
OpDiv>,
typename GenericFixedSizeArray::value_type>());
requires(isAssignableTo<
BinaryOperationResult<
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
value_type,
ValueType2,
OpDiv>,
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
value_type>());
//! \return a pointer to the underlying array serving as element storage.
TFEL_HOST_DEVICE constexpr typename GenericFixedSizeArray<Child, ArrayPolicy, N>::pointer
data() noexcept;
TFEL_HOST_DEVICE constexpr
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::pointer
data() noexcept;
//! \return a pointer to the underlying array serving as element storage.
TFEL_HOST_DEVICE constexpr
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::const_pointer
data() const noexcept;
data() const noexcept;

protected:
//! \brief assignement operator
Expand Down
37 changes: 24 additions & 13 deletions include/TFEL/Math/Array/GenericFixedSizeArray.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ namespace tfel::math {
TFEL_HOST_DEVICE constexpr GenericFixedSizeArray<Child, ArrayPolicy, N>::
GenericFixedSizeArray(const ValueType& value) noexcept requires(
isAssignableTo<ValueType,
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::value_type>())
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
value_type>())
: GenericFixedSizeArray() {
this->fill(value);
} // end of GenericFixedSizeArray
Expand All @@ -64,7 +65,8 @@ namespace tfel::math {
: GenericFixedSizeArray() {
// static_assert(checkIndexingPoliciesCompatiblity<
// typename ArrayPolicy::indexing_policy,
// typename OtherArray::ArrayPolicy::indexing_policy>());
// typename OtherArray<Child, ArrayPolicy,
// N>::ArrayPolicy::indexing_policy>());
this->operator=(src);
} // end of GenericFixedSizeArray

Expand All @@ -75,8 +77,10 @@ namespace tfel::math {
TFEL_HOST_DEVICE constexpr GenericFixedSizeArray<Child, ArrayPolicy, N>::
GenericFixedSizeArray(
const std::initializer_list<ValueType>& values) noexcept //
requires(isAssignableTo<ValueType,
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::value_type>())
requires(
isAssignableTo<ValueType,
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
value_type>())
: GenericFixedSizeArray() {
if (values.size() == 1u) {
this->fill(*(values.begin()));
Expand All @@ -93,7 +97,8 @@ namespace tfel::math {
GenericFixedSizeArray(const InputIterator p) noexcept //
requires(std::is_same_v<
typename std::iterator_traits<InputIterator>::value_type,
base_type<typename GenericFixedSizeArray::value_type>>) {
base_type<typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
value_type>>) {
const auto& policy = this->getRowMajorIndexingPolicy();
this->import(policy, p, p + this->size());
} // end of GenericFixedSizeArray
Expand Down Expand Up @@ -165,10 +170,13 @@ namespace tfel::math {
GenericFixedSizeArray<Child, ArrayPolicy, N>::operator*=(
const ValueType2& s) noexcept //
requires(isAssignableTo<
BinaryOperationResult<ValueType2,
typename GenericFixedSizeArray::value_type,
OpMult>,
typename GenericFixedSizeArray::value_type>()) {
BinaryOperationResult<
ValueType2,
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
value_type,
OpMult>,
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
value_type>()) {
auto& child = static_cast<Child&>(*this);
child.multiplyByScalar(s);
return child;
Expand All @@ -182,10 +190,13 @@ namespace tfel::math {
GenericFixedSizeArray<Child, ArrayPolicy, N>::operator/=(
const ValueType2& s) noexcept //
requires(isAssignableTo<
BinaryOperationResult<typename GenericFixedSizeArray::value_type,
ValueType2,
OpDiv>,
typename GenericFixedSizeArray::value_type>()) {
BinaryOperationResult<
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
value_type,
ValueType2,
OpDiv>,
typename GenericFixedSizeArray<Child, ArrayPolicy, N>::
value_type>()) {
auto& child = static_cast<Child&>(*this);
child.multiplyByScalar(1 / s);
return child;
Expand Down
36 changes: 22 additions & 14 deletions include/TFEL/Math/Array/GenericRuntimeArray.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,22 @@ namespace tfel::math {
explicit GenericRuntimeArray(
const typename ArrayPolicy::IndexingPolicy&,
const ValueType&) requires(isAssignableTo<ValueType,
typename GenericRuntimeArray<Child, ArrayPolicy>::
typename GenericRuntimeArray<
Child,
ArrayPolicy>::
value_type>());
/*!
* \brief constructor from an initializer list
* \param[in] values: values
*/
template <typename ValueType>
GenericRuntimeArray(
const typename GenericRuntimeArray::indexing_policy,
const typename GenericRuntimeArray<Child, ArrayPolicy>::indexing_policy,
const std::initializer_list<
ValueType>&) requires((isAssignableTo<ValueType,
typename GenericRuntimeArray<Child, ArrayPolicy>::
typename GenericRuntimeArray<
Child,
ArrayPolicy>::
value_type>()) &&
(ArrayPolicy::IndexingPolicy::arity == 1) &&
(ArrayPolicy::IndexingPolicy::
Expand All @@ -130,8 +134,9 @@ namespace tfel::math {
*/
template <typename ValueType>
GenericRuntimeArray(const std::initializer_list<ValueType>&) requires(
(isAssignableTo<ValueType,
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type>()) &&
(isAssignableTo<
ValueType,
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type>()) &&
(ArrayPolicy::IndexingPolicy::arity == 1) &&
(ArrayPolicy::IndexingPolicy::areDataContiguous));
/*!
Expand All @@ -147,16 +152,17 @@ namespace tfel::math {
//! \return a pointer to the underlying array serving as element storage.
typename GenericRuntimeArray<Child, ArrayPolicy>::pointer data() noexcept;
//! \return a pointer to the underlying array serving as element storage.
typename GenericRuntimeArray<Child, ArrayPolicy>::const_pointer data()
const noexcept;
typename GenericRuntimeArray<Child, ArrayPolicy>::const_pointer data() const
noexcept;
//! \brief resize the array
void resize(const typename ArrayPolicy::IndexingPolicy&);
/*!
* \return the physical size used by the underlying array. This size must
* be greater than than the logical number of elements contained in the
* array which is returned by `IndexingPolicy::size`.
*/
typename GenericRuntimeArray<Child, ArrayPolicy>::size_type getContainerSize() const noexcept;
typename GenericRuntimeArray<Child, ArrayPolicy>::size_type
getContainerSize() const noexcept;
// inheriting MutableRuntimeArrayBase' assignement operator
using MutableRuntimeArrayBase<GenericRuntimeArray<Child, ArrayPolicy>,
ArrayPolicy>::operator=;
Expand All @@ -180,17 +186,19 @@ namespace tfel::math {
template <typename ValueType2>
Child& operator*=(const ValueType2&) noexcept requires(
isAssignableTo<
BinaryOperationResult<ValueType2,
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type,
OpMult>,
BinaryOperationResult<
ValueType2,
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type,
OpMult>,
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type>());
//
template <typename ValueType2>
Child& operator/=(const ValueType2&) noexcept requires(
isAssignableTo<
BinaryOperationResult<typename GenericRuntimeArray<Child, ArrayPolicy>::value_type,
ValueType2,
OpDiv>,
BinaryOperationResult<
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type,
ValueType2,
OpDiv>,
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type>());
//
bool empty() const;
Expand Down
24 changes: 14 additions & 10 deletions include/TFEL/Math/Array/GenericRuntimeArray.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ namespace tfel::math {
GenericRuntimeArray<Child, ArrayPolicy>::GenericRuntimeArray(
const typename ArrayPolicy::IndexingPolicy& p,
const ValueType& value) //
requires(
isAssignableTo<ValueType, typename GenericRuntimeArray<Child, ArrayPolicy>::value_type>())
requires(isAssignableTo<
ValueType,
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type>())
: GenericRuntimeArray(p) {
this->fill(value);
} // end of GenericRuntimeArray
Expand All @@ -49,8 +50,9 @@ namespace tfel::math {
GenericRuntimeArray<Child, ArrayPolicy>::GenericRuntimeArray(
const std::initializer_list<ValueType>&
values) requires((isAssignableTo<ValueType,
typename GenericRuntimeArray<Child, ArrayPolicy>::
value_type>()) &&
typename GenericRuntimeArray<
Child,
ArrayPolicy>::value_type>()) &&
(ArrayPolicy::IndexingPolicy::arity == 1) &&
(ArrayPolicy::IndexingPolicy::areDataContiguous))
: GenericRuntimeArray(values.size()) {
Expand Down Expand Up @@ -129,9 +131,10 @@ namespace tfel::math {
Child& GenericRuntimeArray<Child, ArrayPolicy>::
operator*=(const ValueType2& v) noexcept requires(
isAssignableTo<
BinaryOperationResult<ValueType2,
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type,
OpMult>,
BinaryOperationResult<
ValueType2,
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type,
OpMult>,
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type>()) {
auto& child = static_cast<Child&>(*this);
child.multiplyByScalar(v);
Expand All @@ -143,9 +146,10 @@ namespace tfel::math {
Child& GenericRuntimeArray<Child, ArrayPolicy>::
operator/=(const ValueType2& v) noexcept requires(
isAssignableTo<
BinaryOperationResult<typename GenericRuntimeArray<Child, ArrayPolicy>::value_type,
ValueType2,
OpDiv>,
BinaryOperationResult<
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type,
ValueType2,
OpDiv>,
typename GenericRuntimeArray<Child, ArrayPolicy>::value_type>()) {
auto& child = static_cast<Child&>(*this);
child.multiplyByScalar(1 / v);
Expand Down
2 changes: 1 addition & 1 deletion include/TFEL/Math/Matrix/matrix.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#ifndef LIB_TFEL_MATH_MATRIX_IXX
#define LIB_TFEL_MATH_MATRIX_IXX

#include"TFEL/Raise.hxx"
#include "TFEL/Raise.hxx"

namespace tfel::math {

Expand Down

0 comments on commit 91890c6

Please sign in to comment.