moved todos, added function to iterator

This commit is contained in:
David Holzmüller 2019-04-11 17:22:35 +02:00
parent 5881276bd4
commit 6cab30f64c
3 changed files with 36 additions and 22 deletions

View File

@ -196,6 +196,14 @@ class BoundedSumIterator {
size_t numValues() const { return binom(bound + d, d); } size_t numValues() const { return binom(bound + d, d); }
std::vector<size_t> numValuesPerFirstIndex() const {
std::vector<size_t> result;
for (size_t firstIndex = 0; firstIndex <= bound; ++firstIndex) {
result.push_back(binom((bound - firstIndex) + (d - 1), d - 1));
}
return result;
}
/** /**
* Returns an iterator where the last index moves to the front. For an index set defined by a sum * Returns an iterator where the last index moves to the front. For an index set defined by a sum
* bound, nothing changes. * bound, nothing changes.

View File

@ -1,7 +1,17 @@
// Copyright (C) 2008-today The SG++ project /* Copyright 2019 The fast_sparse_interpolation Authors. All Rights Reserved.
// This file is part of the SG++ project. For conditions of distribution and
// use, please see the copyright notice provided with SG++ or at Licensed under the Apache License, Version 2.0 (the "License");
// sgpp.sparsegrids.org you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#pragma once #pragma once
@ -68,20 +78,6 @@ inline std::ostream &operator<<(std::ostream &os, fsi::MultiDimVector const &v)
return os; return os;
} }
// TODO: refactoring:
/**
* - Interface for MultiDimVector
* - Separate Functions for L- and U-Multiplication, Creation of LU decomposition, computation of
* function values
* - Pass a callback function to iterator instead of calling it.next() - this might improve the
* vector functions (could be made recursive or even loops for fixed dimension implementation)
* - Typed interface?
* - Tests?
* - More point distributions / Basis functions?
* - Forward evaluation?
* - Computation of derivatives?
*/
inline double measure_execution_time(std::function<void()> f) { inline double measure_execution_time(std::function<void()> f) {
auto start = std::chrono::high_resolution_clock::now(); auto start = std::chrono::high_resolution_clock::now();
f(); f();

View File

@ -15,9 +15,19 @@ limitations under the License.
#include "common.hpp" #include "common.hpp"
// TODO: refactoring:
/**
* - Interface for MultiDimVector
* - Typed interface?
* - Tests?
* - More point distributions / Basis functions?
* - Forward evaluation?
* - Computation of derivatives?
*/
void runFunctions() { void runFunctions() {
constexpr size_t d = 8; constexpr size_t d = 3;
size_t bound = 24; size_t bound = 100;
fsi::TemplateBoundedSumIterator<d> it(bound); fsi::TemplateBoundedSumIterator<d> it(bound);
// fsi::BoundedSumIterator it(d, bound); // fsi::BoundedSumIterator it(d, bound);
std::vector<MonomialFunctions> phi(d); std::vector<MonomialFunctions> phi(d);
@ -53,6 +63,6 @@ void runFunctions() {
// using namespace fsi; // using namespace fsi;
int main() { int main() {
// runFunctions(); runFunctions();
measurePerformance(); // measurePerformance();
} }