GeoModel - GeoModelCore
Square.cpp
1 //==========================================================================//
2 // Imported from the QAT library (qat.pitt.edu) by the copyright holder //
3 // Joe Boudreau. Software licensed under the terms and conditions of the //
4 // GNU Lesser Public License v3. //
5 //==========================================================================//
6 #include "GeoGenericFunctions/Square.h"
7 #include "GeoGenericFunctions/Variable.h"
8 #include <stdexcept>
9 
10 namespace GeoGenfun {
11 FUNCTION_OBJECT_IMP(Square)
12 
13 Square::Square()
14 {}
15 
16 Square::Square(const Square & right) : AbsFunction(right)
17 {
18 }
19 
20 Square::~Square() {
21 }
22 
23 double Square::operator() (double x) const {
24  return x*x;
25 }
26 
27 
28 
29 Derivative Square::partial(unsigned int index) const {
30  if (index!=0) throw std::range_error("Square: partial derivative index out of range");
31  Variable x;
32  const AbsFunction & fPrime = 2*x;
33  return Derivative(&fPrime);
34 }
35 
36 
37 } // namespace GeoGenfun
Definition: Abs.h:15