1 | /* graphene-simd4x4f.c |
2 | * |
3 | * SPDX-License-Identifier: MIT |
4 | * |
5 | * Copyright 2014 Emmanuele Bassi |
6 | * |
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
8 | * of this software and associated documentation files (the "Software"), to deal |
9 | * in the Software without restriction, including without limitation the rights |
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11 | * copies of the Software, and to permit persons to whom the Software is |
12 | * furnished to do so, subject to the following conditions: |
13 | * |
14 | * The above copyright notice and this permission notice shall be included in |
15 | * all copies or substantial portions of the Software. |
16 | * |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
23 | * THE SOFTWARE. |
24 | */ |
25 | |
26 | /** |
27 | * SECTION:graphene-simd4x4f |
28 | * @Title: SIMD matrix |
29 | * @short_description: Low level floating point 4 by 4 matrix |
30 | * |
31 | * The #graphene_simd4x4f_t type wraps a platform specific implementation of |
32 | * a four by four matrix of floating point values, using four #graphene_simd4f_t |
33 | * row vectors. |
34 | * |
35 | * Like #graphene_simd4f_t, the #graphene_simd4x4f_t type should be treated |
36 | * as an opaque type; you cannot access its components directly, and you can |
37 | * only operate on all components at the same time. |
38 | */ |
39 | |
40 | #include "graphene-private.h" |
41 | #include "graphene-simd4x4f.h" |
42 | |
43 | #include <string.h> |
44 | #include <math.h> |
45 | |
46 | #if defined(GRAPHENE_USE_SSE) || defined(GRAPHENE_USE_GCC) || defined(GRAPHENE_USE_ARM_NEON) |
47 | |
48 | /** |
49 | * graphene_simd4x4f_transpose_in_place: |
50 | * @s: a #graphene_simd4x4f_t |
51 | * |
52 | * Transposes @s in place. |
53 | * |
54 | * Since: 1.0 |
55 | */ |
56 | void |
57 | (graphene_simd4x4f_transpose_in_place) (graphene_simd4x4f_t *s) |
58 | { |
59 | graphene_simd4x4f_transpose_in_place (s); |
60 | } |
61 | |
62 | #else |
63 | |
64 | void |
65 | (graphene_simd4x4f_transpose_in_place) (graphene_simd4x4f_t *s) |
66 | { |
67 | graphene_simd4x4f_t m = *s; |
68 | |
69 | s->x.x = m.x.x; |
70 | s->x.y = m.y.x; |
71 | s->x.z = m.z.x; |
72 | s->x.w = m.w.x; |
73 | |
74 | s->y.x = m.x.y; |
75 | s->y.y = m.y.y; |
76 | s->y.z = m.z.y; |
77 | s->y.w = m.w.y; |
78 | |
79 | s->z.x = m.x.z; |
80 | s->z.y = m.y.z; |
81 | s->z.z = m.z.z; |
82 | s->z.w = m.w.z; |
83 | |
84 | s->w.x = m.x.w; |
85 | s->w.y = m.y.w; |
86 | s->w.z = m.z.w; |
87 | s->w.w = m.w.w; |
88 | } |
89 | |
90 | #endif |
91 | |