forked from OpenRA/OpenRA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmat3x4.cs
842 lines (745 loc) · 33.1 KB
/
cmat3x4.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
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
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 Complex with 3 columns and 4 rows.
/// </summary>
[Serializable]
[DataContract(Namespace = "mat")]
[StructLayout(LayoutKind.Sequential)]
public struct cmat3x4 : IReadOnlyList<Complex>, IEquatable<cmat3x4>
{
#region Fields
/// <summary>
/// Column 0, Rows 0
/// </summary>
[DataMember]
public Complex m00;
/// <summary>
/// Column 0, Rows 1
/// </summary>
[DataMember]
public Complex m01;
/// <summary>
/// Column 0, Rows 2
/// </summary>
[DataMember]
public Complex m02;
/// <summary>
/// Column 0, Rows 3
/// </summary>
[DataMember]
public Complex m03;
/// <summary>
/// Column 1, Rows 0
/// </summary>
[DataMember]
public Complex m10;
/// <summary>
/// Column 1, Rows 1
/// </summary>
[DataMember]
public Complex m11;
/// <summary>
/// Column 1, Rows 2
/// </summary>
[DataMember]
public Complex m12;
/// <summary>
/// Column 1, Rows 3
/// </summary>
[DataMember]
public Complex m13;
/// <summary>
/// Column 2, Rows 0
/// </summary>
[DataMember]
public Complex m20;
/// <summary>
/// Column 2, Rows 1
/// </summary>
[DataMember]
public Complex m21;
/// <summary>
/// Column 2, Rows 2
/// </summary>
[DataMember]
public Complex m22;
/// <summary>
/// Column 2, Rows 3
/// </summary>
[DataMember]
public Complex m23;
#endregion
#region Constructors
/// <summary>
/// Component-wise constructor
/// </summary>
public cmat3x4(Complex m00, Complex m01, Complex m02, Complex m03, Complex m10, Complex m11, Complex m12, Complex m13, Complex m20, Complex m21, Complex m22, Complex m23)
{
this.m00 = m00;
this.m01 = m01;
this.m02 = m02;
this.m03 = m03;
this.m10 = m10;
this.m11 = m11;
this.m12 = m12;
this.m13 = m13;
this.m20 = m20;
this.m21 = m21;
this.m22 = m22;
this.m23 = m23;
}
/// <summary>
/// Constructs this matrix from a cmat2. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cmat2 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m02 = Complex.Zero;
this.m03 = Complex.Zero;
this.m10 = m.m10;
this.m11 = m.m11;
this.m12 = Complex.Zero;
this.m13 = Complex.Zero;
this.m20 = Complex.Zero;
this.m21 = Complex.Zero;
this.m22 = Complex.One;
this.m23 = Complex.Zero;
}
/// <summary>
/// Constructs this matrix from a cmat3x2. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cmat3x2 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m02 = Complex.Zero;
this.m03 = Complex.Zero;
this.m10 = m.m10;
this.m11 = m.m11;
this.m12 = Complex.Zero;
this.m13 = Complex.Zero;
this.m20 = m.m20;
this.m21 = m.m21;
this.m22 = Complex.One;
this.m23 = Complex.Zero;
}
/// <summary>
/// Constructs this matrix from a cmat4x2. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cmat4x2 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m02 = Complex.Zero;
this.m03 = Complex.Zero;
this.m10 = m.m10;
this.m11 = m.m11;
this.m12 = Complex.Zero;
this.m13 = Complex.Zero;
this.m20 = m.m20;
this.m21 = m.m21;
this.m22 = Complex.One;
this.m23 = Complex.Zero;
}
/// <summary>
/// Constructs this matrix from a cmat2x3. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cmat2x3 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m02 = m.m02;
this.m03 = Complex.Zero;
this.m10 = m.m10;
this.m11 = m.m11;
this.m12 = m.m12;
this.m13 = Complex.Zero;
this.m20 = Complex.Zero;
this.m21 = Complex.Zero;
this.m22 = Complex.One;
this.m23 = Complex.Zero;
}
/// <summary>
/// Constructs this matrix from a cmat3. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cmat3 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m02 = m.m02;
this.m03 = Complex.Zero;
this.m10 = m.m10;
this.m11 = m.m11;
this.m12 = m.m12;
this.m13 = Complex.Zero;
this.m20 = m.m20;
this.m21 = m.m21;
this.m22 = m.m22;
this.m23 = Complex.Zero;
}
/// <summary>
/// Constructs this matrix from a cmat4x3. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cmat4x3 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m02 = m.m02;
this.m03 = Complex.Zero;
this.m10 = m.m10;
this.m11 = m.m11;
this.m12 = m.m12;
this.m13 = Complex.Zero;
this.m20 = m.m20;
this.m21 = m.m21;
this.m22 = m.m22;
this.m23 = Complex.Zero;
}
/// <summary>
/// Constructs this matrix from a cmat2x4. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cmat2x4 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m02 = m.m02;
this.m03 = m.m03;
this.m10 = m.m10;
this.m11 = m.m11;
this.m12 = m.m12;
this.m13 = m.m13;
this.m20 = Complex.Zero;
this.m21 = Complex.Zero;
this.m22 = Complex.One;
this.m23 = Complex.Zero;
}
/// <summary>
/// Constructs this matrix from a cmat3x4. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cmat3x4 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m02 = m.m02;
this.m03 = m.m03;
this.m10 = m.m10;
this.m11 = m.m11;
this.m12 = m.m12;
this.m13 = m.m13;
this.m20 = m.m20;
this.m21 = m.m21;
this.m22 = m.m22;
this.m23 = m.m23;
}
/// <summary>
/// Constructs this matrix from a cmat4. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cmat4 m)
{
this.m00 = m.m00;
this.m01 = m.m01;
this.m02 = m.m02;
this.m03 = m.m03;
this.m10 = m.m10;
this.m11 = m.m11;
this.m12 = m.m12;
this.m13 = m.m13;
this.m20 = m.m20;
this.m21 = m.m21;
this.m22 = m.m22;
this.m23 = m.m23;
}
/// <summary>
/// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cvec2 c0, cvec2 c1)
{
this.m00 = c0.x;
this.m01 = c0.y;
this.m02 = Complex.Zero;
this.m03 = Complex.Zero;
this.m10 = c1.x;
this.m11 = c1.y;
this.m12 = Complex.Zero;
this.m13 = Complex.Zero;
this.m20 = Complex.Zero;
this.m21 = Complex.Zero;
this.m22 = Complex.One;
this.m23 = Complex.Zero;
}
/// <summary>
/// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cvec2 c0, cvec2 c1, cvec2 c2)
{
this.m00 = c0.x;
this.m01 = c0.y;
this.m02 = Complex.Zero;
this.m03 = Complex.Zero;
this.m10 = c1.x;
this.m11 = c1.y;
this.m12 = Complex.Zero;
this.m13 = Complex.Zero;
this.m20 = c2.x;
this.m21 = c2.y;
this.m22 = Complex.One;
this.m23 = Complex.Zero;
}
/// <summary>
/// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cvec3 c0, cvec3 c1)
{
this.m00 = c0.x;
this.m01 = c0.y;
this.m02 = c0.z;
this.m03 = Complex.Zero;
this.m10 = c1.x;
this.m11 = c1.y;
this.m12 = c1.z;
this.m13 = Complex.Zero;
this.m20 = Complex.Zero;
this.m21 = Complex.Zero;
this.m22 = Complex.One;
this.m23 = Complex.Zero;
}
/// <summary>
/// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cvec3 c0, cvec3 c1, cvec3 c2)
{
this.m00 = c0.x;
this.m01 = c0.y;
this.m02 = c0.z;
this.m03 = Complex.Zero;
this.m10 = c1.x;
this.m11 = c1.y;
this.m12 = c1.z;
this.m13 = Complex.Zero;
this.m20 = c2.x;
this.m21 = c2.y;
this.m22 = c2.z;
this.m23 = Complex.Zero;
}
/// <summary>
/// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cvec4 c0, cvec4 c1)
{
this.m00 = c0.x;
this.m01 = c0.y;
this.m02 = c0.z;
this.m03 = c0.w;
this.m10 = c1.x;
this.m11 = c1.y;
this.m12 = c1.z;
this.m13 = c1.w;
this.m20 = Complex.Zero;
this.m21 = Complex.Zero;
this.m22 = Complex.One;
this.m23 = Complex.Zero;
}
/// <summary>
/// Constructs this matrix from a series of column vectors. Non-overwritten fields are from an Identity matrix.
/// </summary>
public cmat3x4(cvec4 c0, cvec4 c1, cvec4 c2)
{
this.m00 = c0.x;
this.m01 = c0.y;
this.m02 = c0.z;
this.m03 = c0.w;
this.m10 = c1.x;
this.m11 = c1.y;
this.m12 = c1.z;
this.m13 = c1.w;
this.m20 = c2.x;
this.m21 = c2.y;
this.m22 = c2.z;
this.m23 = c2.w;
}
#endregion
#region Properties
/// <summary>
/// Creates a 2D array with all values (address: Values[x, y])
/// </summary>
public Complex[,] Values => new[,] { { m00, m01, m02, m03 }, { m10, m11, m12, m13 }, { m20, m21, m22, m23 } };
/// <summary>
/// Creates a 1D array with all values (internal order)
/// </summary>
public Complex[] Values1D => new[] { m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23 };
/// <summary>
/// Gets or sets the column nr 0
/// </summary>
public cvec4 Column0
{
get
{
return new cvec4(m00, m01, m02, m03);
}
set
{
m00 = value.x;
m01 = value.y;
m02 = value.z;
m03 = value.w;
}
}
/// <summary>
/// Gets or sets the column nr 1
/// </summary>
public cvec4 Column1
{
get
{
return new cvec4(m10, m11, m12, m13);
}
set
{
m10 = value.x;
m11 = value.y;
m12 = value.z;
m13 = value.w;
}
}
/// <summary>
/// Gets or sets the column nr 2
/// </summary>
public cvec4 Column2
{
get
{
return new cvec4(m20, m21, m22, m23);
}
set
{
m20 = value.x;
m21 = value.y;
m22 = value.z;
m23 = value.w;
}
}
/// <summary>
/// Gets or sets the row nr 0
/// </summary>
public cvec3 Row0
{
get
{
return new cvec3(m00, m10, m20);
}
set
{
m00 = value.x;
m10 = value.y;
m20 = value.z;
}
}
/// <summary>
/// Gets or sets the row nr 1
/// </summary>
public cvec3 Row1
{
get
{
return new cvec3(m01, m11, m21);
}
set
{
m01 = value.x;
m11 = value.y;
m21 = value.z;
}
}
/// <summary>
/// Gets or sets the row nr 2
/// </summary>
public cvec3 Row2
{
get
{
return new cvec3(m02, m12, m22);
}
set
{
m02 = value.x;
m12 = value.y;
m22 = value.z;
}
}
/// <summary>
/// Gets or sets the row nr 3
/// </summary>
public cvec3 Row3
{
get
{
return new cvec3(m03, m13, m23);
}
set
{
m03 = value.x;
m13 = value.y;
m23 = value.z;
}
}
#endregion
#region Static Properties
/// <summary>
/// Predefined all-zero matrix
/// </summary>
public static cmat3x4 Zero { get; } = new cmat3x4(Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero);
/// <summary>
/// Predefined all-ones matrix
/// </summary>
public static cmat3x4 Ones { get; } = new cmat3x4(Complex.One, Complex.One, Complex.One, Complex.One, Complex.One, Complex.One, Complex.One, Complex.One, Complex.One, Complex.One, Complex.One, Complex.One);
/// <summary>
/// Predefined identity matrix
/// </summary>
public static cmat3x4 Identity { get; } = new cmat3x4(Complex.One, Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero, Complex.One, Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero, Complex.One, Complex.Zero);
/// <summary>
/// Predefined all-imaginary-ones matrix
/// </summary>
public static cmat3x4 ImaginaryOnes { get; } = new cmat3x4(Complex.ImaginaryOne, Complex.ImaginaryOne, Complex.ImaginaryOne, Complex.ImaginaryOne, Complex.ImaginaryOne, Complex.ImaginaryOne, Complex.ImaginaryOne, Complex.ImaginaryOne, Complex.ImaginaryOne, Complex.ImaginaryOne, Complex.ImaginaryOne, Complex.ImaginaryOne);
/// <summary>
/// Predefined diagonal-imaginary-one matrix
/// </summary>
public static cmat3x4 ImaginaryIdentity { get; } = new cmat3x4(Complex.ImaginaryOne, Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero, Complex.ImaginaryOne, Complex.Zero, Complex.Zero, Complex.Zero, Complex.Zero, Complex.ImaginaryOne, Complex.Zero);
#endregion
#region Functions
/// <summary>
/// Returns an enumerator that iterates through all fields.
/// </summary>
public IEnumerator<Complex> GetEnumerator()
{
yield return m00;
yield return m01;
yield return m02;
yield return m03;
yield return m10;
yield return m11;
yield return m12;
yield return m13;
yield return m20;
yield return m21;
yield return m22;
yield return m23;
}
/// <summary>
/// Returns an enumerator that iterates through all fields.
/// </summary>
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
#endregion
/// <summary>
/// Returns the number of Fields (3 x 4 = 12).
/// </summary>
public int Count => 12;
/// <summary>
/// Gets/Sets a specific indexed component (a bit slower than direct access).
/// </summary>
public Complex this[int fieldIndex]
{
get
{
switch (fieldIndex)
{
case 0: return m00;
case 1: return m01;
case 2: return m02;
case 3: return m03;
case 4: return m10;
case 5: return m11;
case 6: return m12;
case 7: return m13;
case 8: return m20;
case 9: return m21;
case 10: return m22;
case 11: return m23;
default: throw new ArgumentOutOfRangeException("fieldIndex");
}
}
set
{
switch (fieldIndex)
{
case 0: this.m00 = value; break;
case 1: this.m01 = value; break;
case 2: this.m02 = value; break;
case 3: this.m03 = value; break;
case 4: this.m10 = value; break;
case 5: this.m11 = value; break;
case 6: this.m12 = value; break;
case 7: this.m13 = value; break;
case 8: this.m20 = value; break;
case 9: this.m21 = value; break;
case 10: this.m22 = value; break;
case 11: this.m23 = value; break;
default: throw new ArgumentOutOfRangeException("fieldIndex");
}
}
}
/// <summary>
/// Gets/Sets a specific 2D-indexed component (a bit slower than direct access).
/// </summary>
public Complex this[int col, int row]
{
get
{
return this[col * 4 + row];
}
set
{
this[col * 4 + row] = value;
}
}
/// <summary>
/// Returns true iff this equals rhs component-wise.
/// </summary>
public bool Equals(cmat3x4 rhs) => ((((m00.Equals(rhs.m00) && m01.Equals(rhs.m01)) && m02.Equals(rhs.m02)) && ((m03.Equals(rhs.m03) && m10.Equals(rhs.m10)) && m11.Equals(rhs.m11))) && (((m12.Equals(rhs.m12) && m13.Equals(rhs.m13)) && m20.Equals(rhs.m20)) && ((m21.Equals(rhs.m21) && m22.Equals(rhs.m22)) && m23.Equals(rhs.m23))));
/// <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 cmat3x4 && Equals((cmat3x4) obj);
}
/// <summary>
/// Returns true iff this equals rhs component-wise.
/// </summary>
public static bool operator ==(cmat3x4 lhs, cmat3x4 rhs) => lhs.Equals(rhs);
/// <summary>
/// Returns true iff this does not equal rhs (component-wise).
/// </summary>
public static bool operator !=(cmat3x4 lhs, cmat3x4 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) ^ m02.GetHashCode()) * 397) ^ m03.GetHashCode()) * 397) ^ m10.GetHashCode()) * 397) ^ m11.GetHashCode()) * 397) ^ m12.GetHashCode()) * 397) ^ m13.GetHashCode()) * 397) ^ m20.GetHashCode()) * 397) ^ m21.GetHashCode()) * 397) ^ m22.GetHashCode()) * 397) ^ m23.GetHashCode();
}
}
/// <summary>
/// Returns a transposed version of this matrix.
/// </summary>
public cmat4x3 Transposed => new cmat4x3(m00, m10, m20, m01, m11, m21, m02, m12, m22, m03, m13, m23);
/// <summary>
/// Returns the euclidean length of this matrix.
/// </summary>
public double Length => (double)Math.Sqrt(((((m00.LengthSqr() + m01.LengthSqr()) + m02.LengthSqr()) + ((m03.LengthSqr() + m10.LengthSqr()) + m11.LengthSqr())) + (((m12.LengthSqr() + m13.LengthSqr()) + m20.LengthSqr()) + ((m21.LengthSqr() + m22.LengthSqr()) + m23.LengthSqr()))));
/// <summary>
/// Returns the squared euclidean length of this matrix.
/// </summary>
public double LengthSqr => ((((m00.LengthSqr() + m01.LengthSqr()) + m02.LengthSqr()) + ((m03.LengthSqr() + m10.LengthSqr()) + m11.LengthSqr())) + (((m12.LengthSqr() + m13.LengthSqr()) + m20.LengthSqr()) + ((m21.LengthSqr() + m22.LengthSqr()) + m23.LengthSqr())));
/// <summary>
/// Returns the sum of all fields.
/// </summary>
public Complex Sum => ((((m00 + m01) + m02) + ((m03 + m10) + m11)) + (((m12 + m13) + m20) + ((m21 + m22) + m23)));
/// <summary>
/// Returns the euclidean norm of this matrix.
/// </summary>
public double Norm => (double)Math.Sqrt(((((m00.LengthSqr() + m01.LengthSqr()) + m02.LengthSqr()) + ((m03.LengthSqr() + m10.LengthSqr()) + m11.LengthSqr())) + (((m12.LengthSqr() + m13.LengthSqr()) + m20.LengthSqr()) + ((m21.LengthSqr() + m22.LengthSqr()) + m23.LengthSqr()))));
/// <summary>
/// Returns the one-norm of this matrix.
/// </summary>
public double Norm1 => ((((m00.Magnitude + m01.Magnitude) + m02.Magnitude) + ((m03.Magnitude + m10.Magnitude) + m11.Magnitude)) + (((m12.Magnitude + m13.Magnitude) + m20.Magnitude) + ((m21.Magnitude + m22.Magnitude) + m23.Magnitude)));
/// <summary>
/// Returns the two-norm of this matrix.
/// </summary>
public double Norm2 => (double)Math.Sqrt(((((m00.LengthSqr() + m01.LengthSqr()) + m02.LengthSqr()) + ((m03.LengthSqr() + m10.LengthSqr()) + m11.LengthSqr())) + (((m12.LengthSqr() + m13.LengthSqr()) + m20.LengthSqr()) + ((m21.LengthSqr() + m22.LengthSqr()) + m23.LengthSqr()))));
/// <summary>
/// Returns the max-norm of this matrix.
/// </summary>
public Complex NormMax => Math.Max(Math.Max(Math.Max(Math.Max(Math.Max(Math.Max(Math.Max(Math.Max(Math.Max(Math.Max(Math.Max(m00.Magnitude, m01.Magnitude), m02.Magnitude), m03.Magnitude), m10.Magnitude), m11.Magnitude), m12.Magnitude), m13.Magnitude), m20.Magnitude), m21.Magnitude), m22.Magnitude), m23.Magnitude);
/// <summary>
/// Returns the p-norm of this matrix.
/// </summary>
public double NormP(double p) => Math.Pow(((((Math.Pow((double)m00.Magnitude, p) + Math.Pow((double)m01.Magnitude, p)) + Math.Pow((double)m02.Magnitude, p)) + ((Math.Pow((double)m03.Magnitude, p) + Math.Pow((double)m10.Magnitude, p)) + Math.Pow((double)m11.Magnitude, p))) + (((Math.Pow((double)m12.Magnitude, p) + Math.Pow((double)m13.Magnitude, p)) + Math.Pow((double)m20.Magnitude, p)) + ((Math.Pow((double)m21.Magnitude, p) + Math.Pow((double)m22.Magnitude, p)) + Math.Pow((double)m23.Magnitude, p)))), 1 / p);
/// <summary>
/// Executes a matrix-matrix-multiplication cmat3x4 * cmat2x3 -> cmat2x4.
/// </summary>
public static cmat2x4 operator*(cmat3x4 lhs, cmat2x3 rhs) => new cmat2x4(((lhs.m00 * rhs.m00 + lhs.m10 * rhs.m01) + lhs.m20 * rhs.m02), ((lhs.m01 * rhs.m00 + lhs.m11 * rhs.m01) + lhs.m21 * rhs.m02), ((lhs.m02 * rhs.m00 + lhs.m12 * rhs.m01) + lhs.m22 * rhs.m02), ((lhs.m03 * rhs.m00 + lhs.m13 * rhs.m01) + lhs.m23 * rhs.m02), ((lhs.m00 * rhs.m10 + lhs.m10 * rhs.m11) + lhs.m20 * rhs.m12), ((lhs.m01 * rhs.m10 + lhs.m11 * rhs.m11) + lhs.m21 * rhs.m12), ((lhs.m02 * rhs.m10 + lhs.m12 * rhs.m11) + lhs.m22 * rhs.m12), ((lhs.m03 * rhs.m10 + lhs.m13 * rhs.m11) + lhs.m23 * rhs.m12));
/// <summary>
/// Executes a matrix-matrix-multiplication cmat3x4 * cmat3 -> cmat3x4.
/// </summary>
public static cmat3x4 operator*(cmat3x4 lhs, cmat3 rhs) => new cmat3x4(((lhs.m00 * rhs.m00 + lhs.m10 * rhs.m01) + lhs.m20 * rhs.m02), ((lhs.m01 * rhs.m00 + lhs.m11 * rhs.m01) + lhs.m21 * rhs.m02), ((lhs.m02 * rhs.m00 + lhs.m12 * rhs.m01) + lhs.m22 * rhs.m02), ((lhs.m03 * rhs.m00 + lhs.m13 * rhs.m01) + lhs.m23 * rhs.m02), ((lhs.m00 * rhs.m10 + lhs.m10 * rhs.m11) + lhs.m20 * rhs.m12), ((lhs.m01 * rhs.m10 + lhs.m11 * rhs.m11) + lhs.m21 * rhs.m12), ((lhs.m02 * rhs.m10 + lhs.m12 * rhs.m11) + lhs.m22 * rhs.m12), ((lhs.m03 * rhs.m10 + lhs.m13 * rhs.m11) + lhs.m23 * rhs.m12), ((lhs.m00 * rhs.m20 + lhs.m10 * rhs.m21) + lhs.m20 * rhs.m22), ((lhs.m01 * rhs.m20 + lhs.m11 * rhs.m21) + lhs.m21 * rhs.m22), ((lhs.m02 * rhs.m20 + lhs.m12 * rhs.m21) + lhs.m22 * rhs.m22), ((lhs.m03 * rhs.m20 + lhs.m13 * rhs.m21) + lhs.m23 * rhs.m22));
/// <summary>
/// Executes a matrix-matrix-multiplication cmat3x4 * cmat4x3 -> cmat4.
/// </summary>
public static cmat4 operator*(cmat3x4 lhs, cmat4x3 rhs) => new cmat4(((lhs.m00 * rhs.m00 + lhs.m10 * rhs.m01) + lhs.m20 * rhs.m02), ((lhs.m01 * rhs.m00 + lhs.m11 * rhs.m01) + lhs.m21 * rhs.m02), ((lhs.m02 * rhs.m00 + lhs.m12 * rhs.m01) + lhs.m22 * rhs.m02), ((lhs.m03 * rhs.m00 + lhs.m13 * rhs.m01) + lhs.m23 * rhs.m02), ((lhs.m00 * rhs.m10 + lhs.m10 * rhs.m11) + lhs.m20 * rhs.m12), ((lhs.m01 * rhs.m10 + lhs.m11 * rhs.m11) + lhs.m21 * rhs.m12), ((lhs.m02 * rhs.m10 + lhs.m12 * rhs.m11) + lhs.m22 * rhs.m12), ((lhs.m03 * rhs.m10 + lhs.m13 * rhs.m11) + lhs.m23 * rhs.m12), ((lhs.m00 * rhs.m20 + lhs.m10 * rhs.m21) + lhs.m20 * rhs.m22), ((lhs.m01 * rhs.m20 + lhs.m11 * rhs.m21) + lhs.m21 * rhs.m22), ((lhs.m02 * rhs.m20 + lhs.m12 * rhs.m21) + lhs.m22 * rhs.m22), ((lhs.m03 * rhs.m20 + lhs.m13 * rhs.m21) + lhs.m23 * rhs.m22), ((lhs.m00 * rhs.m30 + lhs.m10 * rhs.m31) + lhs.m20 * rhs.m32), ((lhs.m01 * rhs.m30 + lhs.m11 * rhs.m31) + lhs.m21 * rhs.m32), ((lhs.m02 * rhs.m30 + lhs.m12 * rhs.m31) + lhs.m22 * rhs.m32), ((lhs.m03 * rhs.m30 + lhs.m13 * rhs.m31) + lhs.m23 * rhs.m32));
/// <summary>
/// Executes a matrix-vector-multiplication.
/// </summary>
public static cvec4 operator*(cmat3x4 m, cvec3 v) => new cvec4(((m.m00 * v.x + m.m10 * v.y) + m.m20 * v.z), ((m.m01 * v.x + m.m11 * v.y) + m.m21 * v.z), ((m.m02 * v.x + m.m12 * v.y) + m.m22 * v.z), ((m.m03 * v.x + m.m13 * v.y) + m.m23 * v.z));
/// <summary>
/// Executes a component-wise * (multiply).
/// </summary>
public static cmat3x4 CompMul(cmat3x4 A, cmat3x4 B) => new cmat3x4(A.m00 * B.m00, A.m01 * B.m01, A.m02 * B.m02, A.m03 * B.m03, A.m10 * B.m10, A.m11 * B.m11, A.m12 * B.m12, A.m13 * B.m13, A.m20 * B.m20, A.m21 * B.m21, A.m22 * B.m22, A.m23 * B.m23);
/// <summary>
/// Executes a component-wise / (divide).
/// </summary>
public static cmat3x4 CompDiv(cmat3x4 A, cmat3x4 B) => new cmat3x4(A.m00 / B.m00, A.m01 / B.m01, A.m02 / B.m02, A.m03 / B.m03, A.m10 / B.m10, A.m11 / B.m11, A.m12 / B.m12, A.m13 / B.m13, A.m20 / B.m20, A.m21 / B.m21, A.m22 / B.m22, A.m23 / B.m23);
/// <summary>
/// Executes a component-wise + (add).
/// </summary>
public static cmat3x4 CompAdd(cmat3x4 A, cmat3x4 B) => new cmat3x4(A.m00 + B.m00, A.m01 + B.m01, A.m02 + B.m02, A.m03 + B.m03, A.m10 + B.m10, A.m11 + B.m11, A.m12 + B.m12, A.m13 + B.m13, A.m20 + B.m20, A.m21 + B.m21, A.m22 + B.m22, A.m23 + B.m23);
/// <summary>
/// Executes a component-wise - (subtract).
/// </summary>
public static cmat3x4 CompSub(cmat3x4 A, cmat3x4 B) => new cmat3x4(A.m00 - B.m00, A.m01 - B.m01, A.m02 - B.m02, A.m03 - B.m03, A.m10 - B.m10, A.m11 - B.m11, A.m12 - B.m12, A.m13 - B.m13, A.m20 - B.m20, A.m21 - B.m21, A.m22 - B.m22, A.m23 - B.m23);
/// <summary>
/// Executes a component-wise + (add).
/// </summary>
public static cmat3x4 operator+(cmat3x4 lhs, cmat3x4 rhs) => new cmat3x4(lhs.m00 + rhs.m00, lhs.m01 + rhs.m01, lhs.m02 + rhs.m02, lhs.m03 + rhs.m03, lhs.m10 + rhs.m10, lhs.m11 + rhs.m11, lhs.m12 + rhs.m12, lhs.m13 + rhs.m13, lhs.m20 + rhs.m20, lhs.m21 + rhs.m21, lhs.m22 + rhs.m22, lhs.m23 + rhs.m23);
/// <summary>
/// Executes a component-wise + (add) with a scalar.
/// </summary>
public static cmat3x4 operator+(cmat3x4 lhs, Complex rhs) => new cmat3x4(lhs.m00 + rhs, lhs.m01 + rhs, lhs.m02 + rhs, lhs.m03 + rhs, lhs.m10 + rhs, lhs.m11 + rhs, lhs.m12 + rhs, lhs.m13 + rhs, lhs.m20 + rhs, lhs.m21 + rhs, lhs.m22 + rhs, lhs.m23 + rhs);
/// <summary>
/// Executes a component-wise + (add) with a scalar.
/// </summary>
public static cmat3x4 operator+(Complex lhs, cmat3x4 rhs) => new cmat3x4(lhs + rhs.m00, lhs + rhs.m01, lhs + rhs.m02, lhs + rhs.m03, lhs + rhs.m10, lhs + rhs.m11, lhs + rhs.m12, lhs + rhs.m13, lhs + rhs.m20, lhs + rhs.m21, lhs + rhs.m22, lhs + rhs.m23);
/// <summary>
/// Executes a component-wise - (subtract).
/// </summary>
public static cmat3x4 operator-(cmat3x4 lhs, cmat3x4 rhs) => new cmat3x4(lhs.m00 - rhs.m00, lhs.m01 - rhs.m01, lhs.m02 - rhs.m02, lhs.m03 - rhs.m03, lhs.m10 - rhs.m10, lhs.m11 - rhs.m11, lhs.m12 - rhs.m12, lhs.m13 - rhs.m13, lhs.m20 - rhs.m20, lhs.m21 - rhs.m21, lhs.m22 - rhs.m22, lhs.m23 - rhs.m23);
/// <summary>
/// Executes a component-wise - (subtract) with a scalar.
/// </summary>
public static cmat3x4 operator-(cmat3x4 lhs, Complex rhs) => new cmat3x4(lhs.m00 - rhs, lhs.m01 - rhs, lhs.m02 - rhs, lhs.m03 - rhs, lhs.m10 - rhs, lhs.m11 - rhs, lhs.m12 - rhs, lhs.m13 - rhs, lhs.m20 - rhs, lhs.m21 - rhs, lhs.m22 - rhs, lhs.m23 - rhs);
/// <summary>
/// Executes a component-wise - (subtract) with a scalar.
/// </summary>
public static cmat3x4 operator-(Complex lhs, cmat3x4 rhs) => new cmat3x4(lhs - rhs.m00, lhs - rhs.m01, lhs - rhs.m02, lhs - rhs.m03, lhs - rhs.m10, lhs - rhs.m11, lhs - rhs.m12, lhs - rhs.m13, lhs - rhs.m20, lhs - rhs.m21, lhs - rhs.m22, lhs - rhs.m23);
/// <summary>
/// Executes a component-wise / (divide) with a scalar.
/// </summary>
public static cmat3x4 operator/(cmat3x4 lhs, Complex rhs) => new cmat3x4(lhs.m00 / rhs, lhs.m01 / rhs, lhs.m02 / rhs, lhs.m03 / rhs, lhs.m10 / rhs, lhs.m11 / rhs, lhs.m12 / rhs, lhs.m13 / rhs, lhs.m20 / rhs, lhs.m21 / rhs, lhs.m22 / rhs, lhs.m23 / rhs);
/// <summary>
/// Executes a component-wise / (divide) with a scalar.
/// </summary>
public static cmat3x4 operator/(Complex lhs, cmat3x4 rhs) => new cmat3x4(lhs / rhs.m00, lhs / rhs.m01, lhs / rhs.m02, lhs / rhs.m03, lhs / rhs.m10, lhs / rhs.m11, lhs / rhs.m12, lhs / rhs.m13, lhs / rhs.m20, lhs / rhs.m21, lhs / rhs.m22, lhs / rhs.m23);
/// <summary>
/// Executes a component-wise * (multiply) with a scalar.
/// </summary>
public static cmat3x4 operator*(cmat3x4 lhs, Complex rhs) => new cmat3x4(lhs.m00 * rhs, lhs.m01 * rhs, lhs.m02 * rhs, lhs.m03 * rhs, lhs.m10 * rhs, lhs.m11 * rhs, lhs.m12 * rhs, lhs.m13 * rhs, lhs.m20 * rhs, lhs.m21 * rhs, lhs.m22 * rhs, lhs.m23 * rhs);
/// <summary>
/// Executes a component-wise * (multiply) with a scalar.
/// </summary>
public static cmat3x4 operator*(Complex lhs, cmat3x4 rhs) => new cmat3x4(lhs * rhs.m00, lhs * rhs.m01, lhs * rhs.m02, lhs * rhs.m03, lhs * rhs.m10, lhs * rhs.m11, lhs * rhs.m12, lhs * rhs.m13, lhs * rhs.m20, lhs * rhs.m21, lhs * rhs.m22, lhs * rhs.m23);
}
}