Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
Loading...
Searching...
No Matches
mrdivide_helper.c
Go to the documentation of this file.
1/*
2 * Academic License - for use in teaching, academic research, and meeting
3 * course requirements at degree granting institutions only. Not for
4 * government, commercial, or other organizational use.
5 * File: mrdivide_helper.c
6 *
7 * MATLAB Coder version : 24.2
8 * C/C++ source code generated on : 05-May-2025 19:53:20
9 */
10
11/* Include Files */
12#include "mrdivide_helper.h"
13#include <math.h>
14
15/* Function Definitions */
16/*
17 * Arguments : const double A[4]
18 * const double B[4]
19 * double Y[4]
20 * Return Type : void
21 */
22void mrdiv(const double A[4], const double B[4], double Y[4])
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}
49
50
51/* Function Definitions */
52/*
53 * Arguments : const double B_data[]
54 * int B_size
55 * double Y_data[]
56 * int Y_size[2]
57 * Return Type : void
58 */
59void mrdiv_2(const double B_data[], int B_size, double Y_data[], int Y_size[2])
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}
70
71/*
72 * File trailer for mrdivide_helper.c
73 *
74 * [EOF]
75 */
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.
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)).
Provides MATLAB Coder helper functions for right matrix division.