STK++ 0.9.13
STK_lapack_Util.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::Algebra
27 * created on: 10 avr. 2015
28 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
37#ifndef STK_LAPACK_UTIL_H
38#define STK_LAPACK_UTIL_H
39
40#ifdef STKUSELAPACK
41
42extern "C"
43{
45int ilaenv_(int *, char *, char *, int *, int *,int *, int *);
46
47#ifdef STKREALAREFLOAT
48
50void sgesdd_( char *jobz, int *M, int *N, float *A, int *lda, float *S, float *U, int* ldu
51 , float *vt, int *ldvt, float *work, int *lWork, int *iwork, int *info);
53extern void sgeqrf_(int* M, int* N, float* A, int* lda, float* TAU, float* work, int* lWork, int* info );
55extern void ssyevr_( char *, char *, char *, int *, float *, int *, float *,
56 float *, int *, int *, float *, int *, float *, float *, int *,
57 int *, float *, int *, int *, int *, int *);
59extern int sgelsd_( int *m, int *n, int *nrhs
60 , float *a, int *lda, float *b, int *ldb, float *s, float *rcond
61 , int *rank, float *work, int *lWork
62 , int *iwork, int *info);
63
64#else /* double */
65
67void dgesdd_( char *jobz, int *M, int *N, double *A, int *lda, double *S, double *U, int* ldu
68 , double *vt, int *ldvt, double *work, int *lWork, int *iwork, int *info);
70extern void dgeqrf_(int* M, int* N, double* A, int* lda, double* TAU, double* work, int* lWork, int* info );
72extern void dsyevr_( char *, char *, char *, int *, double *, int *, double *,
73 double *, int *, int *, double *, int *, double *, double *, int *,
74 int *, double *, int *, int *, int *, int *);
76extern int dgelsd_( int *m, int *n, int *nrhs
77 , double *a, int *lda, double *b, int *ldb, double *s, double *rcond
78 , int *rank, double *work, int *lWork
79 , int *iwork, int *info);
80
81#endif
82
83} // extern "C"
84
85#endif // STKUSELAPACK
86
87namespace STK
88{
89namespace lapack
90{
171inline int gelsd( int m, int n, int nrhs
172 , Real * a, int lda
173 , Real * b, int ldb
174 , Real * s
175 , Real *rcond, int *rank
176 , Real *work, int lWork, int* iwork)
177{
178 int info = 1;
179#ifdef STKUSELAPACK
180#ifdef STKREALAREFLOAT
181 sgelsd_( &m, &n, &nrhs, a, &lda, b, &ldb, s, rcond, rank, work, &lWork, iwork, &info);
182#else
183 dgelsd_( &m, &n, &nrhs, a, &lda, b, &ldb, s, rcond, rank, work, &lWork, iwork, &info);
184#endif
185#endif
186 return info;
187}
188
250inline int geqrf(int m, int n, Real* a, int lda, Real* tau, Real *work, int lWork)
251{
252 int info = 1;
253
254#ifdef STKUSELAPACK
255#ifdef STKREALAREFLOAT
256 sgeqrf_(&m, &n, a, &lda, tau, work, &lWork, &info);
257#else
258 dgeqrf_(&m, &n, a, &lda, tau, work, &lWork, &info);
259#endif
260#endif
261
262 return info;
263}
264
436inline int gesdd( char jobz, int m, int n, Real *a, int lda
437 , Real *s, Real *u, int ldu, Real *vt, int ldvt
438 , Real *work, int lWork, int *iWork
439 )
440{
441 int info = 1;
442#ifdef STKUSELAPACK
443#ifdef STKREALAREFLOAT
444 sgesdd_( &jobz, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lWork, iWork, &info);
445#else
446 dgesdd_( &jobz, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lWork, iWork, &info);
447#endif
448#endif
449 return info;
450}
451
606inline int syevr( char jobz, char range, char uplo
607 , int n, Real* a, int lda
608 , Real vl, Real vu, int il, int iu
609 , Real abstol, int *m, Real *w
610 , Real *z, int ldz, int *isuppz
611 , Real *work, int lWork, int *iwork, int liwork
612 )
613{
614 int info = 0;
615#ifdef STKUSELAPACK
616#ifdef STKREALAREFLOAT
617 ssyevr_(&jobz, &range, &uplo, &n, a, &lda, &vl, &vu, &il,
618 &iu, &abstol, m, w, z, &ldz, isuppz, work,
619 &lWork, iwork, &liwork, &info);
620#else
621 dsyevr_(&jobz, &range, &uplo, &n, a, &lda, &vl, &vu, &il,
622 &iu, &abstol, m, w, z, &ldz, isuppz, work,
623 &lWork, iwork, &liwork, &info);
624#endif
625#endif
626 return info;
627}
628
629} // namespace lapack
630
631} // namespace STK
632
633
634#endif /* STK_LAPACK_UTIL_H */
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
int syevr(char jobz, char range, char uplo, int n, Real *a, int lda, Real vl, Real vu, int il, int iu, Real abstol, int *m, Real *w, Real *z, int ldz, int *isuppz, Real *work, int lWork, int *iwork, int liwork)
wrapper of the LAPACK SYEVR routine.
int gelsd(int m, int n, int nrhs, Real *a, int lda, Real *b, int ldb, Real *s, Real *rcond, int *rank, Real *work, int lWork, int *iwork)
wrapper of the LAPACK GELSD routine: computes the minimum-norm solution to a real linear least square...
int geqrf(int m, int n, Real *a, int lda, Real *tau, Real *work, int lWork)
wrapper of the LAPACK DGEQRF routine: computes the Qr decomposition of a matrix.
int gesdd(char jobz, int m, int n, Real *a, int lda, Real *s, Real *u, int ldu, Real *vt, int ldvt, Real *work, int lWork, int *iWork)
wrapper of the LAPACK DGESDD routine.
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.