1 //static const char* sccsid = "@(#)Expr_ArgCosh.cxx 3.2 95/01/10"; // Do not delete this line. Used by sccs.
2 // Copyright: Matra-Datavision 1991
3 // File: Expr_ArgCosh.cxx
4 // Created: Mon May 27 11:59:06 1991
5 // Author: Arnaud BOUZY
8 #include <Expr_ArgCosh.ixx>
9 #include <Expr_NumericValue.hxx>
10 #include <Expr_Cosh.hxx>
11 #include <Expr_Division.hxx>
12 #include <Expr_Square.hxx>
13 #include <Expr_Difference.hxx>
14 #include <Expr_SquareRoot.hxx>
15 #include <Expr_Operators.hxx>
18 Expr_ArgCosh::Expr_ArgCosh (const Handle(Expr_GeneralExpression)& exp)
23 Handle(Expr_GeneralExpression) Expr_ArgCosh::ShallowSimplified () const
25 Handle(Expr_GeneralExpression) op = Operand();
26 if (op->IsKind(STANDARD_TYPE(Expr_NumericValue))) {
27 Handle(Expr_NumericValue) valop = Handle(Expr_NumericValue)::DownCast(op);
28 return new Expr_NumericValue(ACosh(valop->GetValue()));
30 if (op->IsKind(STANDARD_TYPE(Expr_Cosh))) {
31 return op->SubExpression(1);
33 Handle(Expr_ArgCosh) me = this;
37 Handle(Expr_GeneralExpression) Expr_ArgCosh::Copy () const
39 return new Expr_ArgCosh(Expr::CopyShare(Operand()));
42 Standard_Boolean Expr_ArgCosh::IsIdentical (const Handle(Expr_GeneralExpression)& Other) const
44 if (!Other->IsKind(STANDARD_TYPE(Expr_ArgCosh))) {
45 return Standard_False;
47 Handle(Expr_GeneralExpression) op = Operand();
48 return op->IsIdentical(Other->SubExpression(1));
51 Standard_Boolean Expr_ArgCosh::IsLinear () const
53 if (ContainsUnknowns()) {
54 return Standard_False;
59 Handle(Expr_GeneralExpression) Expr_ArgCosh::Derivative (const Handle(Expr_NamedUnknown)& X) const
62 return new Expr_NumericValue(0.0);
64 Handle(Expr_GeneralExpression) op = Operand();
65 Handle(Expr_GeneralExpression) derop = op->Derivative(X);
67 Handle(Expr_Square) sq = new Expr_Square(Expr::CopyShare(op));
69 Handle(Expr_Difference) thedif = sq->ShallowSimplified() - 1.0;
72 Handle(Expr_SquareRoot) theroot = new Expr_SquareRoot(thedif->ShallowSimplified());
74 // ArgCosh'(F(X)) = F'(X)/sqrt(F(X)2-1)
75 Handle(Expr_Division) thediv = derop / theroot->ShallowSimplified();
77 return thediv->ShallowSimplified();
80 Standard_Real Expr_ArgCosh::Evaluate(const Expr_Array1OfNamedUnknown& vars, const TColStd_Array1OfReal& vals) const
82 Standard_Real val = Operand()->Evaluate(vars,vals);
83 return ::Log(val + ::Sqrt(::Square(val)-1.0));
86 TCollection_AsciiString Expr_ArgCosh::String() const
88 TCollection_AsciiString str("ACosh(");
89 str += Operand()->String();