cisst-saw
Loading...
Searching...
No Matches
vctUnaryOperations.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5 Author(s): Ofri Sadowsky
6 Created on: 2003-08-18
7
8 (C) Copyright 2003-2014 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17*/
18
19#pragma once
20#ifndef _vctUnaryOperations_h
21#define _vctUnaryOperations_h
22
27
54template<class _outputElementType, class _inputElementType = _outputElementType>
56{
57 public:
58 typedef _outputElementType OutputElementType;
59 typedef _inputElementType InputElementType;
60
65 class Identity {
66 public:
71 static inline OutputElementType Operate(const InputElementType & input) {
72 return OutputElementType(input);
73 }
74 };
75
80 class AbsValue {
81 public:
86 static inline OutputElementType Operate(const InputElementType & input) {
87 return (input > InputElementType(0)) ? OutputElementType(input) : OutputElementType(-input);
88 }
89 };
90
95 class Floor {
96 public:
97 static inline OutputElementType Operate(const InputElementType & input) {
98 return OutputElementType( floor((double)input) );
99 }
100 };
101
106 class Ceil {
107 public:
108 static inline OutputElementType Operate(const InputElementType & input) {
109 return OutputElementType( ceil((double)input) );
110 }
111 };
112
113
114
119 class Square {
120 public:
125 static inline OutputElementType Operate(const InputElementType & input) {
126 return OutputElementType(input * input);
127 }
128 };
129
134 class Negation {
135 public:
140 static inline OutputElementType Operate(const InputElementType & input) {
141 return OutputElementType(-input);
142 }
143 };
144
147 public:
148 static inline OutputElementType Operate(const InputElementType & input) {
149 return OutputElementType(input > InputElementType(0));
150 }
151 };
152
155 public:
156 static inline OutputElementType Operate(const InputElementType & input) {
157 return OutputElementType(input >= InputElementType(0));
158 }
159 };
160
163 public:
164 static inline OutputElementType Operate(const InputElementType & input) {
165 return OutputElementType(input <= InputElementType(0));
166 }
167 };
168
171 public:
172 static inline OutputElementType Operate(const InputElementType & input) {
173 return OutputElementType(input < InputElementType(0));
174 }
175 };
176
178 class IsNonzero {
179 public:
180 static inline OutputElementType Operate(const InputElementType & input) {
181 return OutputElementType(input != InputElementType(0));
182 }
183 };
184
186 class IsFinite {
187 public:
191 };
192
194 class IsNaN {
195 public:
199 };
200
201 /* template<unsigned int EXPONENT>
202 class Power {
203 public:
204 static inline OutputElementType Operate(const InputElementType & input) {
205 OutputElementType rootOfPower = Power<EXPONENT / 2>::OperationType(input);
206 return ((EXPONENT % 2 == 0)
207 ? (rootOfPower * rootOfPower)
208 : (rootOfPower * rootOfPower * input));
209 }
210 };
211
212 class Power<0> {
213 public:
214 static inline OutputElementType Operate(const InputElementType & input) {
215 return OutputElementType(1);
216 }
217 };
218 */
219};
220
221
222#endif // _vctUnaryOperations_h
223
static CISST_EXPORT bool IsNaN(const Type &value)
static bool IsFinite(const Type &value)
Returns the absolute value of the input as an OutputType object.
Definition vctUnaryOperations.h:80
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:86
Returns the ceiling of the input, that is, the smallest integer greater-than or equal to the input,...
Definition vctUnaryOperations.h:106
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:108
Returns the floor of the input, that is, the largest integer less-than or equal to the input,...
Definition vctUnaryOperations.h:95
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:97
Returns the input as an OutputType object.
Definition vctUnaryOperations.h:65
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:71
Definition vctUnaryOperations.h:186
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:188
Definition vctUnaryOperations.h:194
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:196
Definition vctUnaryOperations.h:170
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:172
Definition vctUnaryOperations.h:154
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:156
Definition vctUnaryOperations.h:162
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:164
Definition vctUnaryOperations.h:178
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:180
Definition vctUnaryOperations.h:146
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:148
Returns the negative of the input as an OutputType object.
Definition vctUnaryOperations.h:134
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:140
Returns the square of the input as an OutputType object.
Definition vctUnaryOperations.h:119
static OutputElementType Operate(const InputElementType &input)
Definition vctUnaryOperations.h:125
Define unary operations on an object as classes.
Definition vctUnaryOperations.h:56
_outputElementType OutputElementType
Definition vctUnaryOperations.h:58
_inputElementType InputElementType
Definition vctUnaryOperations.h:59