This file is indexed.

/usr/lib/python2.7/dist-packages/ffc/utils.py is in python-ffc 1.4.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
# Copyright (C) 2005-2010 Anders Logg
#
# This file is part of FFC.
#
# FFC 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.
#
# FFC 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 FFC. If not, see <http://www.gnu.org/licenses/>.
#
# Modified by Kristian B. Oelgaard, 2009
#
# First added:  2005-02-04
# Last changed: 2014-04-02

# Python modules.
import operator
import functools
import itertools

# FFC modules.
from log import error

def product(sequence):
    "Return the product of all elements in a sequence."
    # Copied from UFL
    return functools.reduce(operator.__mul__, sequence, 1)

def all_equal(sequence):
    "Check that all items in list are equal."
    return sequence[:-1] == sequence[1:]

def pick_first(sequence):
    "Check that all values are equal and return the value."
    if not all_equal(sequence):
        error("Values differ: " + str(sequence))
    return sequence[0]

def listcopy(sequence):
    """Create a copy of the list, calling the copy constructor on each
    object in the list (problems when using copy.deepcopy)."""
    if not sequence:
        return []
    else:
        return [object.__class__(object) for object in sequence]

def compute_permutations(k, n, skip = []):
   """Compute all permutations of k elements from (0, n) in rising order.
   Any elements that are contained in the list skip are not included."""
   if k == 1:
       return [(i,) for i in range(n) if not i in skip]
   pp = compute_permutations(k - 1, n, skip)
   permutations = []
   for i in range(n):
       if i in skip:
           continue
       for p in pp:
           if i < p[0]:
               permutations += [(i, ) + p]
   return permutations

def compute_derivative_tuples(n, gdim):
    """Compute the list of all derivative tuples for derivatives of
    given total order n and given geometric dimension gdim. This
    function returns two lists. The first is a list of tuples, where
    each tuple of length n specifies the coordinate directions of the
    n derivatives. The second is a corresponding list of tuples, where
    each tuple of length gdim specifies the number of derivatives in
    each direction. Both lists have length gdim^n and are ordered as
    expected by the UFC function tabulate_basis_derivatives.

    Example: If n = 2 and gdim = 3, then the nice tuples are

      (0, 0)  <-->  (2, 0, 0)  <-->  d^2/dxdx
      (0, 1)  <-->  (1, 1, 0)  <-->  d^2/dxdy
      (0, 2)  <-->  (1, 0, 1)  <-->  d^2/dxdz
      (1, 0)  <-->  (1, 1, 0)  <-->  d^2/dydx
      (1, 1)  <-->  (0, 2, 0)  <-->  d^2/dydy
      (1, 2)  <-->  (0, 1, 1)  <-->  d^2/dydz
      (2, 0)  <-->  (1, 0, 1)  <-->  d^2/dzdx
      (2, 1)  <-->  (0, 1, 1)  <-->  d^2/dzdy
      (2, 2)  <-->  (0, 0, 2)  <-->  d^2/dzdz
    """

    # Create list of derivatives (note that we have d^n derivatives)
    deriv_tuples = [d for d in itertools.product(*(n*[range(0, gdim)]))]

    # Translate from list of derivative tuples to list of tuples
    # expressing the number of derivatives in each dimension...
    _deriv_tuples = [tuple(len([_d for _d in d if _d == i]) for i in range(gdim))
                     for d in deriv_tuples]

    return deriv_tuples, _deriv_tuples