Public Types | Public Member Functions | Private Attributes | Friends
ecl::PascalsTriangle< N > Class Template Reference

Holds the coefficients for pascal's triangle up to row N. More...

#include <pascals_triangle.hpp>

List of all members.

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.

Detailed Description

template<int N>
class ecl::PascalsTriangle< N >

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;
Template Parameters:
N: calculate the triangle to the N-th power.
See also:
Math::Polynomials.

Definition at line 57 of file pascals_triangle.hpp.


Member Typedef Documentation

template<int N>
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.


Constructor & Destructor Documentation

template<int N>
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.

template<int N>
virtual ecl::PascalsTriangle< N >::~PascalsTriangle ( ) [inline, virtual]

Definition at line 63 of file pascals_triangle.hpp.


Member Function Documentation

template<int N>
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.

Parameters:
index: the diagonal to be iterated.
Returns:
const_iterator : constant iterator pointing pointing to the first element of the specified diagonal.

Definition at line 230 of file pascals_triangle.hpp.

template<int N>
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.

Parameters:
index: the diagonal to be iterated.
Returns:
const_iterator : constant iterator pointing just beyond the last of the specified diagonal.

Definition at line 245 of file pascals_triangle.hpp.


Friends And Related Function Documentation

template<int N>
template<typename OutputStream , int PowerN>
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.

Template Parameters:
OutputStream: the type of stream being used.
PowerN: the order of the pascal's triangle being inserted.
Parameters:
ostream: the stream to send the output to.
triangle: the pascal triangle object.
Returns:
OutputStream : the output stream.

Definition at line 271 of file pascals_triangle.hpp.


Member Data Documentation

template<int N>
Array<int,(N+2)*(N+1)/2> ecl::PascalsTriangle< N >::coefficients [private]

Definition at line 79 of file pascals_triangle.hpp.


The documentation for this class was generated from the following file:


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Sun Oct 5 2014 23:36:08