Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
Loading...
Searching...
No Matches
mtimes.c File Reference
#include "mtimes.h"
#include "rt_nonfinite.h"
Include dependency graph for mtimes.c:

Go to the source code of this file.

Functions

int mtimes (const double A_data[], const int A_size[2], const double B_data[], double C_data[])
 Performs matrix multiplication: C = A * B.
 

Function Documentation

◆ mtimes()

int mtimes ( const double  A_data[],
const int  A_size[2],
const double  B_data[],
double  C_data[] 
)

Performs matrix multiplication: C = A * B.

This function multiplies an M-by-N matrix A with an N-by-P matrix B to produce an M-by-P matrix C. The inner dimensions of A and B must match.

Parameters
[in]A_dataA 1D array representing the first input matrix, A (row-major).
[in]A_sizeAn array of 2 integers specifying the dimensions of A as [rows, cols].
[in]B_dataA 1D array representing the second input matrix, B (row-major). (Note: Its size is inferred from A's dimensions).
[out]C_dataA pre-allocated 1D array where the resulting output matrix C will be stored.
Returns
The size of the first dimension (number of rows) of the resulting matrix C.

Definition at line 23 of file mtimes.c.

25{
26 int C_size;
27 int b_i;
28 int i;
29 int k;
30 C_size = A_size[0];
31 i = A_size[1];
32 if (A_size[0] - 1 >= 0) {
33 C_data[0] = 0.0;
34 }
35 for (k = 0; k < i; k++) {
36 for (b_i = 0; b_i < C_size; b_i++) {
37 C_data[0] += A_data[0] * B_data[0];
38 }
39 }
40 return C_size;
41}

Referenced by cdEvaluation().

Here is the caller graph for this function: