diff --git a/src/numz.zig b/src/numz.zig index 16bc74a..5ae8214 100644 --- a/src/numz.zig +++ b/src/numz.zig @@ -39,12 +39,17 @@ pub fn Matrix(rows: comptime_int, cols: comptime_int, T: type) type { fn array(self: Self) [self.rows]T { return @bitCast(self.mat); } + + fn fromArray(a: [rows]T) Self { + return .{ .mat = @bitCast(a) }; + } }; pub const get = if (cols == 1) vector.get else @compileError("Not a vector"); pub const swizzle = if (cols == 1) vector.swizzle else @compileError("Not a vector"); pub const dot = if (cols == 1) vector.dot else @compileError("Not a vector"); pub const array = if (cols == 1) vector.array else @compileError("Not a vector"); + pub const fromArray = if (cols == 1) vector.fromArray else @compileError("Not a vector"); pub fn splat(s: T) Self { var result: Self = .{ .mat = undefined };