12 #ifndef ECL_GEOMETRY_PASCALS_HPP_ 13 #define ECL_GEOMETRY_PASCALS_HPP_ 69 const_iterator begin(
unsigned int index = 0)
const;
70 const_iterator end(
unsigned int index = 0)
const;
75 template <
typename OutputStream,
int PowerN>
76 friend OutputStream& operator<<(OutputStream &ostream, const PascalsTriangle<PowerN> &triangle);
120 const_iterator begin(
unsigned int index = 0)
const;
128 const_iterator end(
unsigned int index = 0)
const;
133 template <
typename OutputStream>
134 friend OutputStream& operator<<(OutputStream &ostream, const PascalsTriangle<3> &triangle);
179 const_iterator begin(
unsigned int index = 0)
const;
187 const_iterator end(
unsigned int index = 0)
const;
192 template <
typename OutputStream>
193 friend OutputStream& operator<<(OutputStream &ostream, const PascalsTriangle<5> &triangle);
210 for (
int i = N+1; i > 0; --i ) {
211 for (
int j = 0; j < i; ++j ) {
212 if ( ( i == N+1 ) || ( j == 0 ) ) {
213 coefficients[counter] = 1;
215 coefficients[counter] = coefficients[counter-1] + coefficients[counter-(i+1)];
232 for (
unsigned int i = 0; i < index; ++i ) {
233 coeff_index += N+1-i;
235 return const_iterator( &coefficients[coeff_index] );
247 for (
unsigned int i = 0; i <= index; ++i ) {
248 coeff_index += N+1-i;
251 return const_iterator( (&coefficients[coeff_index])+1);
270 template <
typename OutputStream,
int PowerN>
271 OutputStream& operator << ( OutputStream &ostream, const PascalsTriangle<PowerN> &triangle)
275 for (
int i = PowerN+1; i > 0; --i ) {
276 for (
int j = 0; j < i; ++j ) {
277 ostream << format(triangle.coefficients[counter]) <<
" ";
296 template <
typename OutputStream>
297 OutputStream& operator << ( OutputStream &ostream, const PascalsTriangle<3> &triangle)
301 for (
int i = 4; i > 0; --i ) {
302 for (
int j = 0; j < i; ++j ) {
303 ostream << format(triangle.coefficients[counter]) <<
" ";
322 template <
typename OutputStream>
323 OutputStream& operator << ( OutputStream &ostream, const PascalsTriangle<5> &triangle)
327 for (
int i = 6; i > 0; --i ) {
328 for (
int j = 0; j < i; ++j ) {
329 ostream << format(triangle.coefficients[counter]) <<
" ";
virtual ~PascalsTriangle()
Embedded control libraries.
virtual ~PascalsTriangle()
virtual ~PascalsTriangle()
Array< int, 21 > coefficients
Array< int,(N+2) *(N+1)/2 > coefficients
Array< int, 10 > coefficients
Array< int,(N+2) *(N+1)/2 >::const_iterator const_iterator
Utilise the array's iterator for parsing the triangle.
PascalsTriangle()
Default constructor.
const_iterator end(unsigned int index=0) const
Iterator generator for diagonals of pascals triangle [end].
Holds the coefficients for pascal's triangle up to row N.
const_iterator begin(unsigned int index=0) const
Iterator generator for diagonals of pascals triangle [begin].