-
Notifications
You must be signed in to change notification settings - Fork 1
/
ComplexMatrixF.java
845 lines (780 loc) · 29.9 KB
/
ComplexMatrixF.java
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
843
844
845
/*
* Copyright 2020, 2024 Stefan Zobel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.jamu.matrix;
import net.frobenius.ComputationTruncatedException;
import net.frobenius.NotConvergedException;
import net.jamu.complex.Zf;
/**
* A {@code ComplexMatrixF} is a dense matrix of single precision complex
* numbers expressed as an array of primitive floats with column-major storage
* layout. The addressing is zero based. All operations throw a
* {@code NullPointerException} if any of the method arguments is {@code null}.
*/
public interface ComplexMatrixF extends MatrixDimensions, ComplexMatrixFConduct {
/**
* Get the single element as a scalar if this matrix is 1-by-1.
*
* @return the single element as a scalar if this matrix is 1-by-1
* @throws IllegalStateException
* if this matrix is not 1-by-1
*/
Zf toScalar();
/**
* {@code A = alpha * A}
*
* @param alphar
* real part of the scaling factor
* @param alphai
* imaginary part of the scaling factor
* @return {@code A}
*/
ComplexMatrixF scaleInplace(float alphar, float alphai);
/**
* {@code B = alpha * A}
*
* @param alphar
* real part of the scaling factor
* @param alphai
* imaginary part of the scaling factor
* @param B
* output matrix
* @return {@code B}
*/
ComplexMatrixF scale(float alphar, float alphai, ComplexMatrixF B);
/**
* Stores <code>AH = A<sup>*</sup></code> (i.e., the conjugate transpose of
* {@code A}) in {@code AH}.
*
* @param AH
* output matrix (mutated)
* @return {@code AH}
*/
ComplexMatrixF conjTrans(ComplexMatrixF AH);
/**
* Stores <code>AT = A<sup>T</sup></code> (i.e., the transpose of {@code A})
* in {@code AT}.
*
* @param AT
* output matrix (mutated)
* @return {@code AT}
*/
ComplexMatrixF trans(ComplexMatrixF AT);
/**
* {@code A = A + B}
*
* @param B
* the matrix to be added to this matrix
* @return {@code A}
*/
ComplexMatrixF addInplace(ComplexMatrixF B);
/**
* {@code A = A + alpha * B}
*
* @param alphar
* real part of the scaling factor for {@code B}
* @param alphai
* imaginary part of the scaling factor for {@code B}
* @param B
* matrix to be added to this matrix (after scaling)
* @return {@code A}
*/
ComplexMatrixF addInplace(float alphar, float alphai, ComplexMatrixF B);
/**
* {@code C = A + B}
*
* @param B
* matrix to be added to this matrix
* @param C
* output matrix for the result
* @return {@code C}
*/
ComplexMatrixF add(ComplexMatrixF B, ComplexMatrixF C);
/**
* {@code C = A + alpha * B}
*
* @param alphar
* real part of the scaling factor for {@code B}
* @param alphai
* imaginary part of the scaling factor for {@code B}
* @param B
* matrix to be added to this matrix (after scaling)
* @param C
* output matrix for the result
* @return {@code C}
*/
ComplexMatrixF add(float alphar, float alphai, ComplexMatrixF B, ComplexMatrixF C);
/**
* {@code C = A * B}
*
* @param B
* matrix to be multiplied from the right
* @param C
* output matrix for the result of the multiplication
* @return {@code C}
*/
ComplexMatrixF mult(ComplexMatrixF B, ComplexMatrixF C);
/**
* {@code C = alpha * A * B}
*
* @param alphar
* real part of the scaling factor for the multiplication
* @param alphai
* imaginary part of the scaling factor for the multiplication
* @param B
* matrix to be multiplied from the right
* @param C
* output matrix for the result of the multiplication
* @return {@code C}
*/
ComplexMatrixF mult(float alphar, float alphai, ComplexMatrixF B, ComplexMatrixF C);
/**
* {@code C = A * B + C}. On exit, the matrix {@code C} is overwritten by
* the result of the operation.
*
* @param B
* matrix to be multiplied from the right
* @param C
* the matrix to add on input, contains the result of the
* operation on output
* @return {@code C}
*/
ComplexMatrixF multAdd(ComplexMatrixF B, ComplexMatrixF C);
/**
* {@code C = alpha * A * B + C}. On exit, the matrix {@code C} is
* overwritten by the result of the operation.
*
* @param alphar
* real part of the scaling factor for the multiplication
* @param alphai
* imaginary part of the scaling factor for the multiplication
* @param B
* matrix to be multiplied from the right
* @param C
* the matrix to add on input, contains the result of the
* operation on output
* @return {@code C}
*/
ComplexMatrixF multAdd(float alphar, float alphai, ComplexMatrixF B, ComplexMatrixF C);
/**
* <code>C = A<sup>*</sup> * B<sup>*</sup></code>
*
* @param B
* matrix whose conjugate transpose is to be multiplied from the
* right
* @param C
* output matrix for the result of the multiplication
* @return {@code C}
*/
ComplexMatrixF conjTransABmult(ComplexMatrixF B, ComplexMatrixF C);
/**
* <code>C = alpha * A<sup>*</sup> * B<sup>*</sup></code>
*
* @param alphar
* real part of the scaling factor for the multiplication
* @param alphai
* imaginary part of the scaling factor for the multiplication
* @param B
* matrix whose conjugate transpose is to be multiplied from the
* right
* @param C
* output matrix for the result of the multiplication
* @return {@code C}
*/
ComplexMatrixF conjTransABmult(float alphar, float alphai, ComplexMatrixF B, ComplexMatrixF C);
/**
* <code>C = A<sup>*</sup> * B</code>
*
* @param B
* matrix to be multiplied from the right
* @param C
* output matrix for the result of the multiplication
* @return {@code C}
*/
ComplexMatrixF conjTransAmult(ComplexMatrixF B, ComplexMatrixF C);
/**
* <code>C = alpha * A<sup>*</sup> * B</code>
*
* @param alphar
* real part of the scaling factor for the multiplication
* @param alphai
* imaginary part of the scaling factor for the multiplication
* @param B
* matrix to be multiplied from the right
* @param C
* output matrix for the result of the multiplication
* @return {@code C}
*/
ComplexMatrixF conjTransAmult(float alphar, float alphai, ComplexMatrixF B, ComplexMatrixF C);
/**
* <code>C = A * B<sup>*</sup></code>
*
* @param B
* matrix whose conjugate transpose is to be multiplied from the
* right
* @param C
* output matrix for the result of the multiplication
* @return {@code C}
*/
ComplexMatrixF conjTransBmult(ComplexMatrixF B, ComplexMatrixF C);
/**
* <code>C = alpha * A * B<sup>*</sup></code>
*
* @param alphar
* real part of the scaling factor for the multiplication
* @param alphai
* imaginary part of the scaling factor for the multiplication
* @param B
* matrix whose conjugate transpose is to be multiplied from the
* right
* @param C
* output matrix for the result of the multiplication
* @return {@code C}
*/
ComplexMatrixF conjTransBmult(float alphar, float alphai, ComplexMatrixF B, ComplexMatrixF C);
/**
* <code>C = A<sup>*</sup> * B<sup>*</sup> + C</code>. On exit, the matrix
* {@code C} is overwritten by the result of the operation.
*
* @param B
* matrix whose conjugate transpose is to be multiplied from the
* right
* @param C
* the matrix to add on input, contains the result of the
* operation on output
* @return {@code C}
*/
ComplexMatrixF conjTransABmultAdd(ComplexMatrixF B, ComplexMatrixF C);
/**
* <code>C = alpha * A<sup>*</sup> * B<sup>*</sup> + C</code>. On exit, the
* matrix {@code C} is overwritten by the result of the operation.
*
* @param alphar
* real part of the scaling factor for the multiplication
* @param alphai
* imaginary part of the scaling factor for the multiplication
* @param B
* matrix whose conjugate transpose is to be multiplied from the
* right
* @param C
* the matrix to add on input, contains the result of the
* operation on output
* @return {@code C}
*/
ComplexMatrixF conjTransABmultAdd(float alphar, float alphai, ComplexMatrixF B, ComplexMatrixF C);
/**
* <code>C = A<sup>*</sup> * B + C</code>. On exit, the matrix {@code C} is
* overwritten by the result of the operation.
*
* @param B
* matrix to be multiplied from the right
* @param C
* the matrix to add on input, contains the result of the
* operation on output
* @return {@code C}
*/
ComplexMatrixF conjTransAmultAdd(ComplexMatrixF B, ComplexMatrixF C);
/**
* <code>C = alpha * A<sup>*</sup> * B + C</code>. On exit, the matrix
* {@code C} is overwritten by the result of the operation.
*
* @param alphar
* real part of the scaling factor for the multiplication
* @param alphai
* imaginary part of the scaling factor for the multiplication
* @param B
* matrix to be multiplied from the right
* @param C
* the matrix to add on input, contains the result of the
* operation on output
* @return {@code C}
*/
ComplexMatrixF conjTransAmultAdd(float alphar, float alphai, ComplexMatrixF B, ComplexMatrixF C);
/**
* <code>C = A * B<sup>*</sup> + C</code>. On exit, the matrix {@code C} is
* overwritten by the result of the operation.
*
* @param B
* matrix whose conjugate transpose is to be multiplied from the
* right
* @param C
* the matrix to add on input, contains the result of the
* operation on output
* @return {@code C}
*/
ComplexMatrixF conjTransBmultAdd(ComplexMatrixF B, ComplexMatrixF C);
/**
* <code>C = alpha * A * B<sup>*</sup> + C</code>. On exit, the matrix
* {@code C} is overwritten by the result of the operation.
*
* @param alphar
* real part of the scaling factor for the multiplication
* @param alphai
* imaginary part of the scaling factor for the multiplication
* @param B
* matrix whose conjugate transpose is to be multiplied from the
* right
* @param C
* the matrix to add on input, contains the result of the
* operation on output
* @return {@code C}
*/
ComplexMatrixF conjTransBmultAdd(float alphar, float alphai, ComplexMatrixF B, ComplexMatrixF C);
/**
* Get a newly created copy of this matrix.
*
* @return fresh copy of this matrix
*/
ComplexMatrixF copy();
/**
* Set all elements of this matrix to {@code 0.0f + i * 0.0f} mutating this
* matrix.
*
* @return this matrix (mutated)
*/
ComplexMatrixF zeroInplace();
/**
* Copy the {@code other} matrix into this matrix (mutating this matrix)
* where the dimensions of {@code other} and {@code this} must be the same.
*
* @param other
* matrix whose elements should be copied into this matrix
* @return this matrix (mutated)
*/
ComplexMatrixF setInplace(ComplexMatrixF other);
/**
* Overwrite the content of the column indexed by {@code colIdx} with the
* content of the column vector {@code colVector} where {@code colVector}
* must have dimension {@code this.numRows() x 1}.
*
* @param colIdx
* index of the column that will be overwritten by the content of
* {@code colVector}
* @param colVector
* a column vector that has the same number of rows as this
* matrix
* @return this matrix (mutated)
* @since 1.4.4
*/
ComplexMatrixF setColumnInplace(int colIdx, ComplexMatrixF colVector);
/**
* Let {@code this} be a m-by-n matrix and let {@code B} be a j-by-k matrix.
* Set the entries on and above the main diagonal in {@code this} matrix
* from the corresponding entries of the {@code B} matrix and set the
* entries below the main diagonal in {@code this} matrix to zero (mutating
* {@code this} matrix).
* <p>
* The dimensions of {@code B} must satisfy the conditions {@code k >= n}
* ({@code B} must have at least as many columns as {@code this} matrix) and
* {@code j >= min(m, n)} ({@code B} must have at least as many rows as the
* lesser of the number of rows and columns of {@code this} matrix).
*
* @param B
* matrix whose corresponding entries are copied on and above the
* main diagonal of {@code this} matrix
* @return this matrix (mutated)
*/
ComplexMatrixF setInplaceUpperTrapezoidal(ComplexMatrixF B);
/**
* Let {@code this} be a m-by-n matrix and let {@code B} be a j-by-k matrix.
* Set the entries on and below the main diagonal in {@code this} matrix
* from the corresponding entries of the {@code B} matrix and set the
* entries above the main diagonal in {@code this} matrix to zero (mutating
* {@code this} matrix).
* <p>
* The dimensions of {@code B} must satisfy the conditions {@code j >= m}
* ({@code B} must have at least as many rows as {@code this} matrix) and
* {@code k >= min(m, n)} ({@code B} must have at least as many columns as
* the lesser of the number of rows and columns of {@code this} matrix).
*
* @param B
* matrix whose corresponding entries are copied on and below the
* main diagonal of {@code this} matrix
* @return this matrix (mutated)
*/
ComplexMatrixF setInplaceLowerTrapezoidal(ComplexMatrixF B);
/**
* {@code A = alpha * B}
*
* @param alphar
* the real part of the scale factor for {@code B}
* @param alphai
* the imaginary part of the scale factor for {@code B}
* @param other
* matrix to be copied into this matrix after the scalar
* multiplication
* @return {@code A}
*/
ComplexMatrixF setInplace(float alphar, float alphai, ComplexMatrixF other);
/**
* Copy the matrix element at {@code (row, col)} into {@code out}.
*
* @param row
* row index, zero-based
* @param col
* column index, zero-based
*
* @param out
* receiver argument (mutated)
*/
void get(int row, int col, Zf out);
/**
* Get the matrix element at {@code (row, col)}.
*
* @param row
* row index, zero-based
* @param col
* column index, zero-based
* @return the matrix element at {@code (row, col)}
*/
Zf get(int row, int col);
/**
* Set the matrix element at {@code (row, col)} to {@code val} mutating this
* matrix.
*
* @param row
* row index, zero-based
* @param col
* column index, zero-based
* @param valr
* the real part of the new value
* @param vali
* the imaginary part of the new value
* @return this matrix (mutated)
*/
ComplexMatrixF set(int row, int col, float valr, float vali);
/**
* Add {@code val} to the matrix element at {@code (row, col)} mutating this
* matrix.
*
* @param row
* row index, zero-based
* @param col
* column index, zero-based
* @param valr
* the real part of the value to add to the element at
* {@code (row, col)}
* @param vali
* the imaginary part of the value to add to the element at
* {@code (row, col)}
* @return this matrix (mutated)
*/
ComplexMatrixF add(int row, int col, float valr, float vali);
/**
* Copy a submatrix of this matrix into {@code B}.
*
* @param r0
* initial row index (left upper corner) in this matrix
* @param c0
* initial col index (left upper corner) in this matrix
* @param r1
* last row index (right lower corner) in this matrix
* @param c1
* last col index (right lower corner) in this matrix
* @param B
* matrix of dimension at least
* {@code (r1 - r0 + 1) x (c1 - c0 + 1)}
* @param rb
* initial row index (left upper corner) in the matrix {@code B}
* @param cb
* initial col index (left upper corner) in the matrix {@code B}
* @return the submatrix {@code B}
*/
ComplexMatrixF submatrix(int r0, int c0, int r1, int c1, ComplexMatrixF B, int rb, int cb);
/**
* Set a submatrix from the values of matrix {@code B} extending from
* {@code (rb0, cb0)} to {@code (rb1, cb1)} (the upper left and lower right
* corner in {@code B} respectively) at position {@code (r0, c0)} in this
* matrix.
*
* @param r0
* initial row index (left upper corner) in this matrix
* @param c0
* initial col index (left upper corner) in this matrix
* @param rb0
* initial row index (left upper corner) in the matrix {@code B}
* @param cb0
* initial col index (left upper corner) in the matrix {@code B}
* @param rb1
* last row index (right lower corner) in the matrix {@code B}
* @param cb1
* last col index (right lower corner) in the matrix {@code B}
* @param B
* the matrix that holds the values to set in this matrix
* @return this matrix {@code A}
*/
ComplexMatrixF setSubmatrixInplace(int r0, int c0, ComplexMatrixF B, int rb0, int cb0, int rb1, int cb1);
/**
* Computes the solution ({@code X}) to a system of linear equations
* {@code A * X = B}, where {@code A} is either a {@code n x n} matrix and
* {@code X} and {@code B} are {@code n x r} matrices, or where {@code A} is
* a {@code n x m} and matrix {@code X} is a {@code m x r} matrix and
* {@code B} is a {@code n x r} matrix.
*
* @param B
* matrix with the same number of rows as this matrix {@code A},
* and the same number of columns as {@code X}
* @param X
* matrix with number of rows equal to the number of columns of
* this matrix {@code A}, and the same number of columns as
* {@code B}
* @return {@code X}, the solution of dimension either {@code n x r} (in the
* {@code n x n} case) or {@code m x r} (in the {@code m x n} case).
* @throws ComputationTruncatedException
* for exactly singular factors in the LU decomposition of a
* quadratic matrix or for a non-quadratic matrix that doesn't
* have full rank
*/
ComplexMatrixF solve(ComplexMatrixF B, ComplexMatrixF X);
/**
* Matrix inverse for quadratic matrices.
*
* @param inverse
* matrix where the inverse is stored. Must have the same
* dimension as this matrix
* @return the inverse matrix (i.e. the argument {@code inverse})
* @throws IllegalArgumentException
* if this matrix is not quadratic or if {@code inverse} has the
* wrong dimension
* @throws ComputationTruncatedException
* for exactly singular factors in the LU decomposition of this
* matrix
*/
ComplexMatrixF inv(ComplexMatrixF inverse);
/**
* Compute the Moore-Penrose pseudoinverse.
*
* @return the Moore-Penrose Pseudo-Inverse
* @throws NotConvergedException
* if the singular value decomposition did not converge
*/
ComplexMatrixF pseudoInv();
/**
* Computes the eigenvalue decomposition of this matrix if it is quadratic.
*
* @param full
* controls whether the (right) eigenvectors should be computed
* in addition (if {@code true}) or the eigenvalues only (if
* {@code false})
* @return the {@link EvdComplexF} of this matrix, either full or the
* eigenvalues only (if {@code full} is set to {@code false})
* @throws IllegalArgumentException
* if this matrix is not quadratic
* @throws ComputationTruncatedException
* if the QR decomposition failed to compute all eigenvalues
*/
EvdComplexF evd(boolean full);
/**
* Computes the {@code QR} decomposition of this matrix provided it has at
* least as many rows as columns.
*
* @return the {@link QrdComplexF} QR decomposition of this matrix
* @throws IllegalArgumentException
* if this matrix has less rows than columns
*/
QrdComplexF qrd();
/**
* Computes the {@code LU} decomposition of this matrix.
*
* @return the {@link LudComplexF} LU decomposition of this matrix
*/
LudComplexF lud();
/**
* Computes the matrix exponential <code>e<sup>A</sup></code> of this matrix
* if this matrix is a square matrix.
* <p>
* The algorithm uses the Taylor scaling and squaring method from "Bader,
* P.; Blanes, S.; Casas, F.: Computing the Matrix Exponential with an
* Optimized Taylor Polynomial Approximation. Mathematics 2019, 7, 1174."
*
* @return the matrix exponential (<code>e<sup>A</sup></code>) of this
* matrix
* @throws IllegalArgumentException
* if this matrix is not quadratic
*/
ComplexMatrixF expm();
/**
* Hadamard product {@code C = A} \u2218 {@code B} (also known as
* element-wise product) of this matrix (A) and B.
*
* @param B
* the matrix this matrix is multiplied with
* @param out
* output matrix for the result of the multiplication
* @return {@code out}
* @since 1.3.1
*/
ComplexMatrixF hadamard(ComplexMatrixF B, ComplexMatrixF out);
/**
* Computes the singular value decomposition of this matrix.
*
* @param full
* controls whether the full decomposition should be computed (if
* {@code true}) or the singular values only (if {@code false})
* @return the {@link SvdComplexF} of this matrix, either full or the
* singular values only (if {@code full} is set to {@code false})
* @throws NotConvergedException
* if the singular value decomposition did not converge
*/
SvdComplexF svd(boolean full);
/**
* Computes the economy singular value decomposition of this matrix.
*
* @return the {@link SvdEconComplexF} of this matrix
* @throws NotConvergedException
* if the singular value decomposition did not converge
*/
SvdEconComplexF svdEcon();
/**
* Convenience method that computes the singular values of this matrix (this
* is the same as calling {@code A.svd(false).getS();}).
*
* @return array containing the singular values in descending order
* @throws NotConvergedException
* if the singular value decomposition did not converge
* @since 1.2
*/
float[] singularValues();
/**
* Copy into a jagged array. Note that the length of the second dimension is
* {@code 2 x} {@link ComplexMatrixF#numColumns()} because each complex
* number requires two floats to represent the real and the imaginary part.
*
* @return this matrix converted to a jagged array
*/
float[][] toJaggedArray();
/**
* Frobenius norm
*
* @return sqrt of sum of squares of all elements
*/
float normF();
/**
* Induced 2-norm (a.k.a spectral norm or {@code l}<sub>2</sub> operator
* norm) which happens to correspond to the largest singular value.
*
* @return maximum singular value
* @throws NotConvergedException
* if the singular value decomposition did not converge
*/
float norm2();
/**
* Returns the largest absolute value of this matrix (i.e., the "max norm").
* Note that this norm is not submultiplicative.
*
* @return the largest absolute value of all elements
*/
float normMaxAbs();
/**
* Infinity norm (maximum absolute row sum)
*
* @return maximum absolute row sum
*/
float normInf();
/**
* 1-norm (maximum absolute column sum)
*
* @return maximum absolute column sum
*/
float norm1();
/**
* Matrix trace of a square matrix.
*
* @return sum of the diagonal elements
* @throws IllegalArgumentException
* if this matrix is not quadratic
*/
Zf trace();
/**
* Set all elements <code>|x<sub>ij</sub>| ≤ k * 2<sup>-24</sup></code>
* ({@code k} times the machine epsilon for floats) to {@code 0.0f} where
* {@code k} is a positive integer {@code >= 1}. Both the real and the
* imaginary parts are set to {@code 0.0f}.
*
* @param k
* positive integer {@code >= 1}
* @return this matrix zeroed in-place
* @throws IllegalArgumentException
* if {@code k < 1}
*/
ComplexMatrixF zeroizeSubEpsilonInplace(int k);
/**
* Set all elements that are either NaN, positive or negative infinity to
* the respective ersatz value provided by the {@code nanSurrogate},
* {@code posInfSurrogate} and {@code negInfSurrogate} arguments. This is a
* destructive operation that changes this matrix inplace.
*
* @param nanSurrogate
* the substitution value to use for NaN values
* @param posInfSurrogate
* the substitution value to use for positive infinity values
* @param negInfSurrogate
* the substitution value to use for negative infinity values
* @return this matrix changed inplace
*/
ComplexMatrixF sanitizeNonFiniteInplace(float nanSurrogate, float posInfSurrogate, float negInfSurrogate);
/**
* Set all elements that are NaN to the ersatz value provided by the
* {@code nanSurrogate} argument. This is a destructive operation that
* changes this matrix inplace.
*
* @param nanSurrogate
* the substitution value to use for NaN values
* @return this matrix changed inplace
*/
ComplexMatrixF sanitizeNaNInplace(float nanSurrogate);
/**
* Get the reference to the internal backing array without copying.
*
* @return the reference to the internal backing array
*/
float[] getArrayUnsafe();
/**
* Copy the matrix element {@code (row, col)} without bounds checking into
* {@code out}.
*
* @param row
* row index, zero-based
* @param col
* column index, zero-based
* @param out
* receiver argument (mutated)
*/
void getUnsafe(int row, int col, Zf out);
/**
* Get the matrix element {@code (row, col)} without bounds checking.
*
* @param row
* row index, zero-based
* @param col
* column index, zero-based
* @return the matrix element at {@code (row, col)}
*/
Zf getUnsafe(int row, int col);
/**
* Set the matrix element at {@code (row, col)} to {@code val} without
* bounds checking.
*
* @param row
* row index, zero-based
* @param col
* column index, zero-based
* @param valr
* real part of the new value
* @param vali
* imaginary part of the new value
*/
void setUnsafe(int row, int col, float valr, float vali);
}