Skip to content

Instantly share code, notes, and snippets.

View nschloe's full-sized avatar
👨‍💻
doing math

Nico Schlömer nschloe

👨‍💻
doing math
View GitHub Profile
@nschloe
nschloe / real-fft.py
Last active August 14, 2019 18:53
FFT with actual frequencies
# This gist shows how to use numpy's FFT functions to use the discrete FFT
# of a uniformly-spaced data set to get what corresponds to the actual Fourier
# transform as you'd write it down mathematically.
# In particular, the functio uniform_dft returns the corresponding frequencies
# in terms of the coordinate units.
def uniform_dft(interval_length, data):
"""Discrete Fourier Transform of real-valued data, interpreted for a uniform series
over an interval of a given length, including starting and end point.
The function returns the frequencies in units of the coordinate.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
FIND_PACKAGE(Trilinos REQUIRED COMPONENTS Kokkos)
INCLUDE_DIRECTORIES(
SYSTEM
${Trilinos_INCLUDE_DIRS}
#ifndef MYFOO_HPP
#define MYFOO_HPP
#include <vector>
double sum(const std::vector<double> & a) {
double sum = 0.0;
for (const auto & elem: a) {
sum += elem;
}
@nschloe
nschloe / CMakeLists.txt
Created September 1, 2016 21:50
SWIG with Eigen3
cmake_minimum_required(VERSION 3.0)
project(mytest)
FIND_PACKAGE(SWIG REQUIRED)
FIND_PACKAGE(Eigen3 REQUIRED)
INCLUDE(${SWIG_USE_FILE})
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
@nschloe
nschloe / CMakeLists.txt
Created September 1, 2016 13:02
SWIG Python: Derive from C++ base class in Python
cmake_minimum_required(VERSION 3.0)
project(mytest)
FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
cmake_minimum_required(VERSION 3.0)
project(mytest)
FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
cmake_minimum_required(VERSION 3.0)
project(mytest)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
FIND_PACKAGE(CGAL REQUIRED)
find_package(Boost COMPONENTS thread REQUIRED)
add_executable(mytest main.cpp)
@nschloe
nschloe / CMakeLists.txt
Created August 21, 2016 14:07
CGAL Function_vector example
cmake_minimum_required(VERSION 3.0)
project(mytest)
FIND_PACKAGE(CGAL REQUIRED)
find_package(Boost COMPONENTS thread REQUIRED)
ADD_EXECUTABLE(main test.cpp)
TARGET_LINK_LIBRARIES(
main