File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -523,6 +523,63 @@ float matrices and add the result to a third 4x4 matrix.
523
523
return a + b * c;
524
524
}
525
525
526
+ The matrix type extension also supports operations on a matrix and a scalar.
527
+
528
+ .. code-block :: c++
529
+
530
+ typedef float m4x4_t __attribute__((matrix_type(4, 4)));
531
+
532
+ m4x4_t f(m4x4_t a) {
533
+ return (a + 23) * 12;
534
+ }
535
+
536
+ The matrix type extension supports division on a matrix and a scalar but not on a matrix and a matrix.
537
+
538
+ .. code-block :: c++
539
+ typedef float m4x4_t __attribute__((matrix_type(4, 4)));
540
+
541
+ m4x4_t f(m4x4_t a) {
542
+ a = a / 3.0;
543
+ return a;
544
+ }
545
+
546
+ The matrix type extension supports compound assignments for addition, subtraction, and multiplication between matrices
547
+ and between a matrix and a scalar, provided their types are consistent.
548
+
549
+ .. code-block :: c++
550
+
551
+ typedef float m4x4_t __attribute__((matrix_type(4, 4)));
552
+
553
+ m4x4_t f(m4x4_t a, m4x4_t b) {
554
+ a += b;
555
+ a -= b;
556
+ a *= b;
557
+ a += 23;
558
+ a -= 12;
559
+ return a;
560
+ }
561
+
562
+ The matrix type extension supports explicit casts. Implicit type conversion between matrix types is not allowed.
563
+
564
+ .. code-block :: c++
565
+
566
+ typedef int ix5x5 __attribute__((matrix_type(5, 5)));
567
+ typedef float fx5x5 __attribute__((matrix_type(5, 5)));
568
+
569
+ fx5x5 f1(ix5x5 i, fx5x5 f) {
570
+ return (fx5x5) i;
571
+ }
572
+
573
+
574
+ template <typename X>
575
+ using matrix_4_4 = X __attribute__((matrix_type(4, 4)));
576
+
577
+ void f2() {
578
+ matrix_5_5<double> d;
579
+ matrix_5_5<int> i;
580
+ i = (matrix_5_5<int>)d;
581
+ i = static_cast<matrix_5_5<int>>(d);
582
+ }
526
583
527
584
Half-Precision Floating Point
528
585
=============================
You can’t perform that action at this time.
0 commit comments