Skip to content

Commit

Permalink
Added compute few eigenvectors routine
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed Jul 22, 2012
1 parent 532a5dd commit f4b3852
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/shogun/lib/SGMatrix.cpp
Expand Up @@ -592,6 +592,17 @@ double* SGMatrix<T>::compute_eigenvectors(double* matrix, int n, int m)
return eigenvalues;
}

template <class T>
void SGMatrix<T>::compute_few_eigenvectors(double* matrix, double*& eigenvalues, double*& eigenvectors,
int n, int il, int iu)
{
eigenvalues = SG_MALLOC(double, n);
eigenvectors = SG_MALLOC(double, (iu-il+1)*n);
int status = 0;
wrap_dsyevr('V','U',n,matrix,n,il,iu,eigenvalues,eigenvectors,&status);
ASSERT(status==0);
}

template <class T>
SGMatrix<float64_t> SGMatrix<T>::matrix_multiply(
SGMatrix<float64_t> A, SGMatrix<float64_t> B,
Expand Down
13 changes: 13 additions & 0 deletions src/shogun/lib/SGMatrix.h
Expand Up @@ -184,6 +184,19 @@ template<class T> class SGMatrix : public SGReferencedData
* */
static double* compute_eigenvectors(double* matrix, int n, int m);

/** compute few eigenpairs of a symmetric matrix using LAPACK DSYEVR method
* (Relatively Robust Representations).
* Has at least O(n^3/3) complexity
* @param matrix symmetric matrix
* @param eigenvalues contains iu-il+1 eigenvalues in ascending order (to be free'd)
* @param eigenvectors contains iu-il+1 orthonormal eigenvectors of given matrix column-wise (to be free'd)
* @param n dimension of matrix
* @param il low index of requested eigenpairs (1<=il<=n)
* @param iu high index of requested eigenpairs (1<=il<=iu<=n)
*/
void compute_few_eigenvectors(double* matrix, double*& eigenvalues, double*& eigenvectors,
int n, int il, int iu);

/* Computes scale* A*B, where A and B may be transposed.
* Asserts for matching inner dimensions.
* @param A matrix A
Expand Down

0 comments on commit f4b3852

Please sign in to comment.