dot_product#
Calculates the dot product of two vectors and returns the result (scalar). The dot product is the sum over the product of the elements.
-
float uz_matrix_dot_product(uz_matrix_t const *const A, uz_matrix_t const *const B)#
Calculates the dot product (scalar product) of the column vectors A and B. Rows of A and B have to be 1 and the column dimension mus be equal.
- Parameters:
A – Column or row vector
B – Column or row vector
- Returns:
float
Vector Example#
\[\begin{split}\begin{bmatrix}
1 & 2 & 3
\end{bmatrix}
\cdot
\begin{bmatrix}
1 & 2 & 3 \end{bmatrix}
&=
(1 \cdot 1) + (2 \cdot 2) + (3 \cdot 3) \\
&=
14\end{split}\]
1
2void test_uz_matrix_dot_product_two_column_vectors(void){
3 uint32_t rows=1;
4 uint32_t columns=4;
5 float A_data[4]={1,2,3,4};
6 float B_data[4]={1,2,3,4};
7 uz_matrix_t* A=init_array_test_helper(A_data,UZ_MATRIX_SIZE(A_data),rows, columns );
8 uz_matrix_t* B=init_array_test_helper(B_data,UZ_MATRIX_SIZE(B_data),rows, columns );
9 float C=uz_matrix_dot_product(A,B);
10 TEST_ASSERT_EQUAL_FLOAT(30,C);