I have a function f that takes two vectors x and y and
f(x,y) = Transpose(sin(x-y))*Z*sin(x-y)
where Z is a diagonal positive definite matrix of appropriate size. Now, I have a matrix X where each column is a vector (so X1 = X(:,1), X2 = X(:,2), etc). I want to make a matrix K where K(1,1) = f(X1,X1), K(1,2) = f(X1,X2), etc.
I know i can do this with nested for loops but it runs very slow (X contains over 1000 points and K is calculated a few hundred times and it ends up taking about two hours). Now the code I'm basing it off of has similar functions and can do it in about 2 minutes. Anyone know how to quickly do this?
No products are associated with this question.
Play games and win prizes!Learn more