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
ndarray
10.1+37
include
ndarray
detail
UnaryOp.h
Go to the documentation of this file.
1
// -*- c++ -*-
2
/*
3
* LSST Data Management System
4
* Copyright 2008, 2009, 2010, 2011 LSST Corporation.
5
*
6
* This product includes software developed by the
7
* LSST Project (http://www.lsst.org/).
8
*
9
* This program is free software: you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation, either version 3 of the License, or
12
* (at your option) any later version.
13
*
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
18
*
19
* You should have received a copy of the LSST License Statement and
20
* the GNU General Public License along with this program. If not,
21
* see <http://www.lsstcorp.org/LegalNotices/>.
22
*/
23
#ifndef NDARRAY_DETAIL_UnaryOp_h_INCLUDED
24
#define NDARRAY_DETAIL_UnaryOp_h_INCLUDED
25
32
#include "
ndarray/ExpressionBase.h
"
33
#include "
ndarray/vectorize.h
"
34
#include <boost/iterator/iterator_adaptor.hpp>
35
36
namespace
ndarray {
37
namespace
detail {
38
46
template
<
typename
Operand,
typename
UnaryFunction>
47
class
UnaryOpIterator
:
public
boost::iterator_adaptor<
48
UnaryOpIterator<Operand,UnaryFunction>,
49
typename ExpressionTraits<Operand>::Iterator,
50
typename ExpressionTraits< UnaryOpExpression<Operand,UnaryFunction> >::Value,
51
boost::use_default,
52
typename ExpressionTraits< UnaryOpExpression<Operand,UnaryFunction> >::Reference
53
> {
54
typedef
UnaryOpExpression<Operand,UnaryFunction>
Operation
;
55
public
:
56
typedef
typename
ExpressionTraits<Operand>::Iterator
BaseIterator
;
57
typedef
typename
ExpressionTraits<Operation>::Value
Value
;
58
typedef
typename
ExpressionTraits<Operation>::Reference
Reference
;
59
60
UnaryOpIterator
() :
UnaryOpIterator
::iterator_adaptor_(),
_functor
() {}
61
62
UnaryOpIterator
(
BaseIterator
const
& baseIter, UnaryFunction
const
& functor) :
63
UnaryOpIterator
::iterator_adaptor_(baseIter),
_functor
(functor) {}
64
65
UnaryOpIterator
(
UnaryOpIterator
const
& other) :
66
UnaryOpIterator
::iterator_adaptor_(other),
_functor
(other.
_functor
) {}
67
68
private
:
69
friend
class
boost::iterator_core_access
;
70
71
Reference
dereference
()
const
{
72
return
vectorize
(
_functor
,*this->base_reference());
73
}
74
75
UnaryFunction
_functor
;
76
};
77
85
template
<
typename
Operand,
typename
UnaryFunction,
int
N>
86
class
UnaryOpExpression
:
public
ExpressionBase
< UnaryOpExpression<Operand,UnaryFunction,N> > {
87
typedef
UnaryOpExpression<Operand,UnaryFunction,N>
Self
;
88
public
:
89
typedef
typename
ExpressionTraits<Self>::Element
Element
;
90
typedef
typename
ExpressionTraits<Self>::ND
ND
;
91
typedef
typename
ExpressionTraits<Self>::Iterator
Iterator
;
92
typedef
typename
ExpressionTraits<Self>::Value
Value
;
93
typedef
typename
ExpressionTraits<Self>::Reference
Reference
;
94
typedef
Vector<int,N>
Index
;
95
96
UnaryOpExpression
(Operand
const
& operand, UnaryFunction
const
& functor) :
97
_operand
(operand),
_functor
(functor) {}
98
99
Reference
operator[]
(
int
n)
const
{
100
return
Reference
(
_operand
[n],
_functor
);
101
}
102
103
Iterator
begin
()
const
{
104
return
Iterator
(
_operand
.begin(),
_functor
);
105
}
106
107
Iterator
end
()
const
{
108
return
Iterator
(
_operand
.end(),
_functor
);
109
}
110
111
template
<
int
P>
int
getSize
()
const
{
112
return
_operand
.template getSize<P>();
113
}
114
115
Index
getShape
()
const
{
116
return
_operand
.getShape();
117
}
118
119
Operand
_operand
;
120
UnaryFunction
_functor
;
121
};
122
123
}
// namespace detail
124
}
// namespace ndarray
125
126
#endif // !NDARRAY_DETAIL_UnaryOp_h_INCLUDED
ndarray::detail::UnaryOpIterator
Definition:
UnaryOp.h:47
ndarray::detail::UnaryOpIterator::Reference
ExpressionTraits< Operation >::Reference Reference
Definition:
UnaryOp.h:58
ndarray::detail::UnaryOpIterator::UnaryOpIterator
UnaryOpIterator(BaseIterator const &baseIter, UnaryFunction const &functor)
Definition:
UnaryOp.h:62
ndarray::detail::UnaryOpExpression
Definition:
UnaryOp.h:86
ndarray::detail::UnaryOpExpression::Element
ExpressionTraits< Self >::Element Element
Definition:
UnaryOp.h:89
ndarray::detail::UnaryOpExpression::Iterator
ExpressionTraits< Self >::Iterator Iterator
Definition:
UnaryOp.h:91
ndarray::detail::UnaryOpIterator::iterator_core_access
friend class boost::iterator_core_access
Definition:
UnaryOp.h:69
vectorize.h
Code to apply arbitrary scalar functors to arrays.
ndarray::detail::UnaryOpIterator::dereference
Reference dereference() const
Definition:
UnaryOp.h:71
ndarray::detail::UnaryOpIterator::UnaryOpIterator
UnaryOpIterator(UnaryOpIterator const &other)
Definition:
UnaryOp.h:65
ndarray::detail::UnaryOpExpression::operator[]
Reference operator[](int n) const
Definition:
UnaryOp.h:99
ndarray::detail::UnaryOpExpression::Index
Vector< int, N > Index
Definition:
UnaryOp.h:94
ndarray::detail::UnaryOpExpression::getShape
Index getShape() const
Definition:
UnaryOp.h:115
ndarray::detail::UnaryOpIterator::Value
ExpressionTraits< Operation >::Value Value
Definition:
UnaryOp.h:57
ndarray::detail::UnaryOpExpression::_functor
UnaryFunction _functor
Definition:
UnaryOp.h:120
ndarray::Vector< int, N >
ndarray::detail::UnaryOpExpression::_operand
Operand _operand
Definition:
UnaryOp.h:119
ndarray::detail::UnaryOpExpression::ND
ExpressionTraits< Self >::ND ND
Definition:
UnaryOp.h:90
ExpressionBase.h
Definitions for ExpressionBase.
ndarray::detail::UnaryOpExpression::getSize
int getSize() const
Definition:
UnaryOp.h:111
ndarray::detail::UnaryOpExpression::begin
Iterator begin() const
Definition:
UnaryOp.h:103
ndarray::detail::UnaryOpIterator::BaseIterator
ExpressionTraits< Operand >::Iterator BaseIterator
Definition:
UnaryOp.h:56
ndarray::ExpressionTraits
Traits for expressions.
Definition:
ExpressionTraits.h:42
ndarray::detail::UnaryOpExpression::UnaryOpExpression
UnaryOpExpression(Operand const &operand, UnaryFunction const &functor)
Definition:
UnaryOp.h:96
ndarray::vectorize
UnaryFunction::result_type vectorize(UnaryFunction const &functor, Scalar const &scalar)
Apply a non-mutating unary function object to a scalar.
Definition:
vectorize.h:85
ndarray::detail::UnaryOpIterator::Operation
UnaryOpExpression< Operand, UnaryFunction > Operation
Definition:
UnaryOp.h:54
ndarray::detail::UnaryOpIterator::_functor
UnaryFunction _functor
Definition:
UnaryOp.h:75
ndarray::detail::UnaryOpExpression::Reference
ExpressionTraits< Self >::Reference Reference
Definition:
UnaryOp.h:93
ndarray::detail::UnaryOpExpression::end
Iterator end() const
Definition:
UnaryOp.h:107
ndarray::detail::UnaryOpExpression::Self
UnaryOpExpression< Operand, UnaryFunction, N > Self
Definition:
UnaryOp.h:87
ndarray::detail::UnaryOpExpression::Value
ExpressionTraits< Self >::Value Value
Definition:
UnaryOp.h:92
ndarray::ExpressionBase
CRTP base class for all multidimensional expressions.
Definition:
ExpressionBase.h:52
ndarray::detail::UnaryOpIterator::UnaryOpIterator
UnaryOpIterator()
Definition:
UnaryOp.h:60
Generated on Thu Sep 24 2015 02:29:22 for LSSTApplications by
1.8.5