This file contains 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
{ | |
"LanguageServerManager": { | |
"language_servers": { | |
"julia-lsp": { | |
"version": 2, | |
"argv": ["/home/lbo/bin/julia", "-e", "using LanguageServer; runserver()"], | |
"languages": ["julia"], | |
"mime_types": ["text/julia", "text/x-julia"], | |
"display_name": "JuliaLSP" | |
} |
This file contains 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 testsquare1()::Matrix{Int} | |
[1 0 4 0; | |
0 2 0 3; | |
0 0 3 0; | |
0 0 0 4] | |
end | |
function testsquare2()::Matrix{Int} | |
[1 0 0 0; | |
0 2 0 0; | |
0 0 3 0; |
This file contains 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 longest_common_subsequence(x::Vector{T}, y::Vector{T})::Vector{T} where {T} | |
m, n = length(x), length(y) | |
C = zeros(Int, m+1, n+1) | |
# Not necessary: | |
for i = 1:m | |
C[i,1] = 0 | |
end | |
for j = 1:n | |
C[1,j] = 0 | |
end |
This file contains 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 longest_increasing_subsequence(v::Vector{Int})::Vector{Int} | |
M = zeros(Int, length(v)) # M[L] stores last index of sequence with length L. | |
P = zeros(Int, length(v)) # P[i] stores predecessor of element i in longest sequence. | |
Longest = 0 | |
for i = eachindex(v) | |
# Binary search for position in longest-sequence-so-far | |
lo, hi = 1, Longest+1 | |
while lo < hi | |
mid = round(Int, floor((lo+hi)/2)) | |
if v[i] < v[M[mid]] |
This file contains 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
# > X = generate_sorted_matrix(10, 10) | |
# 10×10 Matrix{Int64}: | |
# 2 139 194 248 337 428 544 625 736 873 | |
# 11 141 195 251 340 454 564 644 743 892 | |
# 39 153 200 272 350 454 582 649 786 900 | |
# 58 163 203 284 357 462 586 652 799 912 | |
# 66 164 219 295 359 473 599 654 806 930 | |
# 73 170 220 302 361 482 604 677 813 947 | |
# 74 177 243 303 364 488 609 681 815 957 | |
# 78 187 245 323 409 504 611 696 845 961 |
This file contains 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
#include <iostream> | |
#include <fstream> | |
#include <unordered_set> | |
#include <string> | |
#include <vector> | |
#include <memory> | |
#include <cctype> | |
using namespace std; |
This file contains 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
import numpy as np | |
def knapsack(items=[4,3,1,2], profits=[60, 50, 20, 20], capacity=7): | |
table = np.zeros((len(items)+1, capacity+1)) | |
table[:, 0] = 0 | |
table[0, :] = 0 | |
for item in range(1, len(items)+1): | |
for cap in range(1, capacity+1): | |
y = 0 if items[item-1] > cap else profits[item-1]+table[item-1, cap-items[item-1]] |
This file contains 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 MKL | |
using DataFrames | |
using Flux | |
import ChainRulesCore: ignore_derivatives | |
import Distributions: Bernoulli | |
import CSV | |
import Random: Sampler | |
import BSON | |
import Flux.MLUtils: DataLoader |
This file contains 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 Distributions | |
function mysampler(previous::Union{NamedTuple, Nothing})::NamedTuple | |
µ = rand(Normal(3, 2)) | |
σ = rand(TruncatedNormal(1, 3, 0, Inf)) | |
(µ=µ, σ=σ) | |
end | |
function myloglikelihood(θ::NamedTuple)::Float64 |
This file contains 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 Plots | |
using Random | |
using Distributions, DistributionsAD | |
using LinearAlgebra | |
import Zygote: gradient | |
struct HMC{T,F} | |
sup::AbstractArray{Tuple{T,T}} | |
invM::Matrix{T} | |
pdist::AbstractMvNormal |
NewerOlder