47 const double tol = 1.0e-8;
65 dimension(form.dimension),
66 freedom(form.freedom),
75 dimension(M_scr.getDimension()),
76 freedom(dimension / 2),
80 V(dimension, dimension) {
83 throw SizeError(
"NormalForm::NormalForm()",
"Map is not R^n --> R^n.");
86 throw LogicalError(
"NormalForm::NormalForm()",
"Map dimension is odd.");
108 for(
int i = 0; i < 2 *
freedom; i += 2) {
128 R_dir(i, i) = R_dir(i, i + 1) = R_dir(i + 1, i) = 0.5;
129 R_dir(i + 1, i + 1) = -0.5;
130 R_inv(i, i) = R_inv(i, i + 1) = R_inv(i + 1, i) = 1.0;
131 R_inv(i + 1, i + 1) = -1.0;
135 Rot_inv(i, i) = Rot_inv(i + 1, i + 1) =
real(
lambda(i));
139 I_dir(i, i) = I_dir(i + 1, i + 1) = 0.0;
140 I_dir(i, i + 1) = I_dir(i + 1, i) = 1.0;
143 Rot_inv(i, i) = Rot_inv(i + 1, i + 1) =
real(
lambda(i) +
lambda(i + 1)) * 0.5;
144 Rot_inv(i, i + 1) = Rot_inv(i + 1, i) =
real(
lambda(i) -
lambda(i + 1)) * 0.5;
150 for(
int i = 2 * freedom; i <
dimension; i += 2) {
164 for(
int omega = 2; omega < maxOrder; omega++) {
170 f += temp[i+1].multiplyVariable(i) - temp[i].multiplyVariable(i + 1);
173 f /= double(omega + 1);
183 complex<double> factor = 1.0;
187 for(
int j = 0; j < 2 *
freedom; j += 2) {
188 if(index[j] != index[j+1]) reject =
false;
189 if(
imag(
lambda(j)) != 0.0) count += index[j+1];
190 factor *=
pow(
lambda(j),
int(index[j] - index[j+1]));
193 if(reject ||
std::abs(1.0 - factor) < tol) {
198 factor = 1.0 / (1.0 - factor);
248 for(
int mode1 = 0; mode1 <
freedom; mode1++) {
251 power1[2*mode1] = power3[2*mode1+1] = 4;
252 power2[2*mode1] = power2[2*mode1+1] = 2;
259 for(
int mode2 = mode1 + 1; mode2 <
freedom; mode2++) {
262 power1[2*mode1] = power1[2*mode2] = 2;
263 power2[2*mode1+1] = power2[2*mode2] = 2;
264 power3[2*mode1] = power3[2*mode2+1] = 2;
265 power4[2*mode1+1] = power4[2*mode2+1] = 2;
266 QQ(mode1, mode2) = QQ(mode2, mode1) =
282 for(
int j = 0; j <
V.
nrows(); j += 2) {
284 a.setCoefficient(j + 2,
V(j, 2 * mode));
285 b.setCoefficient(j + 1, -
V(j + 1, 2 * mode + 1));
286 b.setCoefficient(j + 2,
V(j, 2 * mode + 1));
290 return (a * a + b * b);
292 return (a * a - b * b);
324 if(
imag(tlam(i)) != 0.0) {
329 pb += tmat(j, i) * tmat(j + 1, i + 1) - tmat(j + 1, i) * tmat(j, i + 1);
333 lambda(n_c + 1) = tlam(i + 1);
336 double fact2 = pb / fact1;
339 V(j, n_c) = tmat(j, i) / fact1;
340 V(j, n_c + 1) = tmat(j, i + 1) / fact2;
349 V(j, nDim - 1) = 0.0;
353 V(nDim - 1, nDim - 1) = 1.0;
370 for(
int i = 0; i < n_r;) {
372 for(m = i + 1; m < n_r; m++) {
373 if(
std::abs(tlam(i) * tlam(m) - 1.0) < tol)
break;
378 "Cannot find pair of real eigenvalues.");
383 swap(tlam(m), tlam(i + 1));
391 pb += tmat(j, i) * tmat(j + 1, i + 1) - tmat(j + 1, i) * tmat(j, i + 1);
397 lambda(n_c + 1) = tlam(i + 1);
400 V(j, n_c) = (tmat(j, i) + tmat(j, i + 1)) / pb;
401 V(j, n_c + 1) = (tmat(j, i) - tmat(j, i + 1)) / pb;
415 throw LogicalError(
"NormalForm::orderModes()",
"Map dimension is odd.");
419 for(
int i = 0; i < nDim; i += 2) {
424 double c =
std::abs(
V(j, i) *
V(j + 1, i + 1) -
V(j, i + 1) *
V(j + 1, i));
442 double re =
V(i, i) /
sqrt(
V(i, i) *
V(i, i) +
V(i, i + 1) *
V(i, i + 1));
443 double im =
V(i, i + 1) /
sqrt(
V(i, i) *
V(i, i) +
V(i, i + 1) *
V(i, i + 1));
446 double real_part = re *
V(j, i) + im *
V(j, i + 1);
447 double imag_part = re *
V(j, i + 1) - im *
V(j, i);
449 V(j, i + 1) = imag_part;
void swapColumns(int c1, int c2)
Exchange columns.
const Tps< double > & normalForm() const
Get normal-form.
Tps< T > substitute(const Matrix< T > &M) const
Substitute.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Triangle decomposition of a matrix.
Double eigenvector routines.
int degreesOfFreedom() const
Get number of stable degrees of freedom.
const Matrix< double > & eigenVectors() const
Get eigenvectors.
col_iterator col_begin(int c)
Get column iterator.
int getSize() const
Get number of coefficients.
Matrix< double > anharmonicity() const
Get anharmonicities.
Matrix< double > packedEigenVectors() const
Get eigenvectors.
static LieMap< T > ExpMap(const Tps< T > &H)
Lie series.
const TpsMonomial & getExponents(int index) const
Get exponents.
col_iterator col_end(int c)
Get column iterator.
Tps< T > scaleMonomials(const Tps< T > &y) const
Multiply monomial-wise.
Tps< T > log(const Tps< T > &x)
Natural logarithm.
FLieGenerator< T, N > real(const FLieGenerator< std::complex< T >, N > &)
Take real part of a complex generator.
int getTruncOrder() const
Get lowest truncation order in any component.
int getVariables() const
Get number of variables (the same in all components).
Vps< T > filter(int lowOrder, int highOrder) const
Extract range of orders, set others to zero.
void orderModes(Vector< complex< double > >, Matrix< double >)
constexpr double pi
The value of .
constexpr double c
The velocity of light in m/s.
const Tps< double > & normalisingMap() const
Get normalising map.
VpsMap< T > substitute(const VpsMap< T > &vv) const
Substitute.
Matrix< T > linearTerms(const Vector< T > &y) const
Extract linear terms at point.
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
MMatrix< double > im(MMatrix< m_complex > mc)
Vector< complex< double > > lambda
Tps< T > sqrt(const Tps< T > &x)
Square root.
MMatrix< double > re(MMatrix< m_complex > mc)
void setCoefficient(int index, const T &value)
Set coefficient.
Exponent array for Tps<T>.
const T getCoefficient(int index) const
Get coefficient.
FLieGenerator< T, N > imag(const FLieGenerator< std::complex< T >, N > &)
Take imaginary part of a complex generator.
int nrows() const
Get number of rows.
Resonance-free normal form.
Vector< complex< double > > eigenValues() const
Get eigenvalues.
Tps< double > invariant(int i) const
Get invariant polynomial.
const Vector< complex< double > > & eigenValues() const
Get eigenvalues.