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
// shows program modified to avoid array views in inner loops | |
class AbstractKernel { | |
// assumes x[xfirst, ..] and y[yfirst, ..] have shape 1..p | |
proc kernel(x, xfirst: int, y: [?D] ?T, yfirst: int, p: int): T | |
{ | |
return x[xfirst, 0]; // out of bounds (intentionally?) | |
} | |
} |
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
// | |
// May destructing variables for itarable types and tuples | |
// | |
module vlm.utils.destructing; | |
import std.range : empty, popFront, front; | |
import std.traits : isIterable; | |
import std.typecons : Tuple, tuple, isTuple; | |
import std.functional : forward; |
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
const idx_types = [(UInt8, 0x08), (Int8, 0x09), (Int16, 0x0B), (Int32, 0x0C), (Float32, 0x0D), (Float64, 0x0E)] | |
const typefromcode = Dict(idx_types) | |
const codefromtype = Dict(map(reverse, idx_types)) | |
function write_idx(stream::Union{IOStream,String}, data::Array{T,N}) where {T,N} | |
dims = convert(Array{Int32}, collect(size(data))) | |
write(stream, 0x00, 0x00, typefromcode[T], UInt8(N), hton.(dims), hton.(data)) | |
end | |
read_idx(filename::String) = open(read_idx, filename) |