Ejemplo n.º 1
0
bool EIGEN3EXT::eigensym( const T *valA,int nnzA,  const int *irowA,  const int *pcolA,
						 const T *valB,int nnzB,  const int *irowB,  const int *pcolB,
						  int n,int n_eig,T *vals,T *vecs,
						  const char mode,
						  const std::string which){
  
  //check parameters
  const bool valid = (valA!=NULL&&irowA!=NULL&&pcolA!=NULL&&
				valB!=NULL&&irowB!=NULL&&pcolB!=NULL&&
				n_eig>0&&n_eig<n&&vals!=NULL&&vecs!=NULL);
  if(!valid){
	return false;
  }

  ARluSymMatrix<T> A(n, nnzA, const_cast<T*>(valA), const_cast<int*>(irowA), const_cast<int*>(pcolA));
  ARluSymMatrix<T> B(n, nnzB, const_cast<T*>(valB), const_cast<int*>(irowB), const_cast<int*>(pcolB));

  if ('R' == mode){
	ARluSymGenEig<T> dprob(n_eig, A, B , const_cast<char*>(which.c_str()));
	int coveraged = dprob.EigenValVectors(vecs,vals);
	return (coveraged==n_eig);
  }else{
	ARluSymGenEig<T> dprob(mode,n_eig, A, B,0.0f,const_cast<char*>(which.c_str()));
	int coveraged = dprob.EigenValVectors(vecs,vals);
	return (coveraged==n_eig);
  }
}
Ejemplo n.º 2
0
int main()
{

	{
		int     nx;
		int     n;       // Dimension of the problem.
		double  rho;     // Parameter used to define A.
		double* A;       // Pointer to an array that stores the elements of A.

		// Creating a 100x100 matrix.

		nx  = 10;
		rho = 100.0;
		DenseMatrixA(nx, rho, n, A);
		ARdsNonSymMatrix<double> matrix(n, A);

		// Defining what we need: the four eigenvectors of A with largest magnitude.

		ARluNonSymStdEig<double> dprob(4, matrix, "SM", 20);

		// Finding eigenvalues and eigenvectors.

		dprob.FindEigenvectors();

		// Printing solution.

		Solution(matrix, dprob);
	}


	{
		int     nx;
		int     n;       // Dimension of the problem.
		double  rho;     // Parameter used to define A.
		double* A;       // Pointer to an array that stores the elements of A.

		// Creating a 100x100 matrix.

		nx  = 10;
		rho = 100.0;
		DenseMatrixA(nx, rho, n, A);
		ARdsNonSymMatrix<double> matrix(n, A);

		// Defining what we need: the four eigenvectors of A with largest magnitude.

		ARluNonSymStdEig<double> dprob(4, matrix, "LM", 20);

		// Finding eigenvalues and eigenvectors.

		dprob.FindEigenvectors();

		// Printing solution.

		Solution(matrix, dprob);
	}

} // main.