In original numpy version as following, matrix and vector are 3dimension arrays. Is there any way to compute tensordot like numpy?
p, n = 10, 20M = 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.]] 2014年6月24日火曜日 7時08分08秒 UTC+9 Alireza Nejati: > > Actually, a slight modification. The way I wrote it, it will compute the > product of all matrices with all vectors (pxp mults), which is not what you > want. You just want each matrix to multiply its respective vector (p > mults). The solution to that is: > > p = length(matlist) > reduce(+, [matlist[i]*veclist[i] for i = 1:p]) > > On Monday, June 23, 2014 2:43:32 AM UTC+12, Michiaki Ariga wrote: >> >> Hi all, >> >> I'm a Julia newbee, and I'm trying to learn Julia and wrote Julia version >> of rougier's 100 numpy exercises( >> http://www.loria.fr/~rougier/teaching/numpy.100/index.html). >> >> https://github.com/chezou/julia-100-exercises >> >> I'd like you to tell me more "julia way" or something wrong with. >> >> Best regards, >> Michiaki >> >