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
abstract type Person end | |
abstract type Tourist <:Person end | |
abstract type Deer end | |
encounter(a::Deer, b::Tourist) = "bows politely" | |
encounter(a::Tourist, b::Deer) = "feeds" | |
encounter(a::Person, b::Deer) = "beckons" | |
encounter(a::Deer, b::Person) = "ignores" | |
encounter(a::Tourist, b::Deer, foo::String) = "feeds deer $foo" |
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
import LinearAlgebra.det |
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
encounter(a::Person, b::Person) = "hello" | |
encounter(a::Person, b:: Tourist) = "takes picture" | |
encounter(a::Person, b::Person, c::Person) = "converses" | |
dine(a::Tourist) = "picks up fork" |
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
parfor i = 1:100 | |
A(i) = eig(rand(500)) | |
end |
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
x = [1, 1]; | |
for k = 3:1000000 | |
x(k) = x(k-1) + x(k-2); | |
end | |
x = zeros(1000000, 1); x(1:2) = [1, 1] | |
for k = 3:1000000 | |
x(k) = x(k-1) + x(k-2); | |
end |
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
a = rand(500, 500) | |
b = rand(500, 500) | |
c = rand(500, 1) | |
a*b*c % O(N^3) time complexity | |
a*(b*c) % O(N^2) time complexity |
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
ddddd |
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
t = 0:.05:20; | |
y = exp(t); | |
i = 0; | |
for t = 0:.05:20 | |
i = i + 1; | |
y(i) = exp(t); | |
end |
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
x = diag(ones(10000, 1)) % matrix with ones on diagonal and zero elsewhere | |
z = sparse(x) % compressed adjacency list representation |
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 DataFrames | |
using CSV | |
using Random | |
using LinearAlgebra | |
redwine = DataFrames.DataFrame(CSV.File("winequality-red.csv")) | |
mat = Matrix(redwine)[:, 1:11] | |
A = mat[:, 1:end-1] #features | |
y = mat[:, end]; #labels |
OlderNewer