This file is indexed.

/usr/include/casacore/scimath/Mathematics/HistAcc.h is in casacore-dev 2.2.0-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
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
//# HistAcc.h: Histogram Accumulator
//# Copyright (C) 1996,1999,2000,2001
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library 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 Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//#        Internet email: aips2-request@nrao.edu.
//#        Postal address: AIPS++ Project Office
//#                        National Radio Astronomy Observatory
//#                        520 Edgemont Road
//#                        Charlottesville, VA 22903-2475 USA
//#
//#
//# $Id$

#ifndef SCIMATH_HISTACC_H
#define SCIMATH_HISTACC_H

#include <casacore/casa/aips.h>
#include <casacore/casa/Utilities/Fallible.h>
#include <casacore/scimath/Mathematics/StatAcc.h>
#include <casacore/casa/Containers/Block.h>
#include <casacore/casa/iosfwd.h>

namespace casacore { //# NAMESPACE CASACORE - BEGIN

// forward declarations:
template <class T> class Array;
class String;

// <reviewed reviewer="" date="" tests="tHistAcc" demos="">

// <prerequisite>
//   <li> module Arrays
//   <li> <linkto module="Arrays:description">Arrays </linkto> module
// </prerequisite>
//
// <summary> 
// Makes a histogram from input values.
// </summary>
//
// <etymology>
// HistAcc stands for `Histogram Accumulator'. 
// </etymology>
//
// <templating arg=T>
// <li> The accepted input types are real, i.e. Int, uInt, Float, Double, 
// but not Complex. 
// </templating>

// <synopsis>
// Makes a histogram from input values. The histogram bin parameters
// may be defined, or determined from the first n input values.
// The input values are fed to HistAcc via the member function `put'. 
// They can be fed individually, or in the form of an Array. 
//
// The histogram `bins' can be defined via the constructor in the
// form of loop variables: low bin, high bin, bin-width.
// It is also possible to let the bin parameters be determined 
// automatically from the first n (e.g. n=50) input values.
// If the actual nr of input values is less than n when the histogram
// is interrogated in some way, the bin parameters will be determined 
// from what is available.
// </synopsis> 
//
// <example>
// It is usually convenient to let the bins be defined automatically: 
// <srcblock>
//   Matrix<T> vv(30,100);        // an array of input values
//   vv = ...                     // fill the array
//   HistAcc<T> h(25);            // use the first 25 values to define bins 
//   h.put(vv);                   // accumulate values into histogram 
//   h.printHistogram(cout,"vv"); // print the histogram of vv
//   Fallible<Double> median = h1.getMedian();  // return the median
// </srcblock>
//  
// In some cases the bin parameters are pre-defined:
// <srcblock>
//   Vector<T> vv(100,0);        // a vector (array) of values
//   vv = ...                    // fill the vector
//   HistAcc<T> h(-10,20,3);     // bins with width 3, between -10 and 20
//   h.put(vv);                  // accumulate values into histogram   
//   uInt n = h.getSpurious(l,h);// get the number outside the bins
// </srcblock>
//
// The internal statistics accumulator can be interrogated explicitly
// or implicitly:
// <srcblock>
//   StatAcc<T> s = h.getStatistics();     // return the internal StatAcc
//   Fallible<Double> mean = s.getMean();  // get the mean of the input values
//   Fallible<Double> mean = h.getStatistics().getMean();  // alternative
// </srcblock>

// </example>
//
// <motivation>
// </motivation>
//
// <todo asof="">
// </todo>


// *************************************************************************** 

template<class T> class HistAcc  {
public:
    // Constructors and destructor. If the bin-parameters low, high 
    // and width (for lowest and highest bin, and binwidth) are not
    // specified, they will be determined automatically from the
    // first nBuff input values (which are stored in a temporary buffer).
    // <group>
    HistAcc(const uInt nBuff);                 //# fully automatic  
    HistAcc(const uInt nBuff, const T width);  //# semi-automatic    
    HistAcc(const T low, const T high, const T width);  //# fully specified
    HistAcc(const HistAcc&);                   //# copy an existing one
    ~HistAcc(){;} 
    // </group>

    // Copy operations.
    // <group>
    void copy(const HistAcc&);           //# idem
    HistAcc& operator= (const HistAcc&); 
    // </group>

    // Accumulate (put) value(s) into the histogram.
    // <group>
    inline void put(const T v);           //# single value           
    void put(const Array<T>& vv);         //# array 
    void put(const Block<T>& vv);         //# block (simple array)
    // </group>

    // Reset the contents of the bins to zero, but retain the current 
    // bin definition. 
    void reset();                    

    // Empty all bins whose contents is < nmin (e.g. nmin=2). 
    // This is useful to remove `noise' values from the histogram.
    void emptyBinsWithLessThan(const uInt nmin);

    // The median is the 50-percentile (getPercentile(50)), i.e. the 
    // value which has 50 percent of the input values below it.
    // Calculation takes into account the spurious
    // input values, i.e. values that fell outside the bins.
    Fallible<T> getPercentile(const Float p); 
    Fallible<T> getMedian();                 

    // All bins have the same width.
    Fallible<T> getBinWidth() const;           

    // Get the internal Statistics accumulator (see StatAcc,h).
    // It can be used to obtain statistics of the input values.
    const StatAcc<T>& getStatistics();    

    // The return value is the nr of histogram bins, and is invalid
    // if the number is zero. The given blocks/vectors are resized,
    // and contain the contents and centre values of the bins. 
    Fallible<uInt> getHistogram(Block<uInt>& bins, Block<T>& values);

    // Get the nr of `spurious' values, i.e. the ones that fell
    // outside the defined bins. 
    uInt getSpurious(uInt& tooSmall, uInt& tooLarge);        

    // Print histogram.
    // <group>
    void printHistogram(ostream&, const String& caption); 
    // </group>
	
private:
    Block<uInt> itsBinContents;   //# Contents of histogram bins
    Block<T> itsBinHighLimit;     //# High limit of each bin
    T itsUserDefinedBinWidth;     //# if defined

    StatAcc<T> itsStatAcc;        //# private Statistics Accumulator

    Bool itsAutoDefineMode;       //# If true: automatic mode
    Block<T> itsBuffer;           //# temporary storage of input T-values
    uInt itsBufferContents;       //# nr of T-values in buffer 

    // Accumulate a single value into the histogram.
    void put1(const T);

    // Definition of histogram bins with given parameters.
    void defineBins(const T low, const T high, const T width);

    // Internal helper functions for the automatic definition of
    // histogram parameters, using the contents of itsBuffer.  
    // <group> 
    void initBuffer(const uInt size); 
    void putBuffer(const T v);     //# add input value to itsBuffer 
    void clearBuffer();            //# transfer from buffer to bins
    void autoDefineBins(); 
    // </group>

    // Other internal helper function(s).
    // <group>
    void init();   
    Fallible<T> getBinValue(const uInt index) const;  //# bin centre value
    // </group>

};



//*************************** inline functions, have to be in HistAcc.h ****


// Accumulate a single value:

template<class T> 
inline void HistAcc<T>::put(const T v) {
    put1(v);            
}


} //# NAMESPACE CASACORE - END

#ifndef CASACORE_NO_AUTO_TEMPLATES
#include <casacore/scimath/Mathematics/HistAcc.tcc>
#endif //# CASACORE_NO_AUTO_TEMPLATES
#endif