Skip to content

Instantly share code, notes, and snippets.

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

Nico Schlömer nschloe

👨‍💻
doing math
  • Monday Tech
  • Berlin, Germany
  • X @nschloe
View GitHub Profile
@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
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)
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()
@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()
@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")
#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;
}
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}
@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.
@nschloe
nschloe / compare.py
Last active October 26, 2020 12:57
einsum is faster if the tail survives
import perfplot
import numpy
def setup(n):
a = numpy.random.rand(n, 3)
b = numpy.ascontiguousarray(a.T)
return a, b
import numpy
import perfplot
def setup(n):
pts = numpy.random.rand(3, n, 2)
e = numpy.array([
pts[2] - pts[1],
pts[0] - pts[2],
pts[1] - pts[0],