v0.13.1
Loading...
Searching...
No Matches
MatrixFunction.hpp
Go to the documentation of this file.
1/** \file FunctionMatrix.hpp
2 \brief Get function from matrix
3 \ingroup ftensor
4
5 For reference see \cite miehe2001algorithms
6
7 Usage:
8
9 To calculate exponent of matrix, first and second derivatives
10 \code
11 auto f = [](double v) { return exp(v); };
12 auto d_f = [](double v) { return exp(v); };
13 auto dd_f = [](double v) { return exp(v); };
14 \endcode
15
16 Calculate matrix here t_L are vector of eigen values, and t_N is matrix of
17 eigen vectors.
18 \code
19 auto t_A = EigenMatrix::getMat(t_L, t_N, f);
20 \endcode
21 Return t_A is symmetric tensor rank two.
22
23 Calculate derivative
24 \code
25 auto t_P = EigenMatrix::getDiffMat(t_L, t_N, f, d_f ,nb);
26 \endcode
27 where return t_SL is 4th order tensor (symmetry on first two and
28 second to indices, i.e. minor symmetrise)
29
30 Calculate second derivative, L, such that S:L, for given S,
31 \code
32 FTensor::Tensor2<double, 3, 3> t_S{
33
34 1., 0., 0.,
35
36 0., 1., 0.,
37
38 0., 0., 1.};
39
40 auto t_SL = EigenMatrix::getDiffDiffMat( t_L, t_N, f, d_f, dd_f, t_S, nb)
41 \endcode
42 where return t_SL is 4th order tensor (symmetry on first two and
43 second to indices, i.e. minor symmetrise)
44
45 You can calculate eigen values using lapack.
46
47 Eiegn values should be sorted such that unique values are first, and last eiegn
48 value is reapitting. For example if eiegn values are \f[ \lambda = \{1,1,2} \f]
49 should be sorted such that
50 \f[
51 \lambda = \{1,2,1}
52 \f]
53 Eigen vectors should be updated, such that order of eigen vectors follow order
54 of eigen values.
55
56 *
57 */
58
59
60
61#pragma once
62
63namespace EigenMatrix {
64
65template <typename T, int Dim> using Val = const FTensor::Tensor1<T, Dim>;
66template <typename T, int Dim> using Vec = const FTensor::Tensor2<T, Dim, Dim>;
67template <typename T> using Fun = boost::function<T(const T)>;
68
69/**
70 * @brief Get the Mat object
71 *
72 * \f[
73 * \mathbf{B} = f(\mathbf{A})
74 * \f]
75 *
76 * \f[
77 * B_{ij} = \sum_{a}^d f(\lambda^a) n^a_i n^a_j
78 * \f]
79 * where \f$a\f$ is eigen value number.
80 *
81 * @param t_val eigen values
82 * @param t_vec eigen vector
83 * @param f function
84 * @return FTensor::Tensor2_symmetric<double, 3>
85 */
88
89/**
90 * @copydoc EigenMatrix::getMat
91 */
95
96/**
97 * @brief Get the Diff Mat object
98 *
99 * \f[
100 * P_{ijkl} = \frac{\partial B_{ij}}{\partial A_{kl}}
101 * \f]
102 *
103 * \note Eiegn vetore are in rows.
104 *
105 * @param t_val eigen values
106 * @param t_vec eigen vector
107 * @param f function
108 * @param d_f directive of function
109 * @param nb number of nonequal eigen valuse
110 * @return FTensor::Ddg<double, 3, 3>
111 */
113 Vec<double, 3> &t_vec, Fun<double> f,
114 Fun<double> d_f, const int nb);
115/**
116 * @copydoc EigenMatrix::getDiffMat
117 */
121 Fun<double> d_f, const int nb);
122
123/**
124 * @brief Get the Diff Diff Mat object
125 *
126 * \f[
127 * LS_{klmn} =
128 * S_{ij} \frac{\partial^2 B_{ij}}{\partial A_{kl} \partial A_{mn} }
129 * \f]
130 *
131 * \note Eiegn vetore are in rows.
132 *
133 * @param t_val eiegn values
134 * @param t_vec eigen vectors
135 * @param f function
136 * @param d_f directive of function
137 * @param dd_f second directive of function
138 * @param t_S S tensor
139 * @param nb number of nonzero eigen values
140 * @return FTensor::Ddg<double, 3, 3>
141 */
144 Fun<double> d_f, Fun<double> dd_f,
145 FTensor::Tensor2_symmetric<double, 3> &t_S, const int nb);
146
147/**
148 * @copydoc EigenMatrix::getDiffDiffMat
149 */
151 Vec<double, 3> &t_vec, Fun<double> f,
152 Fun<double> d_f, Fun<double> dd_f,
154 const int nb);
155/**
156 * @copydoc EigenMatrix::getDiffMat
157 */
161 Fun<double> d_f, Fun<double> dd_f,
162 FTensor::Tensor2<double, 3, 3> &t_S, const int nb);
163
164/**
165 * @copydoc EigenMatrix::getMat
166 */
169
170/**
171 * @copydoc EigenMatrix::getDiffMat
172 */
174 Vec<double, 2> &t_vec, Fun<double> f,
175 Fun<double> d_f, const int nb);
176
177/**
178 * @copydoc EigenMatrix::getDiffDiffMat
179 */
181 Vec<double, 2> &t_vec, Fun<double> f,
182 Fun<double> d_f, Fun<double> dd_f,
184 const int nb);
185
186/**
187 * @copydoc EigenMatrix::getDiffDiffMat
188 */
191 Fun<double> d_f, Fun<double> dd_f,
192 FTensor::Tensor2_symmetric<double, 2> &t_S, const int nb);
193
194} // namespace EigenMatrix
const double T
boost::function< T(const T)> Fun
FTensor::Ddg< double, 3, 3 > getDiffMat(Val< double, 3 > &t_val, Vec< double, 3 > &t_vec, Fun< double > f, Fun< double > d_f, const int nb)
Get the Diff Mat object.
FTensor::Tensor2_symmetric< double, 3 > getMat(Val< double, 3 > &t_val, Vec< double, 3 > &t_vec, Fun< double > f)
Get the Mat object.
FTensor::Ddg< double, 3, 3 > getDiffDiffMat(Val< double, 3 > &t_val, Vec< double, 3 > &t_vec, Fun< double > f, Fun< double > d_f, Fun< double > dd_f, FTensor::Tensor2< double, 3, 3 > &t_S, const int nb)