This file is indexed.

/usr/include/shark/Models/CMAC.h is in libshark-dev 3.0.1+ds1-2ubuntu1.

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
/*!
 * 
 *
 * \brief       -
 *
 * \author      O. Krause
 * \date        2010-01-01
 *
 *
 * \par Copyright 1995-2015 Shark Development Team
 * 
 * <BR><HR>
 * This file is part of Shark.
 * <http://image.diku.dk/shark/>
 * 
 * Shark 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.
 * 
 * Shark 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 Shark.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef SHARK_ML_MODEL_CMAC_H
#define SHARK_ML_MODEL_CMAC_H

#include <shark/Core/DLLSupport.h>
#include <shark/Models/AbstractModel.h>
#include <shark/Rng/GlobalRng.h>
#include <vector>

namespace shark{

//!
//! \brief The CMACMap class represents a linear combination of piecewise constant functions
//!
//! when a point is fed into the CMAC, it is first mapped into a vector of binary features.
//! For this purpose the inputspace is divided into several tilings. Every tiling produces a bitstring where an element
//! is 1 if the point lies inside the tile, 0 otherwise. The concatenation of all tilings forms the feature vector which is then fed
//! into a linear function.
//! Usually the CMAC is only good for low dimensional input data since the size of the featurevector grows exponentially with the
//! number of dimensions.
//!
class CMACMap :public AbstractModel<RealVector,RealVector>{
protected:
	///offset of the position of every tiling
	RealMatrix m_offset;

	///coordinate offset for every dimension in the Array
	std::vector<std::size_t> m_dimOffset;

	///lower bound and tileWidth for every Dimension
	RealMatrix m_tileBounds;

	///number of tilings
	std::size_t m_tilings;
	std::size_t m_parametersPerTiling;

	std::size_t m_inputSize;
	std::size_t m_outputSize;

	///The parameters of the model
	RealVector m_parameters;

	///calculates the index in the parameter vector for the activated feature in the tiling
	SHARK_EXPORT_SYMBOL std::size_t getArrayIndexForTiling(std::size_t indexOfTiling,RealVector const& point)const;
	///returns an index in the parameter array for each activated feature
	SHARK_EXPORT_SYMBOL std::vector<std::size_t> getIndizes(ConstRealMatrixRow const& point)const;
public:
	///\brief construct the CMAC
	SHARK_EXPORT_SYMBOL CMACMap();

	/// \brief From INameable: return the class name.
	std::string name() const
	{ return "CMACMap"; }

	///\brief initializes the structure of the cmac. it uses the same lower and upper bound for every input dimension. default is [0,1]
	///
	///\param inputs number of input dimensions
	///\param outputs number of output dimensions
	///\param numberOfTilings number of Tilings to be created
	///\param numberOfTiles amount of tiles per dimension
	///\param lower lower bound of input values
	///\param upper upper bound of input values
	///\param randomTiles flag specifying whether distance between tiles is regular or randomized
	SHARK_EXPORT_SYMBOL void setStructure(std::size_t inputs, std::size_t outputs, std::size_t numberOfTilings, std::size_t numberOfTiles, double lower = 0., double upper = 1.,bool randomTiles = false);

	///\brief initializes the structure of the cmac
	///
	///\param inputs number of input dimensions
	///\param outputs number of output dimensions
	///\param numberOfTilings number of Tilings to be created
	///\param numberOfTiles amount of tiles per dimension
	///\param bounds lower and upper bounts for every input dimension. every row consists of (lower,upper)
	///\param randomTiles flag specifying whether distance between tiles is regular or randomized
	SHARK_EXPORT_SYMBOL void setStructure(std::size_t inputs, std::size_t outputs, std::size_t numberOfTilings, std::size_t numberOfTiles, RealMatrix const& bounds,bool randomTiles = false);

	virtual std::size_t inputSize()const
	{
		return m_inputSize;
	}
	virtual std::size_t outputSize()const
	{
		return m_outputSize;
	}

	virtual RealVector parameterVector()const
	{
		return m_parameters;
	}
	virtual void setParameterVector(RealVector const& newParameters)
	{
		SIZE_CHECK(numberOfParameters() == newParameters.size());
		m_parameters=newParameters;
	}
	virtual std::size_t numberOfParameters()const
	{
		return m_parameters.size();
	}

	boost::shared_ptr<State> createState()const{
		return boost::shared_ptr<State>(new EmptyState());
	}
	
	using AbstractModel<RealVector,RealVector>::eval;
	SHARK_EXPORT_SYMBOL void eval(const RealMatrix& patterns,RealMatrix& outputs)const;
	void eval(const RealMatrix& patterns,RealMatrix& outputs, State& state)const{
		eval(patterns,outputs);
	}
	SHARK_EXPORT_SYMBOL void weightedParameterDerivative(
		RealMatrix const& pattern, 
		RealMatrix const& coefficients,  
		State const& state,
		RealVector& gradient)const;

	/// From ISerializable, reads a model from an archive
	SHARK_EXPORT_SYMBOL void read( InArchive & archive );

	/// From ISerializable, writes a model to an archive
	SHARK_EXPORT_SYMBOL void write( OutArchive & archive ) const;
};


}
#endif