Multiplying two multi-dimensional arrays, say, a 1-dimensional with a 3-dimensional array:
[1 2] * reshape(1:8,2,2,2)
gives me the error message:
LoadError: MethodError: `*` has no method matching *(::Array{Int64,2}, ::Array{Int64,3})
Closest candidates are:
*(::Any, ::Any, !Matched::Any, !Matched::Any...)
*{TA,TB}(::Union{DenseArray{TA,1},DenseArray{TA,2},SubArray{TA,1,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64}}}},LD},SubArray{TA,2,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64}}}},LD}}, !Matched::Base.LinAlg.AbstractTriangular{TB,S<:AbstractArray{T,2}})
*{TA,TQ,N}(::Union{DenseArray{TA,N},SubArray{TA,N,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64}}}},LD}}, !Matched::Union{Base.LinAlg.QRCompactWYQ{TQ,M<:AbstractArray{T,2}},Base.LinAlg.QRPackedQ{TQ,S<:AbstractArray{T,2}}})
...
while loading In[167], in expression starting on line 1
in Ac_mul_B at operators.jl:157
using the math definition of multi-dimensional matrix algebra for a (1 by 2) * (2 by 2 by 2) multiplication of matrices/arrays.
A somewhat more general example can be A*B = C meaning sum_k A_{i,j,k} B_{k,l,m} = C_{i,j,l,m}, where A is a 3-index matrix, or tensor if you like, B is a 3-index one, and the resulting C is a four index matrix/tensor, but, in general, there can be any number of dimensions and a dimension can have any size (within reason). See more info on the definition of a matrix product or tensor contraction.
What is the right syntax of this multiplication in Julia?
.*
instead of*
– Gnimuckron
. Or the elementwise product.*
? – mschauer*
there. – Ferenc