Search for question
Question

Fact: We cannot take the inner product of two vectors of different dimensionality. We illustrate this with an example next. using LinearAlgebra: dot a = [1, 2, 3, 5] [4, 5,

6] 4 b 5 dot (b, a) Run Revert LoadError: Dimension Mismatch("first array has length 3 which does not match the length of the second, 4.") DimensionMismatch("first array has length 3 which does not match the length of the second, 4.") Stale outputs x Code arrcred (15m) Stacktrace: [1] dot (::Array [Int64, 1), Array (Int64,1)) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Linear Algebra/src/generic.jl: 889 [2] top-level scope at In[38]:4 [3] include_string(:: Function, ::Module, ::String, ::String) at ./loading.jl:1091 What does the following code do? a = [1, 2, 3, 5] b = [4, 5, 6] using Linear Algebra ip = dot (b, a) It returns the inner product value of 32; Julia guesses that I meant for it to do what it did in previous example! It produces a DimensionMismatch error indicating that the lengths of the arrays do not match, so their dot product is not defined. ✓ Passed

Fig: 1