GeoModel - GeoModelCore
Sqrt.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/Sqrt.h"
7 #include <stdexcept>
8 #include <cmath> // for sqrt
9 namespace GeoGenfun {
10 FUNCTION_OBJECT_IMP(Sqrt)
11 
12 Sqrt::Sqrt()
13 {}
14 
15 Sqrt::Sqrt(const Sqrt & right) : AbsFunction(right)
16 {
17 }
18 
19 Sqrt::~Sqrt() {
20 }
21 
22 double Sqrt::operator() (double x) const {
23  return sqrt(x);
24 }
25 
26 
27 Derivative Sqrt::partial(unsigned int index) const {
28  if (index!=0) throw std::range_error("Sqrt: partial derivative index out of range");
29  const AbsFunction & fPrime = (0.5)/Sqrt();
30  return Derivative(&fPrime);
31 }
32 
33 
34 } // namespace GeoGenfun
Definition: Abs.h:15