-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 625d7d3
Showing
23 changed files
with
2,585 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Simple workflow for deploying static content to GitHub Pages | ||
name: Deploy static content to Pages | ||
|
||
on: | ||
# Runs on pushes targeting the default branch | ||
push: | ||
branches: [main] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | ||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
# Build job | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: NPM install | ||
run: npm install | ||
- name: Prepare staging directory | ||
shell: bash | ||
run: | | ||
mkdir staging | ||
rsync -a media style.css index.html staging | ||
rsync -Ra node_modules/reveal.js/dist/{reset,reveal,theme/serif}.css staging | ||
rsync -Ra node_modules/reveal.js/plugin/highlight/monokai.css staging | ||
rsync -Ra node_modules/reveal.js/dist/reveal.js staging | ||
rsync -Ra node_modules/reveal.js/plugin/{zoom/zoom,notes/notes,search/search,markdown/markdown,highlight/highlight}.js staging | ||
- name: Upload pages artifact | ||
uses: actions/upload-pages-artifact@v2 | ||
with: | ||
path: staging | ||
|
||
# Deploy job | ||
deploy: | ||
# Add a dependency to the build job | ||
needs: build | ||
|
||
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | ||
permissions: | ||
pages: write # to deploy to Pages | ||
id-token: write # to verify the deployment originates from an appropriate source | ||
|
||
# Deploy to the github-pages environment | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
|
||
# Specify runner + deployment step | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
.*cache | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Mastering C++ for scientific computing: tools, tips, and tricks | ||
|
||
[**Link to slides**](https://tttapa.github.io/Mastering-Cpp-Scientific-Computing) | ||
|
||
Thanks to its impressive performance and its unrivaled abstraction power, C++ | ||
remains one of the most widely used languages in scientific computing: It lies | ||
at the core of machine learning frameworks like TensorFlow and PyTorch, is the | ||
foundation of vendor-specific tools for programming accelerators like SYCL, | ||
NVIDIA's CUDA or AMD's HIP, and is the go-to language for scientific and | ||
engineering projects spanning the full spectrum from tiny embedded control | ||
applications, all the way up to analyzing the petabytes of data generated by | ||
physics experiments at CERN. | ||
|
||
This seminar will cover tools and guidelines to help you to efficiently develop | ||
safer, more performant, and more maintainable C++ code. We will go over the | ||
following topics: development tools, runtime sanitizers and static analysis, | ||
C++ Core Guidelines, the pitfalls of undefined behavior, build systems and | ||
packaging, portability and compatibility, interfacing with Python, performance, | ||
linear algebra ... The main goal is to cover a broad range of topics, and | ||
provide pointers to further resources to dive into. | ||
|
||
While aimed primarily towards PhD researchers and students who use C++ in their | ||
research or master's thesis, the talk should provide valuable insights for | ||
anyone with an interest in C++. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
--- | ||
Language: Cpp | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveMacros: false | ||
AlignConsecutiveAssignments: true | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlines: Right | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllConstructorInitializersOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: Never | ||
AllowShortCaseLabelsOnASingleLine: true | ||
AllowShortFunctionsOnASingleLine: All | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: true | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: false | ||
AfterControlStatement: false | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
AfterExternBlock: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Attach | ||
BreakBeforeInheritanceComma: false | ||
BreakInheritanceList: BeforeColon | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakConstructorInitializers: BeforeColon | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakStringLiterals: true | ||
ColumnLimit: 80 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DeriveLineEnding: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: true | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '^<poly/.*' | ||
Priority: 10 | ||
- Regex: '^".*' | ||
Priority: 20 | ||
- Regex: '^".+/.*' | ||
Priority: 30 | ||
- Regex: '^<.+/.*' | ||
Priority: 40 | ||
- Regex: '^<.*\.h>' | ||
Priority: 50 | ||
- Regex: '^<.*' | ||
Priority: 60 | ||
IncludeIsMainRegex: '(Test)?$' | ||
IncludeIsMainSourceRegex: '' | ||
IndentCaseLabels: true | ||
IndentGotoLabels: true | ||
IndentPPDirectives: None | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: false | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Auto | ||
ObjCBlockIndentWidth: 2 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 60 | ||
PointerAlignment: Right | ||
QualifierAlignment: Custom | ||
QualifierOrder: [inline, static, constexpr, const, volatile, type] | ||
ReflowComments: false | ||
SortIncludes: true | ||
SortUsingDeclarations: true | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyBlock: false | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInConditionalStatement: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
SpaceBeforeSquareBrackets: false | ||
Standard: c++20 | ||
StatementMacros: | ||
- Q_UNUSED | ||
- QT_REQUIRE_VERSION | ||
TabWidth: 4 | ||
UseCRLF: false | ||
UseTab: Never | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
WarningsAsErrors: '' | ||
HeaderFilterRegex: '(include/poly)' | ||
FormatStyle: file | ||
|
||
Checks: | | ||
*, | ||
-abseil*,-altera*,-android*,-fuchsia*,-google*,-llvm*,-zircon*, | ||
-modernize-use-trailing-return-type, | ||
-*-magic-numbers, | ||
google-build-using-namespace, | ||
CheckOptions: | ||
- key: readability-implicit-bool-conversion.AllowPointerConditions | ||
value: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.21) | ||
project(poly VERSION 1.2.3 LANGUAGES CXX) | ||
# Import CMake testing support | ||
include(CTest) | ||
|
||
# Define user options | ||
option(POLY_INIT_NAN | ||
"Initialize all matrices and vectors to NaN for debugging purposes" Off) | ||
|
||
# Include the build script in the src directory | ||
add_subdirectory("src") | ||
# Include the build script in the test (if enabled) | ||
if (BUILD_TESTING) | ||
add_subdirectory("test") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[requires] | ||
eigen/3.4.0 | ||
[test_requires] | ||
gtest/1.12.1 | ||
[generators] | ||
CMakeDeps | ||
CMakeToolchain | ||
[layout] | ||
cmake_layout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Find dependencies we rely on | ||
find_package(Eigen3 REQUIRED) | ||
# Define the "poly" library and specify the source files it consists of | ||
add_library(poly | ||
"include/poly/poly.hpp" | ||
"include/poly/interpolate.hpp" | ||
"src/interpolate.cpp" | ||
) | ||
# The library requires the 2020 revision of the C++ standard | ||
target_compile_features(poly PUBLIC cxx_std_20) | ||
# Specify the path of the header files | ||
target_include_directories(poly PUBLIC "include") | ||
# Link the Eigen library into our poly library | ||
target_link_libraries(poly PUBLIC Eigen3::Eigen) | ||
# Add custom compiler options or macros | ||
if (POLY_INIT_NAN) | ||
target_compile_definitions(poly PUBLIC EIGEN_INITIALIZE_MATRICES_BY_NAN) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <poly/poly.hpp> | ||
|
||
namespace poly { | ||
|
||
/// Given the vectors @f$ x @f$ and @f$ y @f$, interpolate a Chebyshev | ||
/// polynomial @f$ p @f$ such that @f$ p(x_i) = y_i @f$. | ||
/// @param x Samples of the independent variable. | ||
/// @param y Samples of the dependent variable corresponding to @p x. | ||
/// @pre @p x and @p y should have the same length. | ||
/// @return The coefficients of polynomial @f$ p @f$ in Chebyshev basis. | ||
ChebyshevPolynomial interpolate_cheby(vector_ref_t x, vector_ref_t y); | ||
|
||
} // namespace poly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include <Eigen/Dense> | ||
#include <algorithm> | ||
#include <initializer_list> | ||
#include <utility> | ||
|
||
namespace poly { | ||
|
||
// Handy type aliases to make the rest of the code more readable. | ||
using matrix_t = Eigen::MatrixX<double>; | ||
using vector_t = Eigen::VectorX<double>; | ||
using vector_ref_t = Eigen::Ref<const vector_t>; | ||
using vector_mut_ref_t = Eigen::Ref<vector_t>; | ||
using index_t = Eigen::Index; | ||
|
||
/// Representation of a polynomial in Chebyshev basis. | ||
struct ChebyshevPolynomial { | ||
/// Type of the polynomial coefficients. | ||
using coeff_t = vector_t; | ||
|
||
/// Create an empty polynomial. | ||
ChebyshevPolynomial() = default; | ||
/// Create a polynomial with the given coefficients. | ||
explicit ChebyshevPolynomial(coeff_t init_coeff) | ||
: coefficients{std::move(init_coeff)} {} | ||
/// Create a polynomial with all zero coefficients of the given degree. | ||
explicit ChebyshevPolynomial(index_t degree) | ||
: coefficients{coeff_t::Zero(degree + 1)} {} | ||
/// Create a polynomial with the given coefficients. | ||
ChebyshevPolynomial(std::initializer_list<double> init_coeff) | ||
: coefficients{init_coeff.size()} { | ||
std::ranges::copy(init_coeff, std::begin(this->coefficients)); | ||
} | ||
/// Vector storing the polynomial coefficients in Chebyshev basis. | ||
coeff_t coefficients; | ||
}; | ||
|
||
} // namespace poly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <poly/interpolate.hpp> | ||
#include <Eigen/LU> | ||
#include <cassert> | ||
|
||
namespace poly { | ||
|
||
namespace { | ||
auto make_chebyshev_basis_matrix(vector_ref_t x, index_t degree) { | ||
assert(degree >= 0); | ||
const index_t N = x.size(); | ||
matrix_t V(N, degree + 1); | ||
V.col(0) = vector_t::Ones(N); | ||
if (degree >= 1) { | ||
V.col(1) = x; | ||
for (index_t i = 0; i < degree - 1; ++i) | ||
V.col(i + 2) = 2 * V.col(i + 1).cwiseProduct(x) - V.col(i); | ||
} | ||
return V; | ||
} | ||
} // namespace | ||
|
||
ChebyshevPolynomial interpolate_cheby(vector_ref_t x, vector_ref_t y) { | ||
assert(x.size() == y.size()); | ||
assert(x.size() > 0); | ||
// Construct Vandermonde/basis matrix | ||
auto V = make_chebyshev_basis_matrix(x, x.size() - 1); | ||
// Scale the system | ||
const vector_t scaling = V.colwise().norm().cwiseInverse(); | ||
V *= scaling.asDiagonal(); | ||
// Solve the system, undo scaling | ||
ChebyshevPolynomial solution{V.fullPivLu().solve(y)}; | ||
solution.coefficients.transpose() *= scaling.asDiagonal(); | ||
return solution; | ||
} | ||
|
||
} // namespace poly |
Oops, something went wrong.