This file is indexed.

/usr/include/polymake/tropical/canonicalize.h is in libpolymake-dev-common 3.2r2-3.

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
/* Copyright (c) 1997-2018
	Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
http://www.polymake.org

This program 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, or (at your option) any
later version: http://www.gnu.org/licenses/gpl.txt.

This program 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.
--------------------------------------------------------------------------------
*/

#include "polymake/client.h"
#include "polymake/Vector.h"
#include "polymake/Matrix.h"
#include "polymake/linalg.h"
#include "polymake/TropicalNumber.h"
#include "polymake/polytope/canonicalize.h"

namespace polymake { namespace tropical {
	namespace {

		template <typename Iterator> inline
			bool leading_non_zero(const Iterator& it, std::false_type) { return !is_zero(*it); }

		template <typename Iterator> inline
			bool leading_non_zero(const Iterator& it, std::true_type) { return !it.at_end() && it.index()==0; }
	}

	//The following all canonicalize a matrix/vector of tropical numbers such that the first entry
	// is zero.

	template <typename Vector, typename Addition, typename Scalar>
		void canonicalize_to_leading_zero(GenericVector<Vector, TropicalNumber<Addition, Scalar> >& V)
		{
			typename Vector::iterator it=V.top().begin();
			if (leading_non_zero(it, bool_constant<pm::check_container_feature<Vector, pm::sparse>::value>())) {
				const typename Vector::element_type first=*it;
				V/=first;
			}
		} 

	template <typename Matrix, typename Addition, typename Scalar>
		void canonicalize_to_leading_zero(GenericMatrix<Matrix, TropicalNumber<Addition,Scalar> >& M)
		{
			if (!M.rows())
				throw std::runtime_error("point matrix may not be empty");
			for (typename Entire< Rows<Matrix> >::iterator r=entire(rows(M)); !r.at_end();  ++r)
				canonicalize_to_leading_zero(r->top());
		}

	//Does the same as canonicalize_to_leading_zero, and checks and complains if there is a zero column
	template <typename Matrix, typename Addition, typename Scalar>
		void canonicalize_to_leading_zero_and_check_columns(GenericMatrix<Matrix, TropicalNumber<Addition,Scalar> >&M) {
			for(typename Entire<Rows<Transposed<Matrix> > >::iterator c = entire(rows(T(M))); !c.at_end(); c++) {
				if(support(*c).size() == 0) 
					throw std::runtime_error("The points can't all lie in the same boundary stratum of projective space. Maybe use a projection?");
			}
			return canonicalize_to_leading_zero(M);
		}
/*
	template <typename Vector, typename Addition, typename Scalar>
		void canonicalize_to_nonnegative(GenericVector<Vector, TropicalNumber<Addition,Scalar> >& V)
		{
			const typename Vector::element_type x_min=accumulate(V.top(), operations::min());
			if (pm::check_container_feature<Vector,pm::sparse>::value
					? x_min<0 || V.top().size()==V.dim()
					: !is_zero(x_min))
				V/=x_min;
		}

	template <typename Matrix, typename Addition, typename Scalar>
		void canonicalize_to_nonnegative(GenericMatrix<Matrix, TropicalNumber<Addition,Scalar> >& M)
		{
			if (!M.rows())
				throw std::runtime_error("point matrix may not be empty");
			for (typename Entire< Rows<Matrix> >::iterator r=entire(rows(M)); !r.at_end();  ++r)
				canonicalize_to_nonnegative(r->top());
		}

*/

	//The following canonicalize matrices/vectors of scalars, but representing (finite) 
	//tropical homogeneous coordinates.

	template <typename Vector, typename Scalar>
		void canonicalize_scalar_to_leading_zero(GenericVector<Vector,Scalar>& V)
		{
			typename Vector::iterator it=V.top().begin();
			if (leading_non_zero(it, bool_constant<pm::check_container_feature<Vector, pm::sparse>::value>())) {
				const typename Vector::element_type first=*it;
				V-=same_element_vector(first, V.dim());
			}
		}

	template <typename Matrix, typename Scalar>
		void canonicalize_scalar_to_leading_zero(GenericMatrix<Matrix,Scalar>& M)
		{
			if (!M.rows())
				throw std::runtime_error("point matrix may not be empty");
			for (typename Entire< Rows<Matrix> >::iterator r=entire(rows(M)); !r.at_end();  ++r)
				canonicalize_scalar_to_leading_zero(r->top());
		}

	//FIXME Should this be swapped for min/max, i.e. should there be a nonpositive - or rather,
	// a templated version of this?

	template <typename Vector, typename Scalar>
		void canonicalize_scalar_to_nonnegative(GenericVector<Vector,Scalar>& V)
		{
			const typename Vector::element_type x_min=accumulate(V.top(), operations::min());
			if (pm::check_container_feature<Vector,pm::sparse>::value
					? x_min<0 || V.top().size()==V.dim()
					: !is_zero(x_min))
				V-=same_element_vector(x_min,V.dim());
		}

	template <typename Matrix, typename Scalar>
		void canonicalize_scalar_to_nonnegative(GenericMatrix<Matrix,Scalar>& M)
		{
			if (!M.rows())
				throw std::runtime_error("point matrix may not be empty");
			for (typename Entire< Rows<Matrix> >::iterator r=entire(rows(M)); !r.at_end();  ++r)
				canonicalize_scalar_to_nonnegative(r->top());
		}

	// Assumes as input a matrix of tropically homogeneous vectors with a leading 1/0 indicating
	// vertex or far vertex. Will canonicalize M.minor(All,~[0]) to have first coordinate 0. 
	// Then will canonicalize the full matrix as a usual vertex matrix.
	template <typename Matrix, typename Scalar>
		void canonicalize_vertices_to_leading_zero(GenericMatrix<Matrix,Scalar> &M) {
			canonicalize_scalar_to_leading_zero(M.minor(All,~scalar2set(0)).top());
			for (auto r = entire(rows(M)); !r.at_end(); ++r) {
				polytope::canonicalize_oriented( find_in_range_if(entire(r->top()), operations::non_zero()) );
			}
		}

	template <typename Vector, typename Scalar>
		void canonicalize_vertex_to_leading_zero(GenericVector<Vector,Scalar> &V) {
			canonicalize_scalar_to_leading_zero(V.slice(~scalar2set(0)).top());
			polytope::canonicalize_oriented( find_in_range_if(entire(V.top()), operations::non_zero()) );
		}
  }}