File: definitions.hpp

package info (click to toggle)
python-pyclustering 0.10.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 11,128 kB
  • sloc: cpp: 38,888; python: 24,311; sh: 384; makefile: 105
file content (136 lines) | stat: -rwxr-xr-x 2,954 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*!

@authors Andrei Novikov (pyclustering@yandex.ru)
@date 2014-2020
@copyright BSD-3-Clause

*/


#pragma once


#include <memory>
#include <string>
#include <sstream>
#include <vector>


#if (defined (__GNUC__) && defined(__unix__)) || defined(__APPLE__)
    #if defined(EXPORT_PYCLUSTERING_INTERFACE)
        #define DECLARATION __attribute__ ((__visibility__("default")))
    #else
        #define DECLARATION
    #endif
#elif defined (WIN32) || (_WIN32) || (_WIN64)
    #if defined(EXPORT_PYCLUSTERING_INTERFACE)
        #define DECLARATION __declspec(dllexport)
    #else
        #define DECLARATION
    #endif
#else
    #error Unsupported platform
#endif


namespace pyclustering {


constexpr long long RANDOM_STATE_CURRENT_TIME = -1;     /**< Defines value of the random state that means to use current system time as a seed for random functionality. */


/*!

@brief   Defines a patten that consists of features that describe this pattern.

*/
using pattern           = std::vector<double>;

/*!

@brief   Defines shared pointer to pattern container.

*/
using pattern_ptr       = std::shared_ptr<pattern>;

/*!

@brief   Defines point that represents a container with coordinates.

*/
using point             = std::vector<double>;

/*!

@brief   Defines shared pointer to point container.

*/
using point_ptr         = std::shared_ptr<point>;

/*!

@brief   Defines dataset that represents a container with points.

*/
using dataset           = std::vector<point>;

/*!

@brief   Defines shared pointer to dataset container.

*/
using dataset_ptr       = std::shared_ptr<dataset>;


/*!

@brief   Converts an input scalar value to string representation.

@param[in] p_value: scalar value that should be represented by string.

@return  String representation of a scalar value.

*/
template<typename Type, 
    typename std::enable_if<
        std::is_scalar<Type>::value
    >::type* = nullptr
>
std::string to_string(const Type & p_value) {
    return std::to_string(p_value);
}


/*!

@brief   Converts a container to string representation.

@param[in] p_container: container that should be represented by string.

@return  String representation of a container.

*/
template<typename TypeContainer, 
    typename std::enable_if<
        std::is_same<TypeContainer,
            std::vector<typename TypeContainer::value_type, typename TypeContainer::allocator_type>
        >::value
    >::type* = nullptr
>
std::string to_string(const TypeContainer & p_container) {
    std::stringstream stream;
    stream << "[";
    for (std::size_t p_index = 0; p_index < p_container.size(); p_index++) {
        stream << pyclustering::to_string(p_container[p_index]);

        if (p_index != (p_container.size() - 1)) {
            stream << " ";
        }
    }

    stream << "]";
    return stream.str();
}


}