#ifndef REARR1D_HH #define REARR1D_HH ///////////////////////////////////////////////////////////////////////// //! file="amma/StdType/StdArray/ReArr1d.hh" //! lib=MstdArr //! userlevel=Normal //! author="Radek Marik" //! docentry="Containers.Arrays.1-D Arrays.Specialized Arrays" //! rcsid="$Id: ReArr1d.hh,v 1.12 1999/08/24 10:29:37 ees1cg Exp $" //! date="06/08/95" #include "amma/StdType.hh" #include "amma/NArray1d.hh" class LinearSums2dC; class istream; class ostream; //====================================================================== //======== RealArray1dC ================================================ //====================================================================== //: 1 Dimensional real array class RealArray1dC : public NumArray1dC { public: typedef int MaskSizeT; enum SortOrderT {INCREASING, DECREASING}; public: inline RealArray1dC(); // Creates an empty array. inline RealArray1dC(const SizeT dim); // an real array with the range <0, 'dim'-1> inline RealArray1dC(const IndexRangeC & range); // an real array with the range <'range'.Min(), 'range'.Max()> inline RealArray1dC(const RealArray1dC & vv); // another access to the real array 'vv' inline RealArray1dC(const RealArray1dC & vv, const IndexRangeC & range); // real subarray of the 'vv' with the 'range' inline RealArray1dC(RealT * data, const IndexRangeC & range); // the RealT array is created from the memory location 'data' // with the range of access in <'range'.Min(), 'range'.Max()> // 'data' is not deallocated during destructing of the array RealArray1dC(const char * fileName); // Creates a real array from the file 'fileName'. RealArray1dC(istream & s); // A real array is created from the input stream 's' IndexT MinIndex() const; // find the index of the minimal item IndexT MaxIndex() const; // find the index of the maximal item IndexT FirstGreaterIndex(const RealT value) const; // find the index from the beginning of the array // of the first items which value is greater // than 'value' IndexT FirstGreaterAbsIndex(const RealT value) const; // find the index from the beginning of the array // of the first items which the absolute value is greater // than 'value' void Sort(IndexRangeC r, SortOrderT o = INCREASING); // Sorts the array values inside the range 'r' into the order 'o'. RealT SetZeroMean(); // values of the array are shifted to have zero mean // returns the mean value of the original values RealT SetUnitSum(); // values fo the array are normalizes to have D.C = 1 // returns the sum of the original values RealT NormAbsSum(RealT value = 1.0); // Normalizes this array so that the sum of its absolute values // is 'value'. LinearSums2dC LinearSums2d() const; // Returns the object serving for estimation of linear dependency. RealArray1dC & Convolution(const RealArray1dC & mask); // convolve array with the mask // the result is stored in the same array inline RealArray1dC Enlarge(const IntT factor = 2) const; // Enlarges the real array by item duplications. Every number is duplicated // 'factor' times. The return real array is extended by adding of higher // indexes. inline RealArray1dC Copy() const; // create a copy of the array static RealArray1dC Gauss(MaskSizeT len, RealT tau); // Creates the array containing Gaussian.
// "len" is array size, rounded down to nearest odd no.
// "tau" is ratio of cutoff to peak values (hence must be <= 1) private: inline RealArray1dC(const NumArray1dC & a); // Creates a real value array which is attached to the array 'a'. void SortUp(const IndexRangeC & r); // Sorts the array values inside the range 'r' into the increasing order. void SortDown(const IndexRangeC & r); // Sorts the array values inside the range 'r' into the decreasing order. }; ostream & operator<<(ostream & s, const RealArray1dC & arr); inline RealArray1dC::RealArray1dC() : NumArray1dC() {} inline RealArray1dC::RealArray1dC(const SizeT dim) : NumArray1dC(dim) {} inline RealArray1dC::RealArray1dC(const IndexRangeC & range) : NumArray1dC(range) {} inline RealArray1dC::RealArray1dC(const RealArray1dC & vv) : NumArray1dC(vv) {} inline RealArray1dC::RealArray1dC(const NumArray1dC & a) : NumArray1dC(a) {} inline RealArray1dC::RealArray1dC(const RealArray1dC & vv, const IndexRangeC & range) : NumArray1dC(vv,range) {} inline RealArray1dC::RealArray1dC(RealT * data, const IndexRangeC & range) : NumArray1dC(data,range) {} inline RealArray1dC RealArray1dC::Copy() const { return NumArray1dC(Array1dC::Copy()); } inline RealArray1dC RealArray1dC::Enlarge(const IntT factor) const { return NumArray1dC(Array1dC::Enlarge(factor)); } #endif // End of the include file ReArr1d.hh