2
$\begingroup$

I am trying to do a dot product of two vectors of each 128 dimension. I am just looping each member and calculating the sum.

public Double dotProduct(List<Double> v, List<Double> u) {
    Double dotProduct = 0;
    for (int i = 0; i < 128; i++) {
        dotProduct += v.get(i) * u.get(i);
    }
    return dotProduct;
}

Will strassen's algorithm perform better?

$\endgroup$
2
$\begingroup$

Strassen's algorithm is for multiplying square matrices, not vectors. Your algorithm already runs in (asymptotically) optimal time $O(n)$ (where $n$ is the dimension of the vector), and also uses the optimal number of multiplications.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.