cisst-saw
Loading...
Searching...
No Matches
nmrSVDRSSolver.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 Author(s): Ankur Kapoor
6 Created on: 2004-10-30
7
8 (C) Copyright 2004-2018 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17*/
18
19
24
25#ifndef _nmrSVDRSSolver_h
26#define _nmrSVDRSSolver_h
27
28
31
32
117
118protected:
119 CISSTNETLIB_INTEGER M; /* No. of rows of A, B, G */
120 CISSTNETLIB_INTEGER N; /* No. of cols of A, No of rows and cols of V */
121 CISSTNETLIB_INTEGER Lda; /* >= max(m, n) */
122 CISSTNETLIB_INTEGER Ldb; /* >= m */
123 CISSTNETLIB_INTEGER Nb; /* No. of cols of B and G */
124 vctDynamicMatrix<CISSTNETLIB_DOUBLE> S; /* Singular values, Dim(S)>n */
126
127public:
128
133 nmrSVDRSSolver(void): M(0), N(0)
134 { Allocate(M, N); }
135
136
146 nmrSVDRSSolver( CISSTNETLIB_INTEGER m,
147 CISSTNETLIB_INTEGER n,
148 CISSTNETLIB_INTEGER nb = 1) {
149 Allocate(m, n, nb);
150 }
151
152
161
162
171 inline void Allocate( CISSTNETLIB_INTEGER m,
172 CISSTNETLIB_INTEGER n,
173 CISSTNETLIB_INTEGER nb = 1) {
174 M = m;
175 N = n;
176 Lda = std::max(M, N);
177 Ldb = M;
178 Nb = nb;
179 S.SetSize(N, 1, VCT_COL_MAJOR);
180 Work.SetSize(2 * N, 1, VCT_COL_MAJOR);
181 }
182
183
190 { Allocate(A.rows(), A.cols(), B.cols()); }
191
192
211 CISST_THROW(std::runtime_error)
212 {
213 /* check that the size matches with Allocate() */
214 if ((M != static_cast<CISSTNETLIB_INTEGER>(A.rows())) ||
215 (N != static_cast<CISSTNETLIB_INTEGER>(A.cols())) ||
216 (Nb != static_cast<CISSTNETLIB_INTEGER>(B.cols()))) {
217 cmnThrow(std::runtime_error("nmrSVDRSSolver Solve: Sizes used for Allocate were different"));
218 }
219
220 /* check other dimensions */
221 if (M != static_cast<CISSTNETLIB_INTEGER>(B.rows())) {
222 cmnThrow(std::runtime_error("nmrSVDRSSolver Solve: Sizes of parameters are incompatible"));
223 }
224
225 /* check that the matrices are Fortran like */
226 if (! (A.IsFortran() && B.IsFortran())) {
227 cmnThrow(std::runtime_error("nmrSVDRSSolver Solve: All parameters must be Fortran compatible"));
228 }
229
230#if defined(CISSTNETLIB_VERSION_MAJOR)
231#if (CISSTNETLIB_VERSION_MAJOR >= 3)
232 cisstNetlib_svdrs_(A.Pointer(), &Lda, &M, &N, B.Pointer(),
233 &Ldb, &Nb, S.Pointer(), Work.Pointer());
234#endif
235#else // no major version
236 svdrs_(A.Pointer(), &Lda, &M, &N, B.Pointer(),
237 &Ldb, &Nb, S.Pointer(), Work.Pointer());
238#endif // CISSTNETLIB_VERSION
239 }
240
241
243 { return S; }
244
245};
246
247
248#endif // _nmrSVDRSSolver_h
nmrSVDRSSolver(CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n, CISSTNETLIB_INTEGER nb=1)
Definition nmrSVDRSSolver.h:146
void Solve(vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &B) CISST_THROW(std
Definition nmrSVDRSSolver.h:209
CISSTNETLIB_INTEGER Nb
Definition nmrSVDRSSolver.h:123
CISSTNETLIB_INTEGER Ldb
Definition nmrSVDRSSolver.h:122
nmrSVDRSSolver(vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &B)
Definition nmrSVDRSSolver.h:158
void Allocate(CISSTNETLIB_INTEGER m, CISSTNETLIB_INTEGER n, CISSTNETLIB_INTEGER nb=1)
Definition nmrSVDRSSolver.h:171
vctDynamicMatrix< CISSTNETLIB_DOUBLE > S
Definition nmrSVDRSSolver.h:124
vctDynamicMatrix< CISSTNETLIB_DOUBLE > Work
Definition nmrSVDRSSolver.h:125
const vctDynamicMatrix< CISSTNETLIB_DOUBLE > & GetS(void) const
Definition nmrSVDRSSolver.h:242
CISSTNETLIB_INTEGER Lda
Definition nmrSVDRSSolver.h:121
nmrSVDRSSolver(void)
Definition nmrSVDRSSolver.h:133
void Allocate(vctDynamicMatrix< CISSTNETLIB_DOUBLE > &A, vctDynamicMatrix< CISSTNETLIB_DOUBLE > &B)
Definition nmrSVDRSSolver.h:188
CISSTNETLIB_INTEGER M
Definition nmrSVDRSSolver.h:119
CISSTNETLIB_INTEGER N
Definition nmrSVDRSSolver.h:120
Definition vctForwardDeclarations.h:157
#define CISST_THROW(exceptionParameter)
Somewhat portable compilation warning message. This works with very recent versions of gcc (4....
Definition cmnPortability.h:559
void cmnThrow(const _exceptionType &except, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_ERROR)
Definition cmnThrow.h:76
Declaration of vctDynamicMatrix.
const bool VCT_COL_MAJOR
Definition vctForwardDeclarations.h:44