This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function iain_magic(n::Int) | |
if n % 2 == 1 | |
# Odd-order magic square | |
# http://en.wikipedia.org/wiki/Magic_square#Method_for_constructing_a_magic_square_of_odd_order | |
M = zeros(Int, n, n) | |
for I = 1:n, J = 1:n # row, column | |
@inbounds M[I,J] = n*((I+J-1+div(n,2))%n) + ((I+2J-2)%n) + 1 | |
end | |
return M | |
elseif n % 4 == 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function genspmat2(N) | |
iseven(N) && error("even N not allowed") | |
# Determine memory usage | |
k = N^2 | |
for i in 1:N^2 | |
if i > N | |
k += 2 | |
elseif i > 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Julia | |
getObjectiveValue(m) => 118.11250034248698 | |
norm((getValue(x))[:]) => 100.0 | |
callbacks => 1041 | |
minimum(times) => 2.275295964 | |
median(times) => 2.3760397215 | |
mean(times) => 2.3844805166 | |
dummy => 3.0e8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PYTHON | |
2651 | |
-75.3212163 | |
49.8698305592 | |
min 7.85425305367 | |
mean 7.98054280281 | |
75656742.8543 | |
cb_work_time/ITERS 1.93139100075e-06 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sma_original(avect, numPer) | |
numEle = length(avect) | |
tout = Array(Float32, numEle) | |
for ndx = 1:numEle | |
tsum = 0.0 | |
begndx = max(1, ndx - numPer) | |
for slicendx = begndx:ndx | |
tsum += avect[slicendx] | |
end | |
tout[ndx] = tsum / float32(numPer) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################# | |
# JuMP | |
# An algebraic modelling langauge for Julia | |
# See http://github.com/JuliaOpt/JuMP.jl | |
############################################################################# | |
# goddard.jl | |
# | |
# Goddard Rocket control problem from: | |
# Benchmarking Optimization Software with COPS 3.0 | |
# http://www.mcs.anl.gov/~more/cops/cops3.pdf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param max_u_rho := 1; | |
param max_u_the := 1; | |
param max_u_phi := 1; | |
param L := 5; | |
let tf := 1.0; | |
let {k in 0..nh} rho[k] := 4.5; | |
let {k in 0..nh} the[k] := (2*pi/3)*(k/nh)^2; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AffineTransforms.tformscale | |
AffineTransforms.tformtranslate | |
AffineTransforms.tformfwd3rd | |
AffineTransforms.tformrigid | |
AffineTransforms.rotationmatrix | |
AffineTransforms.tformrotate | |
AffineTransforms.tforminv! | |
AffineTransforms.rotation3 | |
AffineTransforms.rotationparameters | |
AffineTransforms.AffineTransforms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using JuMP | |
_model = Model() | |
import Base: LineEdit, REPL | |
function handle_line(line) | |
if line[1:3] == "Var" | |
Base.parse_input_line("@defVar(_model,$(line[5:end]))") | |
elseif line[1:3] == "Max" || line[1:3] == "Min" |