Domanda

I need to solve a system of n-linear equations with n-unknown variables in C++ using the gaussian method of elimnation. Any hints how to achieve that? I'll be probably using rand(); for the amount of n, since isn't available, because C++11 I can't use.

È stato utile?

Soluzione

to solve a linear system

AX=B

you need to invert a matrix A, which results in A^(-1) and multiply A^(-1) * B to obtain X. This is the example code to invert non-singular matrix using Gauss - Jordan elimination algorithm (complexity is O(n^3)):

matrix inversion using Gauss-Jordan elimination

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top