This file is indexed.

/usr/include/SyFi/ginac_tools.h is in libsyfi1.0-dev 1.0.0.dfsg-1.2.

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
// Copyright (C) 2006-2009 Kent-Andre Mardal and Simula Research Laboratory
//
// This file is part of SyFi.
//
// SyFi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// SyFi 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SyFi. If not, see <http://www.gnu.org/licenses/>.

#ifndef GINAC_TOOLS_IS_INCLUDED
#define GINAC_TOOLS_IS_INCLUDED

#include <string>
#include <iostream>
#include <map>

#include <ginac/ginac.h>

#include "utilities.h"

namespace SyFi
{

	bool compare(const GiNaC::ex & e, const std::string & s);

	void EQUAL_OR_DIE(const GiNaC::ex & e, const std::string & s);

	// Read two archive files and compare the expressions.
	// If any expressions are not equal, prints them and
	// returns false. Returns true if all expressions are equal.
	bool compare_archives(const std::string & first, const std::string & second, std::ostream & os=std::cout);

	// using lst as a vector
	// inner product of vectors or lst
	GiNaC::ex inner(GiNaC::ex a, GiNaC::ex b, bool transposed = false);
	GiNaC::ex inner(GiNaC::exvector& v1, GiNaC::exvector& v2);
	GiNaC::ex inner(GiNaC::lst v1, GiNaC::lst v2);
	GiNaC::lst cross(GiNaC::lst& v1, GiNaC::lst& v2);
	// matrix vector product
	GiNaC::lst matvec(GiNaC::matrix& M, GiNaC::lst& x);
	GiNaC::ex  matvec(GiNaC::ex A, GiNaC::ex x);

	GiNaC::lst ex2equations(GiNaC::ex rel);
	GiNaC::lst collapse(GiNaC::lst l);

	GiNaC::matrix equations2matrix (const GiNaC::ex &eqns, const GiNaC::ex &symbols);
	void matrix_from_equations(const GiNaC::ex &eqns, const GiNaC::ex &symbols, GiNaC::matrix &A, GiNaC::matrix& b);

	GiNaC::ex  lst_to_matrix2(const GiNaC::lst & l);
	GiNaC::lst matrix_to_lst2(const GiNaC::ex & m );

	GiNaC::lst lst_equals(GiNaC::ex a, GiNaC::ex b);

	// FIXME bad name
	int find(GiNaC::ex e, GiNaC::lst list);

	// TODO: remove these two:
	void check_visitor(GiNaC::ex e, GiNaC::lst& exlist);
	void visitor_subst_pow(GiNaC::ex e, GiNaC::exmap& map, ex_int_map& intmap, std::string a);

	// generates a polynom of arbitrary order on a line, a triangle, or a tetrahedron
	GiNaC::ex pol(unsigned int order, unsigned int nsd, const std::string a);
	// generates a vector polynom of arbitrary order on a line, a triangle or a tetrahedron
	GiNaC::lst polv(unsigned int no_fields, unsigned int order, unsigned int nsd, const std::string a);
	// generates a polynom of arbitrary order on a square or a box
	GiNaC::ex polb(unsigned int order, unsigned int nsd, const std::string a);
	// generates a vector polynom of arbitrary order on a squart or a box
	//lst polbv(int order, int nsd, const std::string a);

	// generates a homogenous polynom of arbitrary order on a line, a triangle, or a tetrahedron
	GiNaC::ex homogenous_pol(unsigned int order, unsigned int nsd, const std::string a);
	// generates a homogenous vector polynom of arbitrary order
	GiNaC::lst homogenous_polv(unsigned int no_fields, unsigned int order, unsigned int nsd, const std::string a);

	// generates a Legendre polynom of arbitrary order
	GiNaC::ex legendre(unsigned int order, unsigned int nsd, const std::string a);
	// generates a Legendre vector polynom of arbitrary order
	GiNaC::lst legendrev(unsigned int no_fields, unsigned int order, unsigned int nsd, const std::string a);

	// extracts the coefficents from a polynomial
	GiNaC::exvector coeff(GiNaC::ex pol);
	GiNaC::lst      coeffs(GiNaC::ex pol);
	GiNaC::lst      coeffs(GiNaC::lst pols);

	// extract the basisfunctions and corresponding coefficents from a polynomial
	GiNaC::exmap  pol2basisandcoeff(GiNaC::ex e);
	GiNaC::exmap  pol2basisandcoeff(GiNaC::ex e, GiNaC::ex s);

	// Collect all symbols of an expression
	void collect_symbols(const GiNaC::ex & e, exset & v);

	GiNaC::exvector collect_symbols(const GiNaC::ex & e);

	// Builds a map with the number of occurrences of each symbol.
	// Highly dependent on the current form of the expression.
	GiNaC::exhashmap<int> count_symbols(const GiNaC::ex & e);

	// Extract all symbols into a lst. Useful for comparing
	// expressions to other ex read from an archive.
	GiNaC::ex extract_symbols(const GiNaC::ex & e);

	//std::list<GiNaC::ex> get_symbols(const GiNaC::ex & e);
	//GiNaC::exvector get_symbols(const GiNaC::ex & e);
	//void get_symbols(const GiNaC::ex & e, GiNaC::exmap & em);

	// Utility class to collect statistics about an expression.
	class ExStats
	{
		public:
			ExStats(): muls(0), adds(0), pows(0), functions(0), flops(0) {}

			inline const ExStats & operator+=(const ExStats & rhs)
			{
				muls      += rhs.muls;
				adds      += rhs.adds;
				pows      += rhs.pows;
				functions += rhs.functions;
				flops     += rhs.flops;
				return *this;
			}

			int muls;
			int adds;

			int pows;
			int functions;

			// flops = sum of multiplications and additions, with integer powers interpreted as many multiplications
			int flops;
	};

	// Count the number of operations in an expression.
	ExStats count_ops(const GiNaC::ex & e);

	// ===== expression manipulation

	GiNaC::ex replace_powers(const GiNaC::ex & e, const std::list<GiNaC::symbol> & symbols, std::list<symexpair> & sel, const std::string & tmpsymbolprefix="p_");

};								 // namespace SyFi
#endif