This file is indexed.

/usr/include/BALL/NMR/spectrum.h is in libball1.4-dev 1.4.1+20111206-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
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: spectrum.h,v 1.14.18.6 2007-04-12 13:53:57 anne Exp $
//

#ifndef BALL_NMR_SPECTRUM_H
#define BALL_NMR_SPECTRUM_H

#ifndef BALL_NMR_PEAKLIST_H
#	include<BALL/NMR/peakList.h>
#endif

#ifndef BALL_DATATYPE_REGULARDATA1D_H
#	include<BALL/DATATYPE/regularData1D.h>
#endif

#ifndef BALL_DATATYPE_REGULARDATA2D_H
#	include<BALL/DATATYPE/regularData2D.h>
#endif

#ifndef BALL_DATATYPE_REGULARDATA3D_H
#	include<BALL/DATATYPE/regularData3D.h>
#endif

#ifdef BALL_HAS_FFTW
# include <BALL/MATHS/complex.h>
#ifndef BALL_MATHS_FFT1D_H
# include <BALL/MATHS/FFT1D.h>
#endif
#ifndef BALL_MATHS_FFT2D_H
# include <BALL/MATHS/FFT2D.h>
#endif
#endif


using namespace std;

namespace BALL 
{
	/**	A generic NMR spectrum class.
			 \par
			
			 \par
	\ingroup Spectra
	*/
	template <typename DataT, typename PeakT, typename PositionT = typename PeakT::Position>
	class Spectrum
	{
		public:
		
		/**	Typedefs
		*/
		//@{
		/// The datatype used to store the spectrum
		typedef DataT DataType;
		/// the data type used to store a position (for peaks and data)
		typedef	PositionT PositionType;
		///	The peak type
		typedef	PeakT PeakType;
		/// An iterator 
		typedef typename DataT::Iterator Iterator;
		/// A constant iterator 
		typedef typename DataT::ConstIterator ConstIterator;
		//@}

		/**	Constructors and Destructor
		*/	
		//@{
			// ?????
		Spectrum()
			: data_(),
				sticks_(),
				spacing_(),
				min_(),
				max_()
		{}

		Spectrum(const DataType& data)
			: data_(data),
				sticks_(),
				spacing_(),
				min_(),
				max_()
		{}

		Spectrum(const std::vector<PeakType>& peaks, const PositionType& origin, const PositionType& dimension, const PositionType& spacing)
		{}

		/** Destructor
		*/
		virtual ~Spectrum() {}
		//@}

		/**	@name	Accessors
		*/
		//@{
		///
		const DataType& getData() const;
		///
		DataType& getData();
		
		const vector<float>& getHuInvariants() const;
		
		vector<float>& getHuInvariants();

		//@}

		virtual void clear();
		virtual void clearSticks();
		virtual double difference(const Spectrum<DataT, PeakT, PositionT>& spectrum) const;
		virtual  Spectrum<DataT, PeakT, PositionT> differenceSpectrum(const Spectrum<DataT, PeakT, PositionT>& spectrum);
		virtual double earthMoversDistance(const Spectrum<DataT,PeakT, PositionT>& spectrum) const; 
		
		virtual void convertToGaussian(); 
		virtual void convertToLorentzian(); 
		virtual void computeAllMoments(int  moment_number);

		virtual void setSpacing(const PositionType& spacing);
		virtual PositionType getSpacing() const;

		virtual void setSticks(std::vector<PeakType> sticks) {sticks_ = sticks;};
		virtual std::vector<PeakType> getSticks() const {return sticks_;};
		
	
		// computes the integral over the fabs() of the spectrum
		virtual double getAbsIntegral() const;
		virtual void computeHuInvariants();
		virtual vector<float> computeHuInvariantsDifferences(vector<Spectrum<DataT, PeakT, PositionT> >& spectra);

		/** Computes the difference between the spectra in Fourier space. max_freq and min_freq can be used to
		 *  include only a certain range into the comparison. In this case, we only use the positive frequencies (the
		 *  negative ones are redundant anyhow) and assume that 0<=min_freq<max_freq<=1, where min_freq and max_freq
		 *  are interpreted as percentages, e.g. calling this function with min_freq=0 and max_freq=0.5 would include
		 *  the lower half of the positive frequencies.
		 */
		virtual double getFourierDifference(const Spectrum<DataT,PeakT, PositionT>& spectrum, float min_freq = 1e6, float max_freq = -1e6);

		/** Computes the difference according to the precomputed normal moments up to moment_number. If the values have
		 *  not been precomputed so far, we regenerate them.
		 */
		virtual double getNormalMomentsDifference(Spectrum<DataT,PeakT, PositionT>& spectrum, int moment_number);
		virtual double getCentralMomentsDifference(Spectrum<DataT,PeakT, PositionT>& spectrum, int moment_number);
		virtual double getStandardizedMomentsDifference(Spectrum<DataT,PeakT, PositionT>& spectrum, int moment_number);
		
		/// precomputed normal moments
		std::vector<float> normal_moments;
		/// precomputed central moments
		std::vector<float> central_moments;
		/// precomputed standardized moments
		std::vector<float> standardized_moments;
	
		/// This function requires that DataT has a binaryWrite method
		void binaryWrite(const String& filename);

		/// This function requires that DataT has a binaryRead method
		void binaryRead(const String& filename);

		protected:
			DataType							data_;
			std::vector<PeakType> sticks_;
			PositionType					spacing_; // rausschmeissen , wie auch immer 
			PositionType					min_;     // rausschmeissen , wie auch immer 
			PositionType					max_;     // rausschmeissen , wie auch immer 
			std::vector<float>	 	Hu_invariants_;
	};

	/**	Clear the spectrum.
			Sets all data to zero.  // TODO: what about the  spacing?
	*/
	template <typename DataT, typename PeakT, typename PositionT>
	void Spectrum<DataT, PeakT, PositionT>::clear()
	{
		data_.clear();
		sticks_.clear();
	}
	
	template <typename DataT, typename PeakT, typename PositionT>
	void Spectrum<DataT, PeakT, PositionT>::clearSticks()
	{
		sticks_.clear();
	}


	// TODO: muss die hier stehen??? 
	/**	Calculate the difference between two spectra.
	*/
	template <typename DataT, typename PeakT, typename PositionT>
	double Spectrum<DataT, PeakT, PositionT>::difference(const Spectrum<DataT, PeakT, PositionT>& /* spectrum */) const
	{
		// ?????
		return 0.0;
	}

	/**	Return the spacing.
	*/
	template <typename DataT, typename PeakT, typename PositionT>
	typename Spectrum<DataT, PeakT, PositionT>::PositionType Spectrum<DataT, PeakT, PositionT>::getSpacing() const
	{
		return spacing_;
	}

	/** Set the spacing.
	*/
	template <typename DataT, typename PeakT, typename PositionT>
	void Spectrum<DataT, PeakT, PositionT>::setSpacing(const typename Spectrum<DataT, PeakT, PositionT>::PositionType& spacing)
	{
		spacing_ = spacing;
	}

	/**	Difference operator.
			Calculate the sum of the unsigned differences of the two spectra
	*/
	template <typename DataT, typename PeakT, typename PositionT>
	double operator - (const Spectrum<DataT, PeakT, PositionT>& s1, const Spectrum<DataT, PeakT, PositionT>& s2)
	{
		return s1.difference(s2);
	}
	
	template <typename DataT, typename PeakT, typename PositionT>
	double Spectrum<DataT, PeakT, PositionT>::getNormalMomentsDifference(Spectrum<DataT, PeakT, PositionT>& spectrum, int moment_number)
	{
		if (normal_moments.size() != (Size)moment_number)
			computeAllMoments(moment_number);
		if (spectrum.normal_moments.size() != (Size)moment_number)
			spectrum.computeAllMoments(moment_number);

		double diff = 0.;
		for (int current_moment=0; current_moment<moment_number; current_moment++)
			diff += fabs(normal_moments[current_moment] - spectrum.normal_moments[current_moment]);

		return diff;
	}

	template <typename DataT, typename PeakT, typename PositionT>
	double Spectrum<DataT, PeakT, PositionT>::getCentralMomentsDifference(Spectrum<DataT, PeakT, PositionT>& spectrum, int moment_number)
	{
		if (central_moments.size() != (Size)moment_number)
			computeAllMoments(moment_number);
		if (spectrum.central_moments.size() != (Size)moment_number)
			spectrum.computeAllMoments(moment_number);

		double diff = 0.;
		for (int current_moment=0; current_moment<moment_number; current_moment++)
			diff += fabs(central_moments[current_moment] - spectrum.central_moments[current_moment]);

		return diff;
	}

	template <typename DataT, typename PeakT, typename PositionT>
	double Spectrum<DataT, PeakT, PositionT>::getStandardizedMomentsDifference(Spectrum<DataT, PeakT, PositionT>& spectrum, int moment_number)
	{
		if (standardized_moments.size() != (Size)moment_number)
			computeAllMoments(moment_number);
		if (spectrum.standardized_moments.size() != (Size)moment_number)
			spectrum.computeAllMoments(moment_number);

		double diff = 0.;
		for (int current_moment=0; current_moment<moment_number; current_moment++)
			diff += fabs(standardized_moments[current_moment] - spectrum.standardized_moments[current_moment]);

		return diff;
	}	
	
	template <typename DataT, typename PeakT, typename PositionT>
	const DataT& Spectrum<DataT, PeakT, PositionT>::getData() const
	{
		return data_;
	}
	
	template <typename DataT, typename PeakT, typename PositionT>
	DataT& Spectrum<DataT, PeakT, PositionT>::getData()
	{
		return data_;
	}
/*	
	const vector<float>& getHuInvariants();
*/

	template <typename DataT, typename PeakT, typename PositionT>
	const vector<float>& Spectrum<DataT, PeakT, PositionT>::getHuInvariants() const
	{
		return Hu_invariants_;
	}

	template <typename DataT, typename PeakT, typename PositionT>
	vector<float>& Spectrum<DataT, PeakT, PositionT>::getHuInvariants() 
	{
		return Hu_invariants_;
	}


	
	template <typename DataT, typename PeakT, typename PositionT>
	void Spectrum<DataT, PeakT, PositionT>::computeHuInvariants()
	{
		Log.error()<< "computeHuInvariants() only implemented in 2D" << std::endl;
		return;
	}

	template <typename DataT, typename PeakT, typename PositionT>
	vector<float> Spectrum<DataT, PeakT, PositionT>::computeHuInvariantsDifferences(vector<Spectrum<DataT, PeakT, PositionT> >& /*spectra*/)
	{
		Log.error()<< "computeHuInvariantsDifferences() only implemented in 2D" << std::endl;
		std::vector<float> result;
		return result;
	}

	template <typename DataT, typename PeakT, typename PositionT>
	double Spectrum<DataT, PeakT, PositionT>::getFourierDifference(const Spectrum<DataT, PeakT, PositionT>& spectrum, float min_freq, float max_freq)
	{
		Log.error() << "getFourierDifference only implemented in 1D and 2D" << std::endl;
		return 0.;
	}

	/**	Convenience typedefs
	\ingroup Spectra
	*/
	//@{
	/// One-dimensional spectrum
	typedef Spectrum<RegularData1D, Peak1D> Spectrum1D;

	/// Two-dimensional spectrum
	typedef Spectrum<RegularData2D, Peak2D> Spectrum2D;

	/// Three-dimensional spectrum
	typedef Spectrum<RegularData3D, Peak3D> Spectrum3D;
	//@}
  
	template <typename DataT, typename PeakT, typename PositionT>
	std::ostream& operator << (std::ostream& os, const Spectrum<DataT, PeakT, PositionT>& spectrum);
	
	template <typename DataT, typename PeakT, typename PositionT>
	std::istream& operator >> (std::istream& is, Spectrum<DataT, PeakT, PositionT>& spectrum);

# ifndef BALL_NO_INLINE_FUNCTIONS
#   include <BALL/NMR/spectrum.iC>
# endif
} // namespace BALL


#endif // BALL_NMR_SPECTRUM_H