POV-Ray : Newsgroups : povray.unofficial.patches : Matrices: Tiny improvement : Re: Matrices: Tiny improvement Server Time
2 Sep 2024 08:18:26 EDT (-0400)
  Re: Matrices: Tiny improvement  
From: Thorsten Froehlich
Date: 3 Apr 2000 23:18:31
Message: <38e95f07$1@news.povray.org>
Or in code this could look like:

void MZero (MATRIX result)
{
  register int i;

  for (i = 0 ; i < 16 ; i++) // yes this is legal ANSI C/ISO C++
  {
    result[i] = 0.0;
  }
}

void MIdentity (MATRIX result)
{
  register int i;

  for (i = 0 ; i < 16 ; i++)
  {
    result[i] = 0.0;
  }

  for (i = 0 ; i < 4 ; i++)
  {
    result[i][i] = 1.0;
  }
}

Of course manually unrolling would even account for bad compilers, but the
code above is already unreadable enough.  And, some compilers will even be
able to unrole the current nested loop code, at least that in MZero.


      Thorsten


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.