1 /*
  2  *   Copyright (c) 2012, Michael Lehn
  3  *
  4  *   All rights reserved.
  5  *
  6  *   Redistribution and use in source and binary forms, with or without
  7  *   modification, are permitted provided that the following conditions
  8  *   are met:
  9  *
 10  *   1) Redistributions of source code must retain the above copyright
 11  *      notice, this list of conditions and the following disclaimer.
 12  *   2) Redistributions in binary form must reproduce the above copyright
 13  *      notice, this list of conditions and the following disclaimer in
 14  *      the documentation and/or other materials provided with the
 15  *      distribution.
 16  *   3) Neither the name of the FLENS development group nor the names of
 17  *      its contributors may be used to endorse or promote products derived
 18  *      from this software without specific prior written permission.
 19  *
 20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 31  */
 32 
 33 /* Based on
 34  *
 35        SUBROUTINE DGEJSV( JOBA, JOBU, JOBV, JOBR, JOBT, JOBP,
 36       $                   M, N, A, LDA, SVA, U, LDU, V, LDV,
 37       $                   WORK, LWORK, IWORK, INFO )
 38  *
 39  *  -- LAPACK routine (version 3.3.1)                                    --
 40  *
 41  *  -- Contributed by Zlatko Drmac of the University of Zagreb and     --
 42  *  -- Kresimir Veselic of the Fernuniversitaet Hagen                  --
 43  *  -- April 2011                                                      --
 44  *
 45  *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
 46  *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
 47  *
 48  * This routine is also part of SIGMA (version 1.23, October 23. 2008.)
 49  * SIGMA is a library of algorithms for highly accurate algorithms for
 50  * computation of SVD, PSVD, QSVD, (H,K)-SVD, and for solution of the
 51  * eigenvalue problems Hx = lambda M x, H M x = lambda x with H, M > 0.
 52  *
 53  */
 54 
 55 #ifndef FLENS_LAPACK_SVD_JSV_H
 56 #define FLENS_LAPACK_SVD_JSV_H 1
 57 
 58 #include <flens/matrixtypes/matrixtypes.h>
 59 #include <flens/vectortypes/vectortypes.h>
 60 
 61 namespace flens { namespace lapack {
 62 
 63 namespace JSV {
 64 
 65     // TODO: Find better (more expressive) names for these constants
 66     enum Accuracy  {
 67         accOptC = 'C',
 68         accOptE = 'E',
 69         accOptF = 'F',
 70         accOptG = 'G',
 71         accOptA = 'A',
 72         accOptR = 'R'
 73     };
 74 
 75     enum JobU {
 76         ComputeU   = 'U',
 77         FullsetU   = 'F',
 78         WorkspaceU = 'W',
 79         NoU        = 'N'
 80     };
 81 
 82     enum JobV {
 83         ComputeV        = 'V',
 84         JacobiRotationV = 'J',
 85         WorkspaceV      = 'W',
 86         NoV             = 'N'
 87     };
 88 }
 89 
 90 //== jsv =======================================================================
 91 template <typename MA, typename VSVA, typename MU, typename MV,
 92           typename VWORK, typename VIWORK>
 93     typename GeMatrix<MA>::IndexType
 94     jsv(JSV::Accuracy             accuracy,
 95         JSV::JobU                 jobU,
 96         JSV::JobV                 jobV,
 97         bool                      restrictedRange,
 98         bool                      considerTransA,
 99         bool                      perturb,
100         GeMatrix<MA>              &A,
101         DenseVector<VSVA>         &sva,
102         GeMatrix<MU>              &U,
103         GeMatrix<MV>              &V,
104         DenseVector<VWORK>        &work,
105         DenseVector<VIWORK>       &iwork);
106 
107 //-- forwarding ----------------------------------------------------------------
108 template <typename MA, typename VSVA, typename MU, typename MV,
109           typename VWORK, typename VIWORK>
110     typename MA::IndexType
111     jsv(JSV::Accuracy             accuracy,
112         JSV::JobU                 jobU,
113         JSV::JobV                 jobV,
114         bool                      restrictedRange,
115         bool                      considerTransA,
116         bool                      perturb,
117         MA                        &&A,
118         VSVA                      &&sva,
119         MU                        &&U,
120         MV                        &&V,
121         VWORK                     &&work,
122         VIWORK                    &&iwork);
123 
124 } } // namespace lapack, flens
125 
126 #endif // FLENS_LAPACK_SVD_JSV_H