![]() |
|
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) |
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)
}
}Code: Vector<int> x;
Vector<int> y;
Vector<int> z = VectorAdd(VectorMultiply(x,y),y); |