LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
home
lsstsw
stack
Linux64
meas_algorithms
11.0-2-gb8b8ce7
src
shapelet
Pixel_omp.cc
Go to the documentation of this file.
1
// -*- LSST-C++ -*-
2
3
/*
4
* LSST Data Management System
5
* Copyright 2008, 2009, 2010 LSST Corporation.
6
*
7
* This product includes software developed by the
8
* LSST Project (http://www.lsst.org/).
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the LSST License Statement and
21
* the GNU General Public License along with this program. If not,
22
* see <http://www.lsstcorp.org/LegalNotices/>.
23
*/
24
25
#include "
lsst/meas/algorithms/shapelet/Pixel.h
"
26
27
namespace
lsst {
28
namespace
meas {
29
namespace
algorithms {
30
namespace
shapelet {
31
32
PixelList::PixelList
() :
33
_shouldUsePool(false), _v1(new std::vector<
Pixel
>())
34
{}
35
36
PixelList::PixelList
(
const
int
n) :
37
_shouldUsePool(false), _v1(new std::vector<
Pixel
>(n))
38
{}
39
40
PixelList::PixelList
(
const
PixelList
& rhs) :
41
_shouldUsePool(false), _v1(new std::vector<
Pixel
>(rhs.size()))
42
{
43
if
(rhs.
_shouldUsePool
)
44
std::copy
(rhs.
_v2
->begin(),rhs.
_v2
->end(),
_v1
->begin());
45
else
*
_v1
= *rhs.
_v1
;
46
}
47
48
PixelList
&
PixelList::operator=
(
const
PixelList
& rhs)
49
{
50
if
(
size
() != rhs.
size
())
resize
(rhs.
size
());
51
52
if
(
_shouldUsePool
) {
53
if
(rhs.
_shouldUsePool
) *
_v2
= *rhs.
_v2
;
54
else
std::copy
(rhs.
_v1
->begin(),rhs.
_v1
->end(),
_v2
->begin());
55
}
else
{
56
if
(rhs.
_shouldUsePool
)
57
std::copy
(rhs.
_v2
->begin(),rhs.
_v2
->end(),
_v1
->begin());
58
else
*
_v1
= *rhs.
_v1
;
59
}
60
return
*
this
;
61
}
62
63
PixelList::~PixelList
()
64
{
65
#ifdef _OPENMP
66
#pragma omp critical (PixelList)
67
#endif
68
{
69
_v2
.reset();
70
}
71
}
72
73
void
PixelList::usePool
()
74
{
75
#ifdef PIXELLIST_USE_POOL
76
// This should be done before any elements are added.
77
if
(
_v1
.get())
Assert
(
_v1
->size() == 0);
78
if
(
_v2
.get())
Assert
(
_v2
->size() == 0);
79
_v1
.reset();
80
#ifdef _OPENMP
81
#pragma omp critical (PixelList)
82
#endif
83
{
84
_v2
.reset(
new
std::vector<Pixel,PoolAllocPixel>());
85
}
86
_shouldUsePool
=
true
;
87
#endif
88
}
89
90
size_t
PixelList::size
()
const
91
{
92
if
(
_shouldUsePool
)
return
_v2
->size();
93
else
return
_v1
->size();
94
}
95
96
void
PixelList::reserve
(
const
int
n)
97
{
98
if
(
_shouldUsePool
) {
99
#ifdef _OPENMP
100
#pragma omp critical (PixelList)
101
#endif
102
{
103
_v2
->reserve(n);
104
}
105
}
else
{
106
_v1
->reserve(n);
107
}
108
}
109
110
size_t
PixelList::capacity
()
const
111
{
return
_shouldUsePool
?
_v2
->capacity() :
_v1
->capacity(); }
112
113
void
PixelList::resize
(
const
int
n)
114
{
115
if
(
_shouldUsePool
) {
116
#ifdef _OPENMP
117
#pragma omp critical (PixelList)
118
#endif
119
{
120
_v2
->resize(n);
121
}
122
}
else
{
123
_v1
->resize(n);
124
}
125
}
126
127
void
PixelList::clear
()
128
{
129
if
(
_shouldUsePool
) {
130
#ifdef _OPENMP
131
#pragma omp critical (PixelList)
132
#endif
133
{
134
_v2
->clear();
135
}
136
}
else
{
137
_v1
->clear();
138
}
139
}
140
141
void
PixelList::push_back
(
const
Pixel
& p)
142
{
143
if
(
_shouldUsePool
) {
144
#ifdef _OPENMP
145
#pragma omp critical (PixelList)
146
#endif
147
{
148
_v2
->push_back(p);
149
}
150
}
else
{
151
_v1
->push_back(p);
152
}
153
}
154
155
Pixel
&
PixelList::operator[]
(
const
int
i)
156
{
157
if
(
_shouldUsePool
)
return
(*
_v2
)[i];
158
else
return
(*
_v1
)[i];
159
}
160
161
const
Pixel
&
PixelList::operator[]
(
const
int
i)
const
162
{
163
if
(
_shouldUsePool
)
return
(*
_v2
)[i];
164
else
return
(*
_v1
)[i];
165
}
166
167
struct
PixelListSorter
168
{
169
Position
_cen
;
170
PixelListSorter
(
const
Position
& cen) :
_cen
(cen) {}
171
bool
operator()
(
const
Pixel
& p1,
const
Pixel
& p2)
const
172
{
return
std::norm
(p1.
getPos
()-
_cen
) <
std::norm
(p2.
getPos
()-
_cen
); }
173
};
174
175
void
PixelList::sort
(
const
Position
& cen)
176
{
177
PixelListSorter
sorter(cen);
178
if
(
_shouldUsePool
) std::sort(
_v2
->begin(),
_v2
->end(),sorter);
179
else
std::sort(
_v1
->begin(),
_v1
->end(),sorter);
180
}
181
182
}}}}
lsst::meas::algorithms::shapelet::PixelList::PixelList
PixelList()
Definition:
Pixel_omp.cc:32
lsst::meas::algorithms::shapelet::Pixel::getPos
std::complex< double > getPos() const
Definition:
Pixel.h:47
lsst::meas::algorithms::shapelet::PixelList
Definition:
Pixel.h:72
lsst::meas::algorithms::shapelet::PixelListSorter::PixelListSorter
PixelListSorter(const Position &cen)
Definition:
Pixel_omp.cc:170
lsst::meas::algorithms::shapelet::PixelList::reserve
void reserve(const int n)
Definition:
Pixel_omp.cc:96
lsst::meas::algorithms::shapelet::PixelList::_shouldUsePool
bool _shouldUsePool
Definition:
Pixel.h:97
lsst::meas::algorithms::shapelet::PixelList::_v2
boost::shared_ptr< std::vector< Pixel > > _v2
Definition:
Pixel.h:103
Pixel.h
lsst::meas::algorithms::shapelet::PixelList::push_back
void push_back(const Pixel &p)
Definition:
Pixel_omp.cc:141
ndarray::copy
SelectEigenView< T >::Type copy(Eigen::EigenBase< T > const &other)
Copy an arbitrary Eigen expression into a new EigenView.
Definition:
eigen.h:390
lsst::afw::math::details::norm
T norm(const T &x)
Definition:
Integrate.h:191
lsst::meas::algorithms::shapelet::PixelList::resize
void resize(const int n)
Definition:
Pixel_omp.cc:113
lsst::meas::algorithms::shapelet::PixelList::~PixelList
~PixelList()
Definition:
Pixel_omp.cc:63
lsst::meas::algorithms::shapelet::Position
Definition:
Bounds.h:12
lsst::meas::algorithms::shapelet::PixelList::capacity
size_t capacity() const
Definition:
Pixel_omp.cc:110
lsst::meas::algorithms::shapelet::PixelListSorter
Definition:
Pixel_omp.cc:167
lsst::meas::algorithms::shapelet::PixelListSorter::_cen
Position _cen
Definition:
Pixel_omp.cc:169
lsst::meas::algorithms::shapelet::PixelList::_v1
boost::shared_ptr< std::vector< Pixel > > _v1
Definition:
Pixel.h:98
lsst::meas::algorithms::shapelet::PixelList::operator=
PixelList & operator=(const PixelList &rhs)
Definition:
Pixel_omp.cc:48
lsst::meas::algorithms::shapelet::PixelListSorter::operator()
bool operator()(const Pixel &p1, const Pixel &p2) const
Definition:
Pixel_omp.cc:171
lsst::meas::algorithms::shapelet::PixelList::usePool
void usePool()
Definition:
Pixel_omp.cc:73
lsst::meas::algorithms::shapelet::PixelList::operator[]
Pixel & operator[](const int i)
Definition:
Pixel_omp.cc:155
lsst::meas::algorithms::shapelet::PixelList::clear
void clear()
Definition:
Pixel_omp.cc:127
lsst::meas::algorithms::shapelet::PixelList::sort
void sort(const Position &cen)
Definition:
Pixel_omp.cc:175
lsst::meas::algorithms::shapelet::PixelList::size
size_t size() const
Definition:
Pixel_omp.cc:90
lsst::meas::algorithms::shapelet::Pixel
Definition:
Pixel.h:33
Assert
#define Assert(x)
Definition:
dbg.h:73
Generated on Thu Sep 24 2015 02:29:21 for LSSTApplications by
1.8.5