int main() {
	std::vector<int> summations(4);
	
	summations[0] = 4;
	summations[1] = 5;
	summations[2] = 3;
	summations[3] = 4;
	
	for (Index index(summations); !index.end(); ++index) {
		//std::cout << index << std::endl;
	}
	
	std::vector<int> fixedIndices(2);
	fixedIndices[0] = 0;
	fixedIndices[1] = 2;
	
	std::vector<int> fixedValues(2);
	fixedValues[0] = 0;
	fixedValues[1] = 0;
	

	for (Index index(summations, fixedIndices, fixedValues); !index.end(); ++index) {
		//std::cout << index << std::endl;
	}
	
	std::vector<int> singleSummation(1);
	
	singleSummation[0] = 34;
	
	Index index(singleSummation);
	
	for (index.begin(); !index.end(); ++index) {
		//std::cout << index << std::endl;
	}

	std::cout << std::endl << " FixedEmpty " << std::endl << "===========" << std::endl;
	std::vector<int> all(4);
	all[0] = 0;
	all[1] = 1;
	all[2] = 2;
	all[3] = 3;
	std::vector<int> fixedAll(4);
	fixedAll[0] = 1;
	fixedAll[1] = 1;
	fixedAll[2] = 2;
	fixedAll[3] = 0;

	for (Index index(summations, all, fixedAll); !index.end(); ++index) {
		std::cout << index << std::endl;// this should only be written once
	}
	
	return 0;	
}
示例#2
0
文件: farey.cpp 项目: dagophil/dmath
    std::vector<size_t> number_of_summations(
            std::vector<size_t> const & candidates,
            size_t const n
    ){
        std::set<size_t> ordered_candidates(candidates.begin(), candidates.end());
        ordered_candidates.erase(0);

        std::vector<size_t> summations(n+1, 0);
        summations[0] = 1;
        for (auto const c : ordered_candidates)
        {
            if (c > n)
                break;
            for (size_t i = c; i <= n; ++i)
                summations[i] += summations[i-c];
        }
        return summations;
    }