The Conley-Morse Graphs Software
spacewrap.h
Go to the documentation of this file.
1/////////////////////////////////////////////////////////////////////////////
2///
3/// @file spacewrap.h
4///
5/// Helper functions and an auxiliary class for space wrapping.
6///
7/// @author Pawel Pilarczyk
8///
9/////////////////////////////////////////////////////////////////////////////
10
11// Copyright (C) 1997-2014 by Pawel Pilarczyk.
12//
13// This file is part of my research software package. This is free software:
14// you can redistribute it and/or modify it under the terms of the GNU
15// General Public License as published by the Free Software Foundation,
16// either version 3 of the License, or (at your option) any later version.
17//
18// This software is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU General Public License for more details.
22//
23// You should have received a copy of the GNU General Public License
24// along with this software; see the file "license.txt". If not,
25// please, see <https://www.gnu.org/licenses/>.
26
27// Started on February 11, 2008. Last revision: February 27, 2013.
28
29
30#ifndef _CMGRAPHS_SPACEWRAP_H_
31#define _CMGRAPHS_SPACEWRAP_H_
32
33
34// include selected header files from the CHomP library
35#include "chomp/system/config.h"
36
37// include local header files
38#include "config.h"
39#include "typedefs.h"
40
41
42// --------------------------------------------------
43// -------------- phase space wrapping --------------
44// --------------------------------------------------
45
46/// Sets the appropriate space wrapping and returns true iff there is
47/// some non-trivial wrapping in any direction.
48inline bool setSpaceWrapping (int width)
49{
50 bool wrapping = false;
51 spcCoord wrap [2 * spaceDim];
52 for (int i = 0; i < spaceDim; ++ i)
53 {
54 if (spaceWrapping [i])
55 {
56 wrapping = true;
57 wrap [i] = wrap [spaceDim + i] = width;
58 }
59 else
60 wrap [i] = wrap [spaceDim + i] = 0;
61 }
62 if (wrapping)
63 {
64 spcCube::PointBase::setwrapping (wrap,
65 spaceDim, 2 * spaceDim + 1);
66 }
67 return wrapping;
68} /* setSpaceWrapping */
69
70/// Unsets any space wrapping in the phase space.
71inline void unsetSpaceWrapping ()
72{
73// const spcCoord zero (0);
74 spcCube::PointBase::setwrapping (static_cast<spcCoord> (0));
75 return;
76} /* unsetSpaceWrapping */
77
78/// Sets space wrapping locally.
79/// The space wrapping is set in the constructor of the objects
80/// of this class, and the space wrapping is unset in the destructor.
82{
83public:
84 /// The constructor sets space wrapping.
85 localSpaceWrapping (int width):
87 {
88 return;
89 }
90
91 /// The destructor unsets space wrapping.
93 {
94 if (wrapping)
96 return;
97 }
98
99 /// Returns true iff space wrapping was set in any direction.
100 operator bool () const
101 {
102 return wrapping;
103 }
104
105private:
106 /// Was space wrapping set in any direction?
108
109}; /* class localSpaceWrapping */
110
111
112#endif // _CMGRAPHS_SPACEWRAP_H_
113
Sets space wrapping locally.
Definition: spacewrap.h:82
bool wrapping
Was space wrapping set in any direction?
Definition: spacewrap.h:107
~localSpaceWrapping()
The destructor unsets space wrapping.
Definition: spacewrap.h:92
localSpaceWrapping(int width)
The constructor sets space wrapping.
Definition: spacewrap.h:85
Choice of configuration settings.
const int spaceDim
The dimension of the phase space.
Definition: p_differ.h:48
const bool spaceWrapping[spaceDim]
Is space wrapping (a.k.a.
Definition: p_differ.h:52
bool setSpaceWrapping(int width)
Sets the appropriate space wrapping and returns true iff there is some non-trivial wrapping in any di...
Definition: spacewrap.h:48
void unsetSpaceWrapping()
Unsets any space wrapping in the phase space.
Definition: spacewrap.h:71
Customizable data types for the Conley-Morse graphs computation program.
int spcCoord
The type of coordinates of cubes in the phase space.
Definition: typespace.h:50