Skip to content

Instantly share code, notes, and snippets.

@dfarmer
dfarmer / laplace_torch.lua
Created February 7, 2013 00:01
Torch7 Tensor version Laplace solver
require 'torch'
function calc(N, Niter)
u = torch.zeros(N,N)
u[1] = 1
for i=1,Niter do
lua_update(u)
end
return u
end
@dfarmer
dfarmer / laplace_cdata.lua
Created February 7, 2013 00:03
LuaJIT laplace solver
require 'torch'
local ffi = require("ffi")
function print_mat(mat)
for r=1,#mat do
row = ''
for c=1,#mat[r] do
row = row .. mat[r][c] .. '\t'
end
print(row)
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@dfarmer
dfarmer / readcsv.wl
Created September 3, 2020 02:37
Wolfram ReadCSV
ReadCSV[fn_] := Module[{contents},
contents = Import[fn];
Dataset@
With[{hdr = First[contents]},
AssociationThread[hdr -> #] & /@ Rest@contents]
]
using CImGui
using CImGui.GLFWBackend
using CImGui.OpenGLBackend
using CImGui.GLFWBackend.GLFW
using CImGui.OpenGLBackend.ModernGL
using AbstractPlotting
using GLMakie
import GLMakie: make_context_current, render_frame, to_native, Screen
using CImGui
using CImGui.GLFWBackend
using CImGui.OpenGLBackend
using CImGui.GLFWBackend.GLFW
using CImGui.OpenGLBackend.ModernGL
using AbstractPlotting
using GLMakie
import GLMakie: make_context_current, render_frame, to_native, Screen
# add ImGui rendering pass to GLMakie's rendering loop