Skip to content

Instantly share code, notes, and snippets.

View miguelraz's full-sized avatar
:shipit:

Miguel Raz Guzmán Macedo miguelraz

:shipit:
  • UNAM
  • UNAM, Mexico
View GitHub Profile
@miguelraz
miguelraz / gist:7b1e5909a8b2bc44de0958b96baf8096
Created March 16, 2017 01:30
Possible malloc in subtype.c
==245== Memcheck, a memory error detector
==244== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==244== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==244== Command: ./subtype.c
==244== Parent PID: 243
==244==
--244--
--244-- Valgrind options:
--244-- --leak-check=full
--244-- --show-leak-kinds=all
@miguelraz
miguelraz / gist:536bd341c5d024f2e5148afcc9e00ccd
Last active April 5, 2017 04:09
Chris Rackauckas vs Pycall - Round 1
julia> Pkg.test("PyDSTool")
INFO: Computing test dependencies for PyDSTool...
INFO: No packages to install, update or remove
INFO: Testing PyDSTool
Warning: matplotlib failed to import properly and so is not
providing a graphing interface
2.026891 seconds (1.63 M allocations: 72.990 MB, 5.09% gc time)
LP Point found
LP Point found
PyCont curve EQ1 (type EP-C)
```julia
Pkg.add("DifferentialEquations")
```
INFO: Cloning cache of AlgebraicDiffEq from https://github.com/JuliaDiffEq/AlgebraicDiffEq.jl.git
INFO: Cloning cache of ChunkedArrays from https://github.com/ChrisRackauckas/ChunkedArrays.jl.git
INFO: Cloning cache of DelayDiffEq from https://github.com/JuliaDiffEq/DelayDiffEq.jl.git
INFO: Cloning cache of DiffEqBase from https://github.com/JuliaDiffEq/DiffEqBase.jl.git
User case walkthrough
A user comes into chat and asks:
"I know SSRK methods are already available, so I would like to reuse them.
I have been researching the diffEqs developer guide, however I am relatively new on Julia.
I have developed similar methods on Matlab, but I am interested on using Julia for my work, so it seem a good point to start.
I would appreciate any help.
Maybe someone can share some links of related code that I can review or give me general advice and tips.
Thanks in advance."
At the request of @jiahao, I am trying to compile use cases for physics, chemistry and mathematics.
Chemistry
1. \Delta_vap*E_{m,b} is the molar energy of vaporization. [1, p. 55]
2. \eta_{inh} is the inherent viscosity - SI Unit m^3 kg ^-1
3. Polymerization reactions require the need for the notation `P_x + P_y -> P_{x+y}` [1, p. 72]
4. Units for degree of crystallinity are `w_{c,h}`
5. Modulated smectic mesophases SmÃ, and SmC with a tilde, which can't be currently drawn. [1, p 112]
6. Anisotropy in general requires the squiggle tilde on top of the quantity being referred to, see [1,p. 114]
7. Stochiometric equations sometimes need to describe a molecule/atom as aqueous, with the "aq" subscript.
julia> println("Hola mundo!")
Hola mundo!
julia> Pkg.add("DifferentialEquations")
INFO: Initializing package repository /Users/isabel/.julia/v0.6
INFO: Cloning METADATA from https://github.com/JuliaLang/METADATA.jl
INFO: Cloning cache of AlgebraicDiffEq from https://github.com/JuliaDiffEq/AlgebraicDiffEq.jl.git
INFO: Cloning cache of BinDeps from https://github.com/JuliaLang/BinDeps.jl.git
INFO: Cloning cache of Calculus from https://github.com/johnmyleswhite/Calculus.jl.git
INFO: Cloning cache of ChunkedArrays from https://github.com/ChrisRackauckas/ChunkedArrays.jl.git
pkgs = [
"BenchmarkTools", "ProfileView", "CpuId",
"MacroTools", "RecursiveArrayTools", "ASTInterpreter2",
"Turing",
"DynamicalSystems",
"Convex", "JuMP", "Optim",
"ForwardDiff", "DiffRules", "DiffResults", "ReverseDiff",
"LightGraphs",
"Tensors",
"DifferentialEquations",
@oxinabox this is for my saturday session: gonna try to explain a compiler to non-technical people in 5 minutes...
"To understand why Julia is so special and different, we need to understand how it works from the bottom up.
Computer code goes through many stages of processing from when you write `x = 3` to when it actually assigns that value inside of it to a memory register.
The last part of this process is what we will conveniently call compiler - it is in essence a glorified warehouse manager - it takes orders about boxes of stuff (bits!) and moves them around in the computer (memory!). Let's assume the picture is this simple our purposes.
Now that we have a mental picture of what a compiler is, we can separate Julia from other languages and see why it is special.
# Credit to Kristoffer Carlsson
cd("/Users/kristoffer/julia/stdlib")
import TOML
using LightGraphs
import TikzGraphs
const STDLIB_DIR = "."
const STDLIBS = readdir(STDLIB_DIR)
deps = Dict{String, Int}()
for (i, stdlib) in enumerate(STDLIBS)
# Create a 4 bit DNA/RNA sequence from a 2 bit DNA/RNA sequence, and vice-versa.
function BioSequence{DNAAlphabet{N}}(seq::BioSequence{DNAAlphabet{M}}) where {N<:Int,M<:Int}
@assert N == 4 && M == 2
newseq = BioSequence{DNAAlphabet{4}}(length(seq))
for (i, x) in enumerate(seq)
unsafe_setindex!(newseq, x, i)
end
return newseq
end
function BioSequence{DNAAlphabet{M}}(seq::BioSequence{DNAAlphabet{N}}) where {N<:Int, M<:Int}