Holds the coefficients for pascal's triangle up to row N. More...
#include <pascals_triangle.hpp>
Public Types | |
typedef Array< int,(N+2)*(N+1)/2 > ::const_iterator | const_iterator |
Utilise the array's iterator for parsing the triangle. | |
Public Member Functions | |
const_iterator | begin (unsigned int index=0) const |
Iterator generator for diagonals of pascals triangle [begin]. | |
const_iterator | end (unsigned int index=0) const |
Iterator generator for diagonals of pascals triangle [end]. | |
PascalsTriangle () | |
Default constructor. | |
virtual | ~PascalsTriangle () |
Private Attributes | |
Array< int,(N+2)*(N+1)/2 > | coefficients |
Friends | |
template<typename OutputStream , int PowerN> | |
OutputStream & | operator<< (OutputStream &ostream, const PascalsTriangle< PowerN > &triangle) |
Streaming output insertion operator for for pascal triangles. |
Holds the coefficients for pascal's triangle up to row N.
Stores the coefficients of all rows (determined in diagonal order) up until row N - i.e. all coefficients up to and including those for (x+y)^0 to (x+y)^N. Coefficients are stored as a sequence of rows going from top to bottom right (of the triangle) and moving left. For example, for N = 5, the representation in the array is as shown below:
(*this) = 1,1,1,1,1,1, 1,2,3,4,5, 1,3,6,10, 1,4,10, 1,5, 1;
N | : calculate the triangle to the N-th power. |
Definition at line 57 of file pascals_triangle.hpp.
typedef Array<int,(N+2)*(N+1)/2>::const_iterator ecl::PascalsTriangle< N >::const_iterator |
Utilise the array's iterator for parsing the triangle.
Definition at line 63 of file pascals_triangle.hpp.
ecl::PascalsTriangle< N >::PascalsTriangle | ( | ) |
Default constructor.
This computes all coefficients of the triangle up to row N.
Definition at line 208 of file pascals_triangle.hpp.
virtual ecl::PascalsTriangle< N >::~PascalsTriangle | ( | ) | [inline, virtual] |
Definition at line 63 of file pascals_triangle.hpp.
PascalsTriangle< N >::const_iterator ecl::PascalsTriangle< N >::begin | ( | unsigned int | index = 0 | ) | const |
Iterator generator for diagonals of pascals triangle [begin].
Return a const iterator pointing to the first element of the specified diagonal.
index | : the diagonal to be iterated. |
Definition at line 230 of file pascals_triangle.hpp.
PascalsTriangle< N >::const_iterator ecl::PascalsTriangle< N >::end | ( | unsigned int | index = 0 | ) | const |
Iterator generator for diagonals of pascals triangle [end].
Return a const iterator just past the last element of the specified diagonal.
index | : the diagonal to be iterated. |
Definition at line 245 of file pascals_triangle.hpp.
OutputStream& operator<< | ( | OutputStream & | ostream, |
const PascalsTriangle< PowerN > & | triangle | ||
) | [friend] |
Streaming output insertion operator for for pascal triangles.
Streaming output insertion operator for for pascal triangles.
OutputStream | : the type of stream being used. |
PowerN | : the order of the pascal's triangle being inserted. |
ostream | : the stream to send the output to. |
triangle | : the pascal triangle object. |
Definition at line 271 of file pascals_triangle.hpp.
Array<int,(N+2)*(N+1)/2> ecl::PascalsTriangle< N >::coefficients [private] |
Definition at line 79 of file pascals_triangle.hpp.