This file is indexed.

/usr/lib/python2.7/dist-packages/ffc/uflacs/language/ufl_to_cnodes.py is in python-ffc 2016.2.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# -*- coding: utf-8 -*-
# Copyright (C) 2011-2016 Martin Sandve Alnæs
#
# This file is part of UFLACS.
#
# UFLACS is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# UFLACS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with UFLACS. If not, see <http://www.gnu.org/licenses/>.

"""Tools for C/C++ expression formatting."""

from ffc.log import error

from ufl.corealg.multifunction import MultiFunction
#from ufl.corealg.map_dag import map_expr_dag


class UFL2CNodesMixin(object):
    """Rules collection mixin for a UFL to CNodes translator class."""
    def __init__(self, language):
        self.L = language

    # === Error handlers for missing formatting rules ===

    def expr(self, o):
        "Generic fallback with error message for missing rules."
        error("Missing C++ formatting rule for expr type {0}.".format(o._ufl_class_))

    # === Formatting rules for arithmetic operators ===

    def sum(self, o, a, b):
        return self.L.Add(a, b)

    #def sub(self, o, a, b): # Not in UFL
    #    return self.L.Sub(a, b)

    def product(self, o, a, b):
        return self.L.Mul(a, b)

    def division(self, o, a, b):
        return self.L.Div(a, b)

    # === Formatting rules for conditional expressions ===

    def conditional(self, o, c, t, f):
        return self.L.Conditional(c, t, f)

    def eq(self, o, a, b):
        return self.L.EQ(a, b)

    def ne(self, o, a, b):
        return self.L.NE(a, b)

    def le(self, o, a, b):
        return self.L.LE(a, b)

    def ge(self, o, a, b):
        return self.L.GE(a, b)

    def lt(self, o, a, b):
        return self.L.LT(a, b)

    def gt(self, o, a, b):
        return self.L.GT(a, b)

    def and_condition(self, o, a, b):
        return self.L.And(a, b)

    def or_condition(self, o, a, b):
        return self.L.Or(a, b)

    def not_condition(self, o, a):
        return self.L.Not(a)

    # === Formatting rules for cmath functions ===

    def math_function(self, o, op):
        return self._cmath(o._name, op)

    def sqrt(self, o, op):
        return self._cmath("sqrt", op)

    #def cbrt(self, o, op):  # Not in UFL
    #    return self._cmath("cbrt", op)

    # cmath also has log10 etc
    def ln(self, o, op):
        return self._cmath("log", op)

    # cmath also has exp2 etc
    def exp(self, o, op):
        return self._cmath("exp", op)

    def cos(self, o, op):
        return self._cmath("cos", op)

    def sin(self, o, op):
        return self._cmath("sin", op)

    def tan(self, o, op):
        return self._cmath("tan", op)

    def cosh(self, o, op):
        return self._cmath("cosh", op)

    def sinh(self, o, op):
        return self._cmath("sinh", op)

    def tanh(self, o, op):
        return self._cmath("tanh", op)

    def atan_2(self, o, y, x):
        return self._cmath("atan_2", (y, x))

    def acos(self, o, op):
        return self._cmath("acos", op)

    def asin(self, o, op):
        return self._cmath("asin", op)

    def atan(self, o, op):
        return self._cmath("atan", op)

    #def acosh(self, o, op):  # Not in UFL
    #    return self._cmath("acosh", op)

    #def asinh(self, o, op):  # Not in UFL
    #    return self._cmath("asinh", op)

    #def atanh(self, o, op):  # Not in UFL
    #    return self._cmath("atanh", op)

    def erf(self, o, op):
        return self._cmath("erf", op)

    #def erfc(self, o, op):  # Not in UFL
    #    # C++11 stl has this function
    #    return self._cmath("erfc", op)


class RulesForC(object):
    def _cmath(self, name, op):
        return self.L.Call(name, op)

    def power(self, o, a, b):
        return self.L.Call("pow", (a, b))

    def abs(self, o, op):
        return self.L.Call("fabs", op)

    def min_value(self, o, a, b):
        return self.L.Call("fmin", (a, b))

    def max_value(self, o, a, b):
        return self.L.Call("fmax", (a, b))

    # ignoring bessel functions


class RulesForCpp(object):
    def _cmath(self, name, op):
        return self.L.Call("std::" + name, op)

    def power(self, o, a, b):
        return self.L.Call("std::pow", (a, b))

    def abs(self, o, op):
        return self.L.Call("std::abs", op)

    def min_value(self, o, a, b):
        return self.L.Call("std::min", (a, b))

    def max_value(self, o, a, b):
        return self.L.Call("std::max", (a, b))

    # === Formatting rules for bessel functions ===

    def _bessel(self, o, n, v, name):
        return self.L.Call("boost::math::" + name, (n, v))

    def bessel_i(self, o, n, v):
        return self._bessel(o, n, v, "cyl_bessel_i")

    def bessel_j(self, o, n, v):
        return self._bessel(o, n, v, "cyl_bessel_j")

    def bessel_k(self, o, n, v):
        return self._bessel(o, n, v, "cyl_bessel_k")

    def bessel_y(self, o, n, v):
        return self._bessel(o, n, v, "cyl_neumann")


class UFL2CNodesTranslatorC(MultiFunction, UFL2CNodesMixin, RulesForC):
    """UFL to CNodes translator class."""
    def __init__(self, language):
        MultiFunction.__init__(self)
        UFL2CNodesMixin.__init__(self, language)


class UFL2CNodesTranslatorCpp(MultiFunction, UFL2CNodesMixin, RulesForCpp):
    """UFL to CNodes translator class."""
    def __init__(self, language):
        MultiFunction.__init__(self)
        UFL2CNodesMixin.__init__(self, language)