summaryrefslogtreecommitdiff
path: root/src/CPnts/CPnts_MyRootFunction.cxx
blob: e058b445e433c959857658c4c3cac02c88de442a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <CPnts_MyRootFunction.ixx>

#include <Standard_DomainError.hxx>
#include <math_GaussSingleIntegration.hxx>



void CPnts_MyRootFunction::Init(const CPnts_RealFunction& F,
				const Standard_Address D,
				const Standard_Integer Order)
{
  myFunction.Init(F,D);
  myOrder = Order;
}

void CPnts_MyRootFunction::Init(const Standard_Real X0,
				const Standard_Real L) 
{
  myX0 = X0;
  myL = L;
  myTol = -1; //to supress the tolerance
}

void CPnts_MyRootFunction::Init(const Standard_Real X0,
				const Standard_Real L,
				const Standard_Real Tol) 
{
  myX0 = X0;
  myL = L;
  myTol = Tol;
}

Standard_Boolean CPnts_MyRootFunction::Value(const Standard_Real X,
					     Standard_Real& F)
{
  math_GaussSingleIntegration Length;

  if (myTol <= 0) Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder);
  else Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder, myTol);

  if (Length.IsDone()){ 
    F= Length.Value() - myL; 
    return Standard_True;
  }
  else {
    return Standard_False;
  }
} 

Standard_Boolean CPnts_MyRootFunction::Derivative(const Standard_Real X,  
						  Standard_Real& Df)
{
  return myFunction.Value(X,Df);
}

Standard_Boolean CPnts_MyRootFunction::Values(const Standard_Real X, 
					      Standard_Real& F, 
					      Standard_Real& Df)
{
  math_GaussSingleIntegration Length;

  if (myTol <= 0) Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder);
  else Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder, myTol);

  if (Length.IsDone()){ 
    F= Length.Value() - myL; 
    return myFunction.Value(X,Df);
  }
  else {
    return Standard_False;
  }
}