Task

Create a function/use an in-built function, to compute the   dot product,   also known as the   scalar product   of two vectors.

If possible, make the vectors of arbitrary length.



As an example, compute the dot product of the vectors:

     [1,  3, -5]       and 
     [4, -2, -1]   


If implementing the dot product of two vectors directly:

   each vector must be the same length
   multiply corresponding terms from each vector
   sum the products   (to produce the answer)


Related task

   Vector products


report zdot_product
data: lv_n type i,
      lv_sum type i,
      lt_a type standard table of i,
      lt_b type standard table of i.
 
append: '1' to lt_a, '3' to lt_a, '-5' to lt_a.
append: '4' to lt_b, '-2' to lt_b, '-1' to lt_b.
describe table lt_a lines lv_n.
 
perform dot_product using lt_a lt_b lv_n changing lv_sum.
 
write lv_sum left-justified.
 
form dot_product using it_a like lt_a
                       it_b like lt_b
                       iv_n type i
                 changing
                       ev_sum type i.
  field-symbols: <wa_a> type i, <wa_b> type i.
 
  do iv_n times.
    read table: it_a assigning <wa_a> index sy-index, it_b assigning <wa_b> index sy-index.
    lv_sum = lv_sum + ( <wa_a> * <wa_b> ).
  enddo.
endform.