CPUtils (Fixpoint v0.8.32)
Summary
Functions
latin_square(x)
mat_at(m,i,j)
print_matrix(x,rows,cols, format \ "~2w")
timeit(fun)
timeit_simple(fun)
transpose(m)
Functions
latin_square(x)
latin_square(x)
Ensures that an n x n matrix x
is a Latin Square.
##Examples##
> latin_square(x)
mat_at(m, i, j)
mat_at(m,i,j)
Returns the value (i
,j
) of the 2d matrix mat
.
##Examples##
iex> [[1,2,3],[4,5,6],[7,8,9]] |> mat_at(1,2)
6
print_matrix(x, rows, cols, format \\ "~2w")
print_matrix(x,rows,cols, format \ "~2w")
Pretty print x
as a matrix.
Note: x
is assumed to be a list of rows*cols elements.
format
is the spacing of the values, defaults to "~2w".
timeit(fun)
timeit(fun)
From https://stackoverflow.com/questions/29668635/how-can-we-easily-time-function-calls-in-elixir
A more elaborate timing function. Prints
- Name of the function
- Result
- Time in seconds
##Examples##
> timeit(&test1/0)
timeit_simple(fun)
timeit_simple(fun)
A simple timing function, returns the time in seconds (as a string).
##Examples##
> Util.timeit_simple(&Test1.main/0)
> Util.timeit_simple(fn () -> Test1.main() end)
transpose(m)
transpose(m)
Returns a transposed version of m
.
##Example##
iex> [[1,2,3],[4,5,6],[7,8,9]] |> transpose
[[1, 4, 7], [2, 5, 8], [3, 6, 9]]