/usr/include/openturns/NumericalSample.hxx is in libopenturns-dev 1.5-7build2.
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 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | // -*- C++ -*-
/**
* @file NumericalSample.hxx
* @brief The class NumericalSample implements blank free samples
*
* Copyright 2005-2015 Airbus-EDF-IMACS-Phimeca
*
* This library 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.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* @author schueller
* @date 2012-04-18 17:56:46 +0200 (Wed, 18 Apr 2012)
*/
#ifndef OPENTURNS_NUMERICALSAMPLE_HXX
#define OPENTURNS_NUMERICALSAMPLE_HXX
#include <iostream> // for std::ostream
#include "TypedInterfaceObject.hxx"
#include "NumericalPoint.hxx"
#include "Description.hxx"
#include "Pointer.hxx"
#include "NumericalSampleImplementation.hxx"
#include "ResourceMap.hxx"
BEGIN_NAMESPACE_OPENTURNS
/**
* @class NumericalSample
*/
class OT_API NumericalSample
: public TypedInterfaceObject<NumericalSampleImplementation>
{
CLASSNAME;
public:
/* Some typedefs for easy reading */
public:
/** Factory of NumericalSample from CSV file */
static NumericalSample ImportFromCSVFile(const FileName & fileName,
const String & csvSeparator = ResourceMap::Get( "csv-file-separator" ));
/** Factory of NumericalSample from Text file */
static NumericalSample ImportFromTextFile(const FileName & fileName,
const String & separator = " ");
/** Export NumericalSample into CSV file */
void exportToCSVFile(const FileName & fileName,
const String & csvSeparator = ResourceMap::Get( "csv-file-separator" )) const;
/** Export a sample as a matrix, one row by realization, in a format suitable to exchange with R. */
String streamToRFormat() const;
public:
/**
* Default constructor
* Build a NumericalSample of 1 dimension and with size equal to 0
*/
NumericalSample();
/** Constructor with size and dimension */
NumericalSample(const UnsignedInteger size,
const UnsignedInteger dim);
/** Constructor from a NumericalPoint (all elements are equal to the NumericalPoint) */
NumericalSample(const UnsignedInteger size,
const NumericalPoint & point);
#ifndef SWIG
/** Constructor from a collection of NumericalPoint */
NumericalSample(const Collection<NumericalPoint> & coll);
/** Constructor from a collection of Indices */
NumericalSample(const Collection<Indices> & coll);
#endif
/** Constructor from implementation */
NumericalSample(const NumericalSampleImplementation & implementation);
private:
/** Constructor from implementation */
NumericalSample(const Implementation & implementation);
public:
/** Comparison operator */
Bool operator ==(const NumericalSample & other) const;
/** Comparison operator */
Bool operator !=(const NumericalSample & other) const;
#ifndef SWIG
NSI_point operator [] (const UnsignedInteger index);
NSI_const_point operator [] (const UnsignedInteger index) const;
NSI_point at (const UnsignedInteger index);
NSI_const_point at (const UnsignedInteger index) const;
NumericalScalar & operator () (const UnsignedInteger i,
const UnsignedInteger j);
const NumericalScalar & operator () (const UnsignedInteger i,
const UnsignedInteger j) const;
NumericalScalar & at (const UnsignedInteger i,
const UnsignedInteger j);
const NumericalScalar & at (const UnsignedInteger i,
const UnsignedInteger j) const;
void erase(NumericalSampleImplementation::iterator first, NumericalSampleImplementation::iterator last);
#endif
// These functions are only intended to be used by SWIG, DO NOT use them for your own purpose !
// INTENTIONALY NOT DOCUMENTED
const NumericalScalar * __baseaddress__ () const;
UnsignedInteger __elementsize__ () const;
/* Method __len__() is for Python */
UnsignedInteger __len__() const;
/* Method __contains__() is for Python */
Bool __contains__(const NumericalPoint & val) const;
const NumericalPoint __getitem__ (const UnsignedInteger index) const;
void __setitem__ (const UnsignedInteger index,
const NumericalPoint & val);
void erase(const UnsignedInteger first,
const UnsignedInteger last);
void erase(const UnsignedInteger index);
/** erase the whole sample */
void clear();
/**
* String converter
* This method shows human readable information on the
* internal state of an NumericalSample. It is used when streaming
* the NumericalSample or for user information.
*/
String __repr__() const;
String __str__(const String & offset = "") const;
/** Description accessor */
void setDescription(const Description & description);
Description getDescription() const;
/** Dimension accessor */
UnsignedInteger getDimension() const;
/** Size accessor */
UnsignedInteger getSize() const;
/** Maximum accessor */
NumericalPoint getMax() const;
/** Minimum accessor */
NumericalPoint getMin() const;
/** Method add() appends an element to the collection */
void add(const NumericalPoint & point);
/** Method add() appends another sample to the collection */
void add(const NumericalSample & sample);
/** Stack the given sample to the current one */
void stack(const NumericalSample & sample);
/**
* Method split() trunk the sample before the index passed as argument
* and returns the remainder as new sample. This method tries its best not for doubling
* memory usage.
*/
NumericalSample split(const UnsignedInteger index);
/**
* Method computeMean() gives the mean of the sample, based on the formula
* mean = sum of the elements in the sample / size of the sample
*/
NumericalPoint computeMean() const;
/**
* Method computeCovariance() gives the covariance of the sample
*/
CovarianceMatrix computeCovariance() const;
/**
* Method computeStandardDeviation() gives the standard deviation of the sample
*/
TriangularMatrix computeStandardDeviation() const;
/**
* Method computeVariance() gives the variance of the sample (by component)
*/
NumericalPoint computeVariance() const;
/** @deprecated */
NumericalPoint computeVariancePerComponent() const;
/**
* Method computeStandardDeviationPerComponent() gives the standard deviation of each component of the sample
*/
NumericalPoint computeStandardDeviationPerComponent() const;
/**
* Method computePearsonCorrelation() gives the Pearson correlation matrix of the sample
*/
CorrelationMatrix computeLinearCorrelation() const;
CorrelationMatrix computePearsonCorrelation() const;
/**
* Method computeSpearmanCorrelation() gives the Spearman correlation matrix of the sample
*/
CorrelationMatrix computeSpearmanCorrelation() const;
/**
* Gives the Kendall correlation matrix of the sample
*/
CorrelationMatrix computeKendallTau() const;
/**
* Method computeRangePerComponent gives the range of the sample (by component)
*/
NumericalPoint computeRange() const;
/** @deprecated */
NumericalPoint computeRangePerComponent() const;
/**
* Method computeMedianPerComponent() gives the median of the sample (by component)
*/
NumericalPoint computeMedian() const;
/** @deprecated */
NumericalPoint computeMedianPerComponent() const;
/**
* Method computeSkewness() gives the skewness of the sample (by component)
*/
NumericalPoint computeSkewness() const;
/** @deprecated */
NumericalPoint computeSkewnessPerComponent() const;
/**
* Method computeKurtosis() gives the kurtosis of the sample (by component)
*/
NumericalPoint computeKurtosis() const;
/** @deprecated */
NumericalPoint computeKurtosisPerComponent() const;
/**
* Gives the centered moment of order k of the sample (by component)
*/
NumericalPoint computeCenteredMoment(const UnsignedInteger k) const;
/** @deprecated */
NumericalPoint computeCenteredMomentPerComponent(const UnsignedInteger k) const;
/**
* Gives the raw moment of order k of the sample (by component)
*/
NumericalPoint computeRawMoment(const UnsignedInteger k) const;
/** @deprecated */
NumericalPoint computeRawMomentPerComponent(const UnsignedInteger k) const;
/**
* Method computeQuantilePerComponent() gives the quantile per component of the sample
*/
NumericalPoint computeQuantilePerComponent(const NumericalScalar prob) const;
/**
* Method computeQuantile() gives the N-dimension quantile of the sample
*/
NumericalPoint computeQuantile(const NumericalScalar prob) const;
/**
* Get the empirical CDF of the sample
*/
NumericalScalar computeEmpiricalCDF(const NumericalPoint & point,
const Bool tail = false) const;
/**
* Get the position of a point in the sample.
* Returns size+1 if the point does not belong to the sample.
*/
UnsignedInteger find(const NumericalPoint & point) const;
/**
* Translate realizations in-place
*/
NumericalSample & operator += (const NumericalScalar translation);
NumericalSample & operator += (const NumericalPoint & translation);
NumericalSample & operator += (const NumericalSample & translation);
NumericalSample & operator -= (const NumericalScalar translation);
NumericalSample & operator -= (const NumericalPoint & translation);
NumericalSample & operator -= (const NumericalSample & translation);
/** Translate/scale realizations */
NumericalSample operator + (const NumericalScalar translation) const;
NumericalSample operator + (const NumericalPoint & translation) const;
NumericalSample operator + (const NumericalSample & translation) const;
NumericalSample operator - (const NumericalScalar translation) const;
NumericalSample operator - (const NumericalPoint & translation) const;
NumericalSample operator - (const NumericalSample & translation) const;
NumericalSample operator * (const NumericalScalar scaling) const;
NumericalSample operator * (const NumericalPoint & scaling) const;
NumericalSample operator * (const SquareMatrix & scaling) const;
NumericalSample operator / (const NumericalScalar scaling) const;
NumericalSample operator / (const NumericalPoint & scaling) const;
NumericalSample operator / (const SquareMatrix & scaling) const;
/**
* Scale realizations componentwise in-place
*/
NumericalSample & operator *= (const NumericalScalar scaling);
NumericalSample & operator *= (const NumericalPoint & scaling);
NumericalSample & operator *= (const SquareMatrix & scaling);
NumericalSample & operator /= (const NumericalScalar scaling);
NumericalSample & operator /= (const NumericalPoint & scaling);
NumericalSample & operator /= (const SquareMatrix & scaling);
/** Ranked sample */
NumericalSample rank() const;
/** Ranked component */
NumericalSample rank(const UnsignedInteger index) const;
/** Sorted sample */
NumericalSample sort() const;
/** Sorted component */
NumericalSample sort(const UnsignedInteger index) const;
/** Sorted according a component */
NumericalSample sortAccordingToAComponent(const UnsignedInteger index) const;
/** Store a sample in a temporary text file, one realization by line. Returns the file name. */
virtual String storeToTemporaryFile() const;
/** Get the i-th marginal sample */
NumericalSample getMarginal(const UnsignedInteger index) const;
/** Get the marginal sample corresponding to indices dimensions */
NumericalSample getMarginal(const Indices & indices) const;
/** Returns a pointer to the underlying implementation object */
virtual ImplementationAsPersistentObject getImplementationAsPersistentObject() const;
/** Sets the pointer to the underlying implementation object */
virtual void setImplementationAsPersistentObject(const ImplementationAsPersistentObject & obj);
}; /* class NumericalSample */
END_NAMESPACE_OPENTURNS
#endif /* OPENTURNS_NUMERICALSAMPLE_HXX */
|