X, Y = meshgrid(linspace(-1,1,100),linspace(-1,1,100))
D = sqrtm(X*X + Y*Y)
sigma, mu = 1.0, 0.0
G = exp(-( (D.-mu)^2 / ( 2.0 * sigma^2 ) ) )
sigma, mu = 1.0, 0.0
G = [ exp(-(x-mu).^2/(2.0*sigma^2) -(y-mu).^2/(2.0*sigma^2) ) for x in linspace(-1,1,100), y in linspace(-1,1,100) ]Feel free to check out (and contribute!) to https://github.com/quinnj/Rosetta-Julia. I started it when I first got involved with julia and it's got a fair number of examples and exercises.
-Jacob
p, n = 10, 20 M = np.ones((p,n,n)) V = np.ones((p,n,1)) S = np.tensordot(M, V, axes=[[0, 2], [0, 1]]) print S # returns #[[ 15.] # [ 15.] # [ 15.] # [ 15.] # [ 15.]]
In original numpy version as following, matrix and vector are 3dimension arrays.Is there any way to compute tensordot like numpy?
R = sqrt(X'*X + Y'*Y)