tomstewart89 / BasicLinearAlgebra

A library for using matrices and linear algebra on Arduino
MIT License
185 stars 38 forks source link

Delete a matrix instace #50

Closed VitorCMatias closed 2 years ago

VitorCMatias commented 2 years ago

Hello, I am using you pack in a project , and I need to delete some matrix objecs, but I did not fount a proper function in the documentation, does a function like that exists? I am using the Invert function like this: inv_a = Invert(A);

tomstewart89 commented 2 years ago

Hey @VitorCMatias, assuming you declared your Matrix as a local variable (i.e somewhere inside a pair of curly braces {}) then the Matrix will automatically be deleted when it goes out of scope (i.e when execution reaches the closing }). So for example:

void foo()
{
    BLA::Matrix<3,3> bar;

    // some other stuff
} // bar will be deleted when execution reaches this line

From your code snippet I'm guessing that you'd like to delete that A matrix once you've found its inverse. In that case I'd recommend just using the in-place inversion function which'll save you allocating inv_a in the first place.

Hope that helps! Let me know if you have any trouble