-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aecc2b7
commit 3045711
Showing
11 changed files
with
1,756 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright Carlos BRITO PACHECO 2021 - 2022. | ||
* Distributed under the Boost Software License, Version 1.0. | ||
* (See accompanying file LICENSE or copy at | ||
* https://www.boost.org/LICENSE_1_0.txt) | ||
*/ | ||
#ifndef RODIN_VARIATIONAL_COSH_H | ||
#define RODIN_VARIATIONAL_COSH_H | ||
|
||
#include "Rodin/Math.h" | ||
#include "ForwardDecls.h" | ||
#include "Function.h" | ||
#include "RealFunction.h" | ||
|
||
namespace Rodin::Variational | ||
{ | ||
/** | ||
* @defgroup CoshSpecializations Cosh Template Specializations | ||
* @brief Template specializations of the Cosh class. | ||
* @see Cosh | ||
*/ | ||
|
||
/** | ||
* @ingroup CoshSpecializations | ||
*/ | ||
template <class NestedDerived> | ||
class Cosh<FunctionBase<NestedDerived>> final | ||
: public RealFunctionBase<Cosh<FunctionBase<NestedDerived>>> | ||
{ | ||
public: | ||
using OperandType = FunctionBase<NestedDerived>; | ||
|
||
using Parent = RealFunctionBase<Cosh<FunctionBase<NestedDerived>>>; | ||
|
||
Cosh(const OperandType& v) | ||
: m_operand(v.copy()) | ||
{} | ||
|
||
Cosh(const Cosh& other) | ||
: Parent(other), | ||
m_operand(other.m_operand->copy()) | ||
{} | ||
|
||
Cosh(Cosh&& other) | ||
: Parent(std::move(other)), | ||
m_operand(std::move(other.m_operand)) | ||
{} | ||
|
||
constexpr | ||
Cosh& traceOf(Geometry::Attribute attr) | ||
{ | ||
m_operand->traceOf(attr); | ||
return *this; | ||
} | ||
|
||
constexpr | ||
Cosh& traceOf(const FlatSet<Geometry::Attribute>& attrs) | ||
{ | ||
m_operand->traceOf(attrs); | ||
return *this; | ||
} | ||
|
||
Real getValue(const Geometry::Point& p) const | ||
{ | ||
return Math::cosh(getOperand().getValue(p)); | ||
} | ||
|
||
const OperandType& getOperand() const | ||
{ | ||
assert(m_operand); | ||
return *m_operand; | ||
} | ||
|
||
Cosh* copy() const noexcept override | ||
{ | ||
return new Cosh(*this); | ||
} | ||
|
||
private: | ||
std::unique_ptr<OperandType> m_operand; | ||
}; | ||
|
||
template <class NestedDerived> | ||
Cosh(const FunctionBase<NestedDerived>&) -> Cosh<FunctionBase<NestedDerived>>; | ||
|
||
/** | ||
* @brief Helper function to construct objects of type Cosh. | ||
*/ | ||
template <class NestedDerived> | ||
auto cosh(const FunctionBase<NestedDerived>& f) | ||
{ | ||
return Cosh(f); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright Carlos BRITO PACHECO 2021 - 2022. | ||
* Distributed under the Boost Software License, Version 1.0. | ||
* (See accompanying file LICENSE or copy at | ||
* https://www.boost.org/LICENSE_1_0.txt) | ||
*/ | ||
#ifndef RODIN_VARIATIONAL_EXP_H | ||
#define RODIN_VARIATIONAL_EXP_H | ||
|
||
#include <cmath> | ||
#include "ForwardDecls.h" | ||
#include "Function.h" | ||
#include "RealFunction.h" | ||
|
||
namespace Rodin::Variational | ||
{ | ||
/** | ||
* @defgroup ExpSpecializations Exp Template Specializations | ||
* @brief Template specializations of the Exp class. | ||
* @see Exp | ||
*/ | ||
|
||
/** | ||
* @ingroup ExpSpecializations | ||
*/ | ||
template <class NestedDerived> | ||
class Exp<FunctionBase<NestedDerived>> | ||
: public RealFunctionBase<Exp<FunctionBase<NestedDerived>>> | ||
{ | ||
public: | ||
using OperandType = FunctionBase<NestedDerived>; | ||
|
||
using Parent = RealFunctionBase<Exp<OperandType>>; | ||
|
||
using OperandRangeType = typename FormLanguage::Traits<OperandType>::RangeType; | ||
|
||
Exp(const OperandType& v) | ||
: m_v(v.copy()) | ||
{} | ||
|
||
Exp(const Exp& other) | ||
: Parent(other), | ||
m_v(other.m_v->copy()) | ||
{} | ||
|
||
Exp(Exp&& other) | ||
: Parent(std::move(other)), | ||
m_v(std::move(other.m_v)) | ||
{} | ||
|
||
constexpr | ||
auto getValue(const Geometry::Point& p) const | ||
{ | ||
return Math::exp(getOperand().getValue(p)); | ||
} | ||
|
||
const OperandType& getOperand() const | ||
{ | ||
assert(m_v); | ||
return *m_v; | ||
} | ||
|
||
Exp* copy() const noexcept override | ||
{ | ||
return new Exp(*this); | ||
} | ||
|
||
private: | ||
std::unique_ptr<OperandType> m_v; | ||
}; | ||
|
||
template <class NestedDerived> | ||
Exp(const FunctionBase<NestedDerived>&) -> Exp<FunctionBase<NestedDerived>>; | ||
|
||
template <class NestedDerived> | ||
constexpr auto | ||
exp(const FunctionBase<NestedDerived>& op) | ||
{ | ||
return Exp(op); | ||
} | ||
} | ||
|
||
#endif | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.