forked from OpenRA/OpenRA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hmat2.cs
669 lines (560 loc) · 23.9 KB
/
hmat2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Numerics;
using System.Linq;
using GlmSharp.Swizzle;
// ReSharper disable InconsistentNaming
namespace GlmSharp
{
/// <summary>
/// A matrix of type Half with 2 columns and 2 rows.
/// </summary>
[Serializable]
[DataContract(Namespace = "mat")]
[StructLayout(LayoutKind.Sequential)]
public struct hmat2 : IReadOnlyList<Half>, IEquatable<hmat2>
{
#region Fields
/// <summary>
/// Column 0, Rows 0
/// </summary>
[DataMember]
public Half m00;
/// <summary>
/// Column 0, Rows 1
/// </summary>
[DataMember]
public Half m01;
/// <summary>
/// Column 1, Rows 0
/// </summary>
[DataMember]
public Half m10;
/// <summary>
/// Column 1, Rows 1
/// </summary>
[DataMember]
public Half m11;
#endregion
#region Constructors
/// <summary>
/// Component-wise constructor
/// </summary>
public hmat2(Half m00, Half m01, Half m10, Half m11)
{
this.m00 = m00;
this.m01 = m01;
this.m10 = m10;
this.m11 = m11;
}
/// <summary>
/// Constructs this matrix from a hmat2. Non-overwritten fields are from an Identity matrix.
/// </summary>
public hmat2(hmat2 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m10 = m.m10;
this.m11 = m.m11;
}
/// <summary>
/// Constructs this matrix from a hmat3x2. Non-overwritten fields are from an Identity matrix.
/// </summary>
public hmat2(hmat3x2 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m10 = m.m10;
this.m11 = m.m11;
}
/// <summary>
/// Constructs this matrix from a hmat4x2. Non-overwritten fields are from an Identity matrix.
/// </summary>
public hmat2(hmat4x2 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m10 = m.m10;
this.m11 = m.m11;
}
/// <summary>
/// Constructs this matrix from a hmat2x3. Non-overwritten fields are from an Identity matrix.
/// </summary>
public hmat2(hmat2x3 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m10 = m.m10;
this.m11 = m.m11;
}
/// <summary>
/// Constructs this matrix from a hmat3. Non-overwritten fields are from an Identity matrix.
/// </summary>
public hmat2(hmat3 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m10 = m.m10;
this.m11 = m.m11;
}
/// <summary>
/// Constructs this matrix from a hmat4x3. Non-overwritten fields are from an Identity matrix.
/// </summary>
public hmat2(hmat4x3 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m10 = m.m10;
this.m11 = m.m11;
}
/// <summary>
/// Constructs this matrix from a hmat2x4. Non-overwritten fields are from an Identity matrix.
/// </summary>
public hmat2(hmat2x4 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m10 = m.m10;
this.m11 = m.m11;
}
/// <summary>
/// Constructs this matrix from a hmat3x4. Non-overwritten fields are from an Identity matrix.
/// </summary>
public hmat2(hmat3x4 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m10 = m.m10;
this.m11 = m.m11;
}
/// <summary>
/// Constructs this matrix from a hmat4. Non-overwritten fields are from an Identity matrix.
/// </summary>
public hmat2(hmat4 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m10 = m.m10;
this.m11 = m.m11;
}
/// <summary>
/// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
/// </summary>
public hmat2(hvec2 c0, hvec2 c1)
{
this.m00 = c0.x;
this.m01 = c0.y;
this.m10 = c1.x;
this.m11 = c1.y;
}
#endregion
#region Properties
/// <summary>
/// Creates a 2D array with all values (address: Values[x, y])
/// </summary>
public Half[,] Values => new[,] { { m00, m01 }, { m10, m11 } };
/// <summary>
/// Creates a 1D array with all values (internal order)
/// </summary>
public Half[] Values1D => new[] { m00, m01, m10, m11 };
/// <summary>
/// Gets or sets the column nr 0
/// </summary>
public hvec2 Column0
{
get
{
return new hvec2(m00, m01);
}
set
{
m00 = value.x;
m01 = value.y;
}
}
/// <summary>
/// Gets or sets the column nr 1
/// </summary>
public hvec2 Column1
{
get
{
return new hvec2(m10, m11);
}
set
{
m10 = value.x;
m11 = value.y;
}
}
/// <summary>
/// Gets or sets the row nr 0
/// </summary>
public hvec2 Row0
{
get
{
return new hvec2(m00, m10);
}
set
{
m00 = value.x;
m10 = value.y;
}
}
/// <summary>
/// Gets or sets the row nr 1
/// </summary>
public hvec2 Row1
{
get
{
return new hvec2(m01, m11);
}
set
{
m01 = value.x;
m11 = value.y;
}
}
#endregion
#region Static Properties
/// <summary>
/// Predefined all-zero matrix
/// </summary>
public static hmat2 Zero { get; } = new hmat2(Half.Zero, Half.Zero, Half.Zero, Half.Zero);
/// <summary>
/// Predefined all-ones matrix
/// </summary>
public static hmat2 Ones { get; } = new hmat2(Half.One, Half.One, Half.One, Half.One);
/// <summary>
/// Predefined identity matrix
/// </summary>
public static hmat2 Identity { get; } = new hmat2(Half.One, Half.Zero, Half.Zero, Half.One);
/// <summary>
/// Predefined all-MaxValue matrix
/// </summary>
public static hmat2 AllMaxValue { get; } = new hmat2(Half.MaxValue, Half.MaxValue, Half.MaxValue, Half.MaxValue);
/// <summary>
/// Predefined diagonal-MaxValue matrix
/// </summary>
public static hmat2 DiagonalMaxValue { get; } = new hmat2(Half.MaxValue, Half.Zero, Half.Zero, Half.MaxValue);
/// <summary>
/// Predefined all-MinValue matrix
/// </summary>
public static hmat2 AllMinValue { get; } = new hmat2(Half.MinValue, Half.MinValue, Half.MinValue, Half.MinValue);
/// <summary>
/// Predefined diagonal-MinValue matrix
/// </summary>
public static hmat2 DiagonalMinValue { get; } = new hmat2(Half.MinValue, Half.Zero, Half.Zero, Half.MinValue);
/// <summary>
/// Predefined all-Epsilon matrix
/// </summary>
public static hmat2 AllEpsilon { get; } = new hmat2(Half.Epsilon, Half.Epsilon, Half.Epsilon, Half.Epsilon);
/// <summary>
/// Predefined diagonal-Epsilon matrix
/// </summary>
public static hmat2 DiagonalEpsilon { get; } = new hmat2(Half.Epsilon, Half.Zero, Half.Zero, Half.Epsilon);
/// <summary>
/// Predefined all-NaN matrix
/// </summary>
public static hmat2 AllNaN { get; } = new hmat2(Half.NaN, Half.NaN, Half.NaN, Half.NaN);
/// <summary>
/// Predefined diagonal-NaN matrix
/// </summary>
public static hmat2 DiagonalNaN { get; } = new hmat2(Half.NaN, Half.Zero, Half.Zero, Half.NaN);
/// <summary>
/// Predefined all-NegativeInfinity matrix
/// </summary>
public static hmat2 AllNegativeInfinity { get; } = new hmat2(Half.NegativeInfinity, Half.NegativeInfinity, Half.NegativeInfinity, Half.NegativeInfinity);
/// <summary>
/// Predefined diagonal-NegativeInfinity matrix
/// </summary>
public static hmat2 DiagonalNegativeInfinity { get; } = new hmat2(Half.NegativeInfinity, Half.Zero, Half.Zero, Half.NegativeInfinity);
/// <summary>
/// Predefined all-PositiveInfinity matrix
/// </summary>
public static hmat2 AllPositiveInfinity { get; } = new hmat2(Half.PositiveInfinity, Half.PositiveInfinity, Half.PositiveInfinity, Half.PositiveInfinity);
/// <summary>
/// Predefined diagonal-PositiveInfinity matrix
/// </summary>
public static hmat2 DiagonalPositiveInfinity { get; } = new hmat2(Half.PositiveInfinity, Half.Zero, Half.Zero, Half.PositiveInfinity);
#endregion
#region Functions
/// <summary>
/// Returns an enumerator that iterates through all fields.
/// </summary>
public IEnumerator<Half> GetEnumerator()
{
yield return m00;
yield return m01;
yield return m10;
yield return m11;
}
/// <summary>
/// Returns an enumerator that iterates through all fields.
/// </summary>
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
#endregion
/// <summary>
/// Returns the number of Fields (2 x 2 = 4).
/// </summary>
public int Count => 4;
/// <summary>
/// Gets/Sets a specific indexed component (a bit slower than direct access).
/// </summary>
public Half this[int fieldIndex]
{
get
{
switch (fieldIndex)
{
case 0: return m00;
case 1: return m01;
case 2: return m10;
case 3: return m11;
default: throw new ArgumentOutOfRangeException("fieldIndex");
}
}
set
{
switch (fieldIndex)
{
case 0: this.m00 = value; break;
case 1: this.m01 = value; break;
case 2: this.m10 = value; break;
case 3: this.m11 = value; break;
default: throw new ArgumentOutOfRangeException("fieldIndex");
}
}
}
/// <summary>
/// Gets/Sets a specific 2D-indexed component (a bit slower than direct access).
/// </summary>
public Half this[int col, int row]
{
get
{
return this[col * 2 + row];
}
set
{
this[col * 2 + row] = value;
}
}
/// <summary>
/// Returns true iff this equals rhs component-wise.
/// </summary>
public bool Equals(hmat2 rhs) => ((m00.Equals(rhs.m00) && m01.Equals(rhs.m01)) && (m10.Equals(rhs.m10) && m11.Equals(rhs.m11)));
/// <summary>
/// Returns true iff this equals rhs type- and component-wise.
/// </summary>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is hmat2 && Equals((hmat2) obj);
}
/// <summary>
/// Returns true iff this equals rhs component-wise.
/// </summary>
public static bool operator ==(hmat2 lhs, hmat2 rhs) => lhs.Equals(rhs);
/// <summary>
/// Returns true iff this does not equal rhs (component-wise).
/// </summary>
public static bool operator !=(hmat2 lhs, hmat2 rhs) => !lhs.Equals(rhs);
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
public override int GetHashCode()
{
unchecked
{
return ((((((m00.GetHashCode()) * 397) ^ m01.GetHashCode()) * 397) ^ m10.GetHashCode()) * 397) ^ m11.GetHashCode();
}
}
/// <summary>
/// Returns a transposed version of this matrix.
/// </summary>
public hmat2 Transposed => new hmat2(m00, m10, m01, m11);
/// <summary>
/// Returns the minimal component of this matrix.
/// </summary>
public Half MinElement => Half.Min(Half.Min(Half.Min(m00, m01), m10), m11);
/// <summary>
/// Returns the maximal component of this matrix.
/// </summary>
public Half MaxElement => Half.Max(Half.Max(Half.Max(m00, m01), m10), m11);
/// <summary>
/// Returns the euclidean length of this matrix.
/// </summary>
public float Length => (float)Math.Sqrt(((m00*m00 + m01*m01) + (m10*m10 + m11*m11)));
/// <summary>
/// Returns the squared euclidean length of this matrix.
/// </summary>
public float LengthSqr => ((m00*m00 + m01*m01) + (m10*m10 + m11*m11));
/// <summary>
/// Returns the sum of all fields.
/// </summary>
public Half Sum => ((m00 + m01) + (m10 + m11));
/// <summary>
/// Returns the euclidean norm of this matrix.
/// </summary>
public float Norm => (float)Math.Sqrt(((m00*m00 + m01*m01) + (m10*m10 + m11*m11)));
/// <summary>
/// Returns the one-norm of this matrix.
/// </summary>
public float Norm1 => ((Half.Abs(m00) + Half.Abs(m01)) + (Half.Abs(m10) + Half.Abs(m11)));
/// <summary>
/// Returns the two-norm of this matrix.
/// </summary>
public float Norm2 => (float)Math.Sqrt(((m00*m00 + m01*m01) + (m10*m10 + m11*m11)));
/// <summary>
/// Returns the max-norm of this matrix.
/// </summary>
public Half NormMax => Half.Max(Half.Max(Half.Max(Half.Abs(m00), Half.Abs(m01)), Half.Abs(m10)), Half.Abs(m11));
/// <summary>
/// Returns the p-norm of this matrix.
/// </summary>
public double NormP(double p) => Math.Pow(((Math.Pow((double)Half.Abs(m00), p) + Math.Pow((double)Half.Abs(m01), p)) + (Math.Pow((double)Half.Abs(m10), p) + Math.Pow((double)Half.Abs(m11), p))), 1 / p);
/// <summary>
/// Returns determinant of this matrix.
/// </summary>
public Half Determinant => m00 * m11 - m10 * m01;
/// <summary>
/// Returns the adjunct of this matrix.
/// </summary>
public hmat2 Adjugate => new hmat2(m11, -m01, -m10, m00);
/// <summary>
/// Returns the inverse of this matrix (use with caution).
/// </summary>
public hmat2 Inverse => Adjugate / Determinant;
/// <summary>
/// Executes a matrix-matrix-multiplication hmat2 * hmat2 -> hmat2.
/// </summary>
public static hmat2 operator*(hmat2 lhs, hmat2 rhs) => new hmat2((lhs.m00 * rhs.m00 + lhs.m10 * rhs.m01), (lhs.m01 * rhs.m00 + lhs.m11 * rhs.m01), (lhs.m00 * rhs.m10 + lhs.m10 * rhs.m11), (lhs.m01 * rhs.m10 + lhs.m11 * rhs.m11));
/// <summary>
/// Executes a matrix-matrix-multiplication hmat2 * hmat3x2 -> hmat3x2.
/// </summary>
public static hmat3x2 operator*(hmat2 lhs, hmat3x2 rhs) => new hmat3x2((lhs.m00 * rhs.m00 + lhs.m10 * rhs.m01), (lhs.m01 * rhs.m00 + lhs.m11 * rhs.m01), (lhs.m00 * rhs.m10 + lhs.m10 * rhs.m11), (lhs.m01 * rhs.m10 + lhs.m11 * rhs.m11), (lhs.m00 * rhs.m20 + lhs.m10 * rhs.m21), (lhs.m01 * rhs.m20 + lhs.m11 * rhs.m21));
/// <summary>
/// Executes a matrix-matrix-multiplication hmat2 * hmat4x2 -> hmat4x2.
/// </summary>
public static hmat4x2 operator*(hmat2 lhs, hmat4x2 rhs) => new hmat4x2((lhs.m00 * rhs.m00 + lhs.m10 * rhs.m01), (lhs.m01 * rhs.m00 + lhs.m11 * rhs.m01), (lhs.m00 * rhs.m10 + lhs.m10 * rhs.m11), (lhs.m01 * rhs.m10 + lhs.m11 * rhs.m11), (lhs.m00 * rhs.m20 + lhs.m10 * rhs.m21), (lhs.m01 * rhs.m20 + lhs.m11 * rhs.m21), (lhs.m00 * rhs.m30 + lhs.m10 * rhs.m31), (lhs.m01 * rhs.m30 + lhs.m11 * rhs.m31));
/// <summary>
/// Executes a matrix-vector-multiplication.
/// </summary>
public static hvec2 operator*(hmat2 m, hvec2 v) => new hvec2((m.m00 * v.x + m.m10 * v.y), (m.m01 * v.x + m.m11 * v.y));
/// <summary>
/// Executes a matrix-matrix-divison A / B == A * B^-1 (use with caution).
/// </summary>
public static hmat2 operator/(hmat2 A, hmat2 B) => A * B.Inverse;
/// <summary>
/// Executes a component-wise * (multiply).
/// </summary>
public static hmat2 CompMul(hmat2 A, hmat2 B) => new hmat2(A.m00 * B.m00, A.m01 * B.m01, A.m10 * B.m10, A.m11 * B.m11);
/// <summary>
/// Executes a component-wise / (divide).
/// </summary>
public static hmat2 CompDiv(hmat2 A, hmat2 B) => new hmat2(A.m00 / B.m00, A.m01 / B.m01, A.m10 / B.m10, A.m11 / B.m11);
/// <summary>
/// Executes a component-wise + (add).
/// </summary>
public static hmat2 CompAdd(hmat2 A, hmat2 B) => new hmat2(A.m00 + B.m00, A.m01 + B.m01, A.m10 + B.m10, A.m11 + B.m11);
/// <summary>
/// Executes a component-wise - (subtract).
/// </summary>
public static hmat2 CompSub(hmat2 A, hmat2 B) => new hmat2(A.m00 - B.m00, A.m01 - B.m01, A.m10 - B.m10, A.m11 - B.m11);
/// <summary>
/// Executes a component-wise + (add).
/// </summary>
public static hmat2 operator+(hmat2 lhs, hmat2 rhs) => new hmat2(lhs.m00 + rhs.m00, lhs.m01 + rhs.m01, lhs.m10 + rhs.m10, lhs.m11 + rhs.m11);
/// <summary>
/// Executes a component-wise + (add) with a scalar.
/// </summary>
public static hmat2 operator+(hmat2 lhs, Half rhs) => new hmat2(lhs.m00 + rhs, lhs.m01 + rhs, lhs.m10 + rhs, lhs.m11 + rhs);
/// <summary>
/// Executes a component-wise + (add) with a scalar.
/// </summary>
public static hmat2 operator+(Half lhs, hmat2 rhs) => new hmat2(lhs + rhs.m00, lhs + rhs.m01, lhs + rhs.m10, lhs + rhs.m11);
/// <summary>
/// Executes a component-wise - (subtract).
/// </summary>
public static hmat2 operator-(hmat2 lhs, hmat2 rhs) => new hmat2(lhs.m00 - rhs.m00, lhs.m01 - rhs.m01, lhs.m10 - rhs.m10, lhs.m11 - rhs.m11);
/// <summary>
/// Executes a component-wise - (subtract) with a scalar.
/// </summary>
public static hmat2 operator-(hmat2 lhs, Half rhs) => new hmat2(lhs.m00 - rhs, lhs.m01 - rhs, lhs.m10 - rhs, lhs.m11 - rhs);
/// <summary>
/// Executes a component-wise - (subtract) with a scalar.
/// </summary>
public static hmat2 operator-(Half lhs, hmat2 rhs) => new hmat2(lhs - rhs.m00, lhs - rhs.m01, lhs - rhs.m10, lhs - rhs.m11);
/// <summary>
/// Executes a component-wise / (divide) with a scalar.
/// </summary>
public static hmat2 operator/(hmat2 lhs, Half rhs) => new hmat2(lhs.m00 / rhs, lhs.m01 / rhs, lhs.m10 / rhs, lhs.m11 / rhs);
/// <summary>
/// Executes a component-wise / (divide) with a scalar.
/// </summary>
public static hmat2 operator/(Half lhs, hmat2 rhs) => new hmat2(lhs / rhs.m00, lhs / rhs.m01, lhs / rhs.m10, lhs / rhs.m11);
/// <summary>
/// Executes a component-wise * (multiply) with a scalar.
/// </summary>
public static hmat2 operator*(hmat2 lhs, Half rhs) => new hmat2(lhs.m00 * rhs, lhs.m01 * rhs, lhs.m10 * rhs, lhs.m11 * rhs);
/// <summary>
/// Executes a component-wise * (multiply) with a scalar.
/// </summary>
public static hmat2 operator*(Half lhs, hmat2 rhs) => new hmat2(lhs * rhs.m00, lhs * rhs.m01, lhs * rhs.m10, lhs * rhs.m11);
/// <summary>
/// Executes a component-wise lesser-than comparison.
/// </summary>
public static bmat2 operator<(hmat2 lhs, hmat2 rhs) => new bmat2(lhs.m00 < rhs.m00, lhs.m01 < rhs.m01, lhs.m10 < rhs.m10, lhs.m11 < rhs.m11);
/// <summary>
/// Executes a component-wise lesser-than comparison with a scalar.
/// </summary>
public static bmat2 operator<(hmat2 lhs, Half rhs) => new bmat2(lhs.m00 < rhs, lhs.m01 < rhs, lhs.m10 < rhs, lhs.m11 < rhs);
/// <summary>
/// Executes a component-wise lesser-than comparison with a scalar.
/// </summary>
public static bmat2 operator<(Half lhs, hmat2 rhs) => new bmat2(lhs < rhs.m00, lhs < rhs.m01, lhs < rhs.m10, lhs < rhs.m11);
/// <summary>
/// Executes a component-wise lesser-or-equal comparison.
/// </summary>
public static bmat2 operator<=(hmat2 lhs, hmat2 rhs) => new bmat2(lhs.m00 <= rhs.m00, lhs.m01 <= rhs.m01, lhs.m10 <= rhs.m10, lhs.m11 <= rhs.m11);
/// <summary>
/// Executes a component-wise lesser-or-equal comparison with a scalar.
/// </summary>
public static bmat2 operator<=(hmat2 lhs, Half rhs) => new bmat2(lhs.m00 <= rhs, lhs.m01 <= rhs, lhs.m10 <= rhs, lhs.m11 <= rhs);
/// <summary>
/// Executes a component-wise lesser-or-equal comparison with a scalar.
/// </summary>
public static bmat2 operator<=(Half lhs, hmat2 rhs) => new bmat2(lhs <= rhs.m00, lhs <= rhs.m01, lhs <= rhs.m10, lhs <= rhs.m11);
/// <summary>
/// Executes a component-wise greater-than comparison.
/// </summary>
public static bmat2 operator>(hmat2 lhs, hmat2 rhs) => new bmat2(lhs.m00 > rhs.m00, lhs.m01 > rhs.m01, lhs.m10 > rhs.m10, lhs.m11 > rhs.m11);
/// <summary>
/// Executes a component-wise greater-than comparison with a scalar.
/// </summary>
public static bmat2 operator>(hmat2 lhs, Half rhs) => new bmat2(lhs.m00 > rhs, lhs.m01 > rhs, lhs.m10 > rhs, lhs.m11 > rhs);
/// <summary>
/// Executes a component-wise greater-than comparison with a scalar.
/// </summary>
public static bmat2 operator>(Half lhs, hmat2 rhs) => new bmat2(lhs > rhs.m00, lhs > rhs.m01, lhs > rhs.m10, lhs > rhs.m11);
/// <summary>
/// Executes a component-wise greater-or-equal comparison.
/// </summary>
public static bmat2 operator>=(hmat2 lhs, hmat2 rhs) => new bmat2(lhs.m00 >= rhs.m00, lhs.m01 >= rhs.m01, lhs.m10 >= rhs.m10, lhs.m11 >= rhs.m11);
/// <summary>
/// Executes a component-wise greater-or-equal comparison with a scalar.
/// </summary>
public static bmat2 operator>=(hmat2 lhs, Half rhs) => new bmat2(lhs.m00 >= rhs, lhs.m01 >= rhs, lhs.m10 >= rhs, lhs.m11 >= rhs);
/// <summary>
/// Executes a component-wise greater-or-equal comparison with a scalar.
/// </summary>
public static bmat2 operator>=(Half lhs, hmat2 rhs) => new bmat2(lhs >= rhs.m00, lhs >= rhs.m01, lhs >= rhs.m10, lhs >= rhs.m11);
}
}