Hello,
so I made a little Gauss Matrix solver because I was bored and rewrote it to instead of being a [][]f32
be a []f32
. The problem is the following function:
fn sort(matrix: [][]f32) void {
const lt = struct {
fn f(_: void, lhs: []f32, rhs: []f32) bool {
std.debug.assert(lhs.len == rhs.len);
return std.mem.indexOfNone(f32, lhs, &.{0}) orelse lhs.len <
std.mem.indexOfNone(f32, rhs, &.{0}) orelse rhs.len;
}
}.f;
std.sort.pdq([]f32, matrix, {}, lt);
}
Is there a way to rewrite this so that the function signature looks like this:
/// n is the width of the matrix
fn sort(matrix: []f32, n: usize) void { ... }
while still using the standard libraries sorting functions and no allocator?