Skip to content

Instantly share code, notes, and snippets.

@tueda
tueda / UF_mathics.m
Last active September 20, 2017 12:11
UF function on Mathics #mma
(*
* UF[] by A. Smirnov.
* U and F are obtained by computing the matrix determinant.
*)
UF[xx_, yy_, z_] := Module[{degree, coeff, i, t2, t1, t0, zz},
zz = Map[Rationalize[##,0]&, z, {0, Infinity}];
degree = -Sum[yy[[i]]*x[i], {i, 1, Length[yy]}];
coeff = 1;
For[i = 1, i <= Length[xx], i++,
t2 = Coefficient[degree, xx[[i]], 2];
#-
#define oldt "0.0"
#procedure time(str)
#message `str'
#system bc <<< `time_'-`oldt'
#redefine oldt "`time_'"
#endprocedure
@tueda
tueda / simopt.frm
Last active November 4, 2016 14:45
simopt: simultaneous optimization of rational functions in FORM
#-
Off stats;
CF pow,log;
CF pow1,log1;
S x,n
S uuu;
Auto S ttt;
#procedure simopt(F,t1,t2,type,file)
./configure --with-api=windows --host=i686-w64-mingw32 --build=i686-pc-cygwin --enable-static-link
./configure --with-api=windows --host=x86_64-w64-mingw32 --build=x86_64-pc-cygwin --enable-static-link
cp 1.odt backup/1-`date '+%Y%m%d%H%M%S'`.odt
@tueda
tueda / gist:9eae90b9b56662a12099
Last active August 29, 2015 14:19
A shell script to check the disk usage.
du --max-depth=1 --block-size=1K --total | sort -n
@tueda
tueda / includable.tex
Created April 28, 2015 00:29
An example of LaTeX file, which can be typeset both as a standalone file and a source that can be included by another file via \input.
\makeatletter
\newif\ifStandalone
\ifx\documentclass\@twoclasseserror
\Standalonefalse
\else
\Standalonetrue
\fi
\makeatother
\ifStandalone
\documentclass{article}
LineOffset[{x1_, y1_}, {x2_, y2_}, d_] := Module[{r, dx, dy},
dx = x2 - x1;
dy = y2 - y1;
r = Sqrt[dx^2 + dy^2];
{{x1 + d / r dx, y1 + d / r dy},
{x2 - d / r dx, y2 - d / r dy}} // N
];
ArcOffset[{r_, a1_, a2_}, d_] := Module[{da},
da = 180 d / Pi / r;
@tueda
tueda / make_temp_dir.py
Created May 11, 2015 22:40
Making a temporary directory with a context manager.
import contextlib
import datetime
import tempfile
import shutil
@contextlib.contextmanager
def make_temp_dir(prefix=""):
"A context manager for a temporary directory."
if prefix:
prefix += "."