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

Provides MATLAB Coder helper functions for right matrix division. More...

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

Go to the source code of this file.

Functions

void mrdiv (const double A[4], const double B[4], double Y[4])
 Calculates the right matrix division for two 2x2 matrices (Y = A * inv(B)).
 
void mrdiv_2 (const double B_data[], int B_size, double Y_data[], int Y_size[2])
 Performs element-wise division of a scalar by each element of a matrix.
 

Detailed Description

Provides MATLAB Coder helper functions for right matrix division.

Author
Francesco Abate, MSA (Originally generated by MATLAB Coder)
Version
24.2 (MATLAB Coder version)
Date
2025-05-05

This auto-generated helper file from MATLAB Coder provides C equivalents of MATLAB's right matrix divide operator (/). This operation is used to solve linear matrix equations of the form Y * B = A by calculating Y = A * inv(B).

These functions are used as low-level utilities within more complex control algorithms, such as the Kalman filter, for matrix calculations.

Definition in file mrdivide_helper.h.

Function Documentation

◆ mrdiv()

void mrdiv ( const double  A[4],
const double  B[4],
double  Y[4] 
)

Calculates the right matrix division for two 2x2 matrices (Y = A * inv(B)).

Solves the matrix equation Y * B = A where A, B, and the result Y are all 2x2 matrices.

Parameters
[in]AA 4-element array representing the numerator 2x2 matrix (row-major).
[in]BA 4-element array representing the denominator 2x2 matrix (row-major), which will be inverted during the calculation.
[out]YA 4-element array where the resulting 2x2 matrix Y is stored.
Returns
None
Warning
This function does not check if matrix B is invertible. Providing a singular matrix for B may result in undefined behavior or NaNs in the output.

Definition at line 22 of file mrdivide_helper.c.

23{
24 double a21;
25 double a22;
26 double a22_tmp;
27 int Y_tmp;
28 int r1;
29 int r2;
30 if (fabs(B[1]) > fabs(B[0])) {
31 r1 = 1;
32 r2 = 0;
33 } else {
34 r1 = 0;
35 r2 = 1;
36 }
37 a21 = B[r2] / B[r1];
38 a22_tmp = B[r1 + 2];
39 a22 = B[r2 + 2] - a21 * a22_tmp;
40 Y_tmp = r1 << 1;
41 Y[Y_tmp] = A[0] / B[r1];
42 r2 <<= 1;
43 Y[r2] = (A[2] - Y[Y_tmp] * a22_tmp) / a22;
44 Y[Y_tmp] -= Y[r2] * a21;
45 Y[Y_tmp + 1] = A[1] / B[r1];
46 Y[r2 + 1] = (A[3] - Y[Y_tmp + 1] * a22_tmp) / a22;
47 Y[Y_tmp + 1] -= Y[r2 + 1] * a21;
48}

◆ mrdiv_2()

void mrdiv_2 ( const double  B_data[],
int  B_size,
double  Y_data[],
int  Y_size[2] 
)

Performs element-wise division of a scalar by each element of a matrix.

This is a specialized helper function that appears to handle a scalar division operation, likely 1 / B where B is a scalar represented as a 1x1 matrix. The output dimensions are explicitly handled.

Parameters
[in]B_dataArray containing the scalar divisor (the denominator).
[in]B_sizeThe size of B_data (expected to be 1).
[out]Y_dataArray where the result of the division is stored.
[out]Y_sizeThe dimensions of the output array Y_data.
Returns
None
Warning
The behavior is undefined if the scalar in B_data is zero.

Definition at line 59 of file mrdivide_helper.c.

60{
61 if (B_size == 0) {
62 Y_size[0] = 1;
63 Y_size[1] = 0;
64 } else {
65 Y_size[0] = 1;
66 Y_size[1] = 1;
67 Y_data[0] = 1.0 / B_data[0];
68 }
69}

Referenced by cdEvaluation().

Here is the caller graph for this function: