Skip to content

Commit

Permalink
Implementation of operator << on Matrix22 for stream output.
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Thompson <oxt3479@rit.edu>
  • Loading branch information
oxt3479 authored and cary-ilm committed Apr 17, 2020
1 parent 8213c01 commit 98ce944
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions IlmBase/Imath/ImathMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -4076,6 +4076,35 @@ Matrix44<T>::shear (const Shear6<S> &h)
// Implementation of stream output
//--------------------------------

template <class T>
std::ostream &
operator << (std::ostream &s, const Matrix22<T> &m)
{
std::ios_base::fmtflags oldFlags = s.flags();
int width;

if (s.flags() & std::ios_base::fixed)
{
s.setf (std::ios_base::showpoint);
width = static_cast<int>(s.precision()) + 5;
}
else
{
s.setf (std::ios_base::scientific);
s.setf (std::ios_base::showpoint);
width = static_cast<int>(s.precision()) + 8;
}

s << "(" << std::setw (width) << m[0][0] <<
" " << std::setw (width) << m[0][1] << "\n" <<

" " << std::setw (width) << m[1][0] <<
" " << std::setw (width) << m[1][1] << ")\n";

s.flags (oldFlags);
return s;
}

template <class T>
std::ostream &
operator << (std::ostream &s, const Matrix33<T> &m)
Expand Down

0 comments on commit 98ce944

Please sign in to comment.