The original C file is cblas_example1.c
$cinterop -def liblapack.def -o build/c_interop/liblapack
$kotlinc-native lapack.kt -library build/c_interop/liblapack
$./program.kexe
11.0
14.0
| Copyright (C) 2006, Jonathan E. Taylor | |
| All rights reserved. | |
| Copyright (c) 2006-2008 Scipy Developers. | |
| All rights reserved. | |
| Copyright (c) 2009-2018 statsmodels Developers. | |
| All rights reserved. | |
The original C file is cblas_example1.c
$cinterop -def liblapack.def -o build/c_interop/liblapack
$kotlinc-native lapack.kt -library build/c_interop/liblapack
$./program.kexe
11.0
14.0
| import json | |
| import timeit | |
| from collections import defaultdict | |
| n_executions = 10000 | |
| def run_numpy(n_samples, n_bins): | |
| setup = """ | |
| import numpy as xp |
| *.csv |
| import numpy as np | |
| from matplotlib.animation import FuncAnimation | |
| from matplotlib import pyplot as plt | |
| from mcl import Environment, MCL, Agent | |
| def particle_weight(particle_observation, agent_observation): | |
| return 1 if particle_observation == agent_observation else 0 |
| import numpy as np | |
| from matplotlib.animation import FuncAnimation | |
| from matplotlib import pyplot as plt | |
| from mcl import Environment, MCL, Agent | |
| def particle_weight(particle_observation, agent_observation): | |
| return 1 if particle_observation == agent_observation else 0 |
| using PyPlot | |
| using PyCall | |
| PyDict(pyimport("matplotlib")["rcParams"])["font.size"] = 18 | |
| include("ode_solvers.jl") | |
| f(x, y) = -3sin(10*x) / exp(x+y^2) |
| from xml.etree import ElementTree as ET | |
| from bs4 import BeautifulSoup | |
| from gensim.models.doc2vec import Doc2Vec, TaggedDocument, DocvecsArray | |
| # root = tree.getroot() | |
| # for neighbor in root.iter("neighbor"): | |
| # print(neighbor) | |
| MIN_LINE_LENGTH = 80 | |
| def generate_documents(): |
| using Base.Test | |
| using Iterators: filter | |
| using Distributions | |
| function h_xs_ys(f, a, b, n_parts) | |
| h = (b - a) / n_parts | |
| xs = linspace(a, b, n_parts + 1) | |
| ys = [f(x) for x in xs] | |
| h, xs, ys |
| using Base.Test | |
| function integrate(f, a, b, n_samples=100) | |
| assert(b > a) | |
| h = (b - a) / n_samples | |
| xs = linspace(a, b, n_samples) | |
| ys = [f(x) for x in xs] | |
| h * ((ys[1] + ys[end]) / 2 + sum(ys[2:end-1])) | |
| end |