Example #1
0
 rot_mx rot_mx::cancel() const
 {
   int g = den();
   for(std::size_t i=0;i<9;i++) g = scitbx::math::gcd_int(g, num_[i]);
   if (g == 0) return *this;
   return rot_mx(num_ / g, den() / g);
 }
Example #2
0
 rot_mx rot_mx::inverse() const
 {
   int det_den3 = num_.determinant();
   if (det_den3 == 0) throw error("Rotation matrix is not invertible.");
   return rot_mx(
     num_.co_factor_matrix_transposed() * (den_*den_), den_) / det_den3;
 }
Example #3
0
 rot_mx rot_mx::inverse_cancel() const
 {
   int det_den3 = num_.determinant();
   if (det_den3 == 0) throw error("Rotation matrix is not invertible.");
   rat d(det_den3, den_);
   return rot_mx(num_.co_factor_matrix_transposed() * d.denominator(), 1)
     .divide(d.numerator());
 }
Example #4
0
 rot_mx operator/(rot_mx const& lhs, int rhs)
 {
   sg_mat3 new_num;
   for(std::size_t i=0;i<9;i++) {
     if (lhs.num_[i] % rhs) throw_unsuitable_rot_mx(__FILE__, __LINE__);
     new_num[i] = lhs.num_[i] / rhs;
   }
   return rot_mx(new_num, lhs.den_);
 }
Example #5
0
 rot_mx rot_mx::divide(int rhs) const
 {
   sg_mat3 new_num;
   if (rhs < 0) {
     new_num = -num_;
     rhs = -rhs;
   }
   else {
     new_num = num_;
   }
   return rot_mx(new_num, den_ * rhs).cancel();
 }
Example #6
0
 rot_mx rot_mx::accumulate(int type) const
 {
   CCTBX_ASSERT(den_ == 1);
   int ord = order(type);
   if (ord == 1) return *this;
   CCTBX_ASSERT(ord != 0);
   sg_mat3 result(1);
   sg_mat3 a(num_);
   result += a;
   for(int i=2; i < ord; ++i) {
     a = a*num_;
     result += a;
   }
   return rot_mx(result, 1);
 }
Example #7
0
 rot_mx
 operator-() const { return rot_mx(-num_, den_); }