Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matrix Template Library matrix inversion

I'm trying to inverse a matrix with version Boost boost_1_37_0 and MTL mtl4-alpha-1-r6418. I can't seem to locate the matrix inversion code. I've googled for examples and they seem to reference lu.h that seems to be missing in the above release(s). Any hints?

@Matt suggested copying lu.h, but that seems to be from MTL2 rather than MTL4. I'm having trouble compiling with MTL2 with VS05 or higher.

So, any idea how to do a matrix inversion in MTL4?

Update: I think I understand Matt better and I'm heading down this ITL path.

like image 966
kenny Avatar asked May 02 '26 10:05

kenny


1 Answers

Looks like you use lu_factor, and then lu_inverse. I don't remember what you have to do with the pivots, though. From the documentation.

And yeah, like you said, it looks like their documentations says you need lu.h, somehow:

How do I invert a matrix?

The first question you should ask yourself is whether you want to really compute the inverse of a matrix or if you really want to solve a linear system. For solving a linear system of equations, it is not necessary to explicitly compute the matrix inverse. Rather, it is more efficient to compute triangular factors of the matrix and then perform forward and backward triangular solves with the factors. More about solving linear systems is given below. If you really want to invert a matrix, there is a function lu_inverse() in mtl/lu.h.

If nothing else, you can look at lu.h on their site.

like image 101
Matt Cruikshank Avatar answered May 04 '26 00:05

Matt Cruikshank



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!