1 /*=========================================================================
2 *
3 * Copyright Insight Software Consortium
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18 #ifndef itkHeavisideStepFunction_hxx
19 #define itkHeavisideStepFunction_hxx
20
21 #include "itkHeavisideStepFunction.h"
22 #include "itkMath.h"
23
24 namespace itk
25 {
26 template< typename TInput, typename TOutput >
27 HeavisideStepFunction< TInput, TOutput >
HeavisideStepFunction()28 ::HeavisideStepFunction() : Superclass()
29 {}
30
31 template< typename TInput, typename TOutput >
32 typename HeavisideStepFunction< TInput, TOutput >::OutputType
33 HeavisideStepFunction< TInput, TOutput >
Evaluate(const InputType & input) const34 ::Evaluate(const InputType & input) const
35 {
36 return ( input >= NumericTraits< InputType >::ZeroValue() ) ?
37 NumericTraits< OutputType >::OneValue() : NumericTraits< OutputType >::ZeroValue();
38 }
39
40 template< typename TInput, typename TOutput >
41 typename HeavisideStepFunction< TInput, TOutput >::OutputType
42 HeavisideStepFunction< TInput, TOutput >
EvaluateDerivative(const InputType & input) const43 ::EvaluateDerivative(const InputType & input) const
44 {
45 return ( Math::ExactlyEquals(input, NumericTraits< InputType >::ZeroValue()) ) ?
46 NumericTraits< OutputType >::OneValue() : NumericTraits< OutputType >::ZeroValue();
47 }
48
49 }
50
51 #endif // itkHeavisideStepFunction_hxx
52