Qy
1 program
Added 2026-03-06T10:53:03Z
Agent: claude-codeModel: claude-sonnet-4-6WebSearch: enabled
Evidence
Report issue
View issues
Aliases: —
Provenance: commit 66a49fb4a4 · authored 2026-03-06T11:53:41+01:00 · agent claude-code · model claude-sonnet-4-6
Sources mentioning this language
1 source · not in taxonomy (canonical name didn't match any upstream)
LLM-contributed programs
Matrix Multiplication
Provenance: commit 66a49fb4a4 · authored 2026-03-06T11:53:41+01:00 · agent claude-code · model claude-sonnet-4-6 · WebSearch enabled
type Matrix = (
data: MutArrayBox[F32],
rows: I64,
cols: I64
);
def matrix (r: I64, c: I64) = (
new Matrix(new MutArrayBox[F32](r * c), r, c)
);
def matrix_index (m, ir, ic) = (
// NOTE: all matrices store indices in COLUMN MAJOR format
ic * m.rows + ir
);
def matrix_ptr (m: Ptr[Matrix], ir, ic) = (
m.data.ptr(matrix_index(m, ir, ic))
);
def matrix_get (m: Ptr[Matrix], ir, ic) = (
*matrix_ptr(m, ir, ic)
);
def print_matrix (m: Ptr[Matrix]) = do {
val i = push mut 0L;
val comma = push ", ";
val lsqbrk = push "[";
val lpad = push " ";
val rsqbrk = push "]";
val rsqbrk_row_end = push "]\n";
val lfeed_row_end = push "\n";
val ss = push new_string_stream(default_heap_allocator);
while (*i < m.rows) do {
string_stream_push_string_view(ss,
to_string_view(if (*i == 0L) { lsqbrk } else { lpad }));
val j = push mut 0L;
string_stream_push_string_view(ss, to_string_view(lsqbrk));
while (*j < m.cols) do {
string_stream_push_number_f32(ss, matrix_get(m, *i, *j), 10, 0);
if (*j < m.cols - 1L) {
string_stream_push_string_view(ss, to_string_view(comma));
};
j := 1L + *j;
};
string_stream_push_string_view(ss, to_string_view(rsqbrk));
string_stream_push_string_view(ss,
to_string_view(if (*i == m.rows-1L) { rsqbrk_row_end } else { lfeed_row_end }));
i := 1L + *i;
};
file_print(file_stdout, string_stream_flush(ss));
};
def main () = do {
file_print(file_stdout, "2D Matrices!\n");
val rows = 4L;
val cols = 4L;
val m = push new Matrix(
new MutArrayBox[F32](rows * cols),
rows, cols
);
print_matrix(m);
0
};