Skip to content

Commit

Permalink
added divide. now for the basic arithmetic operations dervis can be c…
Browse files Browse the repository at this point in the history
…alculated
  • Loading branch information
Konrad1991 committed Jun 3, 2024
1 parent 97dfe77 commit 77db7cd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/etr_bits/Vector/DerivativeCalc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ static constexpr auto walkTD() {
TimesDerivTrait>();
}

template <typename TRaw>
requires IsDivide<TRaw>
static constexpr auto walkTD() {
using TDDivision = std::remove_const_t<std::remove_reference_t<TRaw>>;
constexpr auto LT = produceVariableType<typename TDDivision::typeTraitL>();
constexpr auto RT = produceVariableType<typename TDDivision::typeTraitR>();
constexpr auto LDeriv = walkTD<typename TDDivision::typeTraitL>();
constexpr auto RDeriv = walkTD<typename TDDivision::typeTraitR>();
return produceQuarternyType<decltype(LT), decltype(RT), decltype(LDeriv),
decltype(RDeriv), QuarternaryTrait,
DivideDerivTrait>();
}

template <typename TD>
requires IsAddition<TD>
static constexpr auto walkTD() {
Expand Down
8 changes: 8 additions & 0 deletions tests/Derivatives_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,13 @@ int main() {
print(b, av);
print(get_derivs(a));
print(get_derivs(b));

std::cout << "\n"
<< "a = a / b" << std::endl;
a = a / b;
print(a, av);
print(b, av);
print(get_derivs(a));
print(get_derivs(b));
}
}

0 comments on commit 77db7cd

Please sign in to comment.