cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nmrLSqLin.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Ankur Kapoor
7  Created on: 2005-10-18
8 
9  (C) Copyright 2005-2015 Johns Hopkins University (JHU), All Rights Reserved.
10 
11 --- begin cisst license - do not edit ---
12 
13 This software is provided "as is" under an open source license, with
14 no warranty. The complete license can be found in license.txt and
15 http://www.cisst.org/cisst/license.txt.
16 
17 --- end cisst license ---
18 */
19 
20 
27 #ifndef _nmrLSqLin_h
28 #define _nmrLSqLin_h
29 
30 #include <algorithm>
31 #include <cisstCommon/cmnThrow.h>
35 
36 // Always include last
38 
107 /*
108  ****************************************************************************
109  DYNAMIC SIZE
110  ****************************************************************************
111  */
112 
116 protected:
140 
155 
156  /* Just store Ma, Me, Mg, and N, which are needed
157  to check if A matrix passed to solve method matches
158  the allocated size.
159  For LS problem Me == 0 and Mg ==0
160  For LSI problem Me == 0
161  Otherwise LSEI problem
162  */
163  size_t m_Ma;
164  size_t m_Me;
165  size_t m_Mg;
166  size_t m_N;
167 
168 public:
174  static inline CISSTNETLIB_INTEGER GetWorkspaceSize(size_t ma, size_t me, size_t mg, size_t n)
175  {
176  CISSTNETLIB_INTEGER lwork;
177  if ((me == 0) && (mg ==0)) { // case LS (dgels)
178  // Following produces same result as QueryWorkspaceSize_LS().
179  CISSTNETLIB_INTEGER minmn = static_cast<CISSTNETLIB_INTEGER>(std::max(std::min(ma,n),static_cast<size_t>(1)));
180  lwork = 2*minmn;
181  } else if (me == 0) { // case LSI
182  size_t k = std::max(ma+mg,n);
183  lwork = static_cast<CISSTNETLIB_INTEGER>(k+n+(mg+2)*(n+7));
184  } else { // case LSEI
185  size_t k = std::max(ma+mg,n);
186  lwork = static_cast<CISSTNETLIB_INTEGER>(2*(me+n)+k+(mg+2)*(n+7));
187  }
188  return lwork;
189  }
190 
191  static inline CISSTNETLIB_INTEGER GetIWorkspaceSize(size_t CMN_UNUSED(ma), size_t me, size_t mg, size_t n)
192  {
193  if ((me == 0) && (mg ==0)) { // case LS
194  return 0;
195  } else if (me == 0) { // case LSI
196  return static_cast<CISSTNETLIB_INTEGER>(mg+2*n+1);
197  } else { // case LSEI
198  return static_cast<CISSTNETLIB_INTEGER>(mg+2*n+2);
199  }
200  }
201 
204  static CISSTNETLIB_INTEGER QueryWorkspaceSize_LS(size_t ma, size_t n)
205  {
206  // @see http://www.netlib.org/clapack/CLAPACK-3.1.1/SRC/dgels.c
207  // ma = rows of matrix A, aka M
208  // n = cols of matrix A, aka N
209  char trans = 'N';
210  CISSTNETLIB_INTEGER Mrows = static_cast<CISSTNETLIB_INTEGER>(ma);
211  CISSTNETLIB_INTEGER Ncols = static_cast<CISSTNETLIB_INTEGER>(n);
212  CISSTNETLIB_INTEGER nrhs = 1;
213  CISSTNETLIB_INTEGER lda = static_cast<CISSTNETLIB_INTEGER>(std::max(ma,static_cast<size_t>(1)));
214  CISSTNETLIB_INTEGER ldb = static_cast<CISSTNETLIB_INTEGER>(std::max(std::max(static_cast<size_t>(1),ma),n));
215  CISSTNETLIB_INTEGER lwork = -1; // calculate what lwork should be
216  CISSTNETLIB_INTEGER info;
217  CISSTNETLIB_DOUBLE work;
218 
219 #if defined(CISSTNETLIB_VERSION_MAJOR)
220 #if (CISSTNETLIB_VERSION_MAJOR >= 3)
221  cisstNetlib_dgels_(&trans, &Mrows, &Ncols, &nrhs,
222  0, &lda,
223  0, &ldb,
224  &work, &lwork, &info);
225 #endif
226 #else // no major version
227  dgels_(&trans, &Mrows, &Ncols, &nrhs,
228  0, &lda,
229  0, &ldb,
230  &work, &lwork, &info);
231 #endif // CISSTNETLIB_VERSION
232  CMN_ASSERT(info == 0);
233  // optimal work array size lwork is stored in first entry of work array
234  return static_cast<CISSTNETLIB_INTEGER>(work);
235  }
236 
240  template <typename _matrixOwnerTypeA>
242  {
243  return nmrLSqLinSolutionDynamic::GetWorkspaceSize(inA.rows(), 0, 0, inA.cols());
244  }
248  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeG>
251  {
252  return nmrLSqLinSolutionDynamic::GetWorkspaceSize(inA.rows(), 0, inG.rows(), inA.cols());
253  }
254  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeG>
257  {
258  return nmrLSqLinSolutionDynamic::GetIWorkspaceSize(inA.rows(), 0, inG.rows(), inA.cols());
259  }
263  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeE, typename _matrixOwnerTypeG>
267  {
268  return nmrLSqLinSolutionDynamic::GetWorkspaceSize(inA.rows(), inE.rows(), inG.rows(), inA.cols());
269  }
270  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeE, typename _matrixOwnerTypeG>
274  {
275  return nmrLSqLinSolutionDynamic::GetIWorkspaceSize(inA.rows(), inE.rows(), inG.rows(), inA.cols());
276  }
277 
283  static inline void AllocateWorkspace(CISSTNETLIB_INTEGER ma, CISSTNETLIB_INTEGER me, CISSTNETLIB_INTEGER mg, CISSTNETLIB_INTEGER n, vctDynamicVector<CISSTNETLIB_DOUBLE> &inWork)
284  {
286  }
287  static inline void AllocateIWorkspace(CISSTNETLIB_INTEGER ma, CISSTNETLIB_INTEGER me, CISSTNETLIB_INTEGER mg, CISSTNETLIB_INTEGER n, vctDynamicVector<CISSTNETLIB_INTEGER> &inIWork)
288  {
290  }
296  template <typename _matrixOwnerTypeA>
298  {
300  }
306  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeG>
310  {
312  }
313  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeG>
317  {
319  }
325  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeE, typename _matrixOwnerTypeG>
330  {
332  }
333  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeE, typename _matrixOwnerTypeG>
338  {
340  }
341 
354  class Friend {
355  private:
356  nmrLSqLinSolutionDynamic &solution;
357  public:
358  Friend(nmrLSqLinSolutionDynamic &insolution):solution(insolution) {
359  }
361  return solution.A;
362  }
364  return solution.E;
365  }
367  return solution.G;
368  }
370  return solution.b;
371  }
373  return solution.f;
374  }
376  return solution.h;
377  }
379  return solution.X;
380  }
382  return solution.RNorm;
383  }
385  return solution.InputMemory;
386  }
388  return solution.Work;
389  }
391  return solution.IWork;
392  }
393  inline CISSTNETLIB_INTEGER GetMa(void) {
394  return static_cast<CISSTNETLIB_INTEGER>(solution.m_Ma);
395  }
396  inline CISSTNETLIB_INTEGER GetMe(void) {
397  return static_cast<CISSTNETLIB_INTEGER>(solution.m_Me);
398  }
399  inline CISSTNETLIB_INTEGER GetMg(void) {
400  return static_cast<CISSTNETLIB_INTEGER>(solution.m_Mg);
401  }
402  inline CISSTNETLIB_INTEGER GetN(void) {
403  return static_cast<CISSTNETLIB_INTEGER>(solution.m_N);
404  }
405  };
406  friend class Friend;
407 
415  m_Ma(0),
416  m_Me(0),
417  m_Mg(0),
418  m_N(0) {};
419 
421  nmrLSqLinSolutionDynamic(size_t ma, size_t n)
422  {
423  this->Allocate(ma, 0, 0, n);
424  }
426  nmrLSqLinSolutionDynamic(size_t ma, size_t mg, size_t n)
427  {
428  this->Allocate(ma, 0, mg, n);
429  }
431  nmrLSqLinSolutionDynamic(size_t ma, size_t me, size_t mg, size_t n)
432  {
433  this->Allocate(ma, me, mg, n);
434  }
435 
436  /************************************************************************/
437  /* The following are various constructors for the LS problem */
438  /************************************************************************/
439 
447  template <typename _matrixOwnerTypeA>
449  {
450  this->Allocate(A.rows(), 0, 0, A.cols());
451  }
461  template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeWork>
464  {
465  this->Allocate(A.rows(), 0, 0, A.cols(), inWork);
466  }
476  template <typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork>
477  nmrLSqLinSolutionDynamic(size_t ma, size_t n,
480  {
481  this->SetRef(ma, 0, 0, n, inX, inWork);
482  }
495  template <typename _vectorOwnerTypeX>
496  nmrLSqLinSolutionDynamic(size_t ma, size_t n,
498  {
499  this->SetRef(ma, 0, 0, n, inX);
500  }
510  template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork>
514  {
515  this->SetRef(inA.rows(), 0, 0, inA.cols(), inX, inWork);
516  }
517 
518  /************************************************************************/
519  /* The following are various constructors for the LSI problem */
520  /************************************************************************/
521 
529  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeG>
532  {
533  this->Allocate(A.rows(), 0, G.rows(), A.cols());
534  }
544  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeG,
545  typename _vectorOwnerTypeWork, typename _vectorOwnerTypeIWork>
550  {
551  this->Allocate(A.rows(), 0, G.rows(), A.cols(), inWork, inIWork);
552  }
562  template <typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork, typename _vectorOwnerTypeIWork>
563  nmrLSqLinSolutionDynamic(size_t ma, size_t mg, size_t n,
567  {
568  this->SetRef(ma, 0, mg, n, inX, inWork, inIWork);
569  }
582  template <typename _vectorOwnerTypeX>
583  nmrLSqLinSolutionDynamic(size_t ma, size_t mg, size_t n,
585  {
586  this->SetRef(ma, 0, mg, n, inX);
587  }
597  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeG,
598  typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork,
599  typename _vectorOwnerTypeIWork>
605  {
606  this->SetRef(inA.rows(), 0, inG.rows(), inA.cols(), inX, inWork, inIWork);
607  }
608 
609  /************************************************************************/
610  /* The following are various constructors for LSEI problem */
611  /************************************************************************/
612 
620  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeE, typename _matrixOwnerTypeG>
624  {
625  this->Allocate(A.rows(), E.rows(), G.rows(), A.cols());
626  }
637  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeE,
638  typename _matrixOwnerTypeG, typename _vectorOwnerTypeWork,
639  typename _vectorOwnerTypeIWork>
645  {
646  this->Allocate(A.rows(), E.rows(), G.rows(), A.cols(), inWork, inIWork);
647  }
657  template <typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork, typename _vectorOwnerTypeIWork>
658  nmrLSqLinSolutionDynamic(size_t ma, size_t me, size_t mg, size_t n,
662  {
663  this->SetRef(ma, me, mg, n, inX, inWork, inIWork);
664  }
677  template <typename _vectorOwnerTypeX>
678  nmrLSqLinSolutionDynamic(size_t ma, size_t me, size_t mg, size_t n,
680  {
681  this->SetRef(ma, me, mg, n, inX);
682  }
692  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeE,
693  typename _matrixOwnerTypeG, typename _vectorOwnerTypeX,
694  typename _vectorOwnerTypeWork, typename _vectorOwnerTypeIWork>
701  {
702  this->SetRef(inA.rows(), inE.rows(), inG.rows(), inA.cols(), inX, inWork, inIWork);
703  }
704 
705  /************************************************************************/
706  /* The following are Allocate methods for the LS problem */
707  /************************************************************************/
708 
720  template <typename _matrixOwnerTypeA>
722  {
723  this->Allocate(A.rows(), 0, 0, A.cols());
724  }
743  template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeWork>
746  {
747  this->Allocate(A.rows(), 0, 0, A.cols(), inWork);
748  }
749 
750  /************************************************************************/
751  /* The following are SetRef methods for the LS problem */
752  /************************************************************************/
753 
765  template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork>
769  {
770  this->SetRef(inA.rows(), 0, 0, inA.cols(), inX, inWork);
771  }
786  template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeX>
789  {
790  this->SetRef(inA.rows(), 0, 0, inA.cols(), inX, this->WorkspaceMemory);
791  }
792 
793  /************************************************************************/
794  /* The following are Allocate methods for the LSI problem */
795  /************************************************************************/
796 
809  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeG>
812  {
813  this->Allocate(A.rows(), 0, G.rows(), A.cols());
814  }
834  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeG,
835  typename _vectorOwnerTypeWork, typename _vectorOwnerTypeIWork>
840  {
841  this->Allocate(A.rows(), 0, G.rows(), A.cols(), inWork, inIWork);
842  }
843 
844  /************************************************************************/
845  /* The following are SetRef methods for the LSI problem */
846  /************************************************************************/
847 
859  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeG,
860  typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork,
861  typename _vectorOwnerTypeIWork>
867  {
868  this->SetRef(inA.rows(), 0, inG.rows(), inA.cols(), inX, inWork, inIWork);
869  }
884  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeG, typename _vectorOwnerTypeX>
888  {
889  this->SetRef(inA.rows(), 0, inG.rows(), inA.cols(), inX);
890  }
891 
892  /************************************************************************/
893  /* The following are Allocate methods for the LSEI problem */
894  /************************************************************************/
895 
909  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeE, typename _matrixOwnerTypeG>
913  {
914  this->Allocate(A.rows(), E.rows(), G.rows(), A.cols());
915  }
936  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeE,
937  typename _matrixOwnerTypeG, typename _vectorOwnerTypeWork, typename _vectorOwnerTypeIWork>
943  {
944  this->Allocate(A.rows(), E.rows(), G.rows(), A.cols(), inWork, inIWork);
945  }
946 
947  /************************************************************************/
948  /* The following are SetRef methods for the LSEI problem */
949  /************************************************************************/
950 
962  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeE, typename _matrixOwnerTypeG,
963  typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork,
964  typename _vectorOwnerTypeIWork>
971  {
972  this->SetRef(inA.rows(), inE.rows(), inG.rows(), inA.cols(), inX, inWork, inIWork);
973  }
988  template <typename _matrixOwnerTypeA, typename _matrixOwnerTypeE,
989  typename _matrixOwnerTypeG, typename _vectorOwnerTypeX>
994  {
995  this->SetRef(inA.rows(), inE.rows(), inG.rows(), inA.cols(), inX, this->WorkspaceMemory);
996  }
997 
998  /************************************************************************/
999  /* The following is the Base Allocate Method called by others */
1000  /************************************************************************/
1001 
1011  inline void Allocate(size_t ma, size_t me, size_t mg, size_t n)
1012  {
1013  this->Malloc(ma, me, mg, n, true, true, true);
1014  this->SetRef(ma, me, mg, n, this->WorkspaceMemory, this->InputMemory, this->OutputMemory);
1015  (this->IWork).SetRef((this->IWorkspaceMemory));
1016  }
1027  template <typename _vectorOwnerTypeWork>
1028  inline void Allocate(size_t ma, size_t me, size_t mg, size_t n,
1030  {
1031  CISSTNETLIB_INTEGER lwork = nmrLSqLinSolutionDynamic::GetWorkspaceSize(ma, me, mg, n);
1032  if (lwork > static_cast<CISSTNETLIB_INTEGER>(inWork.size())) {
1033  cmnThrow(std::runtime_error("nmrLSqLin: Incorrect size for Work"));
1034  }
1035  this->Malloc(ma, me, mg, n, false, true, true);
1036  this->SetRef(ma, me, mg, n, inWork, this->InputMemory, this->OutputMemory);
1037  }
1048  template <typename _vectorOwnerTypeWork, typename _vectorOwnerTypeIWork>
1049  inline void Allocate(size_t ma, size_t me, size_t mg, size_t n,
1052  {
1053  CISSTNETLIB_INTEGER lwork = nmrLSqLinSolutionDynamic::GetWorkspaceSize(ma, me, mg, n);
1054  if (lwork > static_cast<CISSTNETLIB_INTEGER>(inWork.size())) {
1055  cmnThrow(std::runtime_error("nmrLSqLin: Incorrect size for Work"));
1056  }
1057  CISSTNETLIB_INTEGER liwork = nmrLSqLinSolutionDynamic::GetIWorkspaceSize(ma, me, mg, n);
1058  if (liwork > static_cast<CISSTNETLIB_INTEGER>(inIWork.size())) {
1059  cmnThrow(std::runtime_error("nmrLSqLin: Incorrect size for IWork"));
1060  }
1061  this->Malloc(ma, me, mg, n, false, true, true);
1062  this->SetRef(ma, me, mg, n, inWork, this->InputMemory, this->OutputMemory);
1063  (this->IWork).SetRef(inIWork);
1064  }
1065 
1066  /************************************************************************/
1067  /* The following is the Base SetRef Method called by others */
1068  /************************************************************************/
1069 
1079  template <typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork>
1080  void SetRef(size_t ma, size_t me, size_t mg, size_t n,
1082  {
1083  CISSTNETLIB_INTEGER lwork = nmrLSqLinSolutionDynamic::GetWorkspaceSize(ma, me, mg, n);
1084  if (lwork > static_cast<CISSTNETLIB_INTEGER>(inWork.size())) {
1085  cmnThrow(std::runtime_error("nmrLSqLin: Incorrect size for Work"));
1086  }
1087  if (n > static_cast<CISSTNETLIB_INTEGER>(inX.size())) {
1088  cmnThrow(std::runtime_error("nmrLSqLin: Incorrect size for X"));
1089  }
1090  this->Malloc(ma, me, mg, n, false, true, false);
1091  this->SetRef(ma, me, mg, n, inWork, this->InputMemory, inX);
1092  }
1102  template <typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork, typename _vectorOwnerTypeIWork>
1103  void SetRef(size_t ma, size_t me, size_t mg, size_t n,
1107  {
1108  CISSTNETLIB_INTEGER lwork = nmrLSqLinSolutionDynamic::GetWorkspaceSize(ma, me, mg, n);
1109  if (lwork > static_cast<CISSTNETLIB_INTEGER>(inWork.size())) {
1110  cmnThrow(std::runtime_error("nmrLSqLin: Incorrect size for Work"));
1111  }
1112  CISSTNETLIB_INTEGER liwork = nmrLSqLinSolutionDynamic::GetIWorkspaceSize(ma, me, mg, n);
1113  if (liwork > static_cast<CISSTNETLIB_INTEGER>(inIWork.size())) {
1114  cmnThrow(std::runtime_error("nmrLSqLin: Incorrect size for IWork"));
1115  }
1116  if (n > inX.size()) {
1117  cmnThrow(std::runtime_error("nmrLSqLin: Incorrect size for X"));
1118  }
1119  this->Malloc(ma, me, mg, n, false, true, false);
1120  this->SetRef(ma, me, mg, n, inWork, this->InputMemory, inX);
1121  (this->IWork).SetRef(inIWork);
1122  }
1123 
1132  template <typename _vectorOwnerTypeX>
1133  void SetRef(size_t ma, size_t me, size_t mg, size_t n,
1135  {
1136  if (n > inX.size()) {
1137  cmnThrow(std::runtime_error("nmrLSqLin: Incorrect size for X"));
1138  }
1139  this->Malloc(ma, me, mg, n, true, true, false);
1140  this->SetRef(ma, me, mg, n, this->WorkspaceMemory, this->InputMemory, inX);
1141  (this->IWork).SetRef((this->IWorkspaceMemory));
1142  }
1143 
1144 protected:
1158  void Malloc(size_t ma, size_t me, size_t mg, size_t n, bool allocateWorkspace, bool allocateInput, bool allocateOutput)
1159  {
1160  m_Ma = ma; m_N = n;
1161  m_Me = me; m_Mg = mg;
1162  if (allocateWorkspace) {
1163  (this->WorkspaceMemory).SetSize(nmrLSqLinSolutionDynamic::GetWorkspaceSize(ma, me, mg, n));
1164  (this->IWorkspaceMemory).SetSize(nmrLSqLinSolutionDynamic::GetIWorkspaceSize(ma, me, mg, n));
1165  }
1166  // allocate InputMemory if mg >0 (LSI or LSEI)
1167  if (mg > 0 && allocateInput) {
1168  (this->InputMemory).SetSize(ma + me + mg, n+1, VCT_COL_MAJOR);
1169  }
1170  if (allocateOutput) {
1171  (this->OutputMemory).SetSize(n);
1172  }
1173  (this->RNorm).SetSize(ma+me);
1174  (this->RNormL).SetRef(ma, (this->RNorm).Pointer(), 1);
1175  (this->RNormE).SetRef(me, (this->RNorm).Pointer(ma), 1);
1176  }
1177  template <typename _vectorOwnerTypeWork, typename _matrixOwnerTypeI, typename _vectorOwnerTypeX>
1178  void SetRef(size_t ma, size_t me, size_t mg, size_t n,
1182  {
1183  //workspace
1184  (this->Work).SetRef(work);
1185  // setref InputMemory if mg >0 (LSI or LSEI)
1186  if (mg > 0) {
1187  if (me > 0) {
1188  //size_type startRow, size_type startCol, size_type rows, size_type cols
1189  //size_type startPosition, size_type length
1190  (this->E).SetRef(input, 0, 0, me, n);
1191  (this->f).SetRef(me, input.Column(n).Pointer(0), 1);
1192  (this->A).SetRef(input, me, 0, ma, n);
1193  (this->b).SetRef(ma, input.Column(n).Pointer(me), 1);
1194  (this->G).SetRef(input, ma + me, 0, mg, n);
1195  (this->h).SetRef(mg, input.Column(n).Pointer(ma + me), 1);
1196  } else {
1197  (this->A).SetRef(input, 0, 0, ma, n);
1198  (this->b).SetRef(ma, input.Column(n).Pointer(0), 1);
1199  (this->G).SetRef(input, ma, 0, mg, n);
1200  (this->h).SetRef(mg, input.Column(n).Pointer(ma), 1);
1201  }
1202  }
1203  //output
1204  (this->X).SetRef(n, x.Pointer(0), 1);
1205  }
1206 
1207 public:
1212  inline const vctDynamicVectorRef<CISSTNETLIB_DOUBLE> &GetX(void) const {
1213  return X;
1214  }
1216  return RNormL;
1217  }
1219  return RNormE;
1220  }
1221 };
1222 
1243 template <typename _matrixOwnerType, typename _vectorOwnerType>
1246  nmrLSqLinSolutionDynamic &solution) throw (std::runtime_error)
1247 {
1248  typename nmrLSqLinSolutionDynamic::Friend solutionFriend(solution);
1249  CISSTNETLIB_INTEGER ret_value;
1250  /* check that the size and storage order matches with Allocate() */
1251  if (A.IsRowMajor() != VCT_COL_MAJOR) {
1252  cmnThrow(std::runtime_error("nmrLSqLinSolver Solve: Input must be in Column Major format"));
1253  }
1254  CISSTNETLIB_INTEGER Mrows = static_cast<CISSTNETLIB_INTEGER>(A.rows());
1255  CISSTNETLIB_INTEGER Ncols = static_cast<CISSTNETLIB_INTEGER>(A.cols());
1256  if ((Mrows != solutionFriend.GetMa()) || (Ncols != solutionFriend.GetN())) {
1257  cmnThrow(std::runtime_error("nmrLSqLinSolver Solve: Size used for Allocate was different"));
1258  }
1259  if (Mrows != static_cast<CISSTNETLIB_INTEGER>(b.size())) {
1260  cmnThrow(std::runtime_error("nmrLSqLinSolver Solve: Size of b must be same as number of rows of A"));
1261  }
1262  char trans = 'N';
1263  CISSTNETLIB_INTEGER nrhs = 1;
1264  CISSTNETLIB_INTEGER lda = std::max(Mrows,static_cast<CISSTNETLIB_INTEGER>(1));
1265  CISSTNETLIB_INTEGER ldb = std::max(std::max(static_cast<CISSTNETLIB_INTEGER>(1),Mrows),Ncols);
1266  CISSTNETLIB_INTEGER lwork = nmrLSqLinSolutionDynamic::GetWorkspaceSize(Mrows, 0, 0, Ncols);
1267 
1268  CISSTNETLIB_DOUBLE *b_ptr = b.Pointer();
1269  if (Mrows < Ncols) {
1270  // Since dgels returns the result, x, in the input array, b, we need
1271  // to make sure that b is large enough. In the underdetermined case (M < N)
1272  // we would therefore have to resize b from M to N; it is more efficient to instead
1273  // pass x, after assigning all M elements of b to x.
1274  solutionFriend.GetX().Assign(b, Mrows);
1275  b_ptr = solutionFriend.GetX().Pointer();
1276  }
1277 #if defined(CISSTNETLIB_VERSION_MAJOR)
1278 #if (CISSTNETLIB_VERSION_MAJOR >= 3)
1279  cisstNetlib_dgels_(&trans, &Mrows, &Ncols, &nrhs,
1280  A.Pointer(), &lda,
1281  b_ptr, &ldb,
1282  solutionFriend.GetWork().Pointer(), &lwork, &ret_value);
1283 #endif
1284 #else // no major version
1285  dgels_(&trans, &Mrows, &Ncols, &nrhs,
1286  A.Pointer(), &lda,
1287  b_ptr, &ldb,
1288  solutionFriend.GetWork().Pointer(), &lwork, &ret_value);
1289 #endif // CISSTNETLIB_VERSION
1290 
1291  if (Mrows >= Ncols) {
1292  // Dgels returns the result in the "b" vector. For the underdetermined case
1293  // (M < N), we already passed the solution vector, x, as "b". Thus, we only
1294  // need to handle the other case here (M >= N), where we need to copy the
1295  // first Ncols elements of b to the solution vector, x.
1296  solutionFriend.GetX().Assign(b, Ncols);
1297  }
1298  return ret_value;
1299 }
1300 
1323 template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeb,
1324  typename _matrixOwnerTypeG, typename _vectorOwnerTypeh>
1329  nmrLSqLinSolutionDynamic &solution) throw (std::runtime_error)
1330 {
1331  typename nmrLSqLinSolutionDynamic::Friend solutionFriend(solution);
1332  /* check that the size and storage order matches with Allocate() */
1333  if ((A.IsRowMajor() != VCT_COL_MAJOR) || (G.IsRowMajor() != VCT_COL_MAJOR)) {
1334  cmnThrow(std::runtime_error("nmrLSqLinSolver Solve: Input must be in Column Major format"));
1335  }
1336  CISSTNETLIB_INTEGER ma = static_cast<CISSTNETLIB_INTEGER>(A.rows());
1337  CISSTNETLIB_INTEGER mg = static_cast<CISSTNETLIB_INTEGER>(G.rows());
1338  CISSTNETLIB_INTEGER na = static_cast<CISSTNETLIB_INTEGER>(A.cols());
1339  CISSTNETLIB_INTEGER ng = static_cast<CISSTNETLIB_INTEGER>(G.cols());
1340  if ((ma != solutionFriend.GetMa()) || (mg != solutionFriend.GetMg())
1341  || (na != solutionFriend.GetN()) || (ng != solutionFriend.GetN())) {
1342  cmnThrow(std::runtime_error("nmrLSqLinSolver Solve: Size used for Allocate was different"));
1343  }
1344  if (ma != static_cast<CISSTNETLIB_INTEGER>(b.size())) {
1345  cmnThrow(std::runtime_error("nmrLSqLinSolver Solve: Size of b must be same as number of rows of A"));
1346  }
1347  if (mg != static_cast<CISSTNETLIB_INTEGER>(h.size())) {
1348  cmnThrow(std::runtime_error("nmrLSqLinSolver Solve: Size of h must be same as number of rows of G"));
1349  }
1350  // make a copy of A, b, G, h
1351  solutionFriend.GetA().Assign(A);
1352  solutionFriend.GetG().Assign(G);
1353  solutionFriend.Getb().Assign(b);
1354  solutionFriend.Geth().Assign(h);
1355  CISSTNETLIB_INTEGER mdw = ma + mg;
1356  CISSTNETLIB_INTEGER mode = 0;
1357  CISSTNETLIB_DOUBLE prgopt = 1.;
1358  solutionFriend.GetIWork()(0) = -1;
1359  solutionFriend.GetIWork()(1) = -1;
1360 
1361 #if defined(CISSTNETLIB_VERSION_MAJOR)
1362 #if (CISSTNETLIB_VERSION_MAJOR >= 3)
1363  cisstNetlib_lsi_(solutionFriend.GetInput().Pointer(), &mdw, &ma, &mg, &na,
1364  &prgopt, solutionFriend.GetX().Pointer(), solutionFriend.GetRNorm().Pointer(), &mode,
1365  solutionFriend.GetWork().Pointer(), solutionFriend.GetIWork().Pointer());
1366 #endif
1367 #else // no major version
1368  lsi_(solutionFriend.GetInput().Pointer(), &mdw, &ma, &mg, &na,
1369  &prgopt, solutionFriend.GetX().Pointer(), solutionFriend.GetRNorm().Pointer(), &mode,
1370  solutionFriend.GetWork().Pointer(), solutionFriend.GetIWork().Pointer());
1371 #endif // CISSTNETLIB_VERSION
1372  return mode;
1373 }
1374 
1399 template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeb,
1400  typename _matrixOwnerTypeE, typename _vectorOwnerTypef,
1401  typename _matrixOwnerTypeG, typename _vectorOwnerTypeh>
1408  nmrLSqLinSolutionDynamic &solution) throw (std::runtime_error)
1409 {
1410  typename nmrLSqLinSolutionDynamic::Friend solutionFriend(solution);
1411  /* check that the size and storage order matches with Allocate() */
1412  if ((A.IsRowMajor() != VCT_COL_MAJOR) || (G.IsRowMajor() != VCT_COL_MAJOR) || (E.IsRowMajor() != VCT_COL_MAJOR)) {
1413  cmnThrow(std::runtime_error("nmrLSqLinSolver Solve: Input must be in Column Major format"));
1414  }
1415  CISSTNETLIB_INTEGER ma = static_cast<CISSTNETLIB_INTEGER>(A.rows());
1416  CISSTNETLIB_INTEGER me = static_cast<CISSTNETLIB_INTEGER>(E.rows());
1417  CISSTNETLIB_INTEGER mg = static_cast<CISSTNETLIB_INTEGER>(G.rows());
1418  CISSTNETLIB_INTEGER na = static_cast<CISSTNETLIB_INTEGER>(A.cols());
1419  CISSTNETLIB_INTEGER ne = static_cast<CISSTNETLIB_INTEGER>(E.cols());
1420  CISSTNETLIB_INTEGER ng = static_cast<CISSTNETLIB_INTEGER>(G.cols());
1421  if ((ma != solutionFriend.GetMa()) || (mg != solutionFriend.GetMg()) || (me != solutionFriend.GetMe())
1422  || (na != solutionFriend.GetN()) || (ng != solutionFriend.GetN() || (ne != solutionFriend.GetN()))
1423  ) {
1424  cmnThrow(std::runtime_error("nmrLSqLinSolver Solve: Size used for Allocate was different"));
1425  }
1426  if (ma != static_cast<CISSTNETLIB_INTEGER>(b.size())) {
1427  cmnThrow(std::runtime_error("nmrLSqLinSolver Solve: Size of b must be same as number of rows of A"));
1428  }
1429  if (mg != static_cast<CISSTNETLIB_INTEGER>(h.size())) {
1430  cmnThrow(std::runtime_error("nmrLSqLinSolver Solve: Size of h must be same as number of rows of G"));
1431  }
1432  if (me != static_cast<CISSTNETLIB_INTEGER>(f.size())) {
1433  cmnThrow(std::runtime_error("nmrLSqLinSolver Solve: Size of f must be same as number of rows of E"));
1434  }
1435  // make a copy of A, b, E, f, G, h
1436  solutionFriend.GetA().Assign(A);
1437  solutionFriend.GetE().Assign(E);
1438  solutionFriend.GetG().Assign(G);
1439  solutionFriend.Getb().Assign(b);
1440  solutionFriend.Getf().Assign(f);
1441  solutionFriend.Geth().Assign(h);
1442  CISSTNETLIB_INTEGER mdw = ma + mg + me;
1443  CISSTNETLIB_INTEGER mode = 0;
1444  CISSTNETLIB_DOUBLE prgopt = 1.;
1445  solutionFriend.GetIWork()(0) = -1;
1446  solutionFriend.GetIWork()(1) = -1;
1447 #if defined(CISSTNETLIB_VERSION_MAJOR)
1448 #if (CISSTNETLIB_VERSION_MAJOR >= 3)
1449  cisstNetlib_lsei_(solutionFriend.GetInput().Pointer(), &mdw, &me, &ma, &mg, &na,
1450  &prgopt, solutionFriend.GetX().Pointer(), solutionFriend.GetRNorm().Pointer(ma),
1451  solutionFriend.GetRNorm().Pointer(), &mode,
1452  solutionFriend.GetWork().Pointer(), solutionFriend.GetIWork().Pointer());
1453 #endif
1454 #else // no major version
1455  lsei_(solutionFriend.GetInput().Pointer(), &mdw, &me, &ma, &mg, &na,
1456  &prgopt, solutionFriend.GetX().Pointer(), solutionFriend.GetRNorm().Pointer(ma),
1457  solutionFriend.GetRNorm().Pointer(), &mode,
1458  solutionFriend.GetWork().Pointer(), solutionFriend.GetIWork().Pointer());
1459 #endif // CISSTNETLIB_VERSION
1460  return mode;
1461 }
1462 
1481 template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeb, typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork>
1486 {
1487  nmrLSqLinSolutionDynamic lsqLinSolution(A.rows(), A.cols(), X, Work);
1488  CISSTNETLIB_INTEGER ret_value = nmrLSqLin(A, b, lsqLinSolution);
1489  return ret_value;
1490 }
1491 
1507 template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeb, typename _vectorOwnerTypeX>
1511 {
1512  nmrLSqLinSolutionDynamic lsqLinSolution(A.rows(), A.cols(), X);
1513  CISSTNETLIB_INTEGER ret_value = nmrLSqLin(A, b, lsqLinSolution);
1514  return ret_value;
1515 }
1516 
1535 template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeb,
1536  typename _matrixOwnerTypeG, typename _vectorOwnerTypeh, typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork>
1543 {
1544  nmrLSqLinSolutionDynamic lsqLinSolution(A.rows(), G.rows(), A.cols(), X, Work);
1545  CISSTNETLIB_INTEGER ret_value = nmrLSqLin(A, b, G, h, lsqLinSolution);
1546  return ret_value;
1547 }
1548 
1566 template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeb,
1567  typename _matrixOwnerTypeG, typename _vectorOwnerTypeh, typename _vectorOwnerTypeX>
1573 {
1574  nmrLSqLinSolutionDynamic lsqLinSolution(A.rows(), G.rows(), A.cols(), X);
1575  CISSTNETLIB_INTEGER ret_value = nmrLSqLin(A, b, G, h, lsqLinSolution);
1576  return ret_value;
1577 }
1578 
1599 template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeb,
1600  typename _matrixOwnerTypeE, typename _vectorOwnerTypef,
1601  typename _matrixOwnerTypeG, typename _vectorOwnerTypeh,
1602  typename _vectorOwnerTypeX, typename _vectorOwnerTypeWork>
1611 {
1612  nmrLSqLinSolutionDynamic lsqLinSolution(A.rows(), E.rows(), G.rows(), A.cols(), X, Work);
1613  CISSTNETLIB_INTEGER ret_value = nmrLSqLin(A, b, E, f, G, h, lsqLinSolution);
1614  return ret_value;
1615 }
1616 
1636 template <typename _matrixOwnerTypeA, typename _vectorOwnerTypeb,
1637  typename _matrixOwnerTypeE, typename _vectorOwnerTypef,
1638  typename _matrixOwnerTypeG, typename _vectorOwnerTypeh,
1639  typename _vectorOwnerTypeX>
1647 {
1648  nmrLSqLinSolutionDynamic lsqLinSolution(A.rows(), E.rows(), G.rows(), A.cols(), X);
1649  CISSTNETLIB_INTEGER ret_value = nmrLSqLin(A, b, E, f, G, h, lsqLinSolution);
1650  return ret_value;
1651 }
1652 
1653 /*
1654 ****************************************************************************
1655 FIXED SIZE
1656 ****************************************************************************
1657 */
1658 
1665 template <vct::size_type _ma, vct::size_type _me, vct::size_type _mg, vct::size_type _n>
1667 {
1668 public:
1669  enum {MIN_MN = (_ma<_n) ? _ma : _n};
1670  enum {K = (_ma + _mg > _n)?(_ma + _mg) : _n};
1672  enum {LWORK_LSI = _n + (_mg + 2)*(_n + 7) + (vct::size_type)K};
1673  enum {LWORK_LSEI = 2*(_me + _n) + (_mg + 2)*(_n + 7) + (vct::size_type)K};
1676  enum {LIWORK = _mg + 2*_n + 2};
1678  //make sizes 1 if 0, it does not affect anything else
1686 
1692 protected:
1697  TypeIWork IWorkspaceMemory;
1701  TypeRNorm RNorm;
1714  TypeInput InputMemory;
1718  TypeX X;
1719  TypeRNormL RNormL;
1720  TypeRNormE RNormE;
1721 
1722 public:
1735  class Friend {
1736  private:
1738  public:
1739  Friend(nmrLSqLinSolutionFixedSize<_ma, _me, _mg, _n> &insolution):solution(insolution) {
1740  }
1741  inline TypeX &GetX(void) {
1742  return solution.X;
1743  }
1744  inline TypeRNorm &GetRNorm(void) {
1745  return solution.RNorm;
1746  }
1747  inline TypeInput &GetInput(void) {
1748  return solution.InputMemory;
1749  }
1750  inline TypeWork &GetWork(void) {
1751  return solution.WorkspaceMemory;
1752  }
1753  inline TypeIWork &GetIWork(void) {
1754  return solution.IWorkspaceMemory;
1755  }
1756  };
1757  friend class Friend;
1758 
1759 public:
1760  /*we set the references too */
1762  RNormL(RNorm.Pointer()),
1763  RNormE(RNorm.Pointer(_ma)) {}
1764 
1769  inline const TypeX &GetX(void) const {
1770  return X;
1771  }
1772  inline const TypeRNormL &GetRNorm(void) const {
1773  return RNormL;
1774  }
1775  inline const TypeRNormE &GetRNormE(void) const {
1776  return RNormE;
1777  }
1778 };
1779 
1780 /******************************************************************************/
1781 /* Overloaded functions for Least Squares (LS) */
1782 /******************************************************************************/
1783 
1784 template <vct::size_type _ma, vct::size_type _n, vct::size_type _work>
1789 {
1790  CISSTNETLIB_INTEGER ret_value;
1791  char trans = 'N';
1792  CISSTNETLIB_INTEGER Mrows = static_cast<CISSTNETLIB_INTEGER>(_ma);
1793  CISSTNETLIB_INTEGER Ncols = static_cast<CISSTNETLIB_INTEGER>(_n);
1794  CISSTNETLIB_INTEGER nrhs = 1;
1795  CISSTNETLIB_INTEGER lda = std::max(Mrows,static_cast<CISSTNETLIB_INTEGER>(1));
1796  CISSTNETLIB_INTEGER ldb = std::max(std::max(static_cast<CISSTNETLIB_INTEGER>(1),Mrows),Ncols);
1797  CISSTNETLIB_INTEGER lwork = static_cast<CISSTNETLIB_INTEGER>(nmrLSqLinSolutionFixedSize<_ma, 0, 0, _n>::LWORK);
1798  CMN_ASSERT(lwork <= static_cast<CISSTNETLIB_INTEGER>(_work));
1799  CISSTNETLIB_DOUBLE *b_ptr = b.Pointer();
1800  if (Mrows < Ncols) {
1801  // Since dgels returns the result, x, in the input array, b, we need
1802  // to make sure that b is large enough. In the underdetermined case (M < N)
1803  // we would therefore have to resize b from M to N; it is more efficient to instead
1804  // pass x, after assigning all M elements of b to x.
1805  memcpy(x.Pointer(), b.Pointer(), Mrows*sizeof(CISSTNETLIB_DOUBLE));
1806  b_ptr = x.Pointer();
1807  }
1808 
1809 #if defined(CISSTNETLIB_VERSION_MAJOR)
1810 #if (CISSTNETLIB_VERSION_MAJOR >= 3)
1811  cisstNetlib_dgels_(&trans, &Mrows, &Ncols, &nrhs,
1812  A.Pointer(), &lda,
1813  b_ptr, &ldb,
1814  Work.Pointer(), &lwork, &ret_value);
1815 #endif
1816 #else // no major version
1817  dgels_(&trans, &Mrows, &Ncols, &nrhs,
1818  A.Pointer(), &lda,
1819  b_ptr, &ldb,
1820  Work.Pointer(), &lwork, &ret_value);
1821 #endif // CISSTNETLIB_VERSION
1822 
1823  if (Mrows >= Ncols) {
1824  // Dgels returns the result in the "b" vector. For the underdetermined case
1825  // (M < N), we already passed the solution vector, x, as "b". Thus, we only
1826  // need to handle the other case here (M >= N), where we need to copy the
1827  // first Ncols elements of b to the solution vector, x.
1828  x.Assign(b.Pointer());
1829  }
1830  return ret_value;
1831 }
1832 
1833 template <vct::size_type _ma, vct::size_type _n>
1837 {
1839  CISSTNETLIB_INTEGER ret_value = nmrLSqLin(A, b, x, work);
1840  return ret_value;
1841 }
1842 
1843 template <vct::size_type _ma, vct::size_type _n>
1847 {
1848  typename nmrLSqLinSolutionFixedSize<_ma, 0, 0, _n>::Friend solutionFriend(solution);
1849  CISSTNETLIB_INTEGER ret_value = nmrLSqLin(A, b, solutionFriend.GetX(), solutionFriend.GetWork());
1850  return ret_value;
1851 }
1852 
1853 /******************************************************************************/
1854 /* Overloaded functions for Least Squares Inequality (LSI) */
1855 /******************************************************************************/
1856 
1857 template <vct::size_type _ma, vct::size_type _mg, vct::size_type _n, vct::size_type _work, vct::size_type _iwork>
1864 {
1865  CISSTNETLIB_INTEGER ma = static_cast<CISSTNETLIB_INTEGER>(_ma);
1866  CISSTNETLIB_INTEGER mg = static_cast<CISSTNETLIB_INTEGER>(_mg);
1867  CISSTNETLIB_INTEGER na = static_cast<CISSTNETLIB_INTEGER>(_n);
1872  // make a copy of A, b, G, h
1873  ARef.Assign(A);
1874  GRef.Assign(G);
1875  bRef.Assign(b);
1876  hRef.Assign(h);
1877  CISSTNETLIB_INTEGER mdw = ma + mg;
1878  CISSTNETLIB_INTEGER mode = 0;
1879  CISSTNETLIB_DOUBLE prgopt = 1.;
1880  IWork(0) = -1;
1881  IWork(1) = -1;
1882 #if defined(CISSTNETLIB_VERSION_MAJOR)
1883 #if (CISSTNETLIB_VERSION_MAJOR >= 3)
1884  cisstNetlib_lsi_(W.Pointer(), &mdw, &ma, &mg, &na,
1885  &prgopt, x.Pointer(), RNorm.Pointer(), &mode,
1886  Work.Pointer(), IWork.Pointer());
1887 #endif
1888 #else // no major version
1889  lsi_(W.Pointer(), &mdw, &ma, &mg, &na,
1890  &prgopt, x.Pointer(), RNorm.Pointer(), &mode,
1891  Work.Pointer(), IWork.Pointer());
1892 #endif // CISSTNETLIB_VERSION
1893  return mode;
1894 }
1895 
1896 template <vct::size_type _ma, vct::size_type _mg, vct::size_type _n>
1902 {
1907  CISSTNETLIB_INTEGER ret_value;
1908  // for some reason windows gets confused with the templates to match, so explicitly
1909  // specifying the template parameters for the functions helps .net
1910  ret_value = nmrLSqLin<_ma, _mg, _n, nmrLSqLinSolutionFixedSize<_ma, 0, _mg, _n>::LWORK,
1912  (A, b, G, h, x, w, rNorm, work, iwork);
1913  return ret_value;
1914 }
1915 
1916 template <vct::size_type _ma, vct::size_type _mg, vct::size_type _n>
1922 {
1923  typename nmrLSqLinSolutionFixedSize<_ma, 0, _mg, _n>::Friend solutionFriend(solution);
1924  CISSTNETLIB_INTEGER ret_value;
1925  // for some reason windows gets confused with the templates to match, so explicitly
1926  // specifying the template parameters for the functions helps .net
1927  ret_value = nmrLSqLin<_ma, _mg, _n, nmrLSqLinSolutionFixedSize<_ma, 0, _mg, _n>::LWORK,
1929  (A, b, G, h,
1930  solutionFriend.GetX(), solutionFriend.GetInput(),
1931  solutionFriend.GetRNorm(), solutionFriend.GetWork(), solutionFriend.GetIWork());
1932  return ret_value;
1933 }
1934 
1935 /******************************************************************************/
1936 /* Overloaded functions for Least Squares Equality & Inequality (LSEI) */
1937 /******************************************************************************/
1938 
1939 template <vct::size_type _ma, vct::size_type _me, vct::size_type _mg,
1940  vct::size_type _n, vct::size_type _work, vct::size_type _iwork>
1948 {
1949  CISSTNETLIB_INTEGER me = static_cast<CISSTNETLIB_INTEGER>(_me);
1950  CISSTNETLIB_INTEGER ma = static_cast<CISSTNETLIB_INTEGER>(_ma);
1951  CISSTNETLIB_INTEGER mg = static_cast<CISSTNETLIB_INTEGER>(_mg);
1952  CISSTNETLIB_INTEGER na = static_cast<CISSTNETLIB_INTEGER>(_n);
1959  // make a copy of A, b, G, h
1960  ARef.Assign(A);
1961  ERef.Assign(E);
1962  GRef.Assign(G);
1963  bRef.Assign(b);
1964  fRef.Assign(f);
1965  hRef.Assign(h);
1966  CISSTNETLIB_INTEGER mdw = ma + me + mg;
1967  CISSTNETLIB_INTEGER mode = 0;
1968  CISSTNETLIB_DOUBLE prgopt = 1.;
1969  IWork(0) = -1;
1970  IWork(1) = -1;
1971 #if defined(CISSTNETLIB_VERSION_MAJOR)
1972 #if (CISSTNETLIB_VERSION_MAJOR >= 3)
1973  cisstNetlib_lsei_(W.Pointer(), &mdw, &me, &ma, &mg, &na,
1974  &prgopt, x.Pointer(), RNorm.Pointer(_ma), RNorm.Pointer(), &mode,
1975  Work.Pointer(), IWork.Pointer());
1976 #endif
1977 #else // no major version
1978  lsei_(W.Pointer(), &mdw, &me, &ma, &mg, &na,
1979  &prgopt, x.Pointer(), RNorm.Pointer(_ma), RNorm.Pointer(), &mode,
1980  Work.Pointer(), IWork.Pointer());
1981 #endif // CISSTNETLIB_VERSION
1982  return mode;
1983 }
1984 
1985 template <vct::size_type _ma, vct::size_type _me, vct::size_type _mg, vct::size_type _n>
1990 {
1995  CISSTNETLIB_INTEGER ret_value;
1996  // for some reason windows gets confused with the templates to match, so explicitly
1997  // specifying the template parameters for the functions helps .net
1998  ret_value = nmrLSqLin<_ma, _me, _mg, _n, nmrLSqLinSolutionFixedSize<_ma, _me, _mg, _n>::LWORK,
2000  (A, b, E, f, G, h, x, w, rNorm, work, iwork);
2001  return ret_value;
2002 }
2003 
2004 template <vct::size_type _ma, vct::size_type _me, vct::size_type _mg, vct::size_type _n>
2009 {
2010  typename nmrLSqLinSolutionFixedSize<_ma, _me, _mg, _n>::Friend solutionFriend(solution);
2011  CISSTNETLIB_INTEGER ret_value;
2012  // for some reason windows gets confused with the templates to match, so explicitly
2013  // specifying the template parameters for the functions helps .net
2014  ret_value = nmrLSqLin<_ma, _me, _mg, _n, nmrLSqLinSolutionFixedSize<_ma, _me, _mg, _n>::LWORK,
2016  (A, b, E, f, G, h,
2017  solutionFriend.GetX(), solutionFriend.GetInput(),
2018  solutionFriend.GetRNorm(), solutionFriend.GetWork(), solutionFriend.GetIWork());
2019  return ret_value;
2020 }
2021 
2022 #endif
nmrLSqLinSolutionDynamic(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeE, CISSTNETLIB_DOUBLE > &inE, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork, vctDynamicVectorBase< _vectorOwnerTypeIWork, CISSTNETLIB_INTEGER > &inIWork)
Definition: nmrLSqLin.h:695
void SetRef(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inIWork)
Definition: nmrLSqLin.h:862
vctDynamicMatrixRef< CISSTNETLIB_DOUBLE > A
Definition: nmrLSqLin.h:144
vctDynamicMatrixRef< CISSTNETLIB_DOUBLE > E
Definition: nmrLSqLin.h:145
vctFixedSizeVectorRef< CISSTNETLIB_DOUBLE,(_me==0)?1:_me, 1 > TypeRNormE
Definition: nmrLSqLin.h:1684
vctDynamicVectorRef< CISSTNETLIB_INTEGER > & GetIWork(void)
Definition: nmrLSqLin.h:390
vctFixedSizeVector< CISSTNETLIB_DOUBLE, LWORK > TypeWork
Definition: nmrLSqLin.h:1687
void SetRef(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX)
Definition: nmrLSqLin.h:787
nmrLSqLinSolutionDynamic(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork)
Definition: nmrLSqLin.h:511
size_t m_Mg
Definition: nmrLSqLin.h:165
Declaration of vctDynamicMatrix.
#define CMN_ASSERT(expr)
Definition: cmnAssert.h:90
vctDynamicVector< CISSTNETLIB_DOUBLE > WorkspaceMemory
Definition: nmrLSqLin.h:120
Definition: nmrLSqLin.h:1674
Definition: vctDynamicMatrixBase.h:42
vctDynamicMatrixRef< CISSTNETLIB_DOUBLE > & GetE(void)
Definition: nmrLSqLin.h:363
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > & GetX(void)
Definition: nmrLSqLin.h:378
static CISSTNETLIB_INTEGER GetWorkspaceSize(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeE, CISSTNETLIB_DOUBLE > &inE, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG)
Definition: nmrLSqLin.h:264
nmrLSqLinSolutionDynamic()
Definition: nmrLSqLin.h:414
static CISSTNETLIB_INTEGER GetWorkspaceSize(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA)
Definition: nmrLSqLin.h:241
static void AllocateWorkspace(CISSTNETLIB_INTEGER ma, CISSTNETLIB_INTEGER me, CISSTNETLIB_INTEGER mg, CISSTNETLIB_INTEGER n, vctDynamicVector< CISSTNETLIB_DOUBLE > &inWork)
Definition: nmrLSqLin.h:283
nmrLSqLinSolutionDynamic(size_t ma, size_t n, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork)
Definition: nmrLSqLin.h:477
#define CMN_UNUSED(argument)
Definition: cmnPortability.h:479
TypeIWork IWorkspaceMemory
Definition: nmrLSqLin.h:1697
nmrLSqLinSolutionDynamic(size_t ma, size_t n, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX)
Definition: nmrLSqLin.h:496
const vctDynamicVectorRef< CISSTNETLIB_DOUBLE > & GetX(void) const
Definition: nmrLSqLin.h:1212
ThisType & Assign(const vctFixedSizeConstMatrixBase< _rows, _cols, __rowStride, __colStride, __elementType, __dataPtrType > &other)
Definition: vctFixedSizeMatrixBase.h:475
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > & GetWork(void)
Definition: nmrLSqLin.h:387
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > X
Definition: nmrLSqLin.h:150
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > & Getb(void)
Definition: nmrLSqLin.h:369
Definition: nmrLSqLin.h:1666
static CISSTNETLIB_INTEGER GetWorkspaceSize(size_t ma, size_t me, size_t mg, size_t n)
Definition: nmrLSqLin.h:174
Declaration of vctFixedSizeMatrix.
void Allocate(size_t ma, size_t me, size_t mg, size_t n, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inIWork)
Definition: nmrLSqLin.h:1049
ThisType & Assign(const vctDynamicConstVectorBase< __vectorOwnerType, value_type > &other)
Definition: vctDynamicVectorBase.h:242
vctDynamicMatrixRef< CISSTNETLIB_DOUBLE > & GetG(void)
Definition: nmrLSqLin.h:366
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > & Geth(void)
Definition: nmrLSqLin.h:375
TypeWork WorkspaceMemory
Definition: nmrLSqLin.h:1696
size_t m_N
Definition: nmrLSqLin.h:166
static void AllocateWorkspace(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG, vctDynamicVector< CISSTNETLIB_DOUBLE > &inWork)
Definition: nmrLSqLin.h:307
TypeRNormE RNormE
Definition: nmrLSqLin.h:1720
size_t m_Ma
Definition: nmrLSqLin.h:163
size_t size_type
Definition: vctContainerTraits.h:35
void SetRef(size_t ma, size_t me, size_t mg, size_t n, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork, vctDynamicVectorBase< _vectorOwnerTypeIWork, CISSTNETLIB_DOUBLE > &inIWork)
Definition: nmrLSqLin.h:1103
const TypeRNormE & GetRNormE(void) const
Definition: nmrLSqLin.h:1775
vctDynamicMatrix< CISSTNETLIB_DOUBLE > InputMemory
Definition: nmrLSqLin.h:139
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > h
Definition: nmrLSqLin.h:149
Definition: nmrLSqLin.h:1676
Definition: nmrLSqLin.h:1673
nmrLSqLinSolutionDynamic(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &G, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork, vctDynamicVectorBase< _vectorOwnerTypeIWork, CISSTNETLIB_INTEGER > &inIWork)
Definition: nmrLSqLin.h:546
Definition: nmrLSqLin.h:1672
void SetRef(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeE, CISSTNETLIB_DOUBLE > &inE, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork, vctDynamicVectorBase< _vectorOwnerTypeIWork, CISSTNETLIB_DOUBLE > &inIWork)
Definition: nmrLSqLin.h:965
static CISSTNETLIB_INTEGER GetIWorkspaceSize(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeE, CISSTNETLIB_DOUBLE > &inE, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG)
Definition: nmrLSqLin.h:271
TypeInput InputMemory
Definition: nmrLSqLin.h:1714
CISSTNETLIB_INTEGER GetN(void)
Definition: nmrLSqLin.h:402
void Allocate(size_t ma, size_t me, size_t mg, size_t n)
Definition: nmrLSqLin.h:1011
static void AllocateIWorkspace(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG, vctDynamicVector< CISSTNETLIB_INTEGER > &inIWork)
Definition: nmrLSqLin.h:314
void Allocate(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicMatrixBase< _matrixOwnerTypeE, CISSTNETLIB_DOUBLE > &E, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &G)
Definition: nmrLSqLin.h:910
TypeRNorm & GetRNorm(void)
Definition: nmrLSqLin.h:1744
ColumnRefType Column(size_type index)
Definition: vctDynamicMatrixBase.h:233
Definition: nmrLSqLin.h:354
Definition: nmrLSqLin.h:115
void SetRef(size_t ma, size_t me, size_t mg, size_t n, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &work, vctDynamicMatrixBase< _matrixOwnerTypeI, CISSTNETLIB_DOUBLE > &input, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &x)
Definition: nmrLSqLin.h:1178
ThisType & Assign(const vctFixedSizeConstVectorBase< _size, __stride, __elementType, __dataPtrType > &other)
Definition: vctFixedSizeVectorBase.h:274
void SetSize(size_type size)
Definition: vctDynamicVector.h:315
vctFixedSizeVector< CISSTNETLIB_DOUBLE, _n > TypeX
Definition: nmrLSqLin.h:1689
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > RNormE
Definition: nmrLSqLin.h:152
nmrLSqLinSolutionDynamic(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork)
Definition: nmrLSqLin.h:462
vctDynamicMatrixRef< CISSTNETLIB_DOUBLE > G
Definition: nmrLSqLin.h:146
TypeWork & GetWork(void)
Definition: nmrLSqLin.h:1750
void Malloc(size_t ma, size_t me, size_t mg, size_t n, bool allocateWorkspace, bool allocateInput, bool allocateOutput)
Definition: nmrLSqLin.h:1158
Definition: nmrLSqLin.h:1671
CISSTNETLIB_INTEGER GetMg(void)
Definition: nmrLSqLin.h:399
static void AllocateWorkspace(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicVector< CISSTNETLIB_DOUBLE > &inWork)
Definition: nmrLSqLin.h:297
void Allocate(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &G, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inIWork)
Definition: nmrLSqLin.h:836
void Allocate(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork)
Definition: nmrLSqLin.h:744
size_type size(void) const
Definition: vctDynamicConstVectorBase.h:164
nmrLSqLinSolutionDynamic(size_t ma, size_t mg, size_t n)
Definition: nmrLSqLin.h:426
void SetRef(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX)
Definition: nmrLSqLin.h:885
const vctDynamicVectorRef< CISSTNETLIB_DOUBLE > & GetRNorm(void) const
Definition: nmrLSqLin.h:1215
vctFixedSizeVector< CISSTNETLIB_DOUBLE, _ma+_me > TypeRNorm
Definition: nmrLSqLin.h:1690
vctFixedSizeMatrixRef< CISSTNETLIB_DOUBLE, _ma, _n, 1, _ma > TypeA
Definition: nmrLSqLin.h:1677
pointer Pointer(size_type rowIndex, size_type colIndex)
Definition: vctDynamicMatrixBase.h:143
TypeX X
Definition: nmrLSqLin.h:1718
void Allocate(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &G)
Definition: nmrLSqLin.h:810
nmrLSqLinSolutionDynamic(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork, vctDynamicVectorBase< _vectorOwnerTypeIWork, CISSTNETLIB_INTEGER > &inIWork)
Definition: nmrLSqLin.h:600
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > Work
Definition: nmrLSqLin.h:153
Definition: nmrLSqLin.h:1675
vctFixedSizeVector< CISSTNETLIB_INTEGER, LIWORK > TypeIWork
Definition: nmrLSqLin.h:1688
CISSTNETLIB_INTEGER GetMe(void)
Definition: nmrLSqLin.h:396
size_type rows() const
Definition: vctDynamicConstMatrixBase.h:238
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > b
Definition: nmrLSqLin.h:147
TypeIWork & GetIWork(void)
Definition: nmrLSqLin.h:1753
static CISSTNETLIB_INTEGER QueryWorkspaceSize_LS(size_t ma, size_t n)
Definition: nmrLSqLin.h:204
An implementation of the ``abstract'' vctFixedSizeMatrixBase.
Definition: vctFixedSizeMatrixRef.h:46
nmrLSqLinSolutionDynamic(size_t ma, size_t mg, size_t n, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork, vctDynamicVectorBase< _vectorOwnerTypeIWork, CISSTNETLIB_INTEGER > &inIWork)
Definition: nmrLSqLin.h:563
size_type cols() const
Definition: vctDynamicConstMatrixBase.h:243
vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _ma+_me+_mg, _n+1, VCT_COL_MAJOR > TypeInput
Definition: nmrLSqLin.h:1691
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > & Getf(void)
Definition: nmrLSqLin.h:372
const TypeRNormL & GetRNorm(void) const
Definition: nmrLSqLin.h:1772
nmrLSqLinSolutionDynamic(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicMatrixBase< _matrixOwnerTypeE, CISSTNETLIB_DOUBLE > &E, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &G)
Definition: nmrLSqLin.h:621
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > RNormL
Definition: nmrLSqLin.h:151
Friend(nmrLSqLinSolutionFixedSize< _ma, _me, _mg, _n > &insolution)
Definition: nmrLSqLin.h:1739
#define cmnThrow(a)
Definition: MinimalCmn.h:4
nmrLSqLinSolutionDynamic(size_t ma, size_t me, size_t mg, size_t n, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX)
Definition: nmrLSqLin.h:678
CISSTNETLIB_INTEGER nmrLSqLin(vctDynamicMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > &A, vctDynamicVectorBase< _vectorOwnerType, CISSTNETLIB_DOUBLE > &b, nmrLSqLinSolutionDynamic &solution)
Definition: nmrLSqLin.h:1244
const TypeX & GetX(void) const
Definition: nmrLSqLin.h:1769
vctFixedSizeVectorRef< CISSTNETLIB_DOUBLE,(_mg==0)?1:_mg, 1 > Typeh
Definition: nmrLSqLin.h:1683
void Allocate(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
Definition: nmrLSqLin.h:721
nmrLSqLinSolutionDynamic(size_t ma, size_t me, size_t mg, size_t n, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork, vctDynamicVectorBase< _vectorOwnerTypeIWork, CISSTNETLIB_INTEGER > &inIWork)
Definition: nmrLSqLin.h:658
nmrLSqLinSolutionDynamic(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
Definition: nmrLSqLin.h:448
pointer Pointer(index_type index=0)
Definition: vctDynamicVectorBase.h:155
static void AllocateIWorkspace(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeE, CISSTNETLIB_DOUBLE > &inE, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG, vctDynamicVector< CISSTNETLIB_INTEGER > &inIWork)
Definition: nmrLSqLin.h:334
vctDynamicVector< CISSTNETLIB_DOUBLE > & GetRNorm(void)
Definition: nmrLSqLin.h:381
vctDynamicVector< CISSTNETLIB_INTEGER > IWorkspaceMemory
Definition: nmrLSqLin.h:121
TypeInput & GetInput(void)
Definition: nmrLSqLin.h:1747
Definition: nmrLSqLin.h:1735
ThisType & Assign(const vctDynamicConstMatrixBase< __matrixOwnerType, value_type > &other)
Definition: vctDynamicMatrixBase.h:509
vctFixedSizeMatrixRef< CISSTNETLIB_DOUBLE,(_me==0)?1:_me, _n, 1,(_me==0)?1:_me > TypeE
Definition: nmrLSqLin.h:1679
Definition: nmrLSqLin.h:1669
vctFixedSizeMatrixRef< CISSTNETLIB_DOUBLE,(_mg==0)?1:_mg, _n, 1,(_mg==0)?1:_mg > TypeG
Definition: nmrLSqLin.h:1680
void Allocate(size_t ma, size_t me, size_t mg, size_t n, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork)
Definition: nmrLSqLin.h:1028
vctFixedSizeVectorRef< CISSTNETLIB_DOUBLE, _ma, 1 > Typeb
Definition: nmrLSqLin.h:1681
vctDynamicMatrixRef< CISSTNETLIB_DOUBLE > & GetA(void)
Definition: nmrLSqLin.h:360
vctDynamicVector< CISSTNETLIB_DOUBLE > RNorm
Definition: nmrLSqLin.h:126
vctFixedSizeVectorRef< CISSTNETLIB_DOUBLE, _ma, 1 > TypeRNormL
Definition: nmrLSqLin.h:1685
void SetRef(size_t ma, size_t me, size_t mg, size_t n, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork)
Definition: nmrLSqLin.h:1080
void SetRef(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork)
Definition: nmrLSqLin.h:766
static CISSTNETLIB_INTEGER GetIWorkspaceSize(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG)
Definition: nmrLSqLin.h:255
static void AllocateIWorkspace(CISSTNETLIB_INTEGER ma, CISSTNETLIB_INTEGER me, CISSTNETLIB_INTEGER mg, CISSTNETLIB_INTEGER n, vctDynamicVector< CISSTNETLIB_INTEGER > &inIWork)
Definition: nmrLSqLin.h:287
vctDynamicVectorRef< CISSTNETLIB_INTEGER > IWork
Definition: nmrLSqLin.h:154
vctFixedSizeVectorRef< CISSTNETLIB_DOUBLE,(_me==0)?1:_me, 1 > Typef
Definition: nmrLSqLin.h:1682
TypeRNorm RNorm
Definition: nmrLSqLin.h:1701
static CISSTNETLIB_INTEGER GetIWorkspaceSize(size_t CMN_UNUSED(ma), size_t me, size_t mg, size_t n)
Definition: nmrLSqLin.h:191
vctDynamicVector< CISSTNETLIB_DOUBLE > OutputMemory
Definition: nmrLSqLin.h:125
nmrLSqLinSolutionFixedSize()
Definition: nmrLSqLin.h:1761
void SetRef(size_t ma, size_t me, size_t mg, size_t n, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX)
Definition: nmrLSqLin.h:1133
Definition: nmrLSqLin.h:1670
static CISSTNETLIB_INTEGER GetWorkspaceSize(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG)
Definition: nmrLSqLin.h:249
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > f
Definition: nmrLSqLin.h:148
Declaration of the template function cmnThrow.
void SetRef(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeE, CISSTNETLIB_DOUBLE > &inE, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX)
Definition: nmrLSqLin.h:990
TypeRNormL RNormL
Definition: nmrLSqLin.h:1719
const bool VCT_COL_MAJOR
Definition: vctForwardDeclarations.h:46
size_t m_Me
Definition: nmrLSqLin.h:164
nmrLSqLinSolutionDynamic(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicMatrixBase< _matrixOwnerTypeE, CISSTNETLIB_DOUBLE > &E, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &G, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork, vctDynamicVectorBase< _vectorOwnerTypeIWork, CISSTNETLIB_INTEGER > &inIWork)
Definition: nmrLSqLin.h:640
Friend(nmrLSqLinSolutionDynamic &insolution)
Definition: nmrLSqLin.h:358
static void AllocateWorkspace(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA, vctDynamicMatrixBase< _matrixOwnerTypeE, CISSTNETLIB_DOUBLE > &inE, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &inG, vctDynamicVector< CISSTNETLIB_DOUBLE > &inWork)
Definition: nmrLSqLin.h:326
nmrLSqLinSolutionDynamic(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &G)
Definition: nmrLSqLin.h:530
vctDynamicMatrix< CISSTNETLIB_DOUBLE > & GetInput(void)
Definition: nmrLSqLin.h:384
Rules of exporting.
nmrLSqLinSolutionDynamic(size_t ma, size_t me, size_t mg, size_t n)
Definition: nmrLSqLin.h:431
CISSTNETLIB_INTEGER GetMa(void)
Definition: nmrLSqLin.h:393
TypeX & GetX(void)
Definition: nmrLSqLin.h:1741
const vctDynamicVectorRef< CISSTNETLIB_DOUBLE > & GetRNormE(void) const
Definition: nmrLSqLin.h:1218
void Allocate(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicMatrixBase< _matrixOwnerTypeE, CISSTNETLIB_DOUBLE > &E, vctDynamicMatrixBase< _matrixOwnerTypeG, CISSTNETLIB_DOUBLE > &G, vctDynamicVectorBase< _vectorOwnerTypeWork, CISSTNETLIB_DOUBLE > &inWork, vctDynamicVectorBase< _vectorOwnerTypeIWork, CISSTNETLIB_DOUBLE > &inIWork)
Definition: nmrLSqLin.h:938
Definition: vctDynamicVectorBase.h:61
nmrLSqLinSolutionDynamic(size_t ma, size_t mg, size_t n, vctDynamicVectorBase< _vectorOwnerTypeX, CISSTNETLIB_DOUBLE > &inX)
Definition: nmrLSqLin.h:583
nmrLSqLinSolutionDynamic(size_t ma, size_t n)
Definition: nmrLSqLin.h:421