Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
UnaryExpressionImpl.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* UnaryExpressionImpl.cc (C) 2000-2007 */
9/* */
10/* Implémentation d'une expression unaire. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/expr/UnaryExpressionImpl.h"
17#include "arcane/expr/OperatorMng.h"
18#include "arcane/expr/BadOperationException.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23ARCANE_BEGIN_NAMESPACE
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28UnaryExpressionImpl::
29UnaryExpressionImpl (IExpressionImpl* first,eOperationType operation)
30: ExpressionImpl()
31, m_first(first)
32, m_operation(operation)
33{
34}
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39String UnaryExpressionImpl::
40operationName(eOperationType type)
41{
42 switch(type)
43 {
44 case UnarySubstract: return "UnarySubstract";
45 case Inverse: return "Inverse";
46 case Acos: return "Acos";
47 case Asin: return "Asin";
48 case Atan: return "Atan";
49 case Ceil: return "Ceil";
50 case Cos: return "Cos";
51 case Cosh: return "Cosh";
52 case Exp: return "Exp";
53 case Fabs: return "Fabs";
54 case Floor: return "Floor";
55 case Log: return "Log";
56 case Log10: return "Log10";
57 case Sin: return "Sin";
58 case Sinh: return "Sinh";
59 case Sqrt: return "Sqrt";
60 case Tan: return "Tan";
61 case Tanh: return "Tanh";
62 default: return "Unknown";
63 }
64}
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69void UnaryExpressionImpl::
70apply(ExpressionResult* result)
71{
72 /*
73 cerr << ">> BEGIN UNARY EXPRESSION "
74 << operationName() << " [" << *result << "]\n";
75 */
76
77 // calcul des expressions gauche et droite
78 ExpressionResult first_op(result->indices());
79 m_first->apply(&first_op);
80
81 // recherche de l'operateur en fonction du type attendu en resultat
82 VariantBase::eType type = first_op.data()->type();
83 UnaryOperator* op = m_op_mng->find(this, type, m_operation);
84 if (!op)
85 throw BadOperationException("UnaryExpressionImpl::apply", operationName(), type);
86
87 op->evaluate(result, first_op.data());
88
89 /*
90 cerr << "<< END UNARY EXPRESSION "
91 << operationName() << " [" << *result << "]\n";
92 */
93}
94
95/*---------------------------------------------------------------------------*/
96/*---------------------------------------------------------------------------*/
97
98ARCANE_END_NAMESPACE
99
100/*---------------------------------------------------------------------------*/
101/*---------------------------------------------------------------------------*/