Skip to content

Instantly share code, notes, and snippets.

View cswiercz's full-sized avatar

Chris Swierczewski cswiercz

View GitHub Profile
@cswiercz
cswiercz / abelfunctions-45-wcache
Created July 29, 2014 18:05
abelfunctions Issue #45 - Puiseux and Intbasis Performance with Caching
[cswiercz@jude abelfunctions] python abelfunctions/integralbasis.py
Tue Jul 29 10:37:15 2014 intbasis.profile
4005669 function calls (3810399 primitive calls) in 11.217 seconds
Ordered by: internal time
List reduced from 1296 to 10 due to restriction <10>
ncalls tottime percall cumtime percall filename:lineno(function)
133971/68128 1.254 0.000 6.858 0.000 cache.py:78(wrapper)
@cswiercz
cswiercz / abelfunctions-45-wocache
Created July 29, 2014 18:05
abelfunctions Issue #45 - Puiseux and Intbasis Performance without Caching
[cswiercz@jude abelfunctions] python abelfunctions/integralbasis.py
Tue Jul 29 10:51:06 2014 intbasis.profile
4736356 function calls (4502151 primitive calls) in 13.222 seconds
Ordered by: internal time
List reduced from 1293 to 10 due to restriction <10>
ncalls tottime percall cumtime percall filename:lineno(function)
158684/76814 1.378 0.000 8.360 0.000 cache.py:78(wrapper)
@cswiercz
cswiercz / gist:610b4081e862260f6c3b
Created October 17, 2014 00:57
Memoryviews and RiemannSurfacePaths
/Users/cswiercz/abelfunctions/abelfunctions/riemann_surface_path.so in abelfunctions.riemann_surface_path.RiemannSurfacePathLine.__init__ (abelfunctions/riemann_surface_path.c:6854)()
/Users/cswiercz/abelfunctions/abelfunctions/riemann_surface_path.so in abelfunctions.riemann_surface_path.RiemannSurfacePathPrimitive.__init__ (abelfunctions/riemann_surface_path.c:2891)()
/Users/cswiercz/abelfunctions/abelfunctions/riemann_surface_path.so in abelfunctions.riemann_surface_path.RiemannSurfacePathPrimitive.set_analytic_continuator (abelfunctions/riemann_surface_path.c:3061)()
/Users/cswiercz/abelfunctions/abelfunctions/analytic_continuation.so in abelfunctions.analytic_continuation.AnalyticContinuatorPuiseux.__init__ (abelfunctions/analytic_continuation.c:2616)()
/Users/cswiercz/abelfunctions/abelfunctions/analytic_continuation.so in abelfunctions.analytic_continuation.AnalyticContinuatorPuiseux._compute_puiseux_series (abelfunctions/analytic_continuation.c:3092)()
@cswiercz
cswiercz / abel-discriminant-path-code
Last active August 29, 2015 14:07
abelfunctions Issue #51 - Simple Discriminant Path Construction Performance (Code)
import numpy
import sympy
import abelfunctions as ab
from sympy.abc import x,y
# construct a Riemann surface
f = -x**7 + 2*x**3*y + y**3
X = ab.RiemannSurface(f,x,y)
@cswiercz
cswiercz / gist:791e51afb246d8010070
Created October 18, 2014 00:25
A bunch of curves.
%matplotlib inline
import numpy
import sympy
from sympy.abc import x,y,t
from sympy import pprint
import matplotlib
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
@cswiercz
cswiercz / pools.py
Created October 29, 2014 22:53
Simple Parallelization in Python with Pools
# Given a function, func(var), the map() function will apply func() to every
# element of a list and return a list of equal size.
def func(var):
return var**2
numbers = [1,2,3,4]
squares = map(func, numbers) # [1,4,9,16]
# The multiprocessing module contains various objects for performing parallel
@cswiercz
cswiercz / variational
Created November 14, 2014 21:35
Variational Derivatives in Save
def variational_derivative(expr,u):
"""Returns the variational derivative of `expr` with respect to `u`.
Variational differentiation is a linear operator so we just need to
figure out how to differentiate a product of terms.
Parameters
----------
expr : expression
u : function
@cswiercz
cswiercz / simple.py
Last active May 14, 2023 01:07
A quick demonstration of how to plot multivalued complex functions in Python.
import numpy
import sympy
from mpl_toolkits.mplot3d import Axes3D
import matplotlib
from matplotlib import cm, colors
from matplotlib import pyplot as plt
branching_number = 2
@cswiercz
cswiercz / simple.py
Last active August 29, 2015 14:24
Computing "Small" Gaussian Primes
from sympy import isprime
from itertools import ifilter, count
def find_b(a):
"""Returns smallest b such that a^2 + b^2 is prime."""
f = lambda b: isprime(a**2 + b**2)
g = ifilter(f, count())
b = g.next()
return b
@cswiercz
cswiercz / c++ output
Created July 17, 2015 20:14
Differences in Vector Allocation / Deallocation between C++ Versions
[cswiercz@clavius vectors] clang++ ./construction.cpp && ./a.out
=========================
===== Experiment #1 =====
=========================
Resizing and new element construction
-- v.resize(3)
-- resizing members
[#0] constructed