Please explain "u is vector of size mnk": [m, n, k] or [1, m*n*k]? Posting a small example would be useful, because currently anybody, who wants to help you, has to create some test data by his own. Then it would be kind, if you do this work once and the others can copy&paste it.
What does "efficient" mean? If the arrays are huge, the memory consumption can dominate the run-time. So please mention some typical sized.
Best Answer