MarmotNumericalDifferentiation.h
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------
2  * _
3  * _ __ ___ __ _ _ __ _ __ ___ ___ | |_
4  * | '_ ` _ \ / _` | '__| '_ ` _ \ / _ \| __|
5  * | | | | | | (_| | | | | | | | | (_) | |_
6  * |_| |_| |_|\__,_|_| |_| |_| |_|\___/ \__|
7  *
8  * Unit of Strength of Materials and Structural Analysis
9  * University of Innsbruck,
10  * 2020 - today
11  *
12  * festigkeitslehre@uibk.ac.at
13  *
14  * Alexander Dummer alexander.dummer@uibk.ac.at
15  *
16  * This file is part of the MAteRialMOdellingToolbox (marmot).
17  *
18  * This library is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU Lesser General Public
20  * License as published by the Free Software Foundation; either
21  * version 2.1 of the License, or (at your option) any later version.
22  *
23  * The full text of the license can be found in the file LICENSE.md at
24  * the top level directory of marmot.
25  * ---------------------------------------------------------------------
26  */
27 
28 #pragma once
29 #include "Marmot/MarmotMath.h"
30 #include "Marmot/MarmotTypedefs.h"
31 #include <functional>
32 
33 namespace Marmot {
34  namespace NumericalAlgorithms::Differentiation {
35 
36  using scalar_to_scalar_function_type = std::function< double( const double x ) >;
37  using vector_to_vector_function_type = std::function< Eigen::VectorXd( const Eigen::VectorXd& X ) >;
38 
39  double forwardDifference( const scalar_to_scalar_function_type& f, const double x );
40  double centralDifference( const scalar_to_scalar_function_type& f, const double x );
41 
42  Eigen::MatrixXd forwardDifference( const vector_to_vector_function_type& F, const Eigen::VectorXd& X );
43  Eigen::MatrixXd centralDifference( const vector_to_vector_function_type& F, const Eigen::VectorXd& X );
44 
45  namespace Complex {
46 
47  const static std::complex< double > imaginaryUnit = { 0, 1 };
48  const static std::complex< double > complexUnit = { 1, 1 };
49  const static std::complex< double > i_ = Marmot::Constants::sqrt2 / 2. * complexUnit;
50 
51  using scalar_to_scalar_function_type = std::function< complexDouble( const complexDouble x ) >;
52  using vector_to_vector_function_type = std::function< Eigen::VectorXcd( const Eigen::VectorXcd& X ) >;
53 
54  double forwardDifference( const scalar_to_scalar_function_type& f, const double x );
55 
56  std::tuple< Eigen::VectorXd, Eigen::MatrixXd > forwardDifference( const vector_to_vector_function_type& F,
57  const Eigen::VectorXd& X );
58 
59  Eigen::MatrixXd centralDifference( const vector_to_vector_function_type& F, const Eigen::VectorXd& X );
60 
62  const Eigen::VectorXd& X );
63 
64  } // namespace Complex
65  } // namespace NumericalAlgorithms::Differentiation
66 } // namespace Marmot
Marmot::NumericalAlgorithms::Differentiation::Complex::complexUnit
static const std::complex< double > complexUnit
Definition: MarmotNumericalDifferentiation.h:48
Marmot::Constants::sqrt2
constexpr double sqrt2
Definition: MarmotConstants.h:50
MarmotTypedefs.h
MarmotMath.h
Marmot::NumericalAlgorithms::Differentiation::Complex::centralDifference
Eigen::MatrixXd centralDifference(const vector_to_vector_function_type &F, const Eigen::VectorXd &X)
Marmot::NumericalAlgorithms::Differentiation::Complex::fourthOrderAccurateDerivative
Eigen::MatrixXd fourthOrderAccurateDerivative(const vector_to_vector_function_type &F, const Eigen::VectorXd &X)
Marmot::NumericalAlgorithms::Differentiation::Complex::forwardDifference
double forwardDifference(const scalar_to_scalar_function_type &f, const double x)
Definition: MarmotNumericalDifferentiation.cpp:82
Marmot::NumericalAlgorithms::Differentiation::vector_to_vector_function_type
std::function< Eigen::VectorXd(const Eigen::VectorXd &X) > vector_to_vector_function_type
Definition: MarmotNumericalDifferentiation.h:37
Marmot::NumericalAlgorithms::Differentiation::centralDifference
double centralDifference(const scalar_to_scalar_function_type &f, const double x)
Definition: MarmotNumericalDifferentiation.cpp:17
Marmot
This file includes functions needed for calculations with stress and strain tensors written in voigt ...
Definition: MarmotTesting.h:30
Marmot::complexDouble
std::complex< double > complexDouble
Definition: MarmotTypedefs.h:59
Marmot::NumericalAlgorithms::Differentiation::Complex::scalar_to_scalar_function_type
std::function< complexDouble(const complexDouble x) > scalar_to_scalar_function_type
Definition: MarmotNumericalDifferentiation.h:51
Marmot::NumericalAlgorithms::Differentiation::forwardDifference
double forwardDifference(const scalar_to_scalar_function_type &f, const double x)
Definition: MarmotNumericalDifferentiation.cpp:10
Marmot::FiniteElement::EAS::F
Eigen::MatrixXd F(const Eigen::MatrixXd &J)
Marmot::NumericalAlgorithms::Differentiation::scalar_to_scalar_function_type
std::function< double(const double x) > scalar_to_scalar_function_type
Definition: MarmotNumericalDifferentiation.h:36
Marmot::NumericalAlgorithms::Differentiation::Complex::vector_to_vector_function_type
std::function< Eigen::VectorXcd(const Eigen::VectorXcd &X) > vector_to_vector_function_type
Definition: MarmotNumericalDifferentiation.h:52
Marmot::NumericalAlgorithms::Differentiation::Complex::i_
static const std::complex< double > i_
Definition: MarmotNumericalDifferentiation.h:49
Marmot::NumericalAlgorithms::Differentiation::Complex::imaginaryUnit
static const std::complex< double > imaginaryUnit
Definition: MarmotNumericalDifferentiation.h:47