cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vctStoreBackUnaryOperations.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 
6  Author(s): Ofri Sadowsky, Anton Deguet
7  Created on: 2003-08-18
8 
9  (C) Copyright 2003-2007 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 */
20 
21 #pragma once
22 #ifndef _vctStoreBackUnaryOperations_h
23 #define _vctStoreBackUnaryOperations_h
24 
55 template<class _inputOutputElementType>
57 {
58  public:
59  typedef _inputOutputElementType InputOutputElementType;
60 
65  class MakeAbs {
66  public:
71  static inline InputOutputElementType Operate(InputOutputElementType & inputOutput) {
72  return (inputOutput = (inputOutput > InputOutputElementType(0))
73  ?
74  InputOutputElementType(inputOutput)
75  :
76  InputOutputElementType(-inputOutput));
77  }
78  };
79 
84  class MakeNegation {
85  public:
90  static inline InputOutputElementType Operate(InputOutputElementType & inputOutput) {
91  return (inputOutput = InputOutputElementType(-inputOutput));
92  }
93  };
94 
99  class MakeFloor {
100  public:
102  return (inputOutput = InputOutputElementType( floor((double)inputOutput) ));
103  }
104  };
105 
110  class MakeCeil {
111  public:
113  return (inputOutput = InputOutputElementType( ceil((double)inputOutput) ));
114  }
115  };
116 
117 
118 };
119 
120 
121 #endif // _vctStoreBackUnaryOperations_h
122 
Returns the floor of the input, that is, the largest integer less-than or equal to the input...
Definition: vctStoreBackUnaryOperations.h:99
Returns the absolute value of the input as an OutputType object.
Definition: vctStoreBackUnaryOperations.h:65
Returns the ceiling of the input, that is, the smallest integer greater-than or equal to the input...
Definition: vctStoreBackUnaryOperations.h:110
Returns the negation of the input as an OutputType object.
Definition: vctStoreBackUnaryOperations.h:84
Define store back unary operations on an object as classes.
Definition: vctStoreBackUnaryOperations.h:56
static InputOutputElementType Operate(InputOutputElementType &inputOutput)
Definition: vctStoreBackUnaryOperations.h:90
static InputOutputElementType Operate(InputOutputElementType &inputOutput)
Definition: vctStoreBackUnaryOperations.h:112
_inputOutputElementType InputOutputElementType
Definition: vctStoreBackUnaryOperations.h:59
static InputOutputElementType Operate(InputOutputElementType &inputOutput)
Definition: vctStoreBackUnaryOperations.h:71
static InputOutputElementType Operate(InputOutputElementType &inputOutput)
Definition: vctStoreBackUnaryOperations.h:101