0022904: Clean up sccsid variables
[occt.git] / src / Expr / Expr_ArgCosh.cxx
CommitLineData
7fd59977 1// Copyright: Matra-Datavision 1991
2// File: Expr_ArgCosh.cxx
3// Created: Mon May 27 11:59:06 1991
4// Author: Arnaud BOUZY
5// <adn>
6
7#include <Expr_ArgCosh.ixx>
8#include <Expr_NumericValue.hxx>
9#include <Expr_Cosh.hxx>
10#include <Expr_Division.hxx>
11#include <Expr_Square.hxx>
12#include <Expr_Difference.hxx>
13#include <Expr_SquareRoot.hxx>
14#include <Expr_Operators.hxx>
15#include <Expr.hxx>
16
17Expr_ArgCosh::Expr_ArgCosh (const Handle(Expr_GeneralExpression)& exp)
18{
19 CreateOperand(exp);
20}
21
22Handle(Expr_GeneralExpression) Expr_ArgCosh::ShallowSimplified () const
23{
24 Handle(Expr_GeneralExpression) op = Operand();
25 if (op->IsKind(STANDARD_TYPE(Expr_NumericValue))) {
26 Handle(Expr_NumericValue) valop = Handle(Expr_NumericValue)::DownCast(op);
27 return new Expr_NumericValue(ACosh(valop->GetValue()));
28 }
29 if (op->IsKind(STANDARD_TYPE(Expr_Cosh))) {
30 return op->SubExpression(1);
31 }
32 Handle(Expr_ArgCosh) me = this;
33 return me;
34}
35
36Handle(Expr_GeneralExpression) Expr_ArgCosh::Copy () const
37{
38 return new Expr_ArgCosh(Expr::CopyShare(Operand()));
39}
40
41Standard_Boolean Expr_ArgCosh::IsIdentical (const Handle(Expr_GeneralExpression)& Other) const
42{
43 if (!Other->IsKind(STANDARD_TYPE(Expr_ArgCosh))) {
44 return Standard_False;
45 }
46 Handle(Expr_GeneralExpression) op = Operand();
47 return op->IsIdentical(Other->SubExpression(1));
48}
49
50Standard_Boolean Expr_ArgCosh::IsLinear () const
51{
52 if (ContainsUnknowns()) {
53 return Standard_False;
54 }
55 return Standard_True;
56}
57
58Handle(Expr_GeneralExpression) Expr_ArgCosh::Derivative (const Handle(Expr_NamedUnknown)& X) const
59{
60 if (!Contains(X)) {
61 return new Expr_NumericValue(0.0);
62 }
63 Handle(Expr_GeneralExpression) op = Operand();
64 Handle(Expr_GeneralExpression) derop = op->Derivative(X);
65
66 Handle(Expr_Square) sq = new Expr_Square(Expr::CopyShare(op));
67 // X2 - 1
68 Handle(Expr_Difference) thedif = sq->ShallowSimplified() - 1.0;
69
70 // sqrt(X2 - 1)
71 Handle(Expr_SquareRoot) theroot = new Expr_SquareRoot(thedif->ShallowSimplified());
72
73 // ArgCosh'(F(X)) = F'(X)/sqrt(F(X)2-1)
74 Handle(Expr_Division) thediv = derop / theroot->ShallowSimplified();
75
76 return thediv->ShallowSimplified();
77}
78
79Standard_Real Expr_ArgCosh::Evaluate(const Expr_Array1OfNamedUnknown& vars, const TColStd_Array1OfReal& vals) const
80{
81 Standard_Real val = Operand()->Evaluate(vars,vals);
82 return ::Log(val + ::Sqrt(::Square(val)-1.0));
83}
84
85TCollection_AsciiString Expr_ArgCosh::String() const
86{
87 TCollection_AsciiString str("ACosh(");
88 str += Operand()->String();
89 str += ")";
90 return str;
91}