20
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
22
* @author: $LastChangedBy: dutka $
23
* @date: $LastChangedDate: 2009-05-28 14:47:53 +0200 (jeu. 28 mai 2009) $
24
* Id: $Id: NumericalPoint.hxx 1262 2009-05-28 12:47:53Z dutka $
23
* @date: $LastChangedDate: 2010-02-04 16:44:49 +0100 (jeu. 04 févr. 2010) $
24
* Id: $Id: NumericalPoint.hxx 1473 2010-02-04 15:44:49Z dutka $
26
26
#ifndef OPENTURNS_NUMERICALPOINT_HXX
27
27
#define OPENTURNS_NUMERICALPOINT_HXX
29
#include "TypedCollectionInterfaceObject.hxx"
30
#include "NumericalPointImplementation.hxx"
30
#include "PersistentCollection.hxx"
31
#include "Description.hxx"
32
#include "Exception.hxx"
32
34
namespace OpenTURNS
44
46
* NumericalPoint implements the classical mathematical point
47
class NumericalPoint :
48
public Common::TypedCollectionInterfaceObject<NumericalPointImplementation>
50
: public PersistentCollection<NumericalScalar>
54
typedef Common::InvalidArgumentException InvalidArgumentException;
55
typedef NumericalPointImplementation::NumericalScalarCollection NumericalScalarCollection;
56
typedef Type::PersistentCollection<NumericalScalar> InternalType;
57
typedef Type::Collection<NumericalScalar> NumericalScalarCollection;
58
typedef InternalType::iterator iterator;
59
typedef InternalType::const_iterator const_iterator;
60
typedef InternalType::reverse_iterator reverse_iterator;
61
typedef InternalType::const_reverse_iterator const_reverse_iterator;
62
typedef Common::InvalidArgumentException InvalidArgumentException;
63
typedef Common::StorageManager StorageManager;
64
typedef Common::PersistentObject PersistentObject;
65
typedef NumericalPoint ImplementationType;
57
67
/** Default constructor */
61
71
NumericalPoint(const UnsignedLong size,
62
72
const NumericalScalar value = 0.0);
64
/** Constructor from implementation */
65
NumericalPoint(const NumericalPointImplementation & implementation);
67
// /** Description Accessor */
68
// void setDescription(const Description & description);
69
// Description getDescription() const;
74
/** Constructor from a collection */
75
NumericalPoint(const Type::Collection<NumericalScalar> & coll);
77
/** Virtual constructor */
78
virtual NumericalPoint * clone() const;
81
virtual ~NumericalPoint() throw();
83
/** Description Accessor */
84
virtual void setDescription(const Description & description) {}
85
virtual Description getDescription() const { return Description( getDimension() ); }
87
/** String converter */
88
String __repr__() const;
89
String __str__() const;
91
/** Dimension accessor */
92
inline UnsignedLong getDimension() const { return PersistentCollection<NumericalScalar>::getSize(); }
93
inline UnsignedLong getSize() const { return PersistentCollection<NumericalScalar>::getSize(); }
71
95
/** Collection accessor */
72
const NumericalScalarCollection & getCollection() const;
74
/** String converter */
75
virtual String __repr__() const;
76
virtual String __str__() const;
78
/* Method __eq__() is for Python */
79
Bool __eq__(const NumericalPoint & rhs) const;
81
/* Method __ne__() is for Python */
82
Bool __ne__(const NumericalPoint & rhs) const;
96
inline const NumericalScalarCollection & getCollection() const { return *this; }
99
/** Coordinate accessor */
100
NumericalScalar & operator[](const UnsignedLong index);
101
const NumericalScalar & operator[](const UnsignedLong index) const;
103
/** Erase the elements between first and last */
104
iterator erase(iterator first, iterator last);
106
/** Erase the element pointed by position */
107
iterator erase(iterator position);
109
/** Erase the element pointed by position */
110
iterator erase(UnsignedLong position);
84
113
/** Addition operator */
85
114
NumericalPoint operator +(const NumericalPoint & rhs) const
86
throw (InvalidArgumentException);
115
/* throw (InvalidArgumentException) */;
88
117
/** Substraction operator */
89
118
NumericalPoint operator -(const NumericalPoint & rhs) const
90
throw (InvalidArgumentException);
119
/* throw (InvalidArgumentException) */;
92
121
/** In-place addition operator */
93
NumericalPoint & operator +=(const NumericalPoint & other) throw (InvalidArgumentException);
122
NumericalPoint & operator +=(const NumericalPoint & other) /* throw (InvalidArgumentException) */;
95
124
/** In-place substraction operator */
96
NumericalPoint & operator -=(const NumericalPoint & other) throw (InvalidArgumentException);
125
NumericalPoint & operator -=(const NumericalPoint & other) /* throw (InvalidArgumentException) */;
98
127
/** Product operator */
99
128
NumericalPoint operator *(const NumericalScalar scalar) const;
110
139
/** Dot product operator */
111
140
static NumericalScalar dot(const NumericalPoint & lhs,
112
141
const NumericalPoint & rhs)
113
throw (InvalidArgumentException);
117
// This class is intented to be used only by derived class that want to usethe constructor from implementation pointer
120
/** Constructor from implementation */
121
NumericalPoint(NumericalPointImplementation * p_implementation, Derived);
142
/* throw (InvalidArgumentException) */;
144
/** Method save() stores the object through the StorageManager */
145
virtual void save(StorageManager::Advocate & adv) const;
147
/** Method load() reloads the object from the StorageManager */
148
virtual void load(StorageManager::Advocate & adv);
152
// /** The description of all components */
153
// Description:: p_description_;
124
155
}; /* class NumericalPoint */