-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmq.ijs
More file actions
1055 lines (956 loc) · 57.4 KB
/
mq.ijs
File metadata and controls
1055 lines (956 loc) · 57.4 KB
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
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
NB. Multiply a general matrix by a matrix with orthonormal
NB. rows or columns, which is represented in factored form
NB.
NB. unmlqxx Multiply a general matrix by a matrix with
NB. orthonormal rows, which is represented in
NB. factored form, as returned by gelqf
NB. unmqlxx Multiply a general matrix by a matrix with
NB. orthonormal columns, which is represented in
NB. factored form, as returned by geqlf
NB. unmqrxx Multiply a general matrix by a matrix with
NB. orthonormal columns, which is represented in
NB. factored form, as returned by geqrf
NB. unmrqxx Multiply a general matrix by a matrix with
NB. orthonormal rows, which is represented in
NB. factored form, as returned by gerqf
NB. unmlzxx Multiply a general matrix by a matrix with
NB. orthonormal rows, which is represented in
NB. factored form, as returned by tzlzf
NB. unmzlxx Multiply a general matrix by a matrix with
NB. orthonormal columns, which is represented in
NB. factored form, as returned by tzzlf
NB. unmzrxx Multiply a general matrix by a matrix with
NB. orthonormal columns, which is represented in
NB. factored form, as returned by tzzrf
NB. unmrzxx Multiply a general matrix by a matrix with
NB. orthonormal rows, which is represented in
NB. factored form, as returned by tzrzf
NB. unmhrxxx Multiply a general matrix by an unitary
NB. (orthogonal) matrix, which is represented in
NB. factored form, as returned by gehrdx
NB.
NB. testunmq Test unmxxxx by general matrix
NB. testunmz Test unmxxxx by trapezoidal matrix
NB. testunmhr Test unmhrxxx by square matrix
NB. testmq Adv. to make verb to test unmxxxxx by matrix
NB. of generator and shape given
NB.
NB. Copyright 2010,2011,2013,2017,2018,2020,2021,2023,2024,
NB. 2025,2026 Igor Zhuravlov
NB.
NB. This file is part of mt
NB.
NB. mt is free software: you can redistribute it and/or
NB. modify it under the terms of the GNU Lesser General
NB. Public License as published by the Free Software
NB. Foundation, either version 3 of the License, or (at your
NB. option) any later version.
NB.
NB. mt is distributed in the hope that it will be useful, but
NB. WITHOUT ANY WARRANTY; without even the implied warranty
NB. of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
NB. See the GNU Lesser General Public License for more
NB. details.
NB.
NB. You should have received a copy of the GNU Lesser General
NB. Public License along with mt. If not, see
NB. <http://www.gnu.org/licenses/>.
NB. =========================================================
NB. Configuration
coclass 'mt'
NB. =========================================================
NB. Local definitions
NB. ---------------------------------------------------------
NB. Blocked code constants
MQNB=: 32 NB. block size limit
NB. ---------------------------------------------------------
NB. Dyad Action Side Tran Syntax
NB. unml2ln Q * C left none eCprod=. Qf unml2ln (C, 0)
NB. unml2lc Q^H * C left ct eCprod=. Qf unml2lc (C, 0)
NB. unml2rn C * Q right none eCprod=. Qf unml2rn (C,.0)
NB. unml2rc C * Q^H right ct eCprod=. Qf unml2rc (C,.0)
NB. unm2lln Q * C left none eCprod=. Qf unm2lln (0, C)
NB. unm2llc Q^H * C left ct eCprod=. Qf unm2llc (0, C)
NB. unm2lrn C * Q right none eCprod=. Qf unm2lrn (0,.C)
NB. unm2lrc C * Q^H right ct eCprod=. Qf unm2lrc (0,.C)
NB. unm2rln Q * C left none eCprod=. Qf unm2rln (C, 0)
NB. unm2rlc Q^H * C left ct eCprod=. Qf unm2rlc (C, 0)
NB. unm2rrn C * Q right none eCprod=. Qf unm2rrn (C,.0)
NB. unm2rrc C * Q^H right ct eCprod=. Qf unm2rrc (C,.0)
NB. unmr2ln Q * C left none eCprod=. Qf unmr2ln (0, C)
NB. unmr2lc Q^H * C left ct eCprod=. Qf unmr2lc (0, C)
NB. unmr2rn C * Q right none eCprod=. Qf unmr2rn (0,.C)
NB. unmr2rc C * Q^H right ct eCprod=. Qf unmr2rc (0,.C)
NB.
NB. Description:
NB. Multiply a general matrix C, augmented by trash vector,
NB. by matrix Q. This is non-blocked version of algorithm
NB. where
NB. C - m×(n+1)-matrix or (m+1)×n-matrix to multiply
NB. Qf - unit trapezoidal matrix, it represents Q in
NB. factored form as returned by ge{lq,ql,qr,rq}2,
NB. and contains vectors Vtau[0:k-1]
NB. Q - unitary (orthogonal) matrix, which is defined
NB. as the product of elementary reflectors
NB. eCprod - the product of matrix Q and the augmented
NB. matrix C, trash vector is modified on exit
NB.
NB. Assertions (with appropriate comparison tolerance):
NB. ((((}: @unml2ln , &0)~ tru1 @({. ~ 0 _1 <./ @:+ $)) -: (mp~ (unglq~ <:@c)))~ 0 ?@$~ 0 _1 |.@:+ $) LQf
NB. ((((}: @unml2lc , &0)~ tru1 @({. ~ 0 _1 <./ @:+ $)) -: (mp~ ct@(unglq~ <:@c)))~ 0 ?@$~ 0 _1 |.@:+ $) LQf
NB. ((((}:"1@unml2rn ,. &0)~ tru1 @({. ~ 0 _1 <./ @:+ $)) -: (mp (unglq~ <:@c)))~ 0 ?@$~ 0 _1 + $) LQf
NB. ((((}:"1@unml2rc ,. &0)~ tru1 @({. ~ 0 _1 <./ @:+ $)) -: (mp ct@(unglq~ <:@c)))~ 0 ?@$~ 0 _1 + $) LQf
NB. ((((}. @unm2lln , ~&0)~ (tru1~ -~/@$)@({."1~ _1 0 -@(<./)@:+ $)) -: (mp~ (ungql~ <:@#)))~ 0 ?@$~ _1 0 + $) QfL
NB. ((((}. @unm2llc , ~&0)~ (tru1~ -~/@$)@({."1~ _1 0 -@(<./)@:+ $)) -: (mp~ ct@(ungql~ <:@#)))~ 0 ?@$~ _1 0 + $) QfL
NB. ((((}."1@unm2lrn ,.~&0)~ (tru1~ -~/@$)@({."1~ _1 0 -@(<./)@:+ $)) -: (mp (ungql~ <:@#)))~ 0 ?@$~ _1 0 |.@:+ $) QfL
NB. ((((}."1@unm2lrc ,.~&0)~ (tru1~ -~/@$)@({."1~ _1 0 -@(<./)@:+ $)) -: (mp ct@(ungql~ <:@#)))~ 0 ?@$~ _1 0 |.@:+ $) QfL
NB. ((((}: @unm2rln , &0)~ trl1 @({."1~ _1 0 <./ @:+ $)) -: (mp~ (ungqr~ <:@#)))~ 0 ?@$~ _1 0 + $) QfR
NB. ((((}: @unm2rlc , &0)~ trl1 @({."1~ _1 0 <./ @:+ $)) -: (mp~ ct@(ungqr~ <:@#)))~ 0 ?@$~ _1 0 + $) QfR
NB. ((((}:"1@unm2rrn ,. &0)~ trl1 @({."1~ _1 0 <./ @:+ $)) -: (mp (ungqr~ <:@#)))~ 0 ?@$~ _1 0 |.@:+ $) QfR
NB. ((((}:"1@unm2rrc ,. &0)~ trl1 @({."1~ _1 0 <./ @:+ $)) -: (mp ct@(ungqr~ <:@#)))~ 0 ?@$~ _1 0 |.@:+ $) QfR
NB. ((((}. @unmr2ln , ~&0)~ (trl1~ -~/@$)@({. ~ 0 _1 -@(<./)@:+ $)) -: (mp~ (ungrq~ <:@c)))~ 0 ?@$~ 0 _1 |.@:+ $) RQf
NB. ((((}. @unmr2lc , ~&0)~ (trl1~ -~/@$)@({. ~ 0 _1 -@(<./)@:+ $)) -: (mp~ ct@(ungrq~ <:@c)))~ 0 ?@$~ 0 _1 |.@:+ $) RQf
NB. ((((}."1@unmr2rn ,.~&0)~ (trl1~ -~/@$)@({. ~ 0 _1 -@(<./)@:+ $)) -: (mp (ungrq~ <:@c)))~ 0 ?@$~ 0 _1 + $) RQf
NB. ((((}."1@unmr2rc ,.~&0)~ (trl1~ -~/@$)@({. ~ 0 _1 -@(<./)@:+ $)) -: (mp ct@(ungrq~ <:@c)))~ 0 ?@$~ 0 _1 + $) RQf
NB.
NB. Notes:
NB. - input's and output's shapes are the same
NB. - unml2xx implement LAPACK's DORML2, ZUNML2
NB. - unm2lxx implement LAPACK's DORM2L, ZUNM2L
NB. - unm2rxx implement LAPACK's DORM2R, ZUNM2R
NB. - unmr2xx implement LAPACK's DORMR2, ZUNMR2
NB. - unm{l2,2l,2r,r2}{ln,lc,rn,rc} and
NB. unm{lq,ql,qr,rq}{ln,lc,rn,rc} respectively are
NB. topologic equivalents
unml2ln=: ((larflcfr&:>/@,~ (-@c <\ ,)@|. )~ <)^:(0 < #@[)
unml2lc=: ((larflnfr&:>/@,~ (-@c <\ ,) )~ <)^:(0 < #@[)
unml2rn=: ((larfrcfr&:>/@,~ (-@c <\ ,) )~ <)^:(0 < #@[)
unml2rc=: ((larfrnfr&:>/@,~ (-@c <\ ,)@|. )~ <)^:(0 < #@[)
unm2lln=: ((larflnbc&:>/@,~ (-@c <\ ,)@|.@|:)~ <)^:(0 < c@[)
unm2llc=: ((larflcbc&:>/@,~ (-@c <\ ,) @|:)~ <)^:(0 < c@[)
unm2lrn=: ((larfrnbc&:>/@,~ (-@c <\ ,) @|:)~ <)^:(0 < c@[)
unm2lrc=: ((larfrcbc&:>/@,~ (-@c <\ ,)@|.@|:)~ <)^:(0 < c@[)
unm2rln=: ((larflnfc&:>/@,~ (-@c <\ ,) @|:)~ <)^:(0 < c@[)
unm2rlc=: ((larflcfc&:>/@,~ (-@c <\ ,)@|.@|:)~ <)^:(0 < c@[)
unm2rrn=: ((larfrnfc&:>/@,~ (-@c <\ ,)@|.@|:)~ <)^:(0 < c@[)
unm2rrc=: ((larfrcfc&:>/@,~ (-@c <\ ,) @|:)~ <)^:(0 < c@[)
unmr2ln=: ((larflcbr&:>/@,~ (-@c <\ ,) )~ <)^:(0 < #@[)
unmr2lc=: ((larflnbr&:>/@,~ (-@c <\ ,)@|. )~ <)^:(0 < #@[)
unmr2rn=: ((larfrcbr&:>/@,~ (-@c <\ ,)@|. )~ <)^:(0 < #@[)
unmr2rc=: ((larfrnbr&:>/@,~ (-@c <\ ,) )~ <)^:(0 < #@[)
NB. ---------------------------------------------------------
NB. Dyad Action Side Tran Syntax
NB. unml3ln Z * C left none eCprod=. Zf unml3ln (0, C)
NB. unml3lc Z^H * C left ct eCprod=. Zf unml3lc (0, C)
NB. unml3rn C * Z right none eCprod=. Zf unml3rn (0,.C)
NB. unml3rc C * Z^H right ct eCprod=. Zf unml3rc (0,.C)
NB. unm3lln Z * C left none eCprod=. Zf unm3lln (C, 0)
NB. unm3llc Z^H * C left ct eCprod=. Zf unm3llc (C, 0)
NB. unm3lrn C * Z right none eCprod=. Zf unm3lrn (C,.0)
NB. unm3lrc C * Z^H right ct eCprod=. Zf unm3lrc (C,.0)
NB. unm3rln Z * C left none eCprod=. Zf unm3rln (0, C)
NB. unm3rlc Z^H * C left ct eCprod=. Zf unm3rlc (0, C)
NB. unm3rrn C * Z right none eCprod=. Zf unm3rrn (0,.C)
NB. unm3rrc C * Z^H right ct eCprod=. Zf unm3rrc (0,.C)
NB. unmr3ln Z * C left none eCprod=. Zf unmr3ln (C, 0)
NB. unmr3lc Z^H * C left ct eCprod=. Zf unmr3lc (C, 0)
NB. unmr3rn C * Z right none eCprod=. Zf unmr3rn (C,.0)
NB. unmr3rc C * Z^H right ct eCprod=. Zf unmr3rc (C,.0)
NB.
NB. Description:
NB. Multiply a general matrix C, augmented by trash vector,
NB. by matrix Z. This is non-blocked version of algorithm
NB. where
NB. C - m×(n+1)-matrix or (m+1)×n-matrix to multiply
NB. Zf - unit trapezoidal matrix, it represents Z in
NB. factored form as returned by tz{lz,zl,zr,rz}3,
NB. and contains vectors Vtau[0:k-1]
NB. Z - unitary (orthonormal) matrix which is defined
NB. as the product of elementary reflectors
NB. eCprod - the product of matrix Z and the augmented
NB. matrix C, trash vector is modified on exit
NB.
NB. Assertions (with appropriate comparison tolerance):
NB. ((((}. @unml3ln , ~&0)~ (idmat@[`(a: <@; liso4dhs@(_1 , [))}~ #)) -: (mp~ (unglz~ <:@c)))~ 0 ?@$~ 0 _1 |.@:+ $) LZf
NB. ((((}. @unml3lc , ~&0)~ (idmat@[`(a: <@; liso4dhs@(_1 , [))}~ #)) -: (mp~ ct@(unglz~ <:@c)))~ 0 ?@$~ 0 _1 |.@:+ $) LZf
NB. ((((}."1@unml3rn ,.~&0)~ (idmat@[`(a: <@; liso4dhs@(_1 , [))}~ #)) -: (mp (unglz~ <:@c)))~ 0 ?@$~ 0 _1 + $) LZf
NB. ((((}."1@unml3rc ,.~&0)~ (idmat@[`(a: <@; liso4dhs@(_1 , [))}~ #)) -: (mp ct@(unglz~ <:@c)))~ 0 ?@$~ 0 _1 + $) LZf
NB. ((((}: @unm3lln , &0)~ (idmat@[`( liso4dhs@( 0 , [))}~ c)) -: (mp~ (ungzl~ <:@#)))~ 0 ?@$~ _1 0 + $) ZfL
NB. ((((}: @unm3llc , &0)~ (idmat@[`( liso4dhs@( 0 , [))}~ c)) -: (mp~ ct@(ungzl~ <:@#)))~ 0 ?@$~ _1 0 + $) ZfL
NB. ((((}:"1@unm3lrn ,. &0)~ (idmat@[`( liso4dhs@( 0 , [))}~ c)) -: (mp (ungzl~ <:@#)))~ 0 ?@$~ _1 0 |.@:+ $) ZfL
NB. ((((}:"1@unm3lrc ,. &0)~ (idmat@[`( liso4dhs@( 0 , [))}~ c)) -: (mp ct@(ungzl~ <:@#)))~ 0 ?@$~ _1 0 |.@:+ $) ZfL
NB. ((((}. @unm3rln , ~&0)~ (idmat@[`( liso4dhs@(_1 , [))}~ c)) -: (mp~ (ungzr~ <:@#)))~ 0 ?@$~ _1 0 + $) ZfR
NB. ((((}. @unm3rlc , ~&0)~ (idmat@[`( liso4dhs@(_1 , [))}~ c)) -: (mp~ ct@(ungzr~ <:@#)))~ 0 ?@$~ _1 0 + $) ZfR
NB. ((((}."1@unm3rrn ,.~&0)~ (idmat@[`( liso4dhs@(_1 , [))}~ c)) -: (mp (ungzr~ <:@#)))~ 0 ?@$~ _1 0 |.@:+ $) ZfR
NB. ((((}."1@unm3rrc ,.~&0)~ (idmat@[`( liso4dhs@(_1 , [))}~ c)) -: (mp ct@(ungzr~ <:@#)))~ 0 ?@$~ _1 0 |.@:+ $) ZfR
NB. ((((}: @unmr3ln , &0)~ (idmat@[`(a: <@; liso4dhs@( 0 , [))}~ #)) -: (mp~ (ungrz~ <:@c)))~ 0 ?@$~ 0 _1 |.@:+ $) RZf
NB. ((((}: @unmr3lc , &0)~ (idmat@[`(a: <@; liso4dhs@( 0 , [))}~ #)) -: (mp~ ct@(ungrz~ <:@c)))~ 0 ?@$~ 0 _1 |.@:+ $) RZf
NB. ((((}:"1@unmr3rn ,. &0)~ (idmat@[`(a: <@; liso4dhs@( 0 , [))}~ #)) -: (mp (ungrz~ <:@c)))~ 0 ?@$~ 0 _1 + $) RZf
NB. ((((}:"1@unmr3rc ,. &0)~ (idmat@[`(a: <@; liso4dhs@( 0 , [))}~ #)) -: (mp ct@(ungrz~ <:@c)))~ 0 ?@$~ 0 _1 + $) RZf
NB.
NB. Notes:
NB. - input's and output's shapes are the same
NB. - unmr3xx implement LAPACK's DORMR3, ZUNMR3
NB. - unm{l3,3l,3r,r3}{ln,lc,rn,rc} and
NB. unm{lz,zl,zr,rz}{ln,lc,rn,rc} respectively are
NB. topologic equivalents
unml3ln=: ((larzlcfr&:>/@,~ (-@c <\ ,)@|. )~ <)^:(0 < #@[)
unml3lc=: ((larzlnfr&:>/@,~ (-@c <\ ,) )~ <)^:(0 < #@[)
unml3rn=: ((larzrcfr&:>/@,~ (-@c <\ ,) )~ <)^:(0 < #@[)
unml3rc=: ((larzrnfr&:>/@,~ (-@c <\ ,)@|. )~ <)^:(0 < #@[)
unm3lln=: ((larzlnbc&:>/@,~ (-@c <\ ,)@|.@|:)~ <)^:(0 < c@[)
unm3llc=: ((larzlcbc&:>/@,~ (-@c <\ ,) @|:)~ <)^:(0 < c@[)
unm3lrn=: ((larzrnbc&:>/@,~ (-@c <\ ,) @|:)~ <)^:(0 < c@[)
unm3lrc=: ((larzrcbc&:>/@,~ (-@c <\ ,)@|.@|:)~ <)^:(0 < c@[)
unm3rln=: ((larzlnfc&:>/@,~ (-@c <\ ,) @|:)~ <)^:(0 < c@[)
unm3rlc=: ((larzlcfc&:>/@,~ (-@c <\ ,)@|.@|:)~ <)^:(0 < c@[)
unm3rrn=: ((larzrnfc&:>/@,~ (-@c <\ ,)@|.@|:)~ <)^:(0 < c@[)
unm3rrc=: ((larzrcfc&:>/@,~ (-@c <\ ,) @|:)~ <)^:(0 < c@[)
unmr3ln=: ((larzlcbr&:>/@,~ (-@c <\ ,) )~ <)^:(0 < #@[)
unmr3lc=: ((larzlnbr&:>/@,~ (-@c <\ ,)@|. )~ <)^:(0 < #@[)
unmr3rn=: ((larzrcbr&:>/@,~ (-@c <\ ,)@|. )~ <)^:(0 < #@[)
unmr3rc=: ((larzrnbr&:>/@,~ (-@c <\ ,) )~ <)^:(0 < #@[)
NB. =========================================================
NB. Interface
NB. ---------------------------------------------------------
NB. Dyad Action Side Tran Syntax
NB. unmlqln Q * C left none B=. LQf unmlqln C
NB. unmlqlc Q^H * C left ct B=. LQf unmlqlc C
NB. unmlqrn C * Q right none B=. LQf unmlqrn C
NB. unmlqrc C * Q^H right ct B=. LQf unmlqrc C
NB.
NB. Description:
NB. Multiply a general matrix C by matrix Q, which is
NB. represented in factored form LQf as returned by gelqf
NB. where
NB. B,C - m×n-matrices
NB. LQf - n×(m+1)-matrix (ln,lc cases) or m×(n+1)-matrix
NB. (rn,rc), contains Qf, the output of gelqf
NB. Qf - k×(m+1)-matrix (ln,lc) or k×(n+1)-matrix (rn,rc),
NB. unit upper trapezoidal (unit diagonal is not
NB. stored), represents the Q in factored form
NB. Q - m×m-matrix (ln,lc) or n×n-matrix (rn,rc), unitary
NB. (orthogonal), which is defined as the product of
NB. k elementary reflectors H(i):
NB. Q = Π{H(i)',i=k-1:0}
NB. H(i) ≡ H(u(i),τ(i)) := I - u(i)' * τ(i) * u(i)
NB. k = min(m,n)
NB.
NB. Assertions (with appropriate comparison tolerance):
NB. ((unmlqln -: (mp~ (unglq~ <:@c))~) 0 ?@$~ 0 _1 |.@:+ $) LQf
NB. ((unmlqlc -: (mp~ ct@(unglq~ <:@c))~) 0 ?@$~ 0 _1 |.@:+ $) LQf
NB. ((unmlqrn -: (mp (unglq~ <:@c))~) 0 ?@$~ 0 _1 + $) LQf
NB. ((unmlqrc -: (mp ct@(unglq~ <:@c))~) 0 ?@$~ 0 _1 + $) LQf
NB.
NB. Notes:
NB. - implement LAPACK's DORMLQ, ZUNMLQ
NB. - unml2{ln,lc,rn,rc} and unmlq{ln,lc,rn,rc} respectively
NB. are topologic equivalents
unmlqln=: }: @(((unml2ln`((larfblcfr&:>/@,~ |.@:({."1)@(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ tru1 @({. ~ 0 _1 <./ @:+ $))~ , &0)`(i.@$@])@.(0 e. $@])
unmlqlc=: }: @(((unml2lc`((larfblnfr&:>/@,~ {."1 @(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ tru1 @({. ~ 0 _1 <./ @:+ $))~ , &0)`(i.@$@])@.(0 e. $@])
unmlqrn=: }:"1@(((unml2rn`((larfbrcfr&:>/@,~ {."1 @(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ tru1 @({. ~ 0 _1 <./ @:+ $))~ ,. &0)`(i.@$@])@.(0 e. $@])
unmlqrc=: }:"1@(((unml2rc`((larfbrnfr&:>/@,~ |.@:({."1)@(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ tru1 @({. ~ 0 _1 <./ @:+ $))~ ,. &0)`(i.@$@])@.(0 e. $@])
NB. ---------------------------------------------------------
NB. Dyad Action Side Tran Syntax
NB. unmqlln Q * C left none B=. QfL unmqlln C
NB. unmqllc Q^H * C left ct B=. QfL unmqllc C
NB. unmqlrn C * Q right none B=. QfL unmqlrn C
NB. unmqlrc C * Q^H right ct B=. QfL unmqlrc C
NB.
NB. Description:
NB. Multiply a general matrix C by matrix Q, which is
NB. represented in factored form QfL as returned by geqlf
NB. where
NB. B,C - m×n-matrices
NB. QfL - (m+1)×n-matrix (ln,lc cases), (n+1)×m-matrix
NB. (rn,rc), contains Qf, the output of geqlf
NB. Qf - (m+1)×k-matrix (ln,lc) or (n+1)×k-matrix (rn,rc),
NB. unit upper trapezoidal (unit diagonal is not
NB. stored), represents the Q in factored form
NB. Q - m×m-matrix (ln,lc) or n×n-matrix (rn,rc), unitary
NB. (orthogonal), which is defined as the product of
NB. k elementary reflectors H(i):
NB. Q = Π{H(i),i=k-1:0}
NB. H(i) ≡ H(u(i),τ(i)) := I - u(i) * τ(i) * u(i)'
NB. k = min(m,n)
NB.
NB. Assertions (with appropriate comparison tolerance):
NB. ((unmqlln -: (mp~ (ungql~ <:@#))~) 0 ?@$~ _1 0 + $) QfL
NB. ((unmqllc -: (mp~ ct@(ungql~ <:@#))~) 0 ?@$~ _1 0 + $) QfL
NB. ((unmqlrn -: (mp (ungql~ <:@#))~) 0 ?@$~ _1 0 |.@:+ $) QfL
NB. ((unmqlrc -: (mp ct@(ungql~ <:@#))~) 0 ?@$~ _1 0 |.@:+ $) QfL
NB.
NB. Notes:
NB. - implement LAPACK's DORMQL, ZUNMQL
NB. - unm2l{ln,lc,rn,rc} and unmql{ln,lc,rn,rc} respectively
NB. are topologic equivalents
unmqlln=: }. @(((unm2lln`((larfblnbc&:>/@,~ |.@ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ (tru1~ -~/@$)@({."1~ _1 0 -@(<./)@:+ $))~ , ~&0)`(i.@$@])@.(0 e. $@])
unmqllc=: }. @(((unm2llc`((larfblcbc&:>/@,~ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ (tru1~ -~/@$)@({."1~ _1 0 -@(<./)@:+ $))~ , ~&0)`(i.@$@])@.(0 e. $@])
unmqlrn=: }."1@(((unm2lrn`((larfbrnbc&:>/@,~ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ (tru1~ -~/@$)@({."1~ _1 0 -@(<./)@:+ $))~ ,.~&0)`(i.@$@])@.(0 e. $@])
unmqlrc=: }."1@(((unm2lrc`((larfbrcbc&:>/@,~ |.@ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ (tru1~ -~/@$)@({."1~ _1 0 -@(<./)@:+ $))~ ,.~&0)`(i.@$@])@.(0 e. $@])
NB. ---------------------------------------------------------
NB. Dyad Action Side Tran Syntax
NB. unmqrln Q * C left none B=. QfR unmqrln C
NB. unmqrlc Q^H * C left ct B=. QfR unmqrlc C
NB. unmqrrn C * Q right none B=. QfR unmqrrn C
NB. unmqrrc C * Q^H right ct B=. QfR unmqrrc C
NB.
NB. Description:
NB. Multiply a general matrix C by matrix Q, which is
NB. represented in factored form QfR as returned by geqrf
NB. where
NB. B,C - m×n-matrices
NB. QfR - (m+1)×n-matrix (ln,lc cases), (n+1)×m-matrix
NB. (rn,rc), contains Qf, the output of geqrf
NB. Qf - (m+1)×k-matrix (ln,lc) or (n+1)×k-matrix (rn,rc),
NB. unit lower trapezoidal (unit diagonal is not
NB. stored), represents the Q in factored form
NB. Q - m×m-matrix (ln,lc) or n×n-matrix (rn,rc), unitary
NB. (orthogonal), which is defined as the product of
NB. k elementary reflectors H(i):
NB. Q = Π{H(i),i=0:k-1}
NB. H(i) ≡ H(u(i),τ(i)) := I - u(i) * τ(i) * u(i)'
NB. k = min(m,n)
NB.
NB. Assertions (with appropriate comparison tolerance):
NB. ((unmqrln -: (mp~ (ungqr~ <:@#))~) 0 ?@$~ _1 0 + $) QfR
NB. ((unmqrlc -: (mp~ ct@(ungqr~ <:@#))~) 0 ?@$~ _1 0 + $) QfR
NB. ((unmqrrn -: (mp (ungqr~ <:@#))~) 0 ?@$~ _1 0 |.@:+ $) QfR
NB. ((unmqrrc -: (mp ct@(ungqr~ <:@#))~) 0 ?@$~ _1 0 |.@:+ $) QfR
NB.
NB. Notes:
NB. - implement LAPACK's DORMQR, ZUNMQR
NB. - unm2r{ln,lc,rn,rc} and unmqr{ln,lc,rn,rc} respectively
NB. are topologic equivalents
unmqrln=: }: @(((unm2rln`((larfblnfc&:>/@,~ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ trl1 @({."1~ _1 0 <./ @:+ $))~ , &0)`(i.@$@])@.(0 e. $@])
unmqrlc=: }: @(((unm2rlc`((larfblcfc&:>/@,~ |.@ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ trl1 @({."1~ _1 0 <./ @:+ $))~ , &0)`(i.@$@])@.(0 e. $@])
unmqrrn=: }:"1@(((unm2rrn`((larfbrnfc&:>/@,~ |.@ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ trl1 @({."1~ _1 0 <./ @:+ $))~ ,. &0)`(i.@$@])@.(0 e. $@])
unmqrrc=: }:"1@(((unm2rrc`((larfbrcfc&:>/@,~ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ trl1 @({."1~ _1 0 <./ @:+ $))~ ,. &0)`(i.@$@])@.(0 e. $@])
NB. ---------------------------------------------------------
NB. Dyad Action Side Tran Syntax
NB. unmrqln Q * C left none B=. RQf unmrqln C
NB. unmrqlc Q^H * C left ct B=. RQf unmrqlc C
NB. unmrqrn C * Q right none B=. RQf unmrqrn C
NB. unmrqrc C * Q^H right ct B=. RQf unmrqrc C
NB.
NB. Description:
NB. Multiply a general matrix C by matrix Q, which is
NB. represented in factored form RQf as returned by gerqf
NB. where
NB. B,C - m×n-matrices
NB. RQf - l×(m+1)-matrix (ln,lc cases) or l×(n+1)-matrix
NB. (rn,rc), contains Qf, the output of gerqf
NB. Qf - k×(m+1)-matrix (ln,lc) or k×(n+1)-matrix (rn,rc),
NB. unit lower trapezoidal (unit diagonal is not
NB. stored), represents the Q in factored form
NB. Q - m×m-matrix (ln,lc) or n×n-matrix (rn,rc), unitary
NB. (orthogonal), which is defined as the product of
NB. k elementary reflectors H(i):
NB. Q = Π{H(i)',i=0:k-1}
NB. H(i) ≡ H(u(i),τ(i)) := I - u(i)' * τ(i) * u(i)
NB. k = min(m,n)
NB.
NB. Assertions (with appropriate comparison tolerance):
NB. ((unmrqln -: (mp~ (ungrq~ <:@c))~) 0 ?@$~ 0 _1 |.@:+ $) RQf
NB. ((unmrqlc -: (mp~ ct@(ungrq~ <:@c))~) 0 ?@$~ 0 _1 |.@:+ $) RQf
NB. ((unmrqrn -: (mp (ungrq~ <:@c))~) 0 ?@$~ 0 _1 + $) RQf
NB. ((unmrqrc -: (mp ct@(ungrq~ <:@c))~) 0 ?@$~ 0 _1 + $) RQf
NB.
NB. Notes:
NB. - implement LAPACK's DORMRQ, ZUNMRQ
NB. - unmr2{ln,lc,rn,rc} and unmrq{ln,lc,rn,rc} respectively
NB. are topologic equivalents
unmrqln=: }. @(((unmr2ln`((larfblcbr&:>/@,~ {."1 @(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ (trl1~ -~/@$)@({. ~ 0 _1 -@(<./)@:+ $))~ , ~&0)`(i.@$@])@.(0 e. $@])
unmrqlc=: }. @(((unmr2lc`((larfblnbr&:>/@,~ |.@:({."1)@(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ (trl1~ -~/@$)@({. ~ 0 _1 -@(<./)@:+ $))~ , ~&0)`(i.@$@])@.(0 e. $@])
unmrqrn=: }."1@(((unmr2rn`((larfbrcbr&:>/@,~ |.@:({."1)@(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ (trl1~ -~/@$)@({. ~ 0 _1 -@(<./)@:+ $))~ ,.~&0)`(i.@$@])@.(0 e. $@])
unmrqrc=: }."1@(((unmr2rc`((larfbrnbr&:>/@,~ {."1 @(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ (trl1~ -~/@$)@({. ~ 0 _1 -@(<./)@:+ $))~ ,.~&0)`(i.@$@])@.(0 e. $@])
NB. ---------------------------------------------------------
NB. Dyad Action Side Tran Syntax
NB. unmlzln Z * C left none B=. LZf unmlzln C
NB. unmlzlc Z^H * C left ct B=. LZf unmlzlc C
NB. unmlzrn C * Z right none B=. LZf unmlzrn C
NB. unmlzrc C * Z^H right ct B=. LZf unmlzrc C
NB.
NB. Description:
NB. Multiply a general matrix C by matrix Z, which is
NB. represented in factored form LZf as returned by tzlzf
NB. where
NB. B,C - m×n-matrices
NB. LZf - k×(m+1)-matrix (ln,lc cases) or k×(n+1)-matrix
NB. (rn,rc), contains Zf (identity submatrix is not
NB. stored), the output of tzlzf
NB. Zf - k×(m+1)-matrix (ln,lc) or k×(n+1)-matrix (rn,rc),
NB. trailing k×k-submatrix is identity, the Z
NB. represented in factored form
NB. Z - m×m-matrix (ln,lc) or n×n-matrix (rn,rc), unitary
NB. (orthogonal), which is defined as the product of
NB. k elementary reflectors H(i):
NB. Z = Π{H(i)',i=k-1:0}
NB. H(i) ≡ H(u(i),τ(i)) := I - u(i)' * τ(i) * u(i)
NB. k ≤ min(m,n)
NB.
NB. Assertions (with appropriate comparison tolerance):
NB. ((unmlzln -: (mp~ (unglz~ <:@c))~) 0 ?@$~ 0 _1 |.@:+ $) LZf
NB. ((unmlzlc -: (mp~ ct@(unglz~ <:@c))~) 0 ?@$~ 0 _1 |.@:+ $) LZf
NB. ((unmlzrn -: (mp (unglz~ <:@c))~) 0 ?@$~ 0 _1 + $) LZf
NB. ((unmlzrc -: (mp ct@(unglz~ <:@c))~) 0 ?@$~ 0 _1 + $) LZf
NB.
NB. Notes:
NB. - unml3{ln,lc,rn,rc} and unmlz{ln,lc,rn,rc} respectively
NB. are topologic equivalents
NB. - if not all reflectors are needed then part of LZf
NB. would be zeroed, e.g.:
NB. original LZf with m=5, n=9:
NB. ( τ0 v0 v0 v0 v0 l 0 0 0 0 )
NB. ( τ1 v1 v1 v1 v1 l l 0 0 0 )
NB. ( τ2 v2 v2 v2 v2 l l l 0 0 )
NB. ( τ3 v3 v3 v3 v3 l l l l 0 )
NB. ( τ4 v4 v4 v4 v4 l l l l l )
NB. LZf used as x argument when k=2:
NB. ( τ3 v3 v3 v3 v3 0 0 0 l 0 )
NB. ( τ4 v4 v4 v4 v4 0 0 0 l l )
NB. note zeroed elements in columns 5,6,7
unmlzln=: }. @(((unml3ln`((larzblcfr&:>/@,~ |.@:({."1)@(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ (idmat@[`(a: <@; liso4dhs@(_1 , [))}~ #))~ , ~&0)`(i.@$@])@.(0 e. $@])
unmlzlc=: }. @(((unml3lc`((larzblnfr&:>/@,~ {."1 @(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ (idmat@[`(a: <@; liso4dhs@(_1 , [))}~ #))~ , ~&0)`(i.@$@])@.(0 e. $@])
unmlzrn=: }."1@(((unml3rn`((larzbrcfr&:>/@,~ {."1 @(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ (idmat@[`(a: <@; liso4dhs@(_1 , [))}~ #))~ ,.~&0)`(i.@$@])@.(0 e. $@])
unmlzrc=: }."1@(((unml3rc`((larzbrnfr&:>/@,~ |.@:({."1)@(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ (idmat@[`(a: <@; liso4dhs@(_1 , [))}~ #))~ ,.~&0)`(i.@$@])@.(0 e. $@])
NB. ---------------------------------------------------------
NB. Dyad Action Side Tran Syntax
NB. unmzlln Z * C left none B=. ZfL unmzlln C
NB. unmzllc Z^H * C left ct B=. ZfL unmzllc C
NB. unmzlrn C * Z right none B=. ZfL unmzlrn C
NB. unmzlrc C * Z^H right ct B=. ZfL unmzlrc C
NB.
NB. Description:
NB. Multiply a general matrix C by matrix Z, which is
NB. represented in factored form ZfL as returned by tzzlf
NB. where
NB. B,C - m×n-matrices
NB. ZfL - (m+1)×k-matrix (ln,lc cases) or (n+1)×k-matrix
NB. (rn,rc), contains Zf (identity submatrix is not
NB. stored), the output of tzzlf
NB. Zf - (m+1)×k-matrix (ln,lc) or (n+1)×k-matrix (rn,rc),
NB. leading k×k-submatrix is identity, the Z
NB. represented in factored form
NB. Z - m×m-matrix (ln,lc) or n×n-matrix (rn,rc), unitary
NB. (orthogonal), which is defined as the product of
NB. k elementary reflectors H(i):
NB. Z = Π{H(i),i=k-1:0}
NB. H(i) ≡ H(u(i),τ(i)) := I - u(i) * τ(i) * u(i)'
NB. k ≤ min(m,n)
NB.
NB. Assertions (with appropriate comparison tolerance):
NB. ((unmzlln -: (mp~ (ungzl~ <:@#))~) 0 ?@$~ _1 0 + $) ZfL
NB. ((unmzllc -: (mp~ ct@(ungzl~ <:@#))~) 0 ?@$~ _1 0 + $) ZfL
NB. ((unmzlrn -: (mp (ungzl~ <:@#))~) 0 ?@$~ _1 0 |.@:+ $) ZfL
NB. ((unmzlrc -: (mp ct@(ungzl~ <:@#))~) 0 ?@$~ _1 0 |.@:+ $) ZfL
NB.
NB. Notes:
NB. - unm3l{ln,lc,rn,rc} and unmzl{ln,lc,rn,rc} respectively
NB. are topologic equivalents
NB. - if not all reflectors are needed then part of ZfL
NB. would be zeroed, e.g.:
NB. original ZfL with m=9, n=5: ZfL used as x argument when k=2:
NB. ( l 0 0 0 0 ) ( l 0 )
NB. ( l l 0 0 0 ) ( l l )
NB. ( l l l 0 0 ) ( 0 0 )
NB. ( l l l l 0 ) ( 0 0 )
NB. ( l l l l l ) ( 0 0 )
NB. ( v0 v1 v2 v3 v4 ) ( v0 v1 )
NB. ( v0 v1 v2 v3 v4 ) ( v0 v1 )
NB. ( v0 v1 v2 v3 v4 ) ( v0 v1 )
NB. ( v0 v1 v2 v3 v4 ) ( v0 v1 )
NB. ( τ0 τ1 τ2 τ3 τ4 ) ( τ0 τ1 )
NB. note zeroed elements in rows 2,3,4
unmzlln=: }: @(((unm3lln`((larzblnbc&:>/@,~ |.@ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ (idmat@[`( liso4dhs@( 0 , [))}~ c))~ , &0)`(i.@$@])@.(0 e. $@])
unmzllc=: }: @(((unm3llc`((larzblcbc&:>/@,~ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ (idmat@[`( liso4dhs@( 0 , [))}~ c))~ , &0)`(i.@$@])@.(0 e. $@])
unmzlrn=: }:"1@(((unm3lrn`((larzbrnbc&:>/@,~ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ (idmat@[`( liso4dhs@( 0 , [))}~ c))~ ,. &0)`(i.@$@])@.(0 e. $@])
unmzlrc=: }:"1@(((unm3lrc`((larzbrcbc&:>/@,~ |.@ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ (idmat@[`( liso4dhs@( 0 , [))}~ c))~ ,. &0)`(i.@$@])@.(0 e. $@])
NB. ---------------------------------------------------------
NB. Dyad Action Side Tran Syntax
NB. unmzrln Z * C left none B=. ZfR unmzrln C
NB. unmzrlc Z^H * C left ct B=. ZfR unmzrlc C
NB. unmzrrn C * Z right none B=. ZfR unmzrrn C
NB. unmzrrc C * Z^H right ct B=. ZfR unmzrrc C
NB.
NB. Description:
NB. Multiply a general matrix C by matrix Z, which is
NB. represented in factored form ZfR as returned by tzzrf
NB. where
NB. B,C - m×n-matrices
NB. ZfR - (m+1)×k-matrix (ln,lc cases) or (n+1)×k-matrix
NB. (rn,rc), contains Zf (identity submatrix is not
NB. stored), the output of tzzrf
NB. Zf - (m+1)×k-matrix (ln,lc) or (n+1)×k-matrix (rn,rc),
NB. trailing k×k-submatrix is identity, the Z
NB. represented in factored form
NB. Z - m×m-matrix (ln,lc) or n×n-matrix (rn,rc), unitary
NB. (orthogonal), which is defined as the product of
NB. k elementary reflectors H(i):
NB. Z = Π{H(i),i=0:k-1}
NB. H(i) ≡ H(u(i),τ(i)) := I - u(i) * τ(i) * u(i)'
NB. k ≤ min(m,n)
NB.
NB. Assertions (with appropriate comparison tolerance):
NB. ((unmzrln -: (mp~ (ungzr~ <:@#))~) 0 ?@$~ _1 0 + $) ZfR
NB. ((unmzrlc -: (mp~ ct@(ungzr~ <:@#))~) 0 ?@$~ _1 0 + $) ZfR
NB. ((unmzrrn -: (mp (ungzr~ <:@#))~) 0 ?@$~ _1 0 |.@:+ $) ZfR
NB. ((unmzrrc -: (mp ct@(ungzr~ <:@#))~) 0 ?@$~ _1 0 |.@:+ $) ZfR
NB.
NB. Notes:
NB. - unm3r{ln,lc,rn,rc} and unmzr{ln,lc,rn,rc} respectively
NB. are topologic equivalents
NB. - if not all reflectors are needed then part of ZfR
NB. would be zeroed, e.g.:
NB. original ZfR with m=9, n=5: ZfR used as x argument when k=2:
NB. ( τ0 τ1 τ2 τ3 τ4 ) ( τ3 τ4 )
NB. ( v0 v1 v2 v3 v4 ) ( v3 v4 )
NB. ( v0 v1 v2 v3 v4 ) ( v3 v4 )
NB. ( v0 v1 v2 v3 v4 ) ( v3 v4 )
NB. ( v0 v1 v2 v3 v4 ) ( v3 v4 )
NB. ( r r r r r ) ( 0 0 )
NB. ( 0 r r r r ) ( 0 0 )
NB. ( 0 0 r r r ) ( 0 0 )
NB. ( 0 0 0 r r ) ( r r )
NB. ( 0 0 0 0 r ) ( 0 r )
NB. note zeroed elements in rows 5,6,7
unmzrln=: }. @(((unm3rln`((larzblnfc&:>/@,~ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ (idmat@[`( liso4dhs@(_1 , [))}~ c))~ , ~&0)`(i.@$@])@.(0 e. $@])
unmzrlc=: }. @(((unm3rlc`((larzblcfc&:>/@,~ |.@ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ (idmat@[`( liso4dhs@(_1 , [))}~ c))~ , ~&0)`(i.@$@])@.(0 e. $@])
unmzrrn=: }."1@(((unm3rrn`((larzbrnfc&:>/@,~ |.@ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ (idmat@[`( liso4dhs@(_1 , [))}~ c))~ ,.~&0)`(i.@$@])@.(0 e. $@])
unmzrrc=: }."1@(((unm3rrc`((larzbrcfc&:>/@,~ {. @(<;.3~ ,:~@(MQNB ,~ #)))~ <)@.(MQNB < c@[))~ (idmat@[`( liso4dhs@(_1 , [))}~ c))~ ,.~&0)`(i.@$@])@.(0 e. $@])
NB. ---------------------------------------------------------
NB. Dyad Action Side Tran Syntax
NB. unmrzln Z * C left none B=. RZf unmrzln C
NB. unmrzlc Z^H * C left ct B=. RZf unmrzlc C
NB. unmrzrn C * Z right none B=. RZf unmrzrn C
NB. unmrzrc C * Z^H right ct B=. RZf unmrzrc C
NB.
NB. Description:
NB. Multiply a general matrix C by matrix Z, which is
NB. represented in factored form RZf as returned by tzrzf
NB. where
NB. B,C - m×n-matrices
NB. RZf - k×(m+1)-matrix (ln,lc cases) or k×(n+1)-matrix
NB. (rn,rc), contains Zf (identity submatrix is not
NB. stored), the output of tzrzf
NB. Zf - k×(m+1)-matrix (ln,lc) or k×(n+1)-matrix (rn,rc),
NB. leading k×k-submatrix is identity, the Z
NB. represented in factored form
NB. Z - m×m-matrix (ln,lc) or n×n-matrix (rn,rc), unitary
NB. (orthogonal), which is defined as the product of
NB. k elementary reflectors H(i):
NB. Z = Π{H(i)',i=0:k-1}
NB. H(i) ≡ H(u(i),τ(i)) := I - u(i)' * τ(i) * u(i)
NB. k ≤ min(m,n)
NB.
NB. Assertions (with appropriate comparison tolerance):
NB. ((unmrzln -: (mp~ (ungrz~ <:@c))~) 0 ?@$~ 0 _1 |.@:+ $) RZf
NB. ((unmrzlc -: (mp~ ct@(ungrz~ <:@c))~) 0 ?@$~ 0 _1 |.@:+ $) RZf
NB. ((unmrzrn -: (mp (ungrz~ <:@c))~) 0 ?@$~ 0 _1 + $) RZf
NB. ((unmrzrc -: (mp ct@(ungrz~ <:@c))~) 0 ?@$~ 0 _1 + $) RZf
NB.
NB. Notes:
NB. - unmr3{ln,lc,rn,rc} and unmrz{ln,lc,rn,rc} respectively
NB. are topologic equivalents
NB. - implement LAPACK's DORMRZ, ZUNMRZ with the following
NB. difference: if not all reflectors are needed then
NB. part of RZf would be zeroed, e.g.:
NB. original RZf with m=5, n=9:
NB. ( r r r r r v0 v0 v0 v0 τ0 )
NB. ( 0 r r r r v1 v1 v1 v1 τ1 )
NB. ( 0 0 r r r v2 v2 v2 v2 τ2 )
NB. ( 0 0 0 r r v3 v3 v3 v3 τ3 )
NB. ( 0 0 0 0 r v4 v4 v4 v4 τ4 )
NB. RZf used as x argument when k=2:
NB. ( r r 0 0 0 v0 v0 v0 v0 τ0 )
NB. ( 0 r 0 0 0 v1 v1 v1 v1 τ1 )
NB. note zeroed elements in columns 2,3,4
unmrzln=: }: @(((unmr3ln`((larzblcbr&:>/@,~ {."1 @(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ (idmat@[`(a: <@; liso4dhs@( 0 , [))}~ #))~ , &0)`(i.@$@])@.(0 e. $@])
unmrzlc=: }: @(((unmr3lc`((larzblnbr&:>/@,~ |.@:({."1)@(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ (idmat@[`(a: <@; liso4dhs@( 0 , [))}~ #))~ , &0)`(i.@$@])@.(0 e. $@])
unmrzrn=: }:"1@(((unmr3rn`((larzbrcbr&:>/@,~ |.@:({."1)@(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ (idmat@[`(a: <@; liso4dhs@( 0 , [))}~ #))~ ,. &0)`(i.@$@])@.(0 e. $@])
unmrzrc=: }:"1@(((unmr3rc`((larzbrnbr&:>/@,~ {."1 @(<;.3~ ,:~@(MQNB , c)))~ <)@.(MQNB < #@[))~ (idmat@[`(a: <@; liso4dhs@( 0 , [))}~ #))~ ,. &0)`(i.@$@])@.(0 e. $@])
NB. ---------------------------------------------------------
NB. Dyad Action Side Tran Syntax
NB. unmhrlln Q * C left none B=. HQf unmhrlln C
NB. unmhrllc Q^H * C left ct B=. HQf unmhrllc C
NB. unmhrlrn C * Q right none B=. HQf unmhrlrn C
NB. unmhrlrc C * Q^H right ct B=. HQf unmhrlrc C
NB.
NB. Description:
NB. Multiply a general matrix C by unitary (orthogonal)
NB. matrix Q, which is represented in factored form HQf as
NB. returned by gehrdl
NB. where
NB. B,C - m×n-matrices
NB. HQf - m×(m+1)-matrix (ln,lc cases) or n×(n+1)-matrix
NB. (rn,rc), contains Qf, the output of gehrdl
NB. Qf - (s-1)×(m-h)-matrix (ln,lc) or (s-1)×(n-h)-matrix
NB. (rn,rc), the unit upper trapezoidal (unit
NB. diagonal is not stored), represents the Q in
NB. factored form, located in HQf[h:h+s-2,h+1:end]
NB. Q - m×m-matrix (ln,lc) or n×n-matrix (rn,rc), is the
NB. unit matrix with unitary (orthogonal) matrix
NB. inserted into elements Q[h:h+s-1,h:h+s-1] :
NB. Q = Π{H(i)',i=h+s-2:h}
NB. H(i) = I - v[i]' * τ[i] * v[i]
NB. hs - 2-vector of integers (h,s) 'head' and 'size',
NB. defines submatrix Qf position in matrix HQf, see
NB. see gehrdl
NB.
NB. Assertions (with appropriate comparison tolerance):
NB. (idmat@c -: clean@(unmhrlln ct@unghrl)@(gehrdl~ 0 , c)) A
NB. (idmat@c -: clean@(unmhrllc unghrl)@(gehrdl~ 0 , c)) A
NB. (idmat@c -: clean@(unmhrlrn ct@unghrl)@(gehrdl~ 0 , c)) A
NB. (idmat@c -: clean@(unmhrlrc unghrl)@(gehrdl~ 0 , c)) A
NB.
NB. Notes:
NB. - instead of using f and s arguments, the following
NB. product is really calculating:
NB. Q = Π{H(i)',i=n-1:0} ,
NB. where
NB. H(0:f-1) = H(f+s-1:n-1) = I .
NB. This approach delivers excessive calculations in rare
NB. case ((f>0) OR (f+s<n)).
unmhrlln=: (unmlqln~ |.!.0)~
unmhrllc=: (unmlqlc~ |.!.0)~
unmhrlrn=: (unmlqrn~ |.!.0)~
unmhrlrc=: (unmlqrc~ |.!.0)~
NB. ---------------------------------------------------------
NB. Dyad Action Side Tran Syntax
NB. unmhruln Q * C left none B=. HQf unmhruln C
NB. unmhrulc Q^H * C left ct B=. HQf unmhrulc C
NB. unmhrurn C * Q right none B=. HQf unmhrurn C
NB. unmhrurc C * Q^H right ct B=. HQf unmhrurc C
NB.
NB. Description:
NB. Multiply a general matrix C by unitary (orthogonal)
NB. matrix Q, which is represented in factored form HQf as
NB. returned by gehrdu
NB. where
NB. B,C - m×n-matrices
NB. HQf - (m+1)×m-matrix (ln,lc cases) or (n+1)×n-matrix
NB. (rn,rc), contains Qf, the output of gehrdu
NB. Qf - (m-h)×(s-1)-matrix (ln,lc) or (n-h)×(s-1)-matrix
NB. (rn,rc), the unit lower trapezoidal (unit
NB. diagonal is not stored), represents the Q in
NB. factored form, located in HQf[h+1:end,h:h+s-2]
NB. Q - m×m-matrix (ln,lc) or n×n-matrix (rn,rc), is the
NB. unit matrix with unitary (orthogonal) matrix
NB. inserted into elements Q[h:h+s-1,h:h+s-1] :
NB. Q = Π{H(i),i=h:h+s-2}
NB. H(i) = I - v[i] * τ[i] * v[i]'
NB. hs - 2-vector of integers (h,s) 'head' and 'size',
NB. defines submatrix Qf position in matrix HQf, see
NB. see gehrdu
NB.
NB. Assertions (with appropriate comparison tolerance):
NB. (idmat@# -: clean@(unmhruln ct@unghru)@(gehrdu~ 0 , #)) A
NB. (idmat@# -: clean@(unmhrulc unghru)@(gehrdu~ 0 , #)) A
NB. (idmat@# -: clean@(unmhrurn ct@unghru)@(gehrdu~ 0 , #)) A
NB. (idmat@# -: clean@(unmhrurc unghru)@(gehrdu~ 0 , #)) A
NB.
NB. Notes:
NB. - models LAPACK's DORMHR, ZUNMHR
NB. - instead of using f and s arguments, the following
NB. product is really calculating:
NB. Q = Π{H(i),i=0:n-1} ,
NB. where
NB. H(0:f-1) = H(f+s-1:n-1) = I .
NB. This approach delivers excessive calculations in rare
NB. case ((f>0) OR (f+s<n)).
unmhruln=: (unmqrln~ 0 _1&(|.!.0))~
unmhrulc=: (unmqrlc~ 0 _1&(|.!.0))~
unmhrurn=: (unmqrrn~ 0 _1&(|.!.0))~
unmhrurc=: (unmqrrc~ 0 _1&(|.!.0))~
NB. =========================================================
NB. Test suite
NB. ---------------------------------------------------------
NB. testunmq
NB.
NB. Description:
NB. Test:
NB. - DORMxx ZUNMxx (math/lapack2 addon)
NB. - unmxxxx (math/mt addon)
NB. by general matrices
NB.
NB. Syntax:
NB. log=. testunmq (A ; C)
NB. where
NB. A - m×n-matrix, is used to produce Qf
NB. C - m×n-matrix, is used as multiplier
NB. log - 6-vector of boxes, test log
NB.
NB. Notes:
NB. - LAPACK's DORMxQ and ZUNMxQ requires A to have at least
NB. 1 row, so Head ({.) is used when (# A) equals 0
testunmq=: 3 : 0
_1 cocreate < 'mttmp'
load_mttmp_ 'math/mt/external/lapack2/dormlq'
load_mttmp_ 'math/mt/external/lapack2/dormql'
load_mttmp_ 'math/mt/external/lapack2/dormqr'
load_mttmp_ 'math/mt/external/lapack2/dormrq'
load_mttmp_ 'math/mt/external/lapack2/zunmlq'
load_mttmp_ 'math/mt/external/lapack2/zunmql'
load_mttmp_ 'math/mt/external/lapack2/zunmqr'
load_mttmp_ 'math/mt/external/lapack2/zunmrq'
'A C'=. y
rcond=. nan`geconi@.(=/@$) C NB. meaninigful for square matrices only
ks=. /:~ ~. (, *@(>./)) 0 , (,~ <.@-:) <./ 'm n'=. $ A NB. 0,1,⌊min(m,n)/2⌋,⌊min(m,n)⌋
Awide=. |:^:(>/@$) A
Atall=. |:^:(</@$) A
normw=. norm1 Cwide=. |:^:(>/@$) C
normt=. norm1 Ctall=. |:^:(</@$) C
LQf=. gelqf Awide
QfL=. geqlf Atall
QfR=. geqrf Atall
RQf=. gerqf Awide
argstlq=. { (< Ctall) ; (< normt) ; (< LQf) ; < <"0 ks
argswlq=. { (< Cwide) ; (< normw) ; (< LQf) ; < <"0 ks
argstql=. { (< Ctall) ; (< normt) ; (< QfL) ; < <"0 ks
argswql=. { (< Cwide) ; (< normw) ; (< QfL) ; < <"0 ks
argstqr=. { (< Ctall) ; (< normt) ; (< QfR) ; < <"0 ks
argswqr=. { (< Cwide) ; (< normw) ; (< QfR) ; < <"0 ks
argstrq=. { (< Ctall) ; (< normt) ; (< RQf) ; < <"0 ks
argswrq=. { (< Cwide) ; (< normw) ; (< RQf) ; < <"0 ks
NB. LAPACK, real datatype
log=. lcat ('''ln''&dormlq_mttmp_' tmonad ((( 3&{:: (}:"1 ; {:"1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ] ) lqt03)))@>"0 argstlq
log=. log lcat ('''lt''&dormlq_mttmp_' tmonad ((( 3&{:: (}:"1 ; {:"1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ct) lqt03)))@>"0 argstlq
log=. log lcat ('''rn''&dormlq_mttmp_' tmonad ((( 3&{:: (}:"1 ; {:"1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp ] ) lqt03)))@>"0 argswlq
log=. log lcat ('''rt''&dormlq_mttmp_' tmonad ((( 3&{:: (}:"1 ; {:"1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp ct) lqt03)))@>"0 argswlq
log=. log lcat ('''ln''&dormql_mttmp_' tmonad (((-@(3&{::) (}. ; {. )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ] ) qlt03)))@>"0 argstql
log=. log lcat ('''lt''&dormql_mttmp_' tmonad (((-@(3&{::) (}. ; {. )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ct) qlt03)))@>"0 argstql
log=. log lcat ('''rn''&dormql_mttmp_' tmonad (((-@(3&{::) (}. ; {. )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp ] ) qlt03)))@>"0 argswql
log=. log lcat ('''rt''&dormql_mttmp_' tmonad (((-@(3&{::) (}. ; {. )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp ct) qlt03)))@>"0 argswql
log=. log lcat ('''ln''&dormqr_mttmp_' tmonad ((( 3&{:: (}: ; {: )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ] ) qrt03)))@>"0 argstqr
log=. log lcat ('''lt''&dormqr_mttmp_' tmonad ((( 3&{:: (}: ; {: )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ct) qrt03)))@>"0 argstqr
log=. log lcat ('''rn''&dormqr_mttmp_' tmonad ((( 3&{:: (}: ; {: )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp ] ) qrt03)))@>"0 argswqr
log=. log lcat ('''rt''&dormqr_mttmp_' tmonad ((( 3&{:: (}: ; {: )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp ct) qrt03)))@>"0 argswqr
log=. log lcat ('''ln''&dormrq_mttmp_' tmonad (((-@(3&{::) (}."1 ; {."1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ] ) rqt03)))@>"0 argstrq
log=. log lcat ('''lt''&dormrq_mttmp_' tmonad (((-@(3&{::) (}."1 ; {."1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ct) rqt03)))@>"0 argstrq
log=. log lcat ('''rn''&dormrq_mttmp_' tmonad (((-@(3&{::) (}."1 ; {."1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp ] ) rqt03)))@>"0 argswrq
log=. log lcat ('''rt''&dormrq_mttmp_' tmonad (((-@(3&{::) (}."1 ; {."1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp ct) rqt03)))@>"0 argswrq
NB. LAPACK, complex datatype
log=. log lcat ('''ln''&zunmlq_mttmp_' tmonad ((( 3&{:: (}:"1 ; {:"1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ] ) lqt03)))@>"0 argstlq
log=. log lcat ('''lc''&zunmlq_mttmp_' tmonad ((( 3&{:: (}:"1 ; {:"1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ct) lqt03)))@>"0 argstlq
log=. log lcat ('''rn''&zunmlq_mttmp_' tmonad ((( 3&{:: (}:"1 ; {:"1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp ] ) lqt03)))@>"0 argswlq
log=. log lcat ('''rc''&zunmlq_mttmp_' tmonad ((( 3&{:: (}:"1 ; {:"1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp ct) lqt03)))@>"0 argswlq
log=. log lcat ('''ln''&zunmql_mttmp_' tmonad (((-@(3&{::) (}. ; {. )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ] ) qlt03)))@>"0 argstql
log=. log lcat ('''lc''&zunmql_mttmp_' tmonad (((-@(3&{::) (}. ; {. )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ct) qlt03)))@>"0 argstql
log=. log lcat ('''rn''&zunmql_mttmp_' tmonad (((-@(3&{::) (}. ; {. )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp ] ) qlt03)))@>"0 argswql
log=. log lcat ('''rc''&zunmql_mttmp_' tmonad (((-@(3&{::) (}. ; {. )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp ct) qlt03)))@>"0 argswql
log=. log lcat ('''ln''&zunmqr_mttmp_' tmonad ((( 3&{:: (}: ; {: )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ] ) qrt03)))@>"0 argstqr
log=. log lcat ('''lc''&zunmqr_mttmp_' tmonad ((( 3&{:: (}: ; {: )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ct) qrt03)))@>"0 argstqr
log=. log lcat ('''rn''&zunmqr_mttmp_' tmonad ((( 3&{:: (}: ; {: )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp ] ) qrt03)))@>"0 argswqr
log=. log lcat ('''rc''&zunmqr_mttmp_' tmonad ((( 3&{:: (}: ; {: )@:({."1) 2&{::) , {.) `]`(rcond"_)`nan`((mp ct) qrt03)))@>"0 argswqr
log=. log lcat ('''ln''&zunmrq_mttmp_' tmonad (((-@(3&{::) (}."1 ; {."1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ] ) rqt03)))@>"0 argstrq
log=. log lcat ('''lc''&zunmrq_mttmp_' tmonad (((-@(3&{::) (}."1 ; {."1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ct) rqt03)))@>"0 argstrq
log=. log lcat ('''rn''&zunmrq_mttmp_' tmonad (((-@(3&{::) (}."1 ; {."1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp ] ) rqt03)))@>"0 argswrq
log=. log lcat ('''rc''&zunmrq_mttmp_' tmonad (((-@(3&{::) (}."1 ; {."1)@ {. 2&{::) , {.) `]`(rcond"_)`nan`((mp ct) rqt03)))@>"0 argswrq
NB. mt, any datatype
log=. log lcat ('unmlqln' tdyad (( 3&{:: {. 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp~ ] ) lqt03)))@>"0 argstlq
log=. log lcat ('unmlqlc' tdyad (( 3&{:: {. 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp~ ct) lqt03)))@>"0 argstlq
log=. log lcat ('unmlqrn' tdyad (( 3&{:: {. 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp ] ) lqt03)))@>"0 argswlq
log=. log lcat ('unmlqrc' tdyad (( 3&{:: {. 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp ct) lqt03)))@>"0 argswlq
log=. log lcat ('unmqlln' tdyad (( -@(3&{::) ({."1) 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp~ ] ) qlt03)))@>"0 argstql
log=. log lcat ('unmqllc' tdyad (( -@(3&{::) ({."1) 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp~ ct) qlt03)))@>"0 argstql
log=. log lcat ('unmqlrn' tdyad (( -@(3&{::) ({."1) 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp ] ) qlt03)))@>"0 argswql
log=. log lcat ('unmqlrc' tdyad (( -@(3&{::) ({."1) 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp ct) qlt03)))@>"0 argswql
log=. log lcat ('unmqrln' tdyad (( 3&{:: ({."1) 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp~ ] ) qrt03)))@>"0 argstqr
log=. log lcat ('unmqrlc' tdyad (( 3&{:: ({."1) 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp~ ct) qrt03)))@>"0 argstqr
log=. log lcat ('unmqrrn' tdyad (( 3&{:: ({."1) 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp ] ) qrt03)))@>"0 argswqr
log=. log lcat ('unmqrrc' tdyad (( 3&{:: ({."1) 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp ct) qrt03)))@>"0 argswqr
log=. log lcat ('unmrqln' tdyad (( -@(3&{::) {. 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp~ ] ) rqt03)))@>"0 argstrq
log=. log lcat ('unmrqlc' tdyad (( -@(3&{::) {. 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp~ ct) rqt03)))@>"0 argstrq
log=. log lcat ('unmrqrn' tdyad (( -@(3&{::) {. 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp ] ) rqt03)))@>"0 argswrq
log=. log lcat ('unmrqrc' tdyad (( -@(3&{::) {. 2&{:: )`(0&{::)`]`(rcond"_)`nan`((mp ct) rqt03)))@>"0 argswrq
coerase < 'mttmp'
log
)
NB. ---------------------------------------------------------
NB. testunmz
NB.
NB. Description:
NB. Test:
NB. - DORMRZ ZUNMRZ (math/lapack2 addon)
NB. - unmxxxx (math/mt addon)
NB. by trapezoidal and general matrices
NB.
NB. Syntax:
NB. log=. testunmz (A ; C)
NB. where
NB. A - m×n-matrix, is used to produce Zf
NB. C - m×n-matrix, is used as multiplier
NB. log - 6-vector of boxes, test log
NB.
NB. Notes:
NB. - LAPACK's DORMRZ and ZUNMRZ requires A to have at least
NB. 1 row, so Head ({.) is used when (# A) equals 0
testunmz=: 3 : 0
_1 cocreate < 'mttmp'
load_mttmp_ 'math/mt/external/lapack2/tzrzf'
load_mttmp_ 'math/mt/external/lapack2/dormrz'
load_mttmp_ 'math/mt/external/lapack2/zunmrz'
'A C'=. y
rcond=. nan`geconi@.(=/@$) C NB. meaninigful for square matrices only
ks=. /:~ ~. (, *@(>./)) 0 , (,~ <.@-:) <./ 'm n'=. $ A NB. 0,1,⌊min(m,n)/2⌋,⌊min(m,n)⌋
Awide=. |:^:(>/@$) A
Atall=. |:^:(</@$) A
normw=. norm1 Cwide=. |:^:(>/@$) C
normt=. norm1 Ctall=. |:^:(</@$) C
LZf=. tzlzf Awide
ZfL=. tzzlf Atall
ZfR=. tzzrf Atall
NB. LAPACK, real datatype
NB. LAPACK stores RZf differently, so we need variants for
NB. rzt03 (check DORMRZ by DORMRZ, heh) and RZf itself
rzt03a=: 1 : 'norm1@(- 0&{:: u ''ln'' dormrz_mttmp_ 3&{:: (<:@(-~/)@$@] ; (}:"1 ; {:"1)@{. , <@idmat@<:@c@]) 2&{::)~ % FP_EPS * 1:^:(0&=)@(1 {:: [) * 1 >. <:@c@(2 {:: [)'
try.
RZf=. tru (0&{:: ,. 1&{::) dtzrzf_mttmp_ Awide
catch.
RZf=. _.
end.
argstrz=. { (< Ctall) ; (< normt) ; (< RZf) ; < <"0 ks
argswrz=. { (< Cwide) ; (< normw) ; (< RZf) ; < <"0 ks
log=. lcat ('''ln''&dormrz_mttmp_' tmonad ((<:@(-~/)@$@(2&{::) ; (3&{:: (}:"1 ; {:"1)@{. 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ] ) rzt03a)))@>"0 argstrz
log=. log lcat ('''lt''&dormrz_mttmp_' tmonad ((<:@(-~/)@$@(2&{::) ; (3&{:: (}:"1 ; {:"1)@{. 2&{::) , {.) `]`(rcond"_)`nan`((mp~ |:) rzt03a)))@>"0 argstrz
log=. log lcat ('''rn''&dormrz_mttmp_' tmonad ((<:@(-~/)@$@(2&{::) ; (3&{:: (}:"1 ; {:"1)@{. 2&{::) , {.) `]`(rcond"_)`nan`((mp ] ) rzt03a)))@>"0 argswrz
log=. log lcat ('''rt''&dormrz_mttmp_' tmonad ((<:@(-~/)@$@(2&{::) ; (3&{:: (}:"1 ; {:"1)@{. 2&{::) , {.) `]`(rcond"_)`nan`((mp |:) rzt03a)))@>"0 argswrz
NB. LAPACK, complex datatype
NB. LAPACK stores RZf differently, so we need variants for
NB. rzt03 (check ZUNMRZ by ZUNMRZ, heh) and RZf itself
rzt03b=: 1 : 'norm1@(- 0&{:: u ''ln'' zunmrz_mttmp_ 3&{:: (<:@(-~/)@$@] ; (}:"1 ; {:"1)@{. , <@idmat@<:@c@]) 2&{::)~ % FP_EPS * 1:^:(0&=)@(1 {:: [) * 1 >. <:@c@(2 {:: [)'
try.
RZf=. tru (0&{:: ,. 1&{::) ztzrzf_mttmp_ Awide
catch.
RZf=. _.
end.
argstrz=. { (< Ctall) ; (< normt) ; (< RZf) ; < <"0 ks
argswrz=. { (< Cwide) ; (< normw) ; (< RZf) ; < <"0 ks
log=. log lcat ('''ln''&zunmrz_mttmp_' tmonad ((<:@(-~/)@$@(2&{::) ; (3&{:: (}:"1 ; {:"1)@{. 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ] ) rzt03b)))@>"0 argstrz
log=. log lcat ('''lc''&zunmrz_mttmp_' tmonad ((<:@(-~/)@$@(2&{::) ; (3&{:: (}:"1 ; {:"1)@{. 2&{::) , {.) `]`(rcond"_)`nan`((mp~ ct) rzt03b)))@>"0 argstrz
log=. log lcat ('''rn''&zunmrz_mttmp_' tmonad ((<:@(-~/)@$@(2&{::) ; (3&{:: (}:"1 ; {:"1)@{. 2&{::) , {.) `]`(rcond"_)`nan`((mp ] ) rzt03b)))@>"0 argswrz
log=. log lcat ('''rc''&zunmrz_mttmp_' tmonad ((<:@(-~/)@$@(2&{::) ; (3&{:: (}:"1 ; {:"1)@{. 2&{::) , {.) `]`(rcond"_)`nan`((mp ct) rzt03b)))@>"0 argswrz
NB. mt, any datatype
RZf=. tzrzf Awide
argstlz=. { (< Ctall) ; (< normt) ; (< LZf) ; < <"0 ks
argswlz=. { (< Cwide) ; (< normw) ; (< LZf) ; < <"0 ks
argstzl=. { (< Ctall) ; (< normt) ; (< ZfL) ; < <"0 ks
argswzl=. { (< Cwide) ; (< normw) ; (< ZfL) ; < <"0 ks
argstzr=. { (< Ctall) ; (< normt) ; (< ZfR) ; < <"0 ks
argswzr=. { (< Cwide) ; (< normw) ; (< ZfR) ; < <"0 ks
argstrz=. { (< Ctall) ; (< normt) ; (< RZf) ; < <"0 ks
argswrz=. { (< Cwide) ; (< normw) ; (< RZf) ; < <"0 ks
log=. log lcat ('unmlzln' tdyad ((-@(3&{::) {. (((}."1~ -) ,. idmat@]) #)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp~ ] ) lzt03 )))@>"0 argstlz
log=. log lcat ('unmlzlc' tdyad ((-@(3&{::) {. (((}."1~ -) ,. idmat@]) #)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp~ ct) lzt03 )))@>"0 argstlz
log=. log lcat ('unmlzrn' tdyad ((-@(3&{::) {. (((}."1~ -) ,. idmat@]) #)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp ] ) lzt03 )))@>"0 argswlz
log=. log lcat ('unmlzrc' tdyad ((-@(3&{::) {. (((}."1~ -) ,. idmat@]) #)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp ct) lzt03 )))@>"0 argswlz
log=. log lcat ('unmzlln' tdyad (( 3&{:: ({."1) (( }. ~ , ~ idmat@]) c)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp~ ] ) zlt03 )))@>"0 argstzl
log=. log lcat ('unmzllc' tdyad (( 3&{:: ({."1) (( }. ~ , ~ idmat@]) c)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp~ ct) zlt03 )))@>"0 argstzl
log=. log lcat ('unmzlrn' tdyad (( 3&{:: ({."1) (( }. ~ , ~ idmat@]) c)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp ] ) zlt03 )))@>"0 argswzl
log=. log lcat ('unmzlrc' tdyad (( 3&{:: ({."1) (( }. ~ , ~ idmat@]) c)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp ct) zlt03 )))@>"0 argswzl
log=. log lcat ('unmzrln' tdyad ((-@(3&{::) ({."1) (((}. ~ -) , idmat@]) c)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp~ ] ) zrt03 )))@>"0 argstzr
log=. log lcat ('unmzrlc' tdyad ((-@(3&{::) ({."1) (((}. ~ -) , idmat@]) c)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp~ ct) zrt03 )))@>"0 argstzr
log=. log lcat ('unmzrrn' tdyad ((-@(3&{::) ({."1) (((}. ~ -) , idmat@]) c)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp ] ) zrt03 )))@>"0 argswzr
log=. log lcat ('unmzrrc' tdyad ((-@(3&{::) ({."1) (((}. ~ -) , idmat@]) c)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp ct) zrt03 )))@>"0 argswzr
log=. log lcat ('unmrzln' tdyad (( 3&{:: {. (( }."1~ ,.~ idmat@]) #)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp~ ] ) rzt03 )))@>"0 argstrz
log=. log lcat ('unmrzlc' tdyad (( 3&{:: {. (( }."1~ ,.~ idmat@]) #)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp~ ct) rzt03 )))@>"0 argstrz
log=. log lcat ('unmrzrn' tdyad (( 3&{:: {. (( }."1~ ,.~ idmat@]) #)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp ] ) rzt03 )))@>"0 argswrz
log=. log lcat ('unmrzrc' tdyad (( 3&{:: {. (( }."1~ ,.~ idmat@]) #)@(2&{::))`(0&{::)`]`(rcond"_)`nan`((mp ct) rzt03 )))@>"0 argswrz
coerase < 'mttmp'
erase 'rzt03a rzt03b'
log
)
NB. ---------------------------------------------------------
NB. testunmhr
NB.
NB. Description:
NB. Test:
NB. - DORMHR ZUNMHR (math/lapack2 addon)
NB. - unmhrxxx (math/mt addon)
NB. by square matrices
NB.
NB. Syntax:
NB. log=. testunmhr (A ; C)
NB. where
NB. A - n×n-matrix, is used to produce Qf
NB. C - n×n-matrix, is used as multiplier
NB. log - 6-vector of boxes, test log
NB.
NB. Notes:
NB. - LAPACK's DORMHR and ZUNMHR requires A to have at least
NB. 1 row, so Head ({.) is used when (# A) equals 0
testunmhr=: 3 : 0
_1 cocreate < 'mttmp'
load_mttmp_ 'math/mt/external/lapack2/gehrd'
load_mttmp_ 'math/mt/external/lapack2/dorghr'
load_mttmp_ 'math/mt/external/lapack2/zunghr'
load_mttmp_ 'math/mt/external/lapack2/dormhr'
load_mttmp_ 'math/mt/external/lapack2/zunmhr'
'A C'=. y
rcond=. nan`geconi@.(=/@$) C NB. meaninigful for square matrices only
normC=. norm1 C
NB. LAPACK, real datatype
NB. LAPACK stores HQf differently, so we need a HQf variant
try.
HuQf=. (0&{:: , 1&{::) 'HuQf2 tau2'=. dgehrd_mttmp_ (1 ; # ; ]) A
Qu=. dorghr_mttmp_ 1 ; (# HuQf2) ; HuQf2 ; tau2
catch.
HuQf=. _.
Qu=. _.
end.
log=. ('''ln''&dormhr_mttmp_' tmonad (((1 ; c ; }: ; }:@{:)@(2&{::) , {.)`]`(rcond"_)`nan`hst03u)) C ; normC ; HuQf ; C mp~ Qu
log=. log lcat ('''lt''&dormhr_mttmp_' tmonad (((1 ; c ; }: ; }:@{:)@(2&{::) , {.)`]`(rcond"_)`nan`hst03u)) C ; normC ; HuQf ; C mp~ |: Qu
log=. log lcat ('''rn''&dormhr_mttmp_' tmonad (((1 ; c ; }: ; }:@{:)@(2&{::) , {.)`]`(rcond"_)`nan`hst03u)) C ; normC ; HuQf ; C mp Qu
log=. log lcat ('''rt''&dormhr_mttmp_' tmonad (((1 ; c ; }: ; }:@{:)@(2&{::) , {.)`]`(rcond"_)`nan`hst03u)) C ; normC ; HuQf ; C mp |: Qu
NB. LAPACK, complex datatype
NB. LAPACK stores HQf differently, so we need a HQf variant
try.
HuQf=. (0&{:: , 1&{::) 'HuQf2 tau2'=. zgehrd_mttmp_ (1 ; # ; ]) A
Qu=. zunghr_mttmp_ 1 ; (# HuQf2) ; HuQf2 ; tau2
catch.