Brainstorming: Noise optimization
#41
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.
Reply
Thanks given by:




Users browsing this thread: 2 Guest(s)