vecmath file split mayhem
This commit is contained in:
55
packages/vecmath/src/rotors/Complex_x8.zig
Normal file
55
packages/vecmath/src/rotors/Complex_x8.zig
Normal file
@@ -0,0 +1,55 @@
|
||||
const std = @import("std");
|
||||
const vm = @import("root");
|
||||
|
||||
pub const Complex_x8 = struct {
|
||||
re: vm.f32x8,
|
||||
im: vm.f32x8,
|
||||
|
||||
pub const Array = [16]f32;
|
||||
|
||||
pub const identity = initSingle(1, 0);
|
||||
|
||||
// --- INIT ---
|
||||
|
||||
pub inline fn init(re: vm.f32x8, im: vm.f32x8) Complex_x8 {
|
||||
return .{ .re = re, .im = im };
|
||||
}
|
||||
|
||||
pub inline fn initSingle(re: f32, im: f32) Complex_x8 {
|
||||
return .{ .re = vm.ps(re), .im = vm.ps(im) };
|
||||
}
|
||||
|
||||
pub inline fn initRotation(angle_turns: vm.f32x8) Complex_x8 {
|
||||
const c, const s = vm.cossin_x8(angle_turns).asArray();
|
||||
return .{ .re = c, .im = s };
|
||||
}
|
||||
|
||||
pub inline fn initRotationSingle(angle_turns: f32) Complex_x8 {
|
||||
const c, const s = vm.cossin(angle_turns).asArray();
|
||||
return .{ .re = vm.ps(c), .im = vm.ps(s) };
|
||||
}
|
||||
|
||||
pub inline fn initSplat(complex: vm.Complex) Complex_x8 {
|
||||
return .{ .re = vm.ps(complex.re), .im = vm.ps(complex.im) };
|
||||
}
|
||||
|
||||
pub inline fn initArray(array: Array) Complex_x8 {
|
||||
const re: vm.f32x8 = array[0..8].*;
|
||||
const im: vm.f32x8 = array[8..16].*;
|
||||
return .{ .re = re, .im = im };
|
||||
}
|
||||
|
||||
pub inline fn initVector2(vector: vm.Vector2x8) Complex_x8 {
|
||||
return @bitCast(vector);
|
||||
}
|
||||
|
||||
// --- CONVERSION ---
|
||||
|
||||
pub inline fn asArray(self: Complex_x8) Array {
|
||||
return @bitCast(self);
|
||||
}
|
||||
|
||||
pub inline fn asVector2(self: Complex_x8) vm.Vector2_x8 {
|
||||
return @bitCast(self);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user