cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nmrSVD.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, Anton Deguet
7  Created on: 2005-10-18
8 
9  (C) Copyright 2005-2013 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 */
20 
21 
28 #ifndef _nmrSVD_h
29 #define _nmrSVD_h
30 
31 #include <cisstCommon/cmnThrow.h>
35 
36 // Always include last
38 
39 
107 
108 public:
115 
119 
120 protected:
123 
130 
140 
149 
154  inline void SetDimension(size_type m,
155  size_type n,
156  bool storageOrder)
157  {
158  StorageOrderMember = storageOrder;
159  MMember = m;
160  NMember = n;
161  }
162 
182  inline void AllocateOutputWorkspace( bool allocateOutput,
183  bool allocateWorkspace)
184  {
185 
186  // allocate output
187  if (allocateOutput) {
188  const size_type minmn =(MMember<NMember)? MMember: NMember;
189  const size_type outputLength = ( MMember * MMember +
190  NMember * NMember +
191  minmn );
192  this->OutputMemory.SetSize(outputLength);
194  (StorageOrderMember) ? MMember : 1,
195  (StorageOrderMember) ? 1 : MMember,
196  this->OutputMemory.Pointer(0));
199  (StorageOrderMember)? 1: NMember,
200  this->OutputMemory.Pointer(MMember * MMember));
201  this->SReference.SetRef((MMember<NMember)? MMember:NMember,
202  this->OutputMemory.Pointer(MMember*MMember + NMember*NMember),
203  1);
204  }
205  else {
206  this->OutputMemory.SetSize(0);
207  }
208  // allocate workspace
209  if (allocateWorkspace) {
211  NMember ) );
213  }
214  else {
215  this->WorkspaceMemory.SetSize(0);
216  }
217  }
218 
219 
227  template <typename _matrixOwnerTypeU,
228  typename _vectorOwnerTypeS,
229  typename _matrixOwnerTypeVt>
230  inline
234  throw(std::runtime_error)
235  {
236 
237  // check sizes and storage order
238  if (! inU.IsSquare(MMember)) {
239  cmnThrow(std::runtime_error("nmrSVDDynamicData: Size of matrix U is incorrect."));
240  }
241  if (inU.StorageOrder() != StorageOrderMember) {
242  cmnThrow(std::runtime_error("nmrSVDDynamicData: Storage order of U is incorrect."));
243  }
244  if (!inU.IsCompact()) {
245  cmnThrow(std::runtime_error("nmrSVDDynamicData: Matrix U must be compact."));
246  }
247  if (! inVt.IsSquare(NMember)) {
248  cmnThrow(std::runtime_error("nmrSVDDynamicData: Size of matrix Vt is incorrect."));
249  }
250  if (inVt.StorageOrder() != StorageOrderMember) {
251  cmnThrow(std::runtime_error("nmrSVDDynamicData: Storage order of Vt is incorrect."));
252  }
253  if (!inVt.IsCompact()) {
254  cmnThrow(std::runtime_error("nmrSVDDynamicData: Matrix Vt must be compact."));
255  }
256  const size_type minmn = (MMember < NMember)? MMember: NMember;
257  if (minmn != inS.size()) {
258  cmnThrow(std::runtime_error("nmrSVDDynamicData: Size of vector S is incorrect."));
259  }
260  if (!inS.IsCompact()) {
261  cmnThrow(std::runtime_error("nmrSVDDynamicData: Vector S must be compact."));
262  }
263  }
264 
265 
273  template <typename _vectorOwnerTypeWorkspace>
274  inline void
276  throw(std::runtime_error)
277  {
278 
279  const size_type lwork =
281 
282  if (lwork > inWorkspace.size()) {
283  cmnThrow(std::runtime_error("nmrSVDDynamicData: Workspace is too small."));
284  }
285 
286  if (!inWorkspace.IsCompact()) {
287  cmnThrow(std::runtime_error("nmrSVDDynamicData: Workspace must be compact."));
288  }
289  }
290 
291 public:
292 
299  {
300  const size_type minmn = (m < n) ? m : n;
301  const size_type maxmn = (m > n) ? m : n;
302  const size_type lwork_1 = 3 * minmn + maxmn;
303  const size_type lwork_2 = 5 * minmn;
304  return (lwork_1 > lwork_2) ? lwork_1 : lwork_2;
305  }
306 
312  template <class _matrixOwnerTypeA>
313  static inline
315  {
316  return nmrSVDDynamicData::WorkspaceSize(inA.rows(), inA.cols());
317  }
318 
319 
327  template <class _matrixOwnerTypeA>
328  static inline
330  {
331  nsize_type matrixSize(A.rows(), A.cols());
332  return matrixSize;
333  }
334 
335 
344  template <class _matrixOwnerTypeA, class _matrixOwnerTypeS, class _vectorOwnerTypeS>
345  static inline
350  throw(std::runtime_error)
351  {
352  if ((A.rows() != matrixS.rows()) || (A.cols() != matrixS.cols())) {
353  cmnThrow(std::runtime_error("nmrSVDDynamicData::UpdateMatrixS: Size of matrix S is incorrect."));
354  }
355  matrixS.SetAll(0.0);
356  matrixS.Diagonal().Assign(vectorS);
357  return matrixS;
358  }
359 
360 #ifndef SWIG
361 #ifndef DOXYGEN
362 
368  class Friend {
369  private:
370  nmrSVDDynamicData & Data;
371  public:
372  Friend(nmrSVDDynamicData &inData): Data(inData) {
373  }
375  return Data.SReference;
376  }
378  return Data.UReference;
379  }
381  return Data.VtReference;
382  }
384  return Data.WorkspaceReference;
385  }
386  inline size_type M(void) {
387  return Data.MMember;
388  }
389  inline size_type N(void) {
390  return Data.NMember;
391  }
392  inline bool StorageOrder(void) {
393  return Data.StorageOrderMember;
394  }
395  };
396  friend class Friend;
397 #endif // DOXYGEN
398 #endif // SWIG
399 
410  MMember(static_cast<size_type>(0)),
411  NMember(static_cast<size_type>(0)),
413  {
414  AllocateOutputWorkspace(false, false);
415  }
416 
429  nmrSVDDynamicData(size_type m, size_type n, bool storageOrder)
430  {
431  this->Allocate(m, n, storageOrder);
432  }
433 
446  template <class _matrixOwnerTypeA>
448  {
449  this->Allocate(A);
450  }
451 
466  template <class _matrixOwnerTypeA, class _vectorOwnerTypeWorkspace>
469  {
470  this->SetRefWorkspace(A, inWorkspace);
471  }
472 
487  template <typename _matrixOwnerTypeU,
488  typename _vectorOwnerTypeS,
489  typename _matrixOwnerTypeVt,
490  typename _vectorOwnerTypeWorkspace>
495  {
496  this->SetRef(inU, inS, inVt, inWorkspace);
497  }
498 
509  template <typename _matrixOwnerTypeU,
510  typename _vectorOwnerTypeS,
511  typename _matrixOwnerTypeVt>
515  {
516  this->SetRefOutput(inU, inS, inVt);
517  }
518 
519 
530  template <class _matrixOwnerTypeA>
531  inline
533  {
534  this->Allocate(A.rows(), A.cols(), A.StorageOrder());
535  }
536 
548  template <class _matrixOwnerTypeA, class _vectorOwnerTypeWorkspace>
549  inline
552  {
553  this->SetDimension(A.rows(), A.cols(), A.StorageOrder());
554 
555  // allocate output and set references
556  this->AllocateOutputWorkspace(true, false);
557 
558  // set reference on user provided workspace
559  this->ThrowUnlessWorkspaceSizeIsCorrect(inWorkspace);
560  this->WorkspaceReference.SetRef(inWorkspace);
561  }
562 
573  void Allocate(size_type m, size_type n, bool storageOrder)
574  {
575  this->SetDimension(m, n, storageOrder);
576  this->AllocateOutputWorkspace(true, true);
577  }
578 
591  template <typename _matrixOwnerTypeU,
592  typename _vectorOwnerTypeS,
593  typename _matrixOwnerTypeVt,
594  typename _vectorOwnerTypeWorkspace>
599  throw(std::runtime_error)
600  {
601  this->SetDimension(inU.rows(),inVt.rows(),inU.StorageOrder());
602  this->AllocateOutputWorkspace(false, false);
603  this->ThrowUnlessOutputSizeIsCorrect(inU, inS, inVt);
604  this->ThrowUnlessWorkspaceSizeIsCorrect(inWorkspace);
605 
606  this->SReference.SetRef(inS);
607  this->UReference.SetRef(inU);
608  this->VtReference.SetRef(inVt);
609  this->WorkspaceReference.SetRef(inWorkspace);
610  }
611 
612 
621  template <typename _matrixOwnerTypeU,
622  typename _vectorOwnerTypeS,
623  typename _matrixOwnerTypeVt>
627  throw(std::runtime_error)
628  {
629  this->SetDimension(inU.rows(), inVt.rows(), inU.StorageOrder());
630  this->ThrowUnlessOutputSizeIsCorrect(inU, inS, inVt);
631 
632  this->SReference.SetRef(inS);
633  this->UReference.SetRef(inU);
634  this->VtReference.SetRef(inVt);
635 
636  AllocateOutputWorkspace(false, true);
637  }
638 
642  inline
644  { return SReference; }
645 
649  inline
651  { return UReference; }
655  inline
657  { return VtReference; }
658 
659 };
660 
661 
662 
663 
664 
691 #ifndef SWIG
692 template <vct::size_type _rows, vct::size_type _cols, bool _storageOrder = VCT_ROW_MAJOR>
694 {
695 public:
696 #ifndef DOXYGEN
698 
699  enum {M = (_storageOrder == VCT_COL_MAJOR) ? _rows : _cols};
700  enum {N = (_storageOrder == VCT_COL_MAJOR) ? _cols : _rows};
701  enum {MIN_MN =
702  (static_cast<size_type>(M) < static_cast<size_type>(N))
703  ?
704  static_cast<size_type>(M)
705  :
706  static_cast<size_type>(N)};
707  enum {LWORK_1 =
708  (3 * static_cast<size_type>(MIN_MN) + (static_cast<size_type>(M)) > static_cast<size_type>(N))
709  ?
710  static_cast<size_type>(M)
711  :
712  static_cast<size_type>(N)};
713  enum {LWORK_2 = 5 * MIN_MN};
714  enum {LWORK =
715  (static_cast<size_type>(LWORK_1) > static_cast<size_type>(LWORK_2))
716  ?
717  static_cast<size_type>(LWORK_1)
718  :
719  static_cast<size_type>(LWORK_2)};
720 #endif // DOXYGEN
721 
739 
740 protected:
741  MatrixTypeU UMember;
742  MatrixTypeVt VtMember;
743  VectorTypeS SMember;
744  VectorTypeWorkspace WorkspaceMember;
746 public:
747 #ifndef DOXYGEN
748 
754  class Friend {
755  private:
757  public:
759  {}
760 
761  inline VectorTypeS & S(void)
762  { return Data.SMember; }
763 
764  inline MatrixTypeU & U(void)
765  { return Data.UMember; }
766 
767  inline MatrixTypeVt & Vt(void)
768  { return Data.VtMember; }
769 
770  inline VectorTypeWorkspace & Workspace(void)
771  { return Data.WorkspaceMember; }
772  };
773  friend class Friend;
774 #endif // DOXYGEN
775 
779 
783  inline const VectorTypeS & S(void) const
784  { return SMember; }
785 
789  inline const MatrixTypeU & U(void) const
790  { return UMember; }
791 
795  inline const MatrixTypeVt & Vt(void) const
796  { return VtMember; }
797 
801  static inline
802  MatrixTypeS & UpdateMatrixS( const VectorTypeS & vectorS,
803  MatrixTypeS & matrixS )
804  {
805  matrixS.SetAll(0.0);
806  matrixS.Diagonal().Assign(vectorS);
807  return matrixS;
808  }
809 };
810 #endif // SWIG
811 
812 
813 
814 
976 
977 
998 template <class _matrixOwnerType>
999 inline
1001  nmrSVDDynamicData & data)
1002  throw (std::runtime_error)
1003 {
1004  typename nmrSVDDynamicData::Friend dataFriend(data);
1005  CISSTNETLIB_INTEGER Info;
1006  char m_Jobu = 'A';
1007  char m_Jobvt = 'A';
1008  CISSTNETLIB_INTEGER m_Lwork =
1009  static_cast<CISSTNETLIB_INTEGER>(nmrSVDDynamicData::WorkspaceSize(dataFriend.M(),
1010  dataFriend.N()));
1011 
1012  /* check that storage order matches with Allocate() */
1013  if (A.StorageOrder() != dataFriend.StorageOrder()) {
1014  cmnThrow(std::runtime_error("nmrSVD: Storage order used for Allocate was different"));
1015  }
1016  /* check sizes */
1017  if ((dataFriend.M() != A.rows()) || (dataFriend.N() != A.cols())) {
1018  cmnThrow(std::runtime_error("nmrSVD: Size used for Allocate was different"));
1019  }
1020  /* check that the matrices are compact */
1021  if (! A.IsCompact()) {
1022  cmnThrow(std::runtime_error("nmrSVD: Requires a compact matrix"));
1023  }
1024 
1025  /* Based on storage order, permute U and Vt as well as dimension */
1026  CISSTNETLIB_DOUBLE *UPtr, *VtPtr;
1027  CISSTNETLIB_INTEGER m_Lda, m_Ldu, m_Ldvt;
1028 
1029  if (A.IsColMajor()) {
1030  m_Lda = (1 > dataFriend.M()) ? 1 : dataFriend.M();
1031  m_Ldu = dataFriend.M();
1032  m_Ldvt = dataFriend.N();
1033  UPtr = dataFriend.U().Pointer();
1034  VtPtr = dataFriend.Vt().Pointer();
1035  } else {
1036  m_Lda = (1 > dataFriend.N()) ? 1 : dataFriend.N();
1037  m_Ldu = dataFriend.N();
1038  m_Ldvt = dataFriend.M();
1039  UPtr = dataFriend.Vt().Pointer();
1040  VtPtr = dataFriend.U().Pointer();
1041  }
1042 
1043  // for versions based on gfortran/lapack, CISSTNETLIB_VERSION is
1044  // defined
1045 #if defined(CISSTNETLIB_VERSION)
1046 #if defined(CISSTNETLIB_VERSION_MAJOR)
1047 #if (CISSTNETLIB_VERSION_MAJOR >= 3)
1048  cisstNetlib_dgesvd_(&m_Jobu, &m_Jobvt, &m_Ldu, &m_Ldvt,
1049  A.Pointer(), &m_Lda, dataFriend.S().Pointer(),
1050  UPtr, &m_Ldu,
1051  VtPtr, &m_Ldvt,
1052  dataFriend.Workspace().Pointer(), &m_Lwork, &Info);
1053 #endif
1054 #else // no major version
1055  dgesvd_(&m_Jobu, &m_Jobvt, &m_Ldu, &m_Ldvt,
1056  A.Pointer(), &m_Lda, dataFriend.S().Pointer(),
1057  UPtr, &m_Ldu,
1058  VtPtr, &m_Ldvt,
1059  dataFriend.Workspace().Pointer(), &m_Lwork, &Info);
1060 #endif // CISSTNETLIB_VERSION
1061 #else
1062  ftnlen jobu_len = (ftnlen)1, jobvt_len = (ftnlen)1;
1063  la_dzlapack_MP_sgesvd_nat(&m_Jobu, &m_Jobvt, &m_Ldu, &m_Ldvt,
1064  A.Pointer(), &m_Lda, dataFriend.S().Pointer(),
1065  UPtr, &m_Ldu,
1066  VtPtr, &m_Ldvt,
1067  dataFriend.Workspace().Pointer(), &m_Lwork, &Info,
1068  jobu_len, jobvt_len);
1069 #endif
1070 
1071  return Info;
1072 }
1073 
1090 template <class _matrixOwnerTypeA,
1091  class _matrixOwnerTypeU,
1092  class _vectorOwnerTypeS,
1093  class _matrixOwnerTypeVt,
1094  class _vectorOwnerTypeWorkspace>
1095 inline
1101 {
1102  nmrSVDDynamicData svdData(U, S, Vt, Workspace);
1103  CISSTNETLIB_INTEGER ret_value = nmrSVD(A, svdData);
1104  return ret_value;
1105 }
1106 
1127 template <class _matrixOwnerTypeA,
1128  class _matrixOwnerTypeU,
1129  class _vectorOwnerTypeS,
1130  class _matrixOwnerTypeVt>
1131 inline
1136 {
1137  nmrSVDDynamicData svdData(U, S, Vt);
1138  CISSTNETLIB_INTEGER ret_value = nmrSVD(A, svdData);
1139  return ret_value;
1140 }
1141 
1142 
1143 #ifndef SWIG // don't have fixed size containers in Python
1144 
1170 template <vct::size_type _rows, vct::size_type _cols, vct::size_type _minmn,
1171  vct::size_type _work, bool _storageOrder>
1172 inline
1178 {
1179  const CISSTNETLIB_INTEGER minmn =
1180  static_cast<CISSTNETLIB_INTEGER>(nmrSVDFixedSizeData<_rows, _cols, _storageOrder>::MIN_MN);
1181  //Assert if requirement is greater than size provided!
1182  CMN_ASSERT(minmn <= static_cast<CISSTNETLIB_INTEGER>(_minmn));
1183  CISSTNETLIB_INTEGER ldu = (_storageOrder == VCT_COL_MAJOR) ? _rows : _cols;
1184  CISSTNETLIB_INTEGER lda = (1 > ldu) ? 1 : ldu;
1185  CISSTNETLIB_INTEGER ldvt = (_storageOrder == VCT_COL_MAJOR) ? _cols : _rows;
1186  CISSTNETLIB_INTEGER lwork =
1187  static_cast<CISSTNETLIB_INTEGER>(nmrSVDFixedSizeData<_rows, _cols, _storageOrder>::LWORK);
1188  //Assert if requirement is greater than size provided!
1189  CMN_ASSERT(lwork <= static_cast<CISSTNETLIB_INTEGER>(_work));
1190  char jobu = 'A';
1191  char jobvt = 'A';
1192  CISSTNETLIB_INTEGER info;
1193  CISSTNETLIB_DOUBLE *UPtr, *VtPtr;
1194  if (_storageOrder == VCT_COL_MAJOR) {
1195  UPtr = U.Pointer();
1196  VtPtr = Vt.Pointer();
1197  } else {
1198  UPtr = Vt.Pointer();
1199  VtPtr = U.Pointer();
1200  }
1201 
1202  // for versions based on gfortran/lapack, CISSTNETLIB_VERSION is
1203  // defined
1204 #if defined(CISSTNETLIB_VERSION)
1205  /* call the LAPACK C function */
1206 #if defined(CISSTNETLIB_VERSION_MAJOR)
1207 #if (CISSTNETLIB_VERSION_MAJOR >= 3)
1208  cisstNetlib_dgesvd_(&jobu, &jobvt, &ldu, &ldvt,
1209  A.Pointer(), &lda, S.Pointer(),
1210  UPtr, &ldu,
1211  VtPtr, &ldvt,
1212  workspace.Pointer(), &lwork, &info);
1213 #endif
1214 #else // no major version
1215  dgesvd_(&jobu, &jobvt, &ldu, &ldvt,
1216  A.Pointer(), &lda, S.Pointer(),
1217  UPtr, &ldu,
1218  VtPtr, &ldvt,
1219  workspace.Pointer(), &lwork, &info);
1220 #endif // CISSTNETLIB_VERSION
1221 #else
1222  ftnlen jobu_len = (ftnlen)1, jobvt_len = (ftnlen)1;
1223  la_dzlapack_MP_sgesvd_nat(&jobu, &jobvt, &ldu, &ldvt,
1224  A.Pointer(), &lda, S.Pointer(),
1225  UPtr, &ldu,
1226  VtPtr, &ldvt,
1227  workspace.Pointer(), &lwork, &info,
1228  jobu_len, jobvt_len);
1229 #endif
1230 
1231  return info;
1232 }
1233 
1249 template <vct::size_type _rows, vct::size_type _cols, vct::size_type _minmn, bool _storageOrder>
1250 inline
1255 {
1257  const CISSTNETLIB_INTEGER ret_value = nmrSVD(A, U, S, Vt, workspace);
1258  return ret_value;
1259 }
1260 
1261 
1287 template <vct::size_type _rows, vct::size_type _cols, bool _storageOrder>
1288 inline
1291 {
1293  CISSTNETLIB_INTEGER ret_value = nmrSVD( A, dataFriend.U(), dataFriend.S(),
1294  dataFriend.Vt(), dataFriend.Workspace() );
1295  return ret_value;
1296 }
1297 #endif // SWIG
1298 
1300 
1301 #endif
1302 
MatrixTypeVt VtMember
Definition: nmrSVD.h:742
Definition: nmrSVD.h:699
nmrSVDFixedSizeData()
Definition: nmrSVD.h:778
vctFixedSizeVector< CISSTNETLIB_DOUBLE, LWORK > VectorTypeWorkspace
Definition: nmrSVD.h:738
Declaration of vctDynamicMatrix.
Definition: nmrSVD.h:707
#define CMN_ASSERT(expr)
Definition: cmnAssert.h:90
MatrixTypeU UMember
Definition: nmrSVD.h:741
Definition: vctDynamicMatrixBase.h:42
vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _cols, _cols, _storageOrder > MatrixTypeVt
Definition: nmrSVD.h:735
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > WorkspaceReference
Definition: nmrSVD.h:138
MatrixTypeVt & Vt(void)
Definition: nmrSVD.h:767
nmrSVDDynamicData(const vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
Definition: nmrSVD.h:447
Definition: nmrSVD.h:713
Definition: nmrSVD.h:701
Definition: nmrSVD.h:714
vctDynamicMatrixRef< CISSTNETLIB_DOUBLE > & Vt(void)
Definition: nmrSVD.h:380
Declaration of vctFixedSizeMatrix.
MatrixTypeU & U(void)
Definition: nmrSVD.h:764
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > & S(void)
Definition: nmrSVD.h:374
vctDynamicMatrixRef< CISSTNETLIB_DOUBLE > UReference
Definition: nmrSVD.h:135
value_type SetAll(const value_type value)
Definition: vctFixedSizeMatrixBase.h:421
void SetRefWorkspace(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &inWorkspace)
Definition: nmrSVD.h:550
Friend(nmrSVDFixedSizeData< _rows, _cols, _storageOrder > &inData)
Definition: nmrSVD.h:758
void SetDimension(size_type m, size_type n, bool storageOrder)
Definition: nmrSVD.h:154
void Allocate(const vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
Definition: nmrSVD.h:532
size_t size_type
Definition: vctContainerTraits.h:35
DiagonalRefType Diagonal(void)
Definition: vctFixedSizeMatrixBase.h:254
const VectorTypeS & S(void) const
Definition: nmrSVD.h:783
bool StorageOrder(void) const
Definition: vctDynamicConstMatrixBase.h:656
Definition: nmrSVD.h:700
static nsize_type MatrixSSize(const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A)
Definition: nmrSVD.h:329
VectorTypeS SMember
Definition: nmrSVD.h:743
void SetRef(size_type size, pointer data, stride_type stride=1)
Definition: vctDynamicVectorRef.h:156
bool StorageOrderMember
Definition: nmrSVD.h:147
VectorTypeS & S(void)
Definition: nmrSVD.h:761
nmrSVDDynamicData(size_type m, size_type n, bool storageOrder)
Definition: nmrSVD.h:429
ThisType & Assign(const vctFixedSizeConstVectorBase< _size, __stride, __elementType, __dataPtrType > &other)
Definition: vctFixedSizeVectorBase.h:274
Definition: nmrSVD.h:754
void SetSize(size_type size)
Definition: vctDynamicVector.h:315
void ThrowUnlessOutputSizeIsCorrect(vctDynamicMatrixBase< _matrixOwnerTypeU, CISSTNETLIB_DOUBLE > &inU, vctDynamicVectorBase< _vectorOwnerTypeS, CISSTNETLIB_DOUBLE > &inS, vctDynamicMatrixBase< _matrixOwnerTypeVt, CISSTNETLIB_DOUBLE > &inVt) const
Definition: nmrSVD.h:231
Definition: vctDynamicConstMatrixBase.h:77
nmrSVDDynamicData(vctDynamicMatrixBase< _matrixOwnerTypeU, CISSTNETLIB_DOUBLE > &inU, vctDynamicVectorBase< _vectorOwnerTypeS, CISSTNETLIB_DOUBLE > &inS, vctDynamicMatrixBase< _matrixOwnerTypeVt, CISSTNETLIB_DOUBLE > &inVt, vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &inWorkspace)
Definition: nmrSVD.h:491
Implementation of a fixed-size vector using template metaprogramming.
Definition: vctFixedSizeVector.h:52
vctFixedSizeVector< CISSTNETLIB_DOUBLE, MIN_MN > VectorTypeS
Definition: nmrSVD.h:729
nmrSVDDynamicData(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &inWorkspace)
Definition: nmrSVD.h:467
vctDynamicVector< CISSTNETLIB_DOUBLE > WorkspaceMemory
Definition: nmrSVD.h:122
vctDynamicMatrixRef< CISSTNETLIB_DOUBLE > VtReference
Definition: nmrSVD.h:136
nmrSVDDynamicData(vctDynamicMatrixBase< _matrixOwnerTypeU, CISSTNETLIB_DOUBLE > &inU, vctDynamicVectorBase< _vectorOwnerTypeS, CISSTNETLIB_DOUBLE > &inS, vctDynamicMatrixBase< _matrixOwnerTypeVt, CISSTNETLIB_DOUBLE > &inVt)
Definition: nmrSVD.h:512
void SetRef(size_type rows, size_type cols, stride_type rowStride, stride_type colStride, pointer dataPointer)
Definition: vctDynamicMatrixRef.h:217
void ThrowUnlessWorkspaceSizeIsCorrect(vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &inWorkspace) const
Definition: nmrSVD.h:275
const vctDynamicMatrixRef< CISSTNETLIB_DOUBLE > & U(void) const
Definition: nmrSVD.h:650
static size_type WorkspaceSize(size_type m, size_type n)
Definition: nmrSVD.h:298
pointer Pointer(size_type rowIndex, size_type colIndex)
Definition: vctDynamicMatrixBase.h:143
vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, _storageOrder > MatrixTypeS
Definition: nmrSVD.h:732
nmrSVDDynamicData()
Definition: nmrSVD.h:409
size_type rows() const
Definition: vctDynamicConstMatrixBase.h:238
vct::size_type size_type
Definition: nmrSVD.h:114
Friend(nmrSVDDynamicData &inData)
Definition: nmrSVD.h:372
size_type cols() const
Definition: vctDynamicConstMatrixBase.h:243
Data for SVD problem (Dynamic).
Definition: nmrSVD.h:106
vctDynamicVector< CISSTNETLIB_DOUBLE > OutputMemory
Definition: nmrSVD.h:129
Definition: nmrSVD.h:368
const MatrixTypeU & U(void) const
Definition: nmrSVD.h:789
void AllocateOutputWorkspace(bool allocateOutput, bool allocateWorkspace)
Definition: nmrSVD.h:182
static vctDynamicMatrixBase< _matrixOwnerTypeS, CISSTNETLIB_DOUBLE > & UpdateMatrixS(const vctDynamicConstMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &A, const vctDynamicConstVectorBase< _vectorOwnerTypeS, CISSTNETLIB_DOUBLE > &vectorS, vctDynamicMatrixBase< _matrixOwnerTypeS, CISSTNETLIB_DOUBLE > &matrixS)
Definition: nmrSVD.h:347
#define cmnThrow(a)
Definition: MinimalCmn.h:4
Implementation of a fixed-size matrix using template metaprogramming.
Definition: vctFixedSizeMatrix.h:52
pointer Pointer(index_type index=0)
Definition: vctDynamicVectorBase.h:155
vctDynamicMatrixRef< CISSTNETLIB_DOUBLE > & U(void)
Definition: nmrSVD.h:377
static size_type WorkspaceSize(vctDynamicMatrixBase< _matrixOwnerTypeA, CISSTNETLIB_DOUBLE > &inA)
Definition: nmrSVD.h:314
void Allocate(size_type m, size_type n, bool storageOrder)
Definition: nmrSVD.h:573
const MatrixTypeVt & Vt(void) const
Definition: nmrSVD.h:795
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > SReference
Definition: nmrSVD.h:137
const vctDynamicMatrixRef< CISSTNETLIB_DOUBLE > & Vt(void) const
Definition: nmrSVD.h:656
Data of SVD problem (Fixed size).
Definition: nmrSVD.h:693
VectorTypeWorkspace WorkspaceMember
Definition: nmrSVD.h:744
Definition: vctDynamicConstVectorBase.h:77
size_type N(void)
Definition: nmrSVD.h:389
bool StorageOrder(void)
Definition: nmrSVD.h:392
static MatrixTypeS & UpdateMatrixS(const VectorTypeS &vectorS, MatrixTypeS &matrixS)
Definition: nmrSVD.h:802
vct::size_type size_type
Definition: nmrSVD.h:697
void SetRef(vctDynamicMatrixBase< _matrixOwnerTypeU, CISSTNETLIB_DOUBLE > &inU, vctDynamicVectorBase< _vectorOwnerTypeS, CISSTNETLIB_DOUBLE > &inS, vctDynamicMatrixBase< _matrixOwnerTypeVt, CISSTNETLIB_DOUBLE > &inVt, vctDynamicVectorBase< _vectorOwnerTypeWorkspace, CISSTNETLIB_DOUBLE > &inWorkspace)
Definition: nmrSVD.h:595
void SetRefOutput(vctDynamicMatrixBase< _matrixOwnerTypeU, CISSTNETLIB_DOUBLE > &inU, vctDynamicVectorBase< _vectorOwnerTypeS, CISSTNETLIB_DOUBLE > &inS, vctDynamicMatrixBase< _matrixOwnerTypeVt, CISSTNETLIB_DOUBLE > &inVt)
Definition: nmrSVD.h:624
Declaration of the template function cmnThrow.
vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _rows, _storageOrder > MatrixTypeU
Definition: nmrSVD.h:726
VectorTypeWorkspace & Workspace(void)
Definition: nmrSVD.h:770
const bool VCT_COL_MAJOR
Definition: vctForwardDeclarations.h:46
vctDynamicVectorRef< CISSTNETLIB_DOUBLE > & Workspace(void)
Definition: nmrSVD.h:383
CISSTNETLIB_INTEGER nmrSVD(vctDynamicMatrixBase< _matrixOwnerType, CISSTNETLIB_DOUBLE > &A, nmrSVDDynamicData &data)
Definition: nmrSVD.h:1000
vctFixedSizeMatrix< CISSTNETLIB_DOUBLE, _rows, _cols, _storageOrder > MatrixTypeA
Definition: nmrSVD.h:723
vctFixedSizeVector< size_type, 2 > nsize_type
Definition: nmrSVD.h:118
Rules of exporting.
size_type MMember
Definition: nmrSVD.h:145
const vctDynamicVectorRef< CISSTNETLIB_DOUBLE > & S(void) const
Definition: nmrSVD.h:643
pointer Pointer(size_type rowIndex, size_type colIndex)
Definition: vctFixedSizeMatrixBase.h:161
Definition: vctDynamicVectorBase.h:61
size_type NMember
Definition: nmrSVD.h:146
size_type M(void)
Definition: nmrSVD.h:386