Go to the documentation of this file.00001
00009
00010
00011
00012
00013 #include "../../include/ecl/geometry/pascals_triangle.hpp"
00014
00015
00016
00017
00018
00019 namespace ecl {
00020
00021
00022
00023
00024 PascalsTriangle<3>::PascalsTriangle() {
00025 coefficients << 1,1,1,1,
00026 1,2,3,
00027 1,3,
00028 1;
00029 }
00030
00031 PascalsTriangle<3>::const_iterator PascalsTriangle<3>::begin(unsigned int row_index) const {
00032 int coeff_index = 0;
00033 for (unsigned int i = 0; i < row_index; ++i ) {
00034 coeff_index += 3+1-i;
00035 }
00036 return const_iterator( &coefficients[coeff_index] );
00037 }
00038 PascalsTriangle<3>::const_iterator PascalsTriangle<3>::end(unsigned int row_index) const {
00039 int coeff_index = 0;
00040 for (unsigned int i = 0; i <= row_index; ++i ) {
00041 coeff_index += 3+1-i;
00042 }
00043 coeff_index -= 1;
00044 return const_iterator( (&coefficients[coeff_index])+1 );
00045 }
00046
00047
00048
00049
00050
00051 PascalsTriangle<5>::PascalsTriangle() {
00052 coefficients << 1,1,1,1,1,1,
00053 1,2,3,4,5,
00054 1,3,6,10,
00055 1,4,10,
00056 1,5,
00057 1;
00058 }
00059
00060 PascalsTriangle<5>::const_iterator PascalsTriangle<5>::begin(unsigned int row_index) const {
00061 int coeff_index = 0;
00062 for (unsigned int i = 0; i < row_index; ++i ) {
00063 coeff_index += 5+1-i;
00064 }
00065 return const_iterator( &coefficients[coeff_index] );
00066 }
00067 PascalsTriangle<5>::const_iterator PascalsTriangle<5>::end(unsigned int row_index) const {
00068 int coeff_index = 0;
00069 for (unsigned int i = 0; i <= row_index; ++i ) {
00070 coeff_index += 5+1-i;
00071 }
00072 coeff_index -= 1;
00073 return const_iterator( (&coefficients[coeff_index])+1 );
00074 }
00075
00076
00077 }