function matMult(A,B) mA,nA = size(A) mB,nB = size(B) R = promote_type(eltype(A),eltype(B)) C = Matrix{R}(undef,mA,nB) @assert nA == mB "Inner dimensions must match." @inbounds for i in axes(A,1) @inbounds for j in axes(B,2) C[i,j] = 0.0 @inbounds for k in axes(A,2) C[i,j] = C[i,j] + A[i,k]*B[k,j] end end end return C end #or, to also support Vectors function matMult(A,B) mA,nA = size(A) sB = size(B) if length(sB) == 1 # B is a vector mB = sB nB = 1 elseif length(sB) == 2 # B is a matrix mB,nB = sB else throw("Input isn't allowed. Dimension Mismatch.") end R = promote_type(eltype(A),eltype(B)) C = Matrix{R}(undef,mA,nB) @assert nA == mB "Inner dimensions must match." @inbounds for i in axes(A,1) @inbounds for j in axes(B,2) C[i,j] = 0.0 @inbounds for k in axes(A,2) C[i,j] = C[i,j] + A[i,k]*B[k,j] end end end return C end