Dynare++: improvements to comments
parent
92224e22be
commit
a6d7baabea
|
@ -36,10 +36,6 @@ IntSequence::getSymmetry() const
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This constructs an ordered integer sequence from the given ordered
|
|
||||||
sequence inserting the given number to the sequence. */
|
|
||||||
|
|
||||||
IntSequence
|
IntSequence
|
||||||
IntSequence::insert(int i) const
|
IntSequence::insert(int i) const
|
||||||
{
|
{
|
||||||
|
@ -128,9 +124,6 @@ IntSequence::sort()
|
||||||
std::sort(data, data+length);
|
std::sort(data, data+length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Here we monotonize the sequence. If an item is less then its
|
|
||||||
predecessor, it is equalized. */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IntSequence::monotone()
|
IntSequence::monotone()
|
||||||
{
|
{
|
||||||
|
@ -139,11 +132,6 @@ IntSequence::monotone()
|
||||||
operator[](i) = operator[](i-1);
|
operator[](i) = operator[](i-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This partially monotones the sequence. The partitioning is done by a
|
|
||||||
symmetry. So the subsequence given by the symmetry classes are
|
|
||||||
monotonized. For example, if the symmetry is y²u³, and the
|
|
||||||
IntSequence is (5,3,1,6,4), the result is (5,5,1,6,6). */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IntSequence::pmonotone(const Symmetry &s)
|
IntSequence::pmonotone(const Symmetry &s)
|
||||||
{
|
{
|
||||||
|
@ -157,17 +145,12 @@ IntSequence::pmonotone(const Symmetry &s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This returns sum of all elements. Useful for symmetries. */
|
|
||||||
|
|
||||||
int
|
int
|
||||||
IntSequence::sum() const
|
IntSequence::sum() const
|
||||||
{
|
{
|
||||||
return std::accumulate(data, data+length, 0);
|
return std::accumulate(data, data+length, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This returns product of subsequent items. Useful for Kronecker product
|
|
||||||
dimensions. */
|
|
||||||
|
|
||||||
int
|
int
|
||||||
IntSequence::mult(int i1, int i2) const
|
IntSequence::mult(int i1, int i2) const
|
||||||
{
|
{
|
||||||
|
@ -175,8 +158,6 @@ IntSequence::mult(int i1, int i2) const
|
||||||
1, std::multiplies<int>());
|
1, std::multiplies<int>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a number of the same items in the beginning of the sequence. */
|
|
||||||
|
|
||||||
int
|
int
|
||||||
IntSequence::getPrefixLength() const
|
IntSequence::getPrefixLength() const
|
||||||
{
|
{
|
||||||
|
@ -186,9 +167,6 @@ IntSequence::getPrefixLength() const
|
||||||
return i+1;
|
return i+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This returns a number of distinct items in the sequence. It supposes
|
|
||||||
that the sequence is ordered. For the empty sequence it returns zero. */
|
|
||||||
|
|
||||||
int
|
int
|
||||||
IntSequence::getNumDistinct() const
|
IntSequence::getNumDistinct() const
|
||||||
{
|
{
|
||||||
|
@ -201,9 +179,6 @@ IntSequence::getNumDistinct() const
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This returns a maximum of the sequence. If the sequence is empty, it
|
|
||||||
returns the least possible int value. */
|
|
||||||
|
|
||||||
int
|
int
|
||||||
IntSequence::getMax() const
|
IntSequence::getMax() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -145,11 +145,28 @@ public:
|
||||||
/* For appending at the end, use pos = size() */
|
/* For appending at the end, use pos = size() */
|
||||||
IntSequence insert(int i, int pos) const;
|
IntSequence insert(int i, int pos) const;
|
||||||
|
|
||||||
|
// In-place sort the sequence in increasing order
|
||||||
void sort();
|
void sort();
|
||||||
|
|
||||||
|
/* Monotonize the sequence: if an item is less then its predecessor, it is
|
||||||
|
equalized. */
|
||||||
void monotone();
|
void monotone();
|
||||||
|
|
||||||
|
/* Partially monotonize the sequence. The partitioning is done by a
|
||||||
|
symmetry. So the subsequence given by the symmetry classes are
|
||||||
|
monotonized. For example, if the symmetry is y²u³, and the
|
||||||
|
IntSequence is (5,3,1,6,4), the result is (5,5,1,6,6). */
|
||||||
void pmonotone(const Symmetry &s);
|
void pmonotone(const Symmetry &s);
|
||||||
|
|
||||||
|
|
||||||
|
// Returns the sum of all elements. Useful for symmetries
|
||||||
int sum() const;
|
int sum() const;
|
||||||
|
|
||||||
|
/* This returns product of elements between indices i1 (included) and i2
|
||||||
|
(excluded). Useful for Kronecker product dimensions. */
|
||||||
int mult(int i1, int i2) const;
|
int mult(int i1, int i2) const;
|
||||||
|
|
||||||
|
// Returns the product of all elements
|
||||||
int
|
int
|
||||||
mult() const
|
mult() const
|
||||||
{
|
{
|
||||||
|
@ -157,12 +174,22 @@ public:
|
||||||
}
|
}
|
||||||
void add(int i);
|
void add(int i);
|
||||||
void add(int f, const IntSequence &s);
|
void add(int f, const IntSequence &s);
|
||||||
|
|
||||||
|
/* Return the number of identical elements at the beginning of the sequence. */
|
||||||
int getPrefixLength() const;
|
int getPrefixLength() const;
|
||||||
|
|
||||||
|
/* This returns a number of distinct items in the sequence. It supposes that
|
||||||
|
the sequence is ordered. Returns zero on the empty sequence. */
|
||||||
int getNumDistinct() const;
|
int getNumDistinct() const;
|
||||||
|
|
||||||
|
/* This returns a maximum of the sequence. If the sequence is empty, it
|
||||||
|
returns the least possible int value. */
|
||||||
int getMax() const;
|
int getMax() const;
|
||||||
|
|
||||||
bool isPositive() const;
|
bool isPositive() const;
|
||||||
bool isConstant() const;
|
bool isConstant() const;
|
||||||
bool isSorted() const;
|
bool isSorted() const;
|
||||||
|
|
||||||
void print() const;
|
void print() const;
|
||||||
/* ⎛sum(this)⎞
|
/* ⎛sum(this)⎞
|
||||||
Computes multinomial coefficient: ⎝ this ⎠
|
Computes multinomial coefficient: ⎝ this ⎠
|
||||||
|
|
Loading…
Reference in New Issue