Skip to content

Instantly share code, notes, and snippets.

@mauro3
mauro3 / fd.jl
Created June 30, 2016 20:01
forwarddiff with in-place functions
using ForwardDiff
const T = Float64 # the datatype used, probably Float64
const dof = 4
fn!(;T_::Type=T, dof_=dof) = zeros(T_,dof_)
function fn!(res, y)#, dydt)
@show typeof(res), typeof(y)
for i=1:dof
@mauro3
mauro3 / inpoly.jl
Created October 11, 2016 19:28
inpoly using winding number
"""
Determines the winding number of a point and a polygon, i.e. how many
times a polygon winds around the point.
It follows Dan Sunday: http://geomalgorithms.com/a03-_inclusion.html.
"""
function windnr(p, poly::Matrix)
@assert length(p)==2
@assert poly[:,1]==poly[:,end]
# Loop over edges
@mauro3
mauro3 / Project.toml
Last active November 12, 2025 09:59
Appl-GL Ng & Björnsson 2003
[deps]
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
# löse aufgabe a/b=0.567567567567567567567567567567567567
# für a und b integer
#
# Plan: b * 0.567567567567567567567567567567567567 muss ein Integer sein, test für viele b's
c = 0.567567567567567567
for b in (1:10000000)
a = b * c
if isapprox(a, round(a), atol= 0.000000001)
@mauro3
mauro3 / Project.toml
Last active October 23, 2024 19:26
HA!
[deps]
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
[compat]
julia = "1.10"