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. More... | |
Public Member Functions | |
| const_iterator | begin (unsigned int index=0) const |
| Iterator generator for diagonals of pascals triangle [begin]. More... | |
| const_iterator | end (unsigned int index=0) const |
| Iterator generator for diagonals of pascals triangle [end]. More... | |
| PascalsTriangle () | |
| Default constructor. More... | |
| 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. More... | |
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:
| N | : calculate the triangle to the N-th power. |
Definition at line 63 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 77 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 214 of file pascals_triangle.hpp.
|
inlinevirtual |
Definition at line 77 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 236 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 251 of file pascals_triangle.hpp.
|
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 277 of file pascals_triangle.hpp.
|
private |
Definition at line 93 of file pascals_triangle.hpp.