Note that there are some explanatory texts on larger screens.

plurals
  1. POTensor Product Algorithm Optimization
    text
    copied!<pre><code>double data[12] = {1, z, z^2, z^3, 1, y, y^2, y^3, 1, x, x^2, x^3}; double result[64] = {1, z, z^2, z^3, y, zy, (z^2)y, (z^3)y, y^2, z(y^2), (z^2)(y^2), (z^3)(y^2), y^3, z(y^3), (z^2)(y^3), (z^3)(y^3), x, zx, (z^2)x, (z^3)x, yx, zyx, (z^2)yx, (z^3)yx, (y^2)x, z(y^2)x, (z^2)(y^2)x, (z^3)(y^2)x, (y^3)x, z(y^3)x, (z^2)(y^3)x, (z^3)(y^3)x, x^2, z(x^2), (z^2)(x^2), (z^3)(x^2), y(x^2), zy(x^2), (z^2)y(x^2), (z^3)y(x^2), (y^2)(x^2), z(y^2)(x^2), (z^2)(y^2)(x^2), (z^3)(y^2)(x^2), (y^3)(x^2), z(y^3)(x^2), (z^2)(y^3)(x^2), (z^3)(y^3)(x^2), x^3, z(x^3), (z^2)(x^3), (z^3)(x^3), y(x^3), zy(x^3), (z^2)y(x^3), (z^3)y(x^3), (y^2)(x^3), z(y^2)(x^3), (z^2)(y^2)(x^3), (z^3)(y^2)(x^3), (y^3)(x^3), z(y^3)(x^3), (z^2)(y^3)(x^3), (z^3)(y^3)(x^3)}; </code></pre> <ul> <li>What is the fastest (fewest executions) to produce <strong>result</strong> given <strong>data</strong>? Assume, that <strong>data</strong> is variable in size, but always a factor of 4 (e.g., 4, 8, 12, etc.).</li> <li>No Boost. I am trying to keep my dependencies small. STL Algorithms are ok.</li> <li>HINT: result array size should always be 4^(multiple size) (e.g., 4, 16, 64, etc.).</li> <li>BONUS: If you can compute <strong>result</strong> just given x, y, z</li> </ul> <p>Additional examples:</p> <pre><code>double data[4] = {1, z, z^2, z^3}; double result[4] = {1, z, z^2, z^3}; double data[8] = {1, z, z^2, z^3, 1, y, y^2, y^3}; double result[16] = { ... }; </code></pre> <p><strong>I chose the accepted answer code after running this benchmark: <a href="https://gist.github.com/1232406" rel="nofollow">https://gist.github.com/1232406</a>. Basically, the top two codes were run and the one with the smallest execution time won.</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload