pascals_triangle.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include "../../include/ecl/geometry/pascals_triangle.hpp"
14 
15 /*****************************************************************************
16 ** Namespaces
17 *****************************************************************************/
18 
19 namespace ecl {
20 
21 /*****************************************************************************
22 ** Implementation [PascalsTriangle<3>]
23 *****************************************************************************/
25  coefficients << 1,1,1,1,
26  1,2,3,
27  1,3,
28  1;
29 }
30 
32  int coeff_index = 0;
33  for (unsigned int i = 0; i < row_index; ++i ) {
34  coeff_index += 3+1-i;
35  }
36  return const_iterator( &coefficients[coeff_index] );
37 }
39  int coeff_index = 0;
40  for (unsigned int i = 0; i <= row_index; ++i ) {
41  coeff_index += 3+1-i;
42  }
43  coeff_index -= 1; // dont want to call beyond the array limit.
44  return const_iterator( (&coefficients[coeff_index])+1 );
45 }
46 
47 
48 /*****************************************************************************
49 ** Implementation [PascalsTriangle<5>]
50 *****************************************************************************/
52  coefficients << 1,1,1,1,1,1,
53  1,2,3,4,5,
54  1,3,6,10,
55  1,4,10,
56  1,5,
57  1;
58 }
59 
61  int coeff_index = 0;
62  for (unsigned int i = 0; i < row_index; ++i ) {
63  coeff_index += 5+1-i;
64  }
65  return const_iterator( &coefficients[coeff_index] );
66 }
68  int coeff_index = 0;
69  for (unsigned int i = 0; i <= row_index; ++i ) {
70  coeff_index += 5+1-i;
71  }
72  coeff_index -= 1; // dont want to call beyond the array limit.
73  return const_iterator( (&coefficients[coeff_index])+1 );
74 }
75 
76 
77 } // namespace ecl
Embedded control libraries.
const_iterator end(unsigned int index=0) const
Iterator generator for diagonals of pascals triangle [end].
const_iterator begin(unsigned int index=0) const
Iterator generator for diagonals of pascals triangle [begin].
Array< int,(N+2)*(N+1)/2 > coefficients
Array< int,(N+2)*(N+1)/2 >::const_iterator const_iterator
Utilise the array&#39;s iterator for parsing the triangle.
PascalsTriangle()
Default constructor.


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:37