mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Add linalg.matrix_cast
This commit is contained in:
@@ -316,10 +316,19 @@ cubic :: proc(v1, v2, v3, v4: $T/[$N]$E, s: E) -> T {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
array_cast :: proc(v: $A/[$N]$T, $U: typeid) -> [N]U {
|
array_cast :: proc(v: $A/[$N]$T, $Elem_Type: typeid) -> (w: [N]Elem_Type) {
|
||||||
w: [N]U;
|
for _, i in v do w[i] = Elem_Type(v[i]);
|
||||||
for _, i in v do w[i] = U(v[i]);
|
return;
|
||||||
return w;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
matrix_cast :: proc(v: $A/[$M][$N]$T, $Elem_Type: typeid) -> (w: [M][N]Elem_Type) {
|
||||||
|
for i in 0..<M {
|
||||||
|
for j in 0..<N {
|
||||||
|
w[i][j] = Elem_Type(v[i][j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
to_f32 :: #force_inline proc(v: $A/[$N]$T) -> [N]f32 { return array_cast(v, f32); }
|
to_f32 :: #force_inline proc(v: $A/[$N]$T) -> [N]f32 { return array_cast(v, f32); }
|
||||||
|
|||||||
Reference in New Issue
Block a user