How to implement tensor product for arbitrary order tensors in octave?
问题 I dont have access to matlab, so I am trying some things with octave . How would you efficiently implement the tensor product described in the following formula? My approach for arbitrary order tensors a and b is the following % Tensor product function out = tp(a,b) if isvector(a) da = prod(size(a)); else da = size(a); endif if isvector(b) db = prod(size(b)); else db = size(b); endif out = reshape(a(:)*(b(:)'),[da,db]); endfunction The if statements are only there in order to catch the case