home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.10.0
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
include
IMP
algebra
version 2.10.0
algebra_macros.h
Go to the documentation of this file.
1
/**
2
* \file IMP/algebra/algebra_macros.h
3
* \brief Various helper macros.
4
*
5
* Copyright 2007-2018 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPALGEBRA_MACROS_H
10
#define IMPALGEBRA_MACROS_H
11
#include "
geometric_primitive_macros.h
"
12
#include <boost/range/iterator_range.hpp>
13
14
#ifdef SWIG
15
#define IMP_ALGEBRA_VECTOR_SWIG_METHODS(D) VectorD(const Floats &f);
16
#else
17
#define IMP_ALGEBRA_VECTOR_SWIG_METHODS(D) \
18
template <class R> \
19
VectorD &operator=(const R &o) { \
20
P::operator=(o); \
21
return *this; \
22
}
23
24
#endif
25
26
#define IMP_ALGEBRA_VECTOR_METHODS(D) \
27
typedef VectorBaseD<D> P; \
28
\
29
public: \
30
/** \brief Will accept a list of floats from Python. */
\
31
template <class Range> \
32
explicit VectorD(const Range &r) \
33
: P(r) {} \
34
template <int OD> \
35
VectorD(const VectorD<OD> &o) \
36
: P(o) { \
37
BOOST_STATIC_ASSERT(OD == D || OD == -1 || D == -1); \
38
} \
39
IMP_ALGEBRA_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 algebra::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
/* IMPALGEBRA_MACROS_H */
geometric_primitive_macros.h
Various important macros for implementing geometry.