21 #ifndef SELDON_FILE_LAPACK_LEAST_SQUARES_CXX
24 #include "Lapack_LeastSquares.hxx"
38 template<
class Prop0,
class Allocator0,
40 void GetQR(Matrix<float, Prop0, ColMajor, Allocator0>& A,
41 Vector<float, VectFull, Allocator1>& tau,
47 Vector<float, VectFull, Allocator1> work(lwork);
48 tau.Reallocate(min(m, n));
49 sgeqrf_(&m, &n, A.GetData(), &m, tau.GetData(),
50 work.GetData(), &lwork, &info.GetInfoRef());
54 template<
class Prop0,
class Allocator0,
56 void GetQR(Matrix<double, Prop0, ColMajor, Allocator0>& A,
57 Vector<double, VectFull, Allocator1>& tau,
63 Vector<double, VectFull, Allocator1> work(lwork);
64 tau.Reallocate(min(m, n));
65 dgeqrf_(&m, &n, A.GetData(), &m, tau.GetData(),
66 work.GetData(), &lwork, &info.GetInfoRef());
70 template<
class Prop0,
class Allocator0,
72 void GetQR(Matrix<complex<float>, Prop0, ColMajor, Allocator0>& A,
73 Vector<complex<float>, VectFull, Allocator1>& tau,
79 Vector<complex<float>, VectFull, Allocator1> work(lwork);
80 tau.Reallocate(min(m, n));
81 cgeqrf_(&m, &n, A.GetData(), &m, tau.GetData(),
82 work.GetData(), &lwork, &info.GetInfoRef());
86 template<
class Prop0,
class Allocator0,
88 void GetQR(Matrix<complex<double>, Prop0, ColMajor, Allocator0>& A,
89 Vector<complex<double>, VectFull, Allocator1>& tau,
95 Vector<complex<double>, VectFull, Allocator1> work(lwork);
96 tau.Reallocate(min(m, n));
97 zgeqrf_(&m, &n, A.GetData(), &m, tau.GetData(),
98 work.GetData(), &lwork, &info.GetInfoRef());
105 template<
class Prop0,
class Allocator0,
107 void GetQR(Matrix<float, Prop0, RowMajor, Allocator0>& A,
108 Vector<float, VectFull, Allocator1>& tau,
113 int lwork = max(m,n);
114 Vector<float, VectFull, Allocator1> work(lwork);
115 tau.Reallocate(min(m, n));
117 sgelqf_(&n, &m, A.GetData(), &n, tau.GetData(),
118 work.GetData(), &lwork, &info.GetInfoRef());
122 template<
class Prop0,
class Allocator0,
124 void GetQR(Matrix<double, Prop0, RowMajor, Allocator0>& A,
125 Vector<double, VectFull, Allocator1>& tau,
130 int lwork = max(m,n);
131 Vector<double, VectFull, Allocator1> work(lwork);
132 tau.Reallocate(min(m, n));
134 dgelqf_(&n, &m, A.GetData(), &n, tau.GetData(),
135 work.GetData(), &lwork, &info.GetInfoRef());
139 template<
class Prop0,
class Allocator0,
141 void GetQR(Matrix<complex<float>, Prop0, RowMajor, Allocator0>& A,
142 Vector<complex<float>, VectFull, Allocator1>& tau,
147 int lwork = max(m,n);
148 Vector<complex<float>, VectFull, Allocator1> work(lwork);
149 tau.Reallocate(min(m, n));
151 cgelqf_(&n, &m, A.GetData(), &n, tau.GetData(),
152 work.GetData(), &lwork, &info.GetInfoRef());
156 template<
class Prop0,
class Allocator0,
158 void GetQR(Matrix<complex<double>, Prop0, RowMajor, Allocator0>& A,
159 Vector<complex<double>, VectFull, Allocator1>& tau,
164 int lwork = max(m,n);
165 Vector<complex<double>, VectFull, Allocator1> work(lwork);
166 tau.Reallocate(min(m, n));
168 zgelqf_(&n, &m, A.GetData(), &n, tau.GetData(),
169 work.GetData(), &lwork, &info.GetInfoRef());
184 template<
class Prop0,
class Allocator0,
186 void GetQR_Pivot(Matrix<double, Prop0, ColMajor, Allocator0>& A,
187 Vector<double, VectFull, Allocator1>& tau,
188 Vector<int>& ipivot, LapackInfo& info)
192 int lwork = 4 * max(m, n);
194 Vector<double, VectFull, Allocator1> work(lwork);
195 tau.Reallocate(min(m, n));
196 dgeqp3_(&m, &n, A.GetData(), &m, ipivot.GetData(), tau.GetData(),
197 work.GetData(), &lwork, &info.GetInfoRef());
211 template<
class Prop0,
class Allocator0,
213 void GetQ_FromQR(Matrix<float, Prop0, ColMajor, Allocator0>& A,
214 Vector<float, VectFull, Allocator1>& tau,
219 int lwork = 2 * max(m, n);
222 #ifdef SELDON_CHECK_DIMENSIONS
224 throw WrongDim(
"GetQ_FromQR",
"tau not large enough");
227 Vector<float, VectFull, Allocator1> work(lwork);
228 sorgqr_(&m, &k, &k, A.GetData(), &m, tau.GetData(),
229 work.GetData(), &lwork, &info.GetInfoRef());
236 template<
class Prop0,
class Allocator0,
238 void GetQ_FromQR(Matrix<complex<float>, Prop0, ColMajor, Allocator0>& A,
239 Vector<complex<float>, VectFull, Allocator1>& tau,
244 int lwork = 2 * max(m, n);
247 #ifdef SELDON_CHECK_DIMENSIONS
249 throw WrongDim(
"GetQ_FromQR",
"tau not large enough");
252 Vector<complex<float>, VectFull, Allocator1> work(lwork);
253 cungqr_(&m, &k, &k, A.GetDataVoid(), &m, tau.GetData(),
254 work.GetDataVoid(), &lwork, &info.GetInfoRef());
261 template<
class Prop0,
class Allocator0,
263 void GetQ_FromQR(Matrix<double, Prop0, ColMajor, Allocator0>& A,
264 Vector<double, VectFull, Allocator1>& tau,
269 int lwork = 2 * max(m, n);
272 #ifdef SELDON_CHECK_DIMENSIONS
274 throw WrongDim(
"GetQ_FromQR",
"tau not large enough");
277 Vector<double, VectFull, Allocator1> work(lwork);
278 dorgqr_(&m, &k, &k, A.GetData(), &m, tau.GetData(),
279 work.GetData(), &lwork, &info.GetInfoRef());
286 template<
class Prop0,
class Allocator0,
288 void GetQ_FromQR(Matrix<complex<double>, Prop0, ColMajor, Allocator0>& A,
289 Vector<complex<double>, VectFull, Allocator1>& tau,
294 int lwork = 2 * max(m, n);
297 #ifdef SELDON_CHECK_DIMENSIONS
299 throw WrongDim(
"GetQ_FromQR",
"tau not large enough");
302 Vector<complex<double>, VectFull, Allocator1> work(lwork);
303 zungqr_(&m, &k, &k, A.GetDataVoid(), &m, tau.GetData(),
304 work.GetDataVoid(), &lwork, &info.GetInfoRef());
311 template<
class Prop0,
class Allocator0,
313 void GetQ_FromLQ(Matrix<float, Prop0, ColMajor, Allocator0>& A,
314 Vector<float, VectFull, Allocator1>& tau,
319 int lwork = 2 * max(m, n);
321 #ifdef SELDON_CHECK_DIMENSIONS
322 if (tau.GetM() < min(m, n))
323 throw WrongDim(
"GetQ_FromLQ",
"tau not large enough");
327 Vector<float, VectFull, Allocator1> work(lwork);
328 sorglq_(&k, &n, &k, A.GetData(), &m, tau.GetData(),
329 work.GetData(), &lwork, &info.GetInfoRef());
336 template<
class Prop0,
class Allocator0,
338 void GetQ_FromLQ(Matrix<complex<float>, Prop0, ColMajor, Allocator0>& A,
339 Vector<complex<float>, VectFull, Allocator1>& tau,
344 int lwork = 2 * max(m, n);
346 #ifdef SELDON_CHECK_DIMENSIONS
347 if (tau.GetM() < min(m, n))
348 throw WrongDim(
"GetQ_FromLQ",
"tau not large enough");
352 Vector<complex<float>, VectFull, Allocator1> work(lwork);
353 cunglq_(&k, &n, &k, A.GetDataVoid(), &m, tau.GetDataVoid(),
354 work.GetDataVoid(), &lwork, &info.GetInfoRef());
361 template<
class Prop0,
class Allocator0,
363 void GetQ_FromLQ(Matrix<double, Prop0, ColMajor, Allocator0>& A,
364 Vector<double, VectFull, Allocator1>& tau,
369 int lwork = 2 * max(m, n);
371 #ifdef SELDON_CHECK_DIMENSIONS
372 if (tau.GetM() < min(m, n))
373 throw WrongDim(
"GetQ_FromLQ",
"tau not large enough");
377 Vector<double, VectFull, Allocator1> work(lwork);
378 dorglq_(&k, &n, &k, A.GetData(), &m, tau.GetData(),
379 work.GetData(), &lwork, &info.GetInfoRef());
386 template<
class Prop0,
class Allocator0,
388 void GetQ_FromLQ(Matrix<complex<double>, Prop0, ColMajor, Allocator0>& A,
389 Vector<complex<double>, VectFull, Allocator1>& tau,
394 int lwork = 2 * max(m, n);
396 #ifdef SELDON_CHECK_DIMENSIONS
397 if (tau.GetM() < min(m, n))
398 throw WrongDim(
"GetQ_FromLQ",
"tau not large enough");
402 Vector<complex<double>, VectFull, Allocator1> work(lwork);
403 zunglq_(&k, &n, &k, A.GetDataVoid(), &m, tau.GetDataVoid(),
404 work.GetDataVoid(), &lwork, &info.GetInfoRef());
411 template<
class Prop0,
class Allocator0,
413 void GetQ_FromQR(Matrix<float, Prop0, RowMajor, Allocator0>& A,
414 Vector<float, VectFull, Allocator1>& tau,
419 int lwork = 2 * max(m, n);
422 #ifdef SELDON_CHECK_DIMENSIONS
424 throw WrongDim(
"GetQ_FromQR",
"tau not large enough");
427 Vector<float, VectFull, Allocator1> work(lwork);
428 sorglq_(&k, &m, &k, A.GetData(), &n, tau.GetData(),
429 work.GetData(), &lwork, &info.GetInfoRef());
437 template<
class Prop0,
class Allocator0,
439 void GetQ_FromQR(Matrix<complex<float>, Prop0, RowMajor, Allocator0>& A,
440 Vector<complex<float>, VectFull, Allocator1>& tau,
445 int lwork = 2 * max(m, n);
448 #ifdef SELDON_CHECK_DIMENSIONS
450 throw WrongDim(
"GetQ_FromQR",
"tau not large enough");
453 Vector<complex<double>, VectFull, Allocator1> work(lwork);
454 cunglq_(&k, &m, &k, A.GetDataVoid(), &n, tau.GetData(),
455 work.GetDataVoid(), &lwork, &info.GetInfoRef());
462 template<
class Prop0,
class Allocator0,
464 void GetQ_FromQR(Matrix<double, Prop0, RowMajor, Allocator0>& A,
465 Vector<double, VectFull, Allocator1>& tau,
470 int lwork = 2 * max(m, n);
473 #ifdef SELDON_CHECK_DIMENSIONS
475 throw WrongDim(
"GetQ_FromQR",
"tau not large enough");
478 Vector<double, VectFull, Allocator1> work(lwork);
479 dorglq_(&k, &m, &k, A.GetData(), &n, tau.GetData(),
480 work.GetData(), &lwork, &info.GetInfoRef());
488 template<
class Prop0,
class Allocator0,
490 void GetQ_FromQR(Matrix<complex<double>, Prop0, RowMajor, Allocator0>& A,
491 Vector<complex<double>, VectFull, Allocator1>& tau,
496 int lwork = 2 * max(m, n);
499 #ifdef SELDON_CHECK_DIMENSIONS
501 throw WrongDim(
"GetQ_FromQR",
"tau not large enough");
504 Vector<complex<double>, VectFull, Allocator1> work(lwork);
505 zunglq_(&k, &m, &k, A.GetDataVoid(), &n, tau.GetData(),
506 work.GetDataVoid(), &lwork, &info.GetInfoRef());
513 template<
class Prop0,
class Allocator0,
515 void GetQ_FromLQ(Matrix<float, Prop0, RowMajor, Allocator0>& A,
516 Vector<float, VectFull, Allocator1>& tau,
521 int lwork = 2 * max(m, n);
523 #ifdef SELDON_CHECK_DIMENSIONS
524 if (tau.GetM() < min(m, n))
525 throw WrongDim(
"GetQ_FromLQ",
"tau not large enough");
529 Vector<float, VectFull, Allocator1> work(lwork);
530 sorgqr_(&n, &k, &k, A.GetData(), &n, tau.GetData(),
531 work.GetData(), &lwork, &info.GetInfoRef());
538 template<
class Prop0,
class Allocator0,
540 void GetQ_FromLQ(Matrix<complex<float>, Prop0, RowMajor, Allocator0>& A,
541 Vector<complex<float>, VectFull, Allocator1>& tau,
546 int lwork = 2 * max(m, n);
548 #ifdef SELDON_CHECK_DIMENSIONS
549 if (tau.GetM() < min(m, n))
550 throw WrongDim(
"GetQ_FromLQ",
"tau not large enough");
554 Vector<complex<float>, VectFull, Allocator1> work(lwork);
555 cungqr_(&n, &k, &k, A.GetDataVoid(), &n, tau.GetDataVoid(),
556 work.GetDataVoid(), &lwork, &info.GetInfoRef());
563 template<
class Prop0,
class Allocator0,
565 void GetQ_FromLQ(Matrix<double, Prop0, RowMajor, Allocator0>& A,
566 Vector<double, VectFull, Allocator1>& tau,
571 int lwork = 2 * max(m, n);
573 #ifdef SELDON_CHECK_DIMENSIONS
574 if (tau.GetM() < min(m, n))
575 throw WrongDim(
"GetQ_FromLQ",
"tau not large enough");
579 Vector<double, VectFull, Allocator1> work(lwork);
580 dorgqr_(&n, &k, &k, A.GetData(), &n, tau.GetData(),
581 work.GetData(), &lwork, &info.GetInfoRef());
588 template<
class Prop0,
class Allocator0,
590 void GetQ_FromLQ(Matrix<complex<double>, Prop0, RowMajor, Allocator0>& A,
591 Vector<complex<double>, VectFull, Allocator1>& tau,
596 int lwork = 2 * max(m, n);
598 #ifdef SELDON_CHECK_DIMENSIONS
599 if (tau.GetM() < min(m, n))
600 throw WrongDim(
"GetQ_FromLQ",
"tau not large enough");
604 Vector<complex<double>, VectFull, Allocator1> work(lwork);
605 zungqr_(&n, &k, &k, A.GetDataVoid(), &n, tau.GetDataVoid(),
606 work.GetDataVoid(), &lwork, &info.GetInfoRef());
624 template<
class Prop0,
class Allocator0,
626 void GetLQ(Matrix<float, Prop0, ColMajor, Allocator0>& A,
627 Vector<float, VectFull, Allocator1>& tau,
632 int lwork = max(m,n);
633 Vector<float, VectFull, Allocator1> work(lwork);
634 tau.Reallocate(min(m, n));
635 sgelqf_(&m, &n, A.GetData(), &m, tau.GetData(),
636 work.GetData(), &lwork, &info.GetInfoRef());
640 template<
class Prop0,
class Allocator0,
642 void GetLQ(Matrix<double, Prop0, ColMajor, Allocator0>& A,
643 Vector<double, VectFull, Allocator1>& tau,
648 int lwork = max(m,n);
649 Vector<double, VectFull, Allocator1> work(lwork);
650 tau.Reallocate(min(m, n));
651 dgelqf_(&m, &n, A.GetData(), &m, tau.GetData(),
652 work.GetData(), &lwork, &info.GetInfoRef());
656 template<
class Prop0,
class Allocator0,
658 void GetLQ(Matrix<complex<float>, Prop0, ColMajor, Allocator0>& A,
659 Vector<complex<float>, VectFull, Allocator1>& tau,
664 int lwork = max(m,n);
665 Vector<complex<float>, VectFull, Allocator1> work(lwork);
666 tau.Reallocate(min(m, n));
667 cgelqf_(&m, &n, A.GetData(), &m, tau.GetData(),
668 work.GetData(), &lwork, &info.GetInfoRef());
672 template<
class Prop0,
class Allocator0,
674 void GetLQ(Matrix<complex<double>, Prop0, ColMajor, Allocator0>& A,
675 Vector<complex<double>, VectFull, Allocator1>& tau,
680 int lwork = max(m,n);
681 Vector<complex<double>, VectFull, Allocator1> work(lwork);
682 tau.Reallocate(min(m, n));
683 zgelqf_(&m, &n, A.GetData(), &m, tau.GetData(),
684 work.GetData(), &lwork, &info.GetInfoRef());
691 template<
class Prop0,
class Allocator0,
693 void GetLQ(Matrix<float, Prop0, RowMajor, Allocator0>& A,
694 Vector<float, VectFull, Allocator1>& tau,
699 int lwork = max(m,n);
700 Vector<float, VectFull, Allocator1> work(lwork);
701 tau.Reallocate(min(m, n));
703 sgeqrf_(&n, &m, A.GetData(), &n, tau.GetData(),
704 work.GetData(), &lwork, &info.GetInfoRef());
708 template<
class Prop0,
class Allocator0,
710 void GetLQ(Matrix<double, Prop0, RowMajor, Allocator0>& A,
711 Vector<double, VectFull, Allocator1>& tau,
716 int lwork = max(m,n);
717 Vector<double, VectFull, Allocator1> work(lwork);
718 tau.Reallocate(min(m, n));
720 dgeqrf_(&n, &m, A.GetData(), &n, tau.GetData(),
721 work.GetData(), &lwork, &info.GetInfoRef());
725 template<
class Prop0,
class Allocator0,
727 void GetLQ(Matrix<complex<float>, Prop0, RowMajor, Allocator0>& A,
728 Vector<complex<float>, VectFull, Allocator1>& tau,
733 int lwork = max(m,n);
734 Vector<complex<float>, VectFull, Allocator1> work(lwork);
735 tau.Reallocate(min(m, n));
737 cgeqrf_(&n, &m, A.GetData(), &n, tau.GetData(),
738 work.GetData(), &lwork, &info.GetInfoRef());
742 template<
class Prop0,
class Allocator0,
744 void GetLQ(Matrix<complex<double>, Prop0, RowMajor, Allocator0>& A,
745 Vector<complex<double>, VectFull, Allocator1>& tau,
750 int lwork = max(m,n);
751 Vector<complex<double>, VectFull, Allocator1> work(lwork);
752 tau.Reallocate(min(m, n));
754 zgeqrf_(&n, &m, A.GetData(), &n, tau.GetData(),
755 work.GetData(), &lwork, &info.GetInfoRef());
770 template<
class Prop0,
class Allocator0,
771 class Allocator1,
class Allocator2>
772 void MltQ_FromQR(
const SeldonTranspose& trans,
773 const Matrix<float, Prop0, ColMajor, Allocator0>& A,
774 const Vector<float, VectFull, Allocator1>& tau,
775 Vector<float, VectFull, Allocator2>& b,
780 #ifdef SELDON_CHECK_DIMENSIONS
781 if (tau.GetM() < min(lda, A.GetN()))
782 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
785 throw WrongDim(
"MltQ_FromQR",
"b not large enough");
791 int lwork = max(m, n);
792 Vector<float, VectFull, Allocator1> work(lwork);
794 char trans_ = trans.Char();
795 sormqr_(&side, &trans_, &m, &n, &k, A.GetData(), &lda, tau.GetData(),
796 b.GetData(), &m, work.GetData(), &lwork,
801 template<
class Prop0,
class Allocator0,
802 class Allocator1,
class Allocator2>
803 void MltQ_FromQR(
const SeldonTranspose& trans,
804 const Matrix<complex<float>, Prop0, ColMajor, Allocator0>& A,
805 const Vector<complex<float>, VectFull, Allocator1>& tau,
806 Vector<complex<float>, VectFull, Allocator2>& b,
811 #ifdef SELDON_CHECK_DIMENSIONS
812 if (tau.GetM() < min(lda, A.GetN()))
813 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
816 throw WrongDim(
"MltQ_FromQR",
"b not large enough");
822 int lwork = max(m, n);
823 Vector<complex<float>, VectFull, Allocator1> work(lwork);
825 char trans_ = trans.Char();
826 cunmqr_(&side, &trans_, &m, &n, &k, A.GetDataVoid(), &lda, tau.GetDataVoid(),
827 b.GetDataVoid(), &m, work.GetDataVoid(), &lwork,
832 template<
class Prop0,
class Allocator0,
833 class Allocator1,
class Allocator2>
834 void MltQ_FromQR(
const SeldonTranspose& trans,
835 const Matrix<double, Prop0, ColMajor, Allocator0>& A,
836 const Vector<double, VectFull, Allocator1>& tau,
837 Vector<double, VectFull, Allocator2>& b,
842 #ifdef SELDON_CHECK_DIMENSIONS
843 if (tau.GetM() < min(lda, A.GetN()))
844 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
847 throw WrongDim(
"MltQ_FromQR",
"b not large enough");
853 int lwork = max(m, n);
854 Vector<double, VectFull, Allocator1> work(lwork);
856 char trans_ = trans.Char();
857 dormqr_(&side, &trans_, &m, &n, &k, A.GetData(), &lda, tau.GetData(),
858 b.GetData(), &m, work.GetData(), &lwork,
863 template<
class Prop0,
class Allocator0,
864 class Allocator1,
class Allocator2>
865 void MltQ_FromQR(
const SeldonTranspose& trans,
866 const Matrix<complex<double>, Prop0, ColMajor, Allocator0>& A,
867 const Vector<complex<double>, VectFull, Allocator1>& tau,
868 Vector<complex<double>, VectFull, Allocator2>& b,
873 #ifdef SELDON_CHECK_DIMENSIONS
874 if (tau.GetM() < min(lda, A.GetN()))
875 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
878 throw WrongDim(
"MltQ_FromQR",
"b not large enough");
884 int lwork = max(m, n);
885 Vector<complex<double>, VectFull, Allocator1> work(lwork);
887 char trans_ = trans.Char();
888 zunmqr_(&side, &trans_, &m, &n, &k, A.GetDataVoid(), &lda, tau.GetDataVoid(),
889 b.GetDataVoid(), &m, work.GetDataVoid(), &lwork,
894 template<
class Prop0,
class Allocator0,
895 class Allocator1,
class Allocator2>
896 void MltQ_FromQR(
const SeldonSide& side,
const SeldonTranspose& trans,
897 const Matrix<float, Prop0, ColMajor, Allocator0>& A,
898 const Vector<float, VectFull, Allocator1>& tau,
899 Matrix<float, Prop0, ColMajor, Allocator2>& C,
903 #ifdef SELDON_CHECK_DIMENSIONS
904 if (tau.GetM() < min(A.GetM(), A.GetN()))
905 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
907 if ( (side.Left() && C.GetM() < A.GetM())
908 || (side.Right() && C.GetN() < A.GetM()))
909 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
914 int lwork = max(A.GetM(), A.GetN());
915 Vector<float, VectFull, Allocator1> work(lwork);
916 char side_ = side.Char();
917 char trans_ = trans.Char();
919 int k = min(A.GetM(), A.GetN());
921 sormqr_(&side_, &trans_, &m, &n, &k, A.GetData(), &lda,
922 tau.GetData(), C.GetData(), &m, work.GetData(), &lwork,
927 template<
class Prop0,
class Allocator0,
928 class Allocator1,
class Allocator2>
929 void MltQ_FromQR(
const SeldonSide& side,
const SeldonTranspose& trans,
930 const Matrix<complex<float>, Prop0, ColMajor, Allocator0>& A,
931 const Vector<complex<float>, VectFull, Allocator1>& tau,
932 Matrix<complex<float>, Prop0, ColMajor, Allocator2>& C,
936 #ifdef SELDON_CHECK_DIMENSIONS
937 if (tau.GetM() < min(A.GetM(), A.GetN()))
938 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
940 if ( (side.Left() && C.GetM() < A.GetM())
941 || (side.Right() && C.GetN() < A.GetM()))
942 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
947 int lwork = max(A.GetM(), A.GetN());
948 Vector<complex<float>, VectFull, Allocator1> work(lwork);
949 char side_ = side.Char();
950 char trans_ = trans.Char();
952 int k = min(A.GetM(), A.GetN());
954 cunmqr_(&side_, &trans_, &m, &n, &k, A.GetDataVoid(), &lda,
955 tau.GetDataVoid(), C.GetDataVoid(), &m,
956 work.GetDataVoid(), &lwork, &info.GetInfoRef());
960 template<
class Prop0,
class Allocator0,
961 class Allocator1,
class Allocator2>
962 void MltQ_FromQR(
const SeldonSide& side,
const SeldonTranspose& trans,
963 const Matrix<double, Prop0, ColMajor, Allocator0>& A,
964 const Vector<double, VectFull, Allocator1>& tau,
965 Matrix<double, Prop0, ColMajor, Allocator2>& C,
969 #ifdef SELDON_CHECK_DIMENSIONS
970 if (tau.GetM() < min(A.GetM(), A.GetN()))
971 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
973 if ( (side.Left() && C.GetM() < A.GetM())
974 || (side.Right() && C.GetN() < A.GetM()))
975 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
980 int lwork = max(A.GetM(), A.GetN());
981 Vector<double, VectFull, Allocator1> work(lwork);
982 char side_ = side.Char();
983 char trans_ = trans.Char();
985 int k = min(A.GetM(), A.GetN());
987 dormqr_(&side_, &trans_, &m, &n, &k, A.GetData(), &lda,
988 tau.GetData(), C.GetData(), &m, work.GetData(), &lwork,
993 template<
class Prop0,
class Allocator0,
994 class Allocator1,
class Allocator2>
995 void MltQ_FromQR(
const SeldonSide& side,
const SeldonTranspose& trans,
996 const Matrix<complex<double>, Prop0, ColMajor, Allocator0>& A,
997 const Vector<complex<double>, VectFull, Allocator1>& tau,
998 Matrix<complex<double>, Prop0, ColMajor, Allocator2>& C,
1002 #ifdef SELDON_CHECK_DIMENSIONS
1003 if (tau.GetM() < min(A.GetM(), A.GetN()))
1004 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1006 if ( (side.Left() && C.GetM() < A.GetM())
1007 || (side.Right() && C.GetN() < A.GetM()))
1008 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1013 int lwork = max(A.GetM(), A.GetN());
1014 Vector<complex<double>, VectFull, Allocator1> work(lwork);
1015 char side_ = side.Char();
1016 char trans_ = trans.Char();
1018 int k = min(A.GetM(), A.GetN());
1020 zunmqr_(&side_, &trans_, &m, &n, &k, A.GetDataVoid(), &lda,
1021 tau.GetDataVoid(), C.GetDataVoid(), &m,
1022 work.GetDataVoid(), &lwork, &info.GetInfoRef());
1026 template<
class Prop0,
class Allocator0,
1027 class Allocator1,
class Allocator2>
1028 void MltQ_FromLQ(
const SeldonTranspose& trans,
1029 const Matrix<float, Prop0, ColMajor, Allocator0>& A,
1030 const Vector<float, VectFull, Allocator1>& tau,
1031 Vector<float, VectFull, Allocator2>& b,
1036 #ifdef SELDON_CHECK_DIMENSIONS
1037 if (tau.GetM() < min(lda, A.GetN()))
1038 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1040 if (b.GetM() < A.GetN())
1041 throw WrongDim(
"MltQ_FromLQ",
"b not large enough");
1047 int lwork = max(m, n);
1048 Vector<float, VectFull, Allocator1> work(lwork);
1050 char trans_ = trans.Char();
1051 sormlq_(&side, &trans_, &m, &n, &k, A.GetData(), &lda, tau.GetData(),
1052 b.GetData(), &m, work.GetData(), &lwork,
1053 &info.GetInfoRef());
1057 template<
class Prop0,
class Allocator0,
1058 class Allocator1,
class Allocator2>
1059 void MltQ_FromLQ(
const SeldonTranspose& trans,
1060 const Matrix<complex<float>, Prop0, ColMajor, Allocator0>& A,
1061 const Vector<complex<float>, VectFull, Allocator1>& tau,
1062 Vector<complex<float>, VectFull, Allocator2>& b,
1067 #ifdef SELDON_CHECK_DIMENSIONS
1068 if (tau.GetM() < min(lda, A.GetN()))
1069 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1071 if (b.GetM() < A.GetN())
1072 throw WrongDim(
"MltQ_FromLQ",
"b not large enough");
1078 int lwork = max(m, n);
1079 Vector<complex<float>, VectFull, Allocator1> work(lwork);
1081 char trans_ = trans.Char();
1082 cunmlq_(&side, &trans_, &m, &n, &k, A.GetDataVoid(), &lda, tau.GetDataVoid(),
1083 b.GetDataVoid(), &m, work.GetDataVoid(), &lwork,
1084 &info.GetInfoRef());
1088 template<
class Prop0,
class Allocator0,
1089 class Allocator1,
class Allocator2>
1090 void MltQ_FromLQ(
const SeldonTranspose& trans,
1091 const Matrix<double, Prop0, ColMajor, Allocator0>& A,
1092 const Vector<double, VectFull, Allocator1>& tau,
1093 Vector<double, VectFull, Allocator2>& b,
1098 #ifdef SELDON_CHECK_DIMENSIONS
1099 if (tau.GetM() < min(lda, A.GetN()))
1100 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1102 if (b.GetM() < A.GetN())
1103 throw WrongDim(
"MltQ_FromLQ",
"b not large enough");
1109 int lwork = max(m, n);
1110 Vector<double, VectFull, Allocator1> work(lwork);
1112 char trans_ = trans.Char();
1113 dormlq_(&side, &trans_, &m, &n, &k, A.GetData(), &lda, tau.GetData(),
1114 b.GetData(), &m, work.GetData(), &lwork,
1115 &info.GetInfoRef());
1119 template<
class Prop0,
class Allocator0,
1120 class Allocator1,
class Allocator2>
1121 void MltQ_FromLQ(
const SeldonTranspose& trans,
1122 const Matrix<complex<double>, Prop0, ColMajor, Allocator0>& A,
1123 const Vector<complex<double>, VectFull, Allocator1>& tau,
1124 Vector<complex<double>, VectFull, Allocator2>& b,
1129 #ifdef SELDON_CHECK_DIMENSIONS
1130 if (tau.GetM() < min(lda, A.GetN()))
1131 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1133 if (b.GetM() < A.GetN())
1134 throw WrongDim(
"MltQ_FromLQ",
"b not large enough");
1140 int lwork = max(m, n);
1141 Vector<complex<double>, VectFull, Allocator1> work(lwork);
1143 char trans_ = trans.Char();
1144 zunmlq_(&side, &trans_, &m, &n, &k, A.GetDataVoid(), &lda, tau.GetDataVoid(),
1145 b.GetDataVoid(), &m, work.GetDataVoid(), &lwork,
1146 &info.GetInfoRef());
1150 template<
class Prop0,
class Allocator0,
1151 class Allocator1,
class Allocator2>
1152 void MltQ_FromLQ(
const SeldonSide& side,
const SeldonTranspose& trans,
1153 const Matrix<float, Prop0, ColMajor, Allocator0>& A,
1154 const Vector<float, VectFull, Allocator1>& tau,
1155 Matrix<float, Prop0, ColMajor, Allocator2>& C,
1159 #ifdef SELDON_CHECK_DIMENSIONS
1160 if (tau.GetM() < min(A.GetM(), A.GetN()))
1161 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1163 if ( (side.Left() && C.GetM() < A.GetN())
1164 || (side.Right() && C.GetN() < A.GetN()))
1165 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1170 int lwork = max(A.GetM(), A.GetN());
1171 Vector<float, VectFull, Allocator1> work(lwork);
1172 char side_ = side.Char();
1173 char trans_ = trans.Char();
1175 int k = min(A.GetM(), A.GetN());
1177 sormlq_(&side_, &trans_, &m, &n, &k, A.GetData(), &lda,
1178 tau.GetData(), C.GetData(), &m, work.GetData(), &lwork,
1179 &info.GetInfoRef());
1183 template<
class Prop0,
class Allocator0,
1184 class Allocator1,
class Allocator2>
1185 void MltQ_FromLQ(
const SeldonSide& side,
const SeldonTranspose& trans,
1186 const Matrix<complex<float>, Prop0, ColMajor, Allocator0>& A,
1187 const Vector<complex<float>, VectFull, Allocator1>& tau,
1188 Matrix<complex<float>, Prop0, ColMajor, Allocator2>& C,
1192 #ifdef SELDON_CHECK_DIMENSIONS
1193 if (tau.GetM() < min(A.GetM(), A.GetN()))
1194 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1196 if ( (side.Left() && C.GetM() < A.GetN())
1197 || (side.Right() && C.GetN() < A.GetN()))
1198 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1203 int lwork = max(A.GetM(), A.GetN());
1204 Vector<complex<float>, VectFull, Allocator1> work(lwork);
1205 char side_ = side.Char();
1206 char trans_ = trans.Char();
1208 int k = min(A.GetM(), A.GetN());
1210 cunmlq_(&side_, &trans_, &m, &n, &k, A.GetDataVoid(), &lda,
1211 tau.GetDataVoid(), C.GetDataVoid(), &m,
1212 work.GetDataVoid(), &lwork, &info.GetInfoRef());
1216 template<
class Prop0,
class Allocator0,
1217 class Allocator1,
class Allocator2>
1218 void MltQ_FromLQ(
const SeldonSide& side,
const SeldonTranspose& trans,
1219 const Matrix<double, Prop0, ColMajor, Allocator0>& A,
1220 const Vector<double, VectFull, Allocator1>& tau,
1221 Matrix<double, Prop0, ColMajor, Allocator2>& C,
1225 #ifdef SELDON_CHECK_DIMENSIONS
1226 if (tau.GetM() < min(A.GetM(), A.GetN()))
1227 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1229 if ( (side.Left() && C.GetM() < A.GetN())
1230 || (side.Right() && C.GetN() < A.GetN()))
1231 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1236 int lwork = max(A.GetM(), A.GetN());
1237 Vector<double, VectFull, Allocator1> work(lwork);
1238 char side_ = side.Char();
1239 char trans_ = trans.Char();
1241 int k = min(A.GetM(), A.GetN());
1243 dormlq_(&side_, &trans_, &m, &n, &k, A.GetData(), &lda,
1244 tau.GetData(), C.GetData(), &m, work.GetData(), &lwork,
1245 &info.GetInfoRef());
1249 template<
class Prop0,
class Allocator0,
1250 class Allocator1,
class Allocator2>
1251 void MltQ_FromLQ(
const SeldonSide& side,
const SeldonTranspose& trans,
1252 const Matrix<complex<double>, Prop0, ColMajor, Allocator0>& A,
1253 const Vector<complex<double>, VectFull, Allocator1>& tau,
1254 Matrix<complex<double>, Prop0, ColMajor, Allocator2>& C,
1258 #ifdef SELDON_CHECK_DIMENSIONS
1259 if (tau.GetM() < min(A.GetM(), A.GetN()))
1260 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1262 if ( (side.Left() && C.GetM() < A.GetN())
1263 || (side.Right() && C.GetN() < A.GetN()))
1264 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1269 int lwork = max(A.GetM(), A.GetN());
1270 Vector<complex<double>, VectFull, Allocator1> work(lwork);
1271 char side_ = side.Char();
1272 char trans_ = trans.Char();
1274 int k = min(A.GetM(), A.GetN());
1276 zunmlq_(&side_, &trans_, &m, &n, &k, A.GetDataVoid(), &lda,
1277 tau.GetDataVoid(), C.GetDataVoid(), &m,
1278 work.GetDataVoid(), &lwork, &info.GetInfoRef());
1285 template<
class Prop0,
class Allocator0,
1286 class Allocator1,
class Allocator2>
1287 void MltQ_FromQR(
const SeldonTranspose& trans,
1288 const Matrix<float, Prop0, RowMajor, Allocator0>& A,
1289 const Vector<float, VectFull, Allocator1>& tau,
1290 Vector<float, VectFull, Allocator2>& b,
1295 #ifdef SELDON_CHECK_DIMENSIONS
1296 if (tau.GetM() < min(lda, A.GetM()))
1297 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1299 if (b.GetM() < A.GetM())
1300 throw WrongDim(
"MltQ_FromQR",
"b not large enough");
1306 int lwork = max(m, n);
1307 Vector<float, VectFull, Allocator1> work(lwork);
1309 char trans_ = trans.RevChar();
1310 sormlq_(&side, &trans_, &m, &n, &k, A.GetData(), &lda, tau.GetData(),
1311 b.GetData(), &m, work.GetData(), &lwork,
1312 &info.GetInfoRef());
1316 template<
class Prop0,
class Allocator0,
1317 class Allocator1,
class Allocator2>
1318 void MltQ_FromQR(
const SeldonTranspose& trans,
1319 const Matrix<complex<float>, Prop0, RowMajor, Allocator0>& A,
1320 const Vector<complex<float>, VectFull, Allocator1>& tau,
1321 Vector<complex<float>, VectFull, Allocator2>& b,
1326 #ifdef SELDON_CHECK_DIMENSIONS
1327 if (tau.GetM() < min(lda, A.GetM()))
1328 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1330 if (b.GetM() < A.GetM())
1331 throw WrongDim(
"MltQ_FromQR",
"b not large enough");
1337 int lwork = max(m, n);
1338 Vector<complex<float>, VectFull, Allocator1> work(lwork);
1341 if (trans.ConjTrans())
1345 cunmlq_(&side, &trans_, &m, &n, &k, A.GetDataVoid(), &lda, tau.GetDataVoid(),
1346 b.GetDataVoid(), &m, work.GetDataVoid(), &lwork,
1347 &info.GetInfoRef());
1353 template<
class Prop0,
class Allocator0,
1354 class Allocator1,
class Allocator2>
1355 void MltQ_FromQR(
const SeldonTranspose& trans,
1356 const Matrix<double, Prop0, RowMajor, Allocator0>& A,
1357 const Vector<double, VectFull, Allocator1>& tau,
1358 Vector<double, VectFull, Allocator2>& b,
1363 #ifdef SELDON_CHECK_DIMENSIONS
1364 if (tau.GetM() < min(lda, A.GetM()))
1365 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1367 if (b.GetM() < A.GetM())
1368 throw WrongDim(
"MltQ_FromQR",
"b not large enough");
1374 int lwork = max(m, n);
1375 Vector<double, VectFull, Allocator1> work(lwork);
1377 char trans_ = trans.RevChar();
1378 dormlq_(&side, &trans_, &m, &n, &k, A.GetData(), &lda, tau.GetData(),
1379 b.GetData(), &m, work.GetData(), &lwork,
1380 &info.GetInfoRef());
1384 template<
class Prop0,
class Allocator0,
1385 class Allocator1,
class Allocator2>
1386 void MltQ_FromQR(
const SeldonTranspose& trans,
1387 const Matrix<complex<double>, Prop0, RowMajor, Allocator0>& A,
1388 const Vector<complex<double>, VectFull, Allocator1>& tau,
1389 Vector<complex<double>, VectFull, Allocator2>& b,
1394 #ifdef SELDON_CHECK_DIMENSIONS
1395 if (tau.GetM() < min(lda, A.GetM()))
1396 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1398 if (b.GetM() < A.GetM())
1399 throw WrongDim(
"MltQ_FromQR",
"b not large enough");
1405 int lwork = max(m, n);
1406 Vector<complex<double>, VectFull, Allocator1> work(lwork);
1409 if (trans.ConjTrans())
1413 zunmlq_(&side, &trans_, &m, &n, &k, A.GetDataVoid(), &lda, tau.GetDataVoid(),
1414 b.GetDataVoid(), &m, work.GetDataVoid(), &lwork,
1415 &info.GetInfoRef());
1421 template<
class Prop0,
class Allocator0,
1422 class Allocator1,
class Allocator2>
1423 void MltQ_FromQR(
const SeldonSide& side,
const SeldonTranspose& trans,
1424 const Matrix<float, Prop0, RowMajor, Allocator0>& A,
1425 const Vector<float, VectFull, Allocator1>& tau,
1426 Matrix<float, Prop0, RowMajor, Allocator2>& C,
1430 #ifdef SELDON_CHECK_DIMENSIONS
1431 if (tau.GetM() < min(A.GetM(), A.GetN()))
1432 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1434 if ( (side.Left() && C.GetM() < A.GetM())
1435 || (side.Right() && C.GetN() < A.GetM()))
1436 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1441 int lwork = max(A.GetM(), A.GetN());
1442 Vector<float, VectFull, Allocator1> work(lwork);
1443 char side_ = side.RevChar();
1444 char trans_ = trans.Char();
1446 int k = min(A.GetM(), A.GetN());
1448 sormlq_(&side_, &trans_, &n, &m, &k, A.GetData(), &lda,
1449 tau.GetData(), C.GetData(), &n, work.GetData(), &lwork,
1450 &info.GetInfoRef());
1454 template<
class Prop0,
class Allocator0,
1455 class Allocator1,
class Allocator2>
1456 void MltQ_FromQR(
const SeldonSide& side,
const SeldonTranspose& trans,
1457 const Matrix<complex<float>, Prop0, RowMajor, Allocator0>& A,
1458 const Vector<complex<float>, VectFull, Allocator1>& tau,
1459 Matrix<complex<float>, Prop0, RowMajor, Allocator2>& C,
1463 #ifdef SELDON_CHECK_DIMENSIONS
1464 if (tau.GetM() < min(A.GetM(), A.GetN()))
1465 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1467 if ( (side.Left() && C.GetM() < A.GetM())
1468 || (side.Right() && C.GetN() < A.GetM()))
1469 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1474 int lwork = max(A.GetM(), A.GetN());
1475 Vector<complex<float>, VectFull, Allocator1> work(lwork);
1476 char side_ = side.RevChar();
1477 char trans_ = trans.Char();
1479 int k = min(A.GetM(), A.GetN());
1481 cunmlq_(&side_, &trans_, &n, &m, &k, A.GetDataVoid(), &lda,
1482 tau.GetDataVoid(), C.GetDataVoid(), &n,
1483 work.GetDataVoid(), &lwork, &info.GetInfoRef());
1487 template<
class Prop0,
class Allocator0,
1488 class Allocator1,
class Allocator2>
1489 void MltQ_FromQR(
const SeldonSide& side,
const SeldonTranspose& trans,
1490 const Matrix<double, Prop0, RowMajor, Allocator0>& A,
1491 const Vector<double, VectFull, Allocator1>& tau,
1492 Matrix<double, Prop0, RowMajor, Allocator2>& C,
1496 #ifdef SELDON_CHECK_DIMENSIONS
1497 if (tau.GetM() < min(A.GetM(), A.GetN()))
1498 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1500 if ( (side.Left() && C.GetM() < A.GetM())
1501 || (side.Right() && C.GetN() < A.GetM()))
1502 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1507 int lwork = max(A.GetM(), A.GetN());
1508 Vector<double, VectFull, Allocator1> work(lwork);
1509 char side_ = side.RevChar();
1510 char trans_ = trans.Char();
1512 int k = min(A.GetM(), A.GetN());
1514 dormlq_(&side_, &trans_, &n, &m, &k, A.GetData(), &lda,
1515 tau.GetData(), C.GetData(), &n, work.GetData(), &lwork,
1516 &info.GetInfoRef());
1520 template<
class Prop0,
class Allocator0,
1521 class Allocator1,
class Allocator2>
1522 void MltQ_FromQR(
const SeldonSide& side,
const SeldonTranspose& trans,
1523 const Matrix<complex<double>, Prop0, RowMajor, Allocator0>& A,
1524 const Vector<complex<double>, VectFull, Allocator1>& tau,
1525 Matrix<complex<double>, Prop0, RowMajor, Allocator2>& C,
1529 #ifdef SELDON_CHECK_DIMENSIONS
1530 if (tau.GetM() < min(A.GetM(), A.GetN()))
1531 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1533 if ( (side.Left() && C.GetM() < A.GetM())
1534 || (side.Right() && C.GetN() < A.GetM()))
1535 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1540 int lwork = max(A.GetM(), A.GetN());
1541 Vector<complex<double>, VectFull, Allocator1> work(lwork);
1542 char side_ = side.RevChar();
1543 char trans_ = trans.Char();
1545 int k = min(A.GetM(), A.GetN());
1547 zunmlq_(&side_, &trans_, &n, &m, &k, A.GetDataVoid(), &lda,
1548 tau.GetDataVoid(), C.GetDataVoid(), &n,
1549 work.GetDataVoid(), &lwork, &info.GetInfoRef());
1553 template<
class Prop0,
class Allocator0,
1554 class Allocator1,
class Allocator2>
1555 void MltQ_FromLQ(
const SeldonTranspose& trans,
1556 const Matrix<float, Prop0, RowMajor, Allocator0>& A,
1557 const Vector<float, VectFull, Allocator1>& tau,
1558 Vector<float, VectFull, Allocator2>& b,
1563 #ifdef SELDON_CHECK_DIMENSIONS
1564 if (tau.GetM() < min(lda, A.GetM()))
1565 throw WrongDim(
"MltQ_FromLQ",
"tau not large enough");
1567 if (b.GetM() < A.GetN())
1568 throw WrongDim(
"MltQ_FromLQ",
"b not large enough");
1574 int lwork = max(m, n);
1575 Vector<float, VectFull, Allocator1> work(lwork);
1577 char trans_ = trans.RevChar();
1578 sormqr_(&side, &trans_, &m, &n, &k, A.GetData(), &lda, tau.GetData(),
1579 b.GetData(), &m, work.GetData(), &lwork,
1580 &info.GetInfoRef());
1584 template<
class Prop0,
class Allocator0,
1585 class Allocator1,
class Allocator2>
1586 void MltQ_FromLQ(
const SeldonTranspose& trans,
1587 const Matrix<complex<float>, Prop0, RowMajor, Allocator0>& A,
1588 const Vector<complex<float>, VectFull, Allocator1>& tau,
1589 Vector<complex<float>, VectFull, Allocator2>& b,
1594 #ifdef SELDON_CHECK_DIMENSIONS
1595 if (tau.GetM() < min(lda, A.GetM()))
1596 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1598 if (b.GetM() < A.GetN())
1599 throw WrongDim(
"MltQ_FromLQ",
"b not large enough");
1605 int lwork = max(m, n);
1606 Vector<complex<float>, VectFull, Allocator1> work(lwork);
1609 if (trans.ConjTrans())
1613 cunmqr_(&side, &trans_, &m, &n, &k, A.GetDataVoid(), &lda, tau.GetDataVoid(),
1614 b.GetDataVoid(), &m, work.GetDataVoid(), &lwork,
1615 &info.GetInfoRef());
1621 template<
class Prop0,
class Allocator0,
1622 class Allocator1,
class Allocator2>
1623 void MltQ_FromLQ(
const SeldonTranspose& trans,
1624 const Matrix<double, Prop0, RowMajor, Allocator0>& A,
1625 const Vector<double, VectFull, Allocator1>& tau,
1626 Vector<double, VectFull, Allocator2>& b,
1631 #ifdef SELDON_CHECK_DIMENSIONS
1632 if (tau.GetM() < min(lda, A.GetM()))
1633 throw WrongDim(
"MltQ_FromLQ",
"tau not large enough");
1635 if (b.GetM() < A.GetN())
1636 throw WrongDim(
"MltQ_FromLQ",
"b not large enough");
1642 int lwork = max(m, n);
1643 Vector<double, VectFull, Allocator1> work(lwork);
1645 char trans_ = trans.RevChar();
1646 dormqr_(&side, &trans_, &m, &n, &k, A.GetData(), &lda, tau.GetData(),
1647 b.GetData(), &m, work.GetData(), &lwork,
1648 &info.GetInfoRef());
1652 template<
class Prop0,
class Allocator0,
1653 class Allocator1,
class Allocator2>
1654 void MltQ_FromLQ(
const SeldonTranspose& trans,
1655 const Matrix<complex<double>, Prop0, RowMajor, Allocator0>& A,
1656 const Vector<complex<double>, VectFull, Allocator1>& tau,
1657 Vector<complex<double>, VectFull, Allocator2>& b,
1662 #ifdef SELDON_CHECK_DIMENSIONS
1663 if (tau.GetM() < min(lda, A.GetM()))
1664 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1666 if (b.GetM() < A.GetN())
1667 throw WrongDim(
"MltQ_FromLQ",
"b not large enough");
1673 int lwork = max(m, n);
1674 Vector<complex<double>, VectFull, Allocator1> work(lwork);
1677 if (trans.ConjTrans())
1681 zunmqr_(&side, &trans_, &m, &n, &k, A.GetDataVoid(), &lda, tau.GetDataVoid(),
1682 b.GetDataVoid(), &m, work.GetDataVoid(), &lwork,
1683 &info.GetInfoRef());
1689 template<
class Prop0,
class Allocator0,
1690 class Allocator1,
class Allocator2>
1691 void MltQ_FromLQ(
const SeldonSide& side,
const SeldonTranspose& trans,
1692 const Matrix<float, Prop0, RowMajor, Allocator0>& A,
1693 const Vector<float, VectFull, Allocator1>& tau,
1694 Matrix<float, Prop0, RowMajor, Allocator2>& C,
1698 #ifdef SELDON_CHECK_DIMENSIONS
1699 if (tau.GetM() < min(A.GetM(), A.GetN()))
1700 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1702 if ( (side.Left() && C.GetM() < A.GetN())
1703 || (side.Right() && C.GetN() < A.GetN()))
1704 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1709 int lwork = max(A.GetM(), A.GetN());
1710 Vector<float, VectFull, Allocator1> work(lwork);
1711 char side_ = side.RevChar();
1712 char trans_ = trans.Char();
1714 int k = min(A.GetM(), A.GetN());
1716 sormqr_(&side_, &trans_, &n, &m, &k, A.GetData(), &lda,
1717 tau.GetData(), C.GetData(), &n, work.GetData(), &lwork,
1718 &info.GetInfoRef());
1722 template<
class Prop0,
class Allocator0,
1723 class Allocator1,
class Allocator2>
1724 void MltQ_FromLQ(
const SeldonSide& side,
const SeldonTranspose& trans,
1725 const Matrix<complex<float>, Prop0, RowMajor, Allocator0>& A,
1726 const Vector<complex<float>, VectFull, Allocator1>& tau,
1727 Matrix<complex<float>, Prop0, RowMajor, Allocator2>& C,
1730 #ifdef SELDON_CHECK_DIMENSIONS
1731 if (tau.GetM() < min(A.GetM(), A.GetN()))
1732 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1734 if ( (side.Left() && C.GetM() < A.GetN())
1735 || (side.Right() && C.GetN() < A.GetN()))
1736 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1741 int lwork = max(A.GetM(), A.GetN());
1742 Vector<complex<float>, VectFull, Allocator1> work(lwork);
1743 char side_ = side.RevChar();
1744 char trans_ = trans.Char();
1746 int k = min(A.GetM(), A.GetN());
1748 cunmqr_(&side_, &trans_, &n, &m, &k, A.GetDataVoid(), &lda,
1749 tau.GetDataVoid(), C.GetDataVoid(), &n,
1750 work.GetDataVoid(), &lwork, &info.GetInfoRef());
1754 template<
class Prop0,
class Allocator0,
1755 class Allocator1,
class Allocator2>
1756 void MltQ_FromLQ(
const SeldonSide& side,
const SeldonTranspose& trans,
1757 const Matrix<double, Prop0, RowMajor, Allocator0>& A,
1758 const Vector<double, VectFull, Allocator1>& tau,
1759 Matrix<double, Prop0, RowMajor, Allocator2>& C,
1763 #ifdef SELDON_CHECK_DIMENSIONS
1764 if (tau.GetM() < min(A.GetM(), A.GetN()))
1765 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1767 if ( (side.Left() && C.GetM() < A.GetN())
1768 || (side.Right() && C.GetN() < A.GetN()))
1769 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1774 int lwork = max(A.GetM(), A.GetN());
1775 Vector<double, VectFull, Allocator1> work(lwork);
1776 char side_ = side.RevChar();
1777 char trans_ = trans.Char();
1779 int k = min(A.GetM(), A.GetN());
1781 dormqr_(&side_, &trans_, &n, &m, &k, A.GetData(), &lda,
1782 tau.GetData(), C.GetData(), &n, work.GetData(), &lwork,
1783 &info.GetInfoRef());
1787 template<
class Prop0,
class Allocator0,
1788 class Allocator1,
class Allocator2>
1789 void MltQ_FromLQ(
const SeldonSide& side,
const SeldonTranspose& trans,
1790 const Matrix<complex<double>, Prop0, RowMajor, Allocator0>& A,
1791 const Vector<complex<double>, VectFull, Allocator1>& tau,
1792 Matrix<complex<double>, Prop0, RowMajor, Allocator2>& C,
1795 #ifdef SELDON_CHECK_DIMENSIONS
1796 if (tau.GetM() < min(A.GetM(), A.GetN()))
1797 throw WrongDim(
"MltQ_FromQR",
"tau not large enough");
1799 if ( (side.Left() && C.GetM() < A.GetN())
1800 || (side.Right() && C.GetN() < A.GetN()))
1801 throw WrongDim(
"MltQ_FromQR",
"C not large enough");
1806 int lwork = max(A.GetM(), A.GetN());
1807 Vector<complex<double>, VectFull, Allocator1> work(lwork);
1808 char side_ = side.RevChar();
1809 char trans_ = trans.Char();
1811 int k = min(A.GetM(), A.GetN());
1813 zunmqr_(&side_, &trans_, &n, &m, &k, A.GetDataVoid(), &lda,
1814 tau.GetDataVoid(), C.GetDataVoid(), &n,
1815 work.GetDataVoid(), &lwork, &info.GetInfoRef());
1830 template <
class Prop0,
class Allocator0,
1831 class Allocator1,
class Allocator2>
1832 void SolveQR(
const Matrix<float, Prop0, ColMajor, Allocator0>& A,
1833 const Vector<float, VectFull, Allocator1>& tau,
1834 Vector<float, VectFull, Allocator2>& b,
1841 int nrhs = 1, nb = b.GetM();
1844 int lwork = max(m, n);
1845 Vector<float, VectFull, Allocator1> work(lwork);
1847 sormqr_(&side, &trans, &m, &nrhs, &k, A.GetData(),
1848 &m, tau.GetData(), b.GetData(),
1849 &m, work.GetData(), &lwork, &info.GetInfoRef());
1852 for (
int i = nb; i < n; i++)
1857 cblas_strsm(CblasColMajor, CblasLeft, CblasUpper, CblasNoTrans,
1858 CblasNonUnit, b.GetM(), nrhs,
1859 alpha, A.GetData(), A.GetM(), b.GetData(), b.GetM());
1863 template <
class Prop0,
class Allocator0,
1864 class Allocator1,
class Allocator2>
1865 void SolveQR(
const Matrix<double, Prop0, ColMajor, Allocator0>& A,
1866 const Vector<double, VectFull, Allocator1>& tau,
1867 Vector<double, VectFull, Allocator2>& b,
1874 #ifdef SELDON_CHECK_DIMENSIONS
1875 if (tau.GetM() < min(m, n))
1876 throw WrongDim(
"SolveQR",
"tau not large enough");
1879 throw WrongDim(
"SolveQR",
"b not large enough");
1885 int lwork = max(m, n);
1886 Vector<double, VectFull, Allocator1> work(lwork);
1888 dormqr_(&side, &trans, &m, &nrhs, &k, A.GetData(),
1889 &m, tau.GetData(), b.GetData(),
1890 &lwork, work.GetData(), &lwork, &info.GetInfoRef());
1897 cblas_dtrsm(CblasColMajor, CblasLeft, CblasUpper, CblasNoTrans,
1898 CblasNonUnit, b.GetM(), nrhs,
1899 alpha, A.GetData(), A.GetM(), b.GetData(), b.GetM());
1903 template <
class Prop0,
class Allocator0,
1904 class Allocator1,
class Allocator2>
1905 void SolveQR(
const Matrix<complex<float>, Prop0, ColMajor, Allocator0>& A,
1906 const Vector<complex<float>, VectFull, Allocator1>& tau,
1907 Vector<complex<float>, VectFull, Allocator2>& b,
1914 #ifdef SELDON_CHECK_DIMENSIONS
1915 if (tau.GetM() < min(m, n))
1916 throw WrongDim(
"SolveQR",
"tau not large enough");
1919 throw WrongDim(
"SolveQR",
"b not large enough");
1925 int lwork = max(m, n);
1926 Vector<complex<float>, VectFull, Allocator1> work(lwork);
1928 cunmqr_(&side, &trans, &m, &nrhs, &k, A.GetData(),
1929 &m, tau.GetData(), b.GetData(),
1930 &m, work.GetData(), &lwork, &info.GetInfoRef());
1936 complex<float> alpha(1);
1937 cblas_ctrsm(CblasColMajor, CblasLeft, CblasUpper, CblasNoTrans,
1938 CblasNonUnit, b.GetM(), nrhs,
1939 &alpha, A.GetData(), A.GetM(), b.GetData(), b.GetM());
1943 template <
class Prop0,
class Allocator0,
1944 class Allocator1,
class Allocator2>
1945 void SolveQR(
const Matrix<complex<double>, Prop0, ColMajor, Allocator0>& A,
1946 const Vector<complex<double>, VectFull, Allocator1>& tau,
1947 Vector<complex<double>, VectFull, Allocator2>& b,
1954 #ifdef SELDON_CHECK_DIMENSIONS
1955 if (tau.GetM() < min(m, n))
1956 throw WrongDim(
"SolveQR",
"tau not large enough");
1959 throw WrongDim(
"SolveQR",
"b not large enough");
1965 int lwork = max(m, n);
1966 Vector<complex<double>, VectFull, Allocator1> work(lwork);
1968 zunmqr_(&side, &trans, &m, &nrhs, &k, A.GetData(),
1969 &m, tau.GetData(), b.GetData(),
1970 &m, work.GetData(), &lwork, &info.GetInfoRef());
1976 complex<double> alpha(1);
1977 cblas_ztrsm(CblasColMajor, CblasLeft, CblasUpper, CblasNoTrans,
1978 CblasNonUnit, b.GetM(), nrhs,
1979 &alpha, A.GetData(), A.GetM(), b.GetData(), b.GetM());
1986 template <
class Prop0,
class Allocator0,
1987 class Allocator1,
class Allocator2>
1988 void SolveQR(
const Matrix<float, Prop0, RowMajor, Allocator0>& A,
1989 const Vector<float, VectFull, Allocator1>& tau,
1990 Vector<float, VectFull, Allocator2>& b,
1996 #ifdef SELDON_CHECK_DIMENSIONS
1997 if (tau.GetM() < min(m, n))
1998 throw WrongDim(
"SolveQR",
"tau not large enough");
2001 throw WrongDim(
"SolveQR",
"b not large enough");
2008 int lwork = max(m, n);
2009 Vector<float, VectFull, Allocator1> work(lwork);
2011 sormlq_(&side, &trans, &m, &nrhs, &k, A.GetData(),
2012 &n, tau.GetData(), b.GetData(),
2013 &m, work.GetData(), &lwork, &info.GetInfoRef());
2015 for (
int i = m; i < n; i++)
2020 cblas_strsm(CblasColMajor, CblasLeft, CblasLower, CblasTrans,
2021 CblasNonUnit, n, nrhs,
2022 alpha, A.GetData(), n, b.GetData(), b.GetM());
2026 template <
class Prop0,
class Allocator0,
2027 class Allocator1,
class Allocator2>
2028 void SolveQR(
const Matrix<double, Prop0, RowMajor, Allocator0>& A,
2029 const Vector<double, VectFull, Allocator1>& tau,
2030 Vector<double, VectFull, Allocator2>& b,
2036 #ifdef SELDON_CHECK_DIMENSIONS
2037 if (tau.GetM() < min(m, n))
2038 throw WrongDim(
"SolveQR",
"tau not large enough");
2041 throw WrongDim(
"SolveQR",
"b not large enough");
2048 int lwork = max(m, n);
2049 Vector<double, VectFull, Allocator1> work(lwork);
2051 dormlq_(&side, &trans, &m, &nrhs, &k, A.GetData(),
2052 &n, tau.GetData(), b.GetData(),
2053 &m, work.GetData(), &lwork, &info.GetInfoRef());
2060 cblas_dtrsm(CblasColMajor, CblasLeft, CblasLower, CblasTrans,
2061 CblasNonUnit, k, nrhs,
2062 alpha, A.GetData(), n, b.GetData(), b.GetM());
2068 template <
class Prop0,
class Allocator0,
2069 class Allocator1,
class Allocator2>
2070 void SolveQR(
const Matrix<double, Prop0, RowMajor, Allocator0>& A,
2071 const Vector<double, VectFull, Allocator1>& tau,
2072 Vector<complex<double>, VectFull, Allocator2>& b,
2078 #ifdef SELDON_CHECK_DIMENSIONS
2079 if (tau.GetM() < min(m, n))
2080 throw WrongDim(
"SolveQR",
"tau not large enough");
2083 throw WrongDim(
"SolveQR",
"b not large enough");
2090 int lwork = max(m, n);
2091 Vector<double, VectFull, Allocator1> work(lwork);
2092 Vector<double> rhs(2*m);
2093 for (
int i = 0; i < m; i++)
2095 rhs(i) = realpart(b(i));
2096 rhs(i+m) = imagpart(b(i));
2100 dormlq_(&side, &trans, &m, &nrhs, &k, A.GetData(),
2101 &n, tau.GetData(), rhs.GetData(),
2102 &m, work.GetData(), &lwork, &info.GetInfoRef());
2104 for (
int i = 0; i < n; i++)
2105 rhs(i+n) = rhs(i+m);
2111 cblas_dtrsm(CblasColMajor, CblasLeft, CblasLower, CblasTrans,
2112 CblasNonUnit, k, nrhs,
2113 alpha, A.GetData(), n, rhs.GetData(), n);
2116 for (
int i = 0; i < n; i++)
2117 b(i) = complex<double>(rhs(i), rhs(i+n));
2121 template <
class Prop0,
class Allocator0,
2122 class Allocator1,
class Allocator2>
2123 void SolveQR(
const Matrix<complex<float>, Prop0, RowMajor, Allocator0>& A,
2124 const Vector<complex<float>, VectFull, Allocator1>& tau,
2125 Vector<complex<float>, VectFull, Allocator2>& b,
2132 #ifdef SELDON_CHECK_DIMENSIONS
2133 if (tau.GetM() < min(m, n))
2134 throw WrongDim(
"SolveQR",
"tau not large enough");
2137 throw WrongDim(
"SolveQR",
"b not large enough");
2143 int lwork = max(m, n);
2144 Vector<complex<float>, VectFull, Allocator1> work(lwork);
2147 cunmlq_(&side, &trans, &m, &nrhs, &k, A.GetData(),
2148 &n, tau.GetData(), b.GetData(),
2149 &m, work.GetData(), &lwork, &info.GetInfoRef());
2156 complex<float> alpha(1);
2157 cblas_ctrsm(CblasColMajor, CblasLeft, CblasLower, CblasTrans,
2158 CblasNonUnit, k, nrhs,
2159 &alpha, A.GetData(), n, b.GetData(), b.GetM());
2163 template <
class Prop0,
class Allocator0,
2164 class Allocator1,
class Allocator2>
2165 void SolveQR(
const Matrix<complex<double>, Prop0, RowMajor, Allocator0>& A,
2166 const Vector<complex<double>, VectFull, Allocator1>& tau,
2167 Vector<complex<double>, VectFull, Allocator2>& b,
2174 #ifdef SELDON_CHECK_DIMENSIONS
2175 if (tau.GetM() < min(m, n))
2176 throw WrongDim(
"SolveQR",
"tau not large enough");
2179 throw WrongDim(
"SolveQR",
"b not large enough");
2185 int lwork = max(m, n);
2186 Vector<complex<double>, VectFull, Allocator1> work(lwork);
2189 zunmlq_(&side, &trans, &m, &nrhs, &k, A.GetData(),
2190 &n, tau.GetData(), b.GetData(),
2191 &m, work.GetData(), &lwork, &info.GetInfoRef());
2198 complex<double> alpha(1);
2199 cblas_ztrsm(CblasColMajor, CblasLeft, CblasLower, CblasTrans,
2200 CblasNonUnit, k, nrhs,
2201 &alpha, A.GetData(), n, b.GetData(), b.GetM());
2216 template <
class Prop0,
class Allocator0,
2217 class Allocator1,
class Allocator2>
2218 void SolveLQ(
const Matrix<float, Prop0, ColMajor, Allocator0>& A,
2219 const Vector<float, VectFull, Allocator1>& tau,
2220 Vector<float, VectFull, Allocator2>& b,
2226 throw Undefined(
"SolveLQ",
"Function implemented only for n >= m");
2229 int nrhs = 1, nb = b.GetM();
2232 int lwork = max(m, n);
2233 Vector<float, VectFull, Allocator1> work(lwork);
2236 cblas_strsm(CblasColMajor, CblasLeft, CblasLower, CblasNoTrans,
2237 CblasNonUnit, m, nrhs,
2238 alpha, A.GetData(), m, b.GetData(), b.GetM());
2241 for (
int i = nb; i < n; i++)
2245 sormlq_(&side, &trans, &n, &nrhs, &k, A.GetData(),
2246 &m, tau.GetData(), b.GetData(),
2247 &n, work.GetData(), &lwork, &info.GetInfoRef());
2251 template <
class Prop0,
class Allocator0,
2252 class Allocator1,
class Allocator2>
2253 void SolveLQ(
const Matrix<double, Prop0, ColMajor, Allocator0>& A,
2254 const Vector<double, VectFull, Allocator1>& tau,
2255 Vector<double, VectFull, Allocator2>& b,
2261 throw Undefined(
"SolveLQ",
"Function implemented only for n >= m");
2263 #ifdef SELDON_CHECK_DIMENSIONS
2264 if (tau.GetM() < min(m, n))
2265 throw WrongDim(
"SolveLQ",
"tau not large enough");
2268 throw WrongDim(
"SolveLQ",
"b not large enough");
2275 int lwork = max(m, n);
2276 Vector<double, VectFull, Allocator1> work(lwork);
2279 cblas_dtrsm(CblasColMajor, CblasLeft, CblasLower, CblasNoTrans,
2280 CblasNonUnit, m, nrhs,
2281 alpha, A.GetData(), m, b.GetData(), b.GetM());
2284 for (
int i = m; i < n; i++)
2288 dormlq_(&side, &trans, &n, &nrhs, &k, A.GetData(),
2289 &m, tau.GetData(), b.GetData(),
2290 &n, work.GetData(), &lwork, &info.GetInfoRef());
2294 template <
class Prop0,
class Allocator0,
2295 class Allocator1,
class Allocator2>
2296 void SolveLQ(
const Matrix<complex<float>, Prop0, ColMajor, Allocator0>& A,
2297 const Vector<complex<float>, VectFull, Allocator1>& tau,
2298 Vector<complex<float>, VectFull, Allocator2>& b,
2304 throw Undefined(
"SolveLQ",
"Function implemented only for n >= m");
2306 #ifdef SELDON_CHECK_DIMENSIONS
2307 if (tau.GetM() < min(m, n))
2308 throw WrongDim(
"SolveLQ",
"tau not large enough");
2311 throw WrongDim(
"SolveLQ",
"b not large enough");
2318 int lwork = max(m, n);
2319 Vector<complex<float>, VectFull, Allocator1> work(lwork);
2321 complex<float> alpha(1);
2322 cblas_ctrsm(CblasColMajor, CblasLeft, CblasLower, CblasNoTrans,
2323 CblasNonUnit, m, nrhs,
2324 &alpha, A.GetData(), m, b.GetData(), b.GetM());
2327 for (
int i = m; i < n; i++)
2331 cunmlq_(&side, &trans, &n, &nrhs, &k, A.GetData(),
2332 &m, tau.GetData(), b.GetData(),
2333 &n, work.GetData(), &lwork, &info.GetInfoRef());
2337 template <
class Prop0,
class Allocator0,
2338 class Allocator1,
class Allocator2>
2339 void SolveLQ(
const Matrix<complex<double>, Prop0, ColMajor, Allocator0>& A,
2340 const Vector<complex<double>, VectFull, Allocator1>& tau,
2341 Vector<complex<double>, VectFull, Allocator2>& b,
2347 throw Undefined(
"SolveLQ",
"Function implemented only for n >= m");
2349 #ifdef SELDON_CHECK_DIMENSIONS
2350 if (tau.GetM() < min(m, n))
2351 throw WrongDim(
"SolveLQ",
"tau not large enough");
2354 throw WrongDim(
"SolveLQ",
"b not large enough");
2361 int lwork = max(m, n);
2362 Vector<complex<double>, VectFull, Allocator1> work(lwork);
2364 complex<double> alpha(1);
2365 cblas_ztrsm(CblasColMajor, CblasLeft, CblasLower, CblasNoTrans,
2366 CblasNonUnit, m, nrhs,
2367 &alpha, A.GetData(), m, b.GetData(), b.GetM());
2370 for (
int i = m; i < n; i++)
2374 zunmlq_(&side, &trans, &n, &nrhs, &k, A.GetData(),
2375 &m, tau.GetData(), b.GetData(),
2376 &n, work.GetData(), &lwork, &info.GetInfoRef());
2383 template <
class Prop0,
class Allocator0,
2384 class Allocator1,
class Allocator2>
2385 void SolveLQ(
const Matrix<float, Prop0, RowMajor, Allocator0>& A,
2386 const Vector<float, VectFull, Allocator1>& tau,
2387 Vector<float, VectFull, Allocator2>& b,
2393 throw Undefined(
"SolveLQ",
"Function implemented only for n >= m");
2395 #ifdef SELDON_CHECK_DIMENSIONS
2396 if (tau.GetM() < min(m, n))
2397 throw WrongDim(
"SolveLQ",
"tau not large enough");
2400 throw WrongDim(
"SolveLQ",
"b not large enough");
2407 int lwork = max(m, n);
2408 Vector<float, VectFull, Allocator1> work(lwork);
2411 cblas_strsm(CblasColMajor, CblasLeft, CblasUpper, CblasTrans,
2412 CblasNonUnit, k, nrhs,
2413 alpha, A.GetData(), A.GetN(), b.GetData(), b.GetM());
2415 for (
int i = m; i < n; i++)
2419 sormqr_(&side, &trans, &n, &nrhs, &k, A.GetData(),
2420 &n, tau.GetData(), b.GetData(),
2421 &n, work.GetData(), &lwork, &info.GetInfoRef());
2425 template <
class Prop0,
class Allocator0,
2426 class Allocator1,
class Allocator2>
2427 void SolveLQ(
const Matrix<double, Prop0, RowMajor, Allocator0>& A,
2428 const Vector<double, VectFull, Allocator1>& tau,
2429 Vector<double, VectFull, Allocator2>& b,
2435 throw Undefined(
"SolveLQ",
"Function implemented only for n >= m");
2437 #ifdef SELDON_CHECK_DIMENSIONS
2438 if (tau.GetM() < min(m, n))
2439 throw WrongDim(
"SolveLQ",
"tau not large enough");
2442 throw WrongDim(
"SolveLQ",
"b not large enough");
2449 int lwork = max(m, n);
2450 Vector<double, VectFull, Allocator1> work(lwork);
2453 cblas_dtrsm(CblasColMajor, CblasLeft, CblasUpper, CblasTrans,
2454 CblasNonUnit, k, nrhs,
2455 alpha, A.GetData(), A.GetN(), b.GetData(), b.GetM());
2457 for (
int i = m; i < n; i++)
2461 dormqr_(&side, &trans, &n, &nrhs, &k, A.GetData(),
2462 &n, tau.GetData(), b.GetData(),
2463 &n, work.GetData(), &lwork, &info.GetInfoRef());
2467 template <
class Prop0,
class Allocator0,
2468 class Allocator1,
class Allocator2>
2469 void SolveLQ(
const Matrix<complex<float>, Prop0, RowMajor, Allocator0>& A,
2470 const Vector<complex<float>, VectFull, Allocator1>& tau,
2471 Vector<complex<float>, VectFull, Allocator2>& b,
2477 throw Undefined(
"SolveLQ",
"Function implemented only for n >= m");
2479 #ifdef SELDON_CHECK_DIMENSIONS
2480 if (tau.GetM() < min(m, n))
2481 throw WrongDim(
"SolveLQ",
"tau not large enough");
2484 throw WrongDim(
"SolveLQ",
"b not large enough");
2491 int lwork = max(m, n);
2492 Vector<complex<float>, VectFull, Allocator1> work(lwork);
2494 complex<float> alpha(1);
2495 cblas_ctrsm(CblasColMajor, CblasLeft, CblasUpper, CblasTrans,
2496 CblasNonUnit,k, nrhs,
2497 &alpha, A.GetData(), A.GetN(), b.GetData(), b.GetM());
2499 for (
int i = m; i < n; i++)
2504 cunmqr_(&side, &trans, &n, &nrhs, &k, A.GetData(),
2505 &n, tau.GetData(), b.GetData(),
2506 &n, work.GetData(), &lwork, &info.GetInfoRef());
2512 template <
class Prop0,
class Allocator0,
2513 class Allocator1,
class Allocator2>
2514 void SolveLQ(
const Matrix<complex<double>, Prop0, RowMajor, Allocator0>& A,
2515 const Vector<complex<double>, VectFull, Allocator1>& tau,
2516 Vector<complex<double>, VectFull, Allocator2>& b,
2522 throw Undefined(
"SolveLQ",
"Function implemented only for n >= m");
2524 #ifdef SELDON_CHECK_DIMENSIONS
2525 if (tau.GetM() < min(m, n))
2526 throw WrongDim(
"SolveLQ",
"tau not large enough");
2529 throw WrongDim(
"SolveLQ",
"b not large enough");
2536 int lwork = max(m, n);
2537 Vector<complex<double>, VectFull, Allocator1> work(lwork);
2539 complex<double> alpha(1);
2540 cblas_ztrsm(CblasColMajor, CblasLeft, CblasUpper, CblasTrans,
2541 CblasNonUnit,k, nrhs,
2542 &alpha, A.GetData(), A.GetN(), b.GetData(), b.GetM());
2544 for (
int i = m; i < n; i++)
2549 zunmqr_(&side, &trans, &n, &nrhs, &k, A.GetData(),
2550 &n, tau.GetData(), b.GetData(),
2551 &n, work.GetData(), &lwork, &info.GetInfoRef());
2565 template<
class T,
class Prop,
class Storage,
class Allocator,
2566 class T2,
class Prop2,
class Storage2,
class Allocator2>
2574 SetComplexZero(zero);
2581 for (
int i = 0; i < m; i++)
2582 for (
int j = 0; j <= min(i, k-1); j++)
2583 B.Set(i, j, A(i, j));
2592 template<
class T,
class Prop,
class Storage,
class Allocator,
2593 class T2,
class Prop2,
class Storage2,
class Allocator2>
2601 SetComplexZero(zero);
2604 B.Reallocate(min(m, n), n);
2607 for (
int i = 0; i < min(m, n); i++)
2608 for (
int j = i; j < n; j++)
2609 B.Set(i, j, A(i, j));
2618 template<
class T,
class Prop,
class Storage,
class Allocator,
2619 class T2,
class Prop2,
class Storage2,
class Allocator2,
2620 class T3,
class Prop3,
class Storage3,
class Allocator3>
2634 GetQ_FromQR(Q, tau);
2642 template<
class T,
class Prop,
class Storage,
class Allocator,
2643 class T2,
class Prop2,
class Storage2,
class Allocator2,
2644 class T3,
class Prop3,
class Storage3,
class Allocator3>
2658 GetQ_FromLQ(Q, tau);
2663 #define SELDON_FILE_LAPACK_LEAST_SQUARES_CXX