Cuberite Forum
Brainstorming: Noise optimization - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: Brainstorming: Noise optimization (/thread-832.html)

Pages: 1 2 3 4 5


RE: Brainstorming: Noise optimization - worktycho - 05-08-2014

I just thought of a rediculous way of doing c++ and SSE in one codebase with efficient vector ops. Since c++ template classes can be equivalent to S-Expressions.
Code:
template<class T, class U>
class VectorAdd
{
  VectorAdd( T a_x, U a_y) :
  m_x(a_x),m_y(a_y)
  {
  }
  T m_x;
  U m_y;
  template<class V>
  Vector<V> Evaluate()
  {
    Vector<V> z;
    for(int i =0; i < m_x.size(); i++)
    {
       z[i] = Evaluate(i)
    }
    return z;
  }
  template<class V>
  V Evaluate(int i)
  {
     return m_x.Evalute(i) + m_y.Evaluate(i)
  }
}
This can then be inlined down to a simple c++ maths equation or sequence of SSE ops and the code using it would look like:
Code:
Vector<int> x;
Vector<int> y;
Vector<int> z = VectorAdd(VectorMultiply(x,y),y);
Don't think I can implement it immediately as I have major exams coming up but it would be an interesting summer project.