From 6cab30f64cd46e86230fc9b421a6f9cffc20c18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Holzm=C3=BCller?= Date: Thu, 11 Apr 2019 17:22:35 +0200 Subject: [PATCH] moved todos, added function to iterator --- src/Iterators.hpp | 8 ++++++++ test/common.hpp | 32 ++++++++++++++------------------ test/main.cpp | 18 ++++++++++++++---- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/Iterators.hpp b/src/Iterators.hpp index 937a186..2a840ae 100644 --- a/src/Iterators.hpp +++ b/src/Iterators.hpp @@ -196,6 +196,14 @@ class BoundedSumIterator { size_t numValues() const { return binom(bound + d, d); } + std::vector numValuesPerFirstIndex() const { + std::vector 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 * bound, nothing changes. diff --git a/test/common.hpp b/test/common.hpp index 57f44cc..a59781b 100644 --- a/test/common.hpp +++ b/test/common.hpp @@ -1,7 +1,17 @@ -// Copyright (C) 2008-today The SG++ project -// This file is part of the SG++ project. For conditions of distribution and -// use, please see the copyright notice provided with SG++ or at -// sgpp.sparsegrids.org +/* Copyright 2019 The fast_sparse_interpolation Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +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 @@ -68,20 +78,6 @@ inline std::ostream &operator<<(std::ostream &os, fsi::MultiDimVector const &v) 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 f) { auto start = std::chrono::high_resolution_clock::now(); f(); diff --git a/test/main.cpp b/test/main.cpp index e8679b2..512ab68 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -15,9 +15,19 @@ limitations under the License. #include "common.hpp" +// TODO: refactoring: +/** + * - Interface for MultiDimVector + * - Typed interface? + * - Tests? + * - More point distributions / Basis functions? + * - Forward evaluation? + * - Computation of derivatives? + */ + void runFunctions() { - constexpr size_t d = 8; - size_t bound = 24; + constexpr size_t d = 3; + size_t bound = 100; fsi::TemplateBoundedSumIterator it(bound); // fsi::BoundedSumIterator it(d, bound); std::vector phi(d); @@ -53,6 +63,6 @@ void runFunctions() { // using namespace fsi; int main() { - // runFunctions(); - measurePerformance(); + runFunctions(); + // measurePerformance(); }