34 lines
569 B
Plaintext
34 lines
569 B
Plaintext
(* ****** ****** *)
|
|
//
|
|
// How to compile:
|
|
//
|
|
// patscc -DATS_MEMALLOC_LIBC -o idmatrix idmatrix.dats
|
|
//
|
|
(* ****** ****** *)
|
|
//
|
|
#include
|
|
"share/atspre_staload.hats"
|
|
//
|
|
(* ****** ****** *)
|
|
|
|
extern
|
|
fun
|
|
idmatrix{n:nat}(n: size_t(n)): matrixref(int, n, n)
|
|
implement
|
|
idmatrix(n) =
|
|
matrixref_tabulate_cloref<int> (n, n, lam(i, j) => bool2int0(i = j))
|
|
|
|
(* ****** ****** *)
|
|
|
|
implement
|
|
main0 () =
|
|
{
|
|
//
|
|
val N = 5
|
|
//
|
|
val M = idmatrix(i2sz(N))
|
|
val () = fprint_matrixref_sep (stdout_ref, M, i2sz(N), i2sz(N), " ", "\n")
|
|
val () = fprint_newline (stdout_ref)
|
|
//
|
|
} (* end of [main0] *)
|