The ARM CMSIS Math library enables efficient matrix operations on STM32 microcontrollers, allowing developers to perform complex linear algebra operations like multiplication, addition, subtraction, and inversion through simple function calls; matrix multiplication requires that the number of columns in the first matrix equals the number of rows in the second matrix, and the library provides functions to verify operation success and display results.
Linear Algebra with CMSIS Math Library on STM32 MCUs
Added:people tend to believe you can do linear algebra operations only in a high level programming languages like in Python however I want to show how to work with matrices quite easily with the help of the RMS library inside of the microcontrollers once you learn them they could be a powerful tool at your disposal to solve various problems this feature of the RMS Library makes your life easier because you can do complex Matrix operations like multiplication addition subtraction and inversion of matrices by writing a few lines of code before I showed how to implement digital filters and a fast Fourier transform using the RMS Library so I'm not going to spend time on explaining how to install how to include this Library into your project instead we State go to the point so so I want to show how to multiply two matrices using the r math Library so here we have two uh two arrays that represents our matrices so we have two dimensional arrays so this array has this Dimension 3x4 and here we have four by two and the first thing we need to do is to Define instances of matrices instance is nothing but abstract where we Define the dimensions of the Matrix and and the and the address of the array that represents the The Matrix and we have F32 because we are working with flow 32 data type and and to store the the result of the multiplication I created the corresponding array and instance and what we need to do first we have to initialize the instances so here we have the pointer to the instance then we have the dimensions and the address of the of the array so I initialize it three instances and to multiply this Matrix matrices A and B we just need to call a single function so here we have a matrix a and Matrix B and the result is the set this is the third argument and this a function returns a value that we can check to verify whether the multiplication is successful or not if it is successful I print all the elements of the of the Matrix using nested for Loops otherwise I just print this this message so let's run the code and see how it is going to work so here we have these matrices and if we run the code we have this result as the multiplication of these two matrices so everything is working perfectly and next thing what I want to do instead of a b I want to do multiplication b a so I just swap the the matrices and let's relaunch the code so let me resume the code and we got this message so it means that something went wrong with the multiplication and can you guess why it didn't work and I believe you found the answer the problem is that um there is a fundamental rule in when multiplying matrices which is the number of columns of the first mathematics have have to be has to be equal to the number of rows in the second Matrix but when we swap the matrices we basically violated this simple rule that's why it didn't work so in a similar fashion you can do other operations for example instead of multiplication let me search for inversion so here we have the inversion or for example getting um taking the transpose of the Matrix so everything can be done easily by calling a corresponding function so this is the end of the tutorial thanks for watching if you want to get similar tutorials regularly please subscribe to my channel and also if you have any questions concerns please feel free to comment the video and also if you want to get the the source code of all my projects and get updates and interesting insights of course you can join my community on patreon and on my website so thanks for watching again see you soon
Up Next

Build Your First Neural Network in PyTorch: A 15-Minute Tutorial
@leakyai
6.6K views•2022-03-21

Introduction to Secure Multiparty Computation with Yehuda Lindell
@fhe_org
7.7K views•2021-02-04

HTTP Requests Explained: GET, POST, PUT, DELETE
@codecademy
103.1K views•2021-10-07

Enigma Machine Mechanics: WWII Encryption Explained
@JaredOwen
13.2M views•2021-12-11
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Computer Science







































