Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
Loading...
Searching...
No Matches
mtimes.h File Reference

A MATLAB Coder helper function for matrix multiplication. More...

#include "rtwtypes.h"
#include <stddef.h>
#include <stdlib.h>
Include dependency graph for mtimes.h:
This graph shows which files directly or indirectly include this file:

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.
 

Detailed Description

A MATLAB Coder helper function for matrix multiplication.

Author
Francesco Abate, MSA (Originally generated by MATLAB Coder)
Version
24.2 (MATLAB Coder version)
Date
2024-12-03

This auto-generated helper file from MATLAB Coder provides a C equivalent of MATLAB's mtimes (matrix multiplication *) operator. It calculates the product of two matrices, C = A * B.

The function is designed to handle matrix multiplication where dimensions are passed as arguments, a common pattern in code generated from MATLAB. It is used as a low-level utility by more complex control algorithms.

Definition in file mtimes.h.

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: