Esempio n. 1
0
int
eig( int N,  const lower_triangular_matrix& C, valarray<double>& diag, square_matrix& Q,
       int niter)
{
  int ret;
  int i, j;

  if (niter == 0) niter = 30*N;

  for (i=0; i < N; ++i)
  {
      vector<double>::const_iterator row = C[i];
      for (j = 0; j <= i; ++j)
          Q[i][j] = Q[j][i] = row[j];
  }

  double* rgtmp = new double[N+1];
  Householder( N, Q, diag, rgtmp);
  ret = QLalgo( N, diag, Q, niter, rgtmp+1);
  delete [] rgtmp;

  return ret;
}
Esempio n. 2
0
/* ========================================================= */
static void Eigen( int N,  double **C, double *diag, double **Q, double *rgtmp)
/* 
 * Calculating eigenvalues and vectors. 
 * Input: 
 *  N: dimension.
 *  C: symmetric (1:N)xN-matrix, solely used to copy data to Q
 *  niter: number of maximal iterations for QL-Algorithm. 
 *  rgtmp: N+1-dimensional vector for temporal use. 
 * Output: 
 *  diag: N eigenvalues. 
 *  Q: Columns are normalized eigenvectors.
 */
{
	int i, j;
	
	if (rgtmp == NULL){ /* was OK in former versions */
		//FATAL("cmaes_t:Eigen(): input parameter double *rgtmp must be non-NULL", 0,0,0);
		fprintf(stderr,"cmaes_t:Eigen(): input parameter double *rgtmp must be non-NULL");
		exit(1);
	}
	
	/* copy C to Q */
	if (C != Q) {
		for (i=0; i < N; ++i)
			for (j = 0; j <= i; ++j)
				Q[i][j] = Q[j][i] = C[i][j];
	}
	
	#if 0
	Householder( N, Q, diag, rgtmp);
	QLalgo( N, diag, Q, 30*N, rgtmp+1);
	#else
	Householder2( N, Q, diag, rgtmp);
	QLalgo2( N, diag, rgtmp, Q);
	#endif
}