Skip to content

Instantly share code, notes, and snippets.

@Deco
Created February 15, 2015 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deco/4082fd7e43f221e06570 to your computer and use it in GitHub Desktop.
Save Deco/4082fd7e43f221e06570 to your computer and use it in GitHub Desktop.
import memory
type MatD*[ElementT] = tuple
elementCount: uint32
dimensionCount: uint16
data: memory[byte]
template matD(dimensions: varargs[float64]; elementT: typedesc): expr =
let dimensionCount = len(dimensions)
let elementCount = foldl(dimensions, a*b)
echo "aaaahhh", a, ", ", b
let headerMemSize = sizeof(MatD[elementT])
let elementMemSize = sizeof(elementT)*elementCount
let dimensionSizeListMemSize = sizeof(byte)*dimensionCount
let dataMemSize = elementMemSize+dimensionSizeListMemSize
let totalMemSize = headerMemSize+dataMemSize
let mem = memalloc() # not yet finished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment