Exemplo n.º 1
0
LScrMatrix4D LScrMatrix4D::diag3() const
{
  Matrix3D mat;
  for (int i=1; i<=3; ++i)
    for (int j=1; j<=3; ++j)
      mat.aij(i,j) = aij(i,j);

  Matrix3D evecs;
  Vector4D evals;
  mat.diag(evecs, evals);

  LScrMatrix4D rval;
  for (int i=1; i<=3; ++i)
    for (int j=1; j<=3; ++j)
      rval.aij(i,j) = evecs.aij(i,j);

  rval.aij(4,1) = evals.x();
  rval.aij(4,2) = evals.y();
  rval.aij(4,3) = evals.z();

  if ( rval.aij(4,1)>rval.aij(4,2) )
    swapcols(rval, 1, 2);
  if ( rval.aij(4,1)>rval.aij(4,3) )
    swapcols(rval, 1, 3);
  if ( rval.aij(4,2)>rval.aij(4,3) )
    swapcols(rval, 2, 3);

  return rval;
}
Exemplo n.º 2
0
// get orthogonalization matrix
const Matrix3D &CrystalInfo::getOrthMat() const
{
  Matrix3D retval;

  if (m_pOrthMat!=NULL) {
    return *m_pOrthMat;
  }

  double alpha = m_alpha*M_PI/180;
  double beta = m_beta*M_PI/180;
  double gamma = m_gamma*M_PI/180;
  double coaster, siaster;

  coaster =
    (cos(beta)*cos(gamma) - cos(alpha))/
    (sin(beta)*sin(gamma));

  siaster = sqrt(1-coaster*coaster);

  retval.aij(1, 1) = m_cella;
  retval.aij(1, 2) = m_cellb * cos(gamma);
  retval.aij(1, 3) = m_cellc * cos(beta);

  retval.aij(2, 1) = 0.0;
  retval.aij(2, 2) = m_cellb * sin(gamma);
  retval.aij(2, 3) = -m_cellc * sin(beta)*coaster;
  
  retval.aij(3, 1) = 0.0;
  retval.aij(3, 2) = 0.0;
  retval.aij(3, 3) = m_cellc * sin(beta)*siaster;
  
  CrystalInfo *pthis = (CrystalInfo *)this;
  pthis->m_pOrthMat = new Matrix3D(retval);
  // retval.dump();
  return *m_pOrthMat;
}