home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
develop.eb1b99edaa,2026/06/22
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
include
IMP
version 20260622.develop.eb1b99edaa
vectord_macros.h
Go to the documentation of this file.
1
/**
2
* \file IMP/vectord_macros.h
3
* \brief Various helper macros for the VectorD class.
4
*
5
* Copyright 2007-2026 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPKERNEL_VECTORD_MACROS_H
10
#define IMPKERNEL_VECTORD_MACROS_H
11
#include <boost/range/iterator_range.hpp>
12
13
#ifdef SWIG
14
#define IMP_VECTOR_SWIG_METHODS(D) VectorD(const Floats &f);
15
#else
16
#define IMP_VECTOR_SWIG_METHODS(D) \
17
template <class R> \
18
VectorD &operator=(const R &o) { \
19
P::operator=(o); \
20
return *this; \
21
}
22
23
#endif
24
25
#define IMP_VECTOR_METHODS(D) \
26
typedef IMP::internal::VectorBaseD<D> P; \
27
\
28
public: \
29
/** \brief Will accept a list of floats from Python. */
\
30
template <class Range> \
31
explicit VectorD(const Range &r) \
32
: P(r) {} \
33
template <int OD> \
34
VectorD(const VectorD<OD> &o) \
35
: P(o) { \
36
static_assert(OD == D || OD == -1 || D == -1, \
37
"VectorD size mismatch"); \
38
} \
39
IMP_VECTOR_SWIG_METHODS(D); \
40
/** The distance between b and e must be equal to D. \
41
*/
\
42
template <class It> \
43
VectorD(It b, It e) \
44
: P(boost::make_iterator_range(b, e)) {} \
45
VectorD() {} \
46
VectorD get_unit_vector() const { return IMP::internal::get_unit_vector(*this); } \
47
VectorD operator*(double s) const { \
48
VectorD ret(*this); \
49
ret *= s; \
50
return ret; \
51
} \
52
VectorD operator/(double s) const { \
53
VectorD ret(*this); \
54
ret /= s; \
55
return ret; \
56
} \
57
VectorD operator-() const { \
58
VectorD ret(*this); \
59
ret *= -1; \
60
return ret; \
61
} \
62
VectorD operator-(const VectorD &o) const { \
63
VectorD ret(*this); \
64
ret -= o; \
65
return ret; \
66
} \
67
VectorD operator+(VectorD ret) const { \
68
ret += *this; \
69
return ret; \
70
} \
71
VectorD &operator+=(const VectorD &o) { \
72
P::operator+=(o); \
73
return *this; \
74
} \
75
VectorD &operator-=(const VectorD &o) { \
76
P::operator-=(o); \
77
return *this; \
78
} \
79
VectorD &operator/=(double f) { \
80
P::operator/=(f); \
81
return *this; \
82
} \
83
VectorD &operator*=(double f) { \
84
P::operator*=(f); \
85
return *this; \
86
} \
87
/* for swig as it doesn't like using. */
\
88
double operator*(const VectorD &o) const { return P::operator*(o); }
89
90
#endif
/* IMPKERNEL_VECTORD_MACROS_H */