Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made arpack wrapper templated, updated preprocessors according to new…
… structure
- Loading branch information
Showing
9 changed files
with
152 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Written (W) 2011 Sergey Lisitsyn | ||
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society | ||
*/ | ||
|
||
#include <shogun/lib/config.h> | ||
#ifdef HAVE_ARPACK | ||
#ifdef HAVE_LAPACK | ||
#include <shogun/mathematics/arpack.h> | ||
#include <shogun/mathematics/arpack_s.h> | ||
#include <shogun/mathematics/arpack_d.h> | ||
|
||
using namespace shogun; | ||
|
||
namespace shogun | ||
{ | ||
|
||
template <> | ||
void arpack_xsxupd<float32_t>(float32_t* matrix, float32_t* rhs_diag, int n, int nev, const char* which, | ||
int mode, bool pos, float32_t shift, float32_t tolerance, | ||
float32_t* eigenvalues, float32_t* eigenvectors, int& status) | ||
{ | ||
arpack_ssxupd(matrix,rhs_diag,n,nev,which,mode,pos,shift,tolerance,eigenvalues,eigenvectors,status); | ||
} | ||
|
||
template <> | ||
void arpack_xsxupd<float64_t>(float64_t* matrix, float64_t* rhs_diag, int n, int nev, const char* which, | ||
int mode, bool pos, float64_t shift, float64_t tolerance, | ||
float64_t* eigenvalues, float64_t* eigenvectors, int& status) | ||
{ | ||
arpack_dsxupd(matrix,rhs_diag,n,nev,which,mode,pos,shift,tolerance,eigenvalues,eigenvectors,status); | ||
} | ||
} | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Written (W) 2011 Sergey Lisitsyn | ||
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society | ||
*/ | ||
|
||
#ifndef ARPACK_H_ | ||
#define ARPACK_H_ | ||
#include <shogun/lib/config.h> | ||
#ifdef HAVE_ARPACK | ||
#ifdef HAVE_LAPACK | ||
|
||
namespace shogun | ||
{ | ||
/** Wrapper for ARPACK's xsaupd/xseupd routines. These ARPACK | ||
* routines are being used to compute specified number of eigenpairs | ||
* (e.g. k largest eigenvalues). Underlying routines involve | ||
* a variant of Arnoldi process called the IRAM | ||
* (Implicitly Restarted Arnoldi Method) reduced to IRLM | ||
* (Implicitly Restarted Lanczos Method). A strategy specifying | ||
* which eigenpairs to compute should be provided as parameter. | ||
* | ||
* @param matrix symmetric real matrix of size n*n | ||
* (will be modified if mode==3) | ||
* @param rhs_diag array of size n representing right hand side diagonal matrix, | ||
* should be NULL if non-general eigenproblem to be solved | ||
* @param n size of matrix | ||
* @param nev number of eigenpairs to compute (nev<=n) | ||
* @param which eigenvalue finding strategy. Possible values: | ||
* - "LM": nev Largest Magnitude eigenvalues | ||
* - "SM": nev Smallest Magnitude eigenvalues | ||
* - "LA": nev Largest Algebraic eigenvalues | ||
* (if mode==3 eigenvalues from the right of shift) | ||
* - "SA": nev Smallest Algebraic eigenvalues | ||
* (if mode==3 eigenvalues from the left of shift) | ||
* - "BE": half of nev from each end of the spectrum, i.e. nev%2 | ||
* smallest and nev%2 largest eigenvalues. If nev is odd, | ||
* one more largest eigenvalue will be computed | ||
* @param mode shift-mode of IRLM. Possible values: | ||
* - 1: regular mode | ||
* - 3: shift-invert mode | ||
* @param pos true if matrix is positive definite (Cholesky factorization is used in | ||
* this case instead of LUP factorization)) | ||
* @param shift shift for shift-invert (3) mode of IRLM. In this mode | ||
* routine will compute eigenvalues near provided shift | ||
* @param tolerance tolerance with eigenvalues should be computed (zero means machine precision) | ||
* @param eigenvalues array of size nev to hold computed eigenvalues | ||
* @param eigenvectors array of size nev*n to hold computed eigenvectors | ||
* @param status on output -1 if computation failed | ||
*/ | ||
template <typename ST> | ||
void arpack_xsxupd(ST* matrix, ST* rhs_diag, int n, int nev, const char* which, | ||
int mode, bool pos, ST shift, ST tolerance, | ||
ST* eigenvalues, ST* eigenvectors, int& status); | ||
} | ||
#endif /* HAVE_LAPACK */ | ||
#endif /* HAVE_ARPACK */ | ||
#endif /* ARPACK_H_ */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.