Quelqu'un peut-il me montrer comment calculer l'inverse d'une matrice? J'utilise VC++ 6.0Comment puis-je calculer l'inverse d'une matrice?
0
A
Répondre
0
un coup d'oeil à CodeProject, uncancodenow, etc ..
http://www.codeproject.com/KB/recipes/IsrMatrixCalc.aspx
http://www.codeproject.com/KB/recipes/DotNet2Datastructures.aspx?msg=2645798#xx2645798xx
www.freedownloadscenter.com/Programming/C_and_C___Tools_and_Components/C___Matrix_Template_Class.html
1
Une autre bonne source est Numerical Recipes, bien que cela puisse être un peu exagéré.
2
Le MFC n'est pas un outil pour les méthodes numériques.
Le calcul de l'inverse d'une matrice nxn est simple. Je vais vous donner l'algorithme:
/* I took this from my implementation of CMatrix
* It works, but I'm not sure if it's the most efficient algorithm.
*
* 1. Start with Q = Identity, whose inverse is R = Identity.
* 2. Set i = 0
* 3. Replace the i-th column (zero-based count) vector of Q with the i-th
* column of the input matrix. This is an update of rank 1, so...
* 4. Using the Sherman-Morrison formula, update R (the inverse of Q).
* 5. The Sherman-Morrison formula also updates the determinant of the matrix.
* If it's zero, then the original matrix was not invertible.
* 6. Increment i
* 7. If i = n, stop
*
* NOTES:
*
* This algorithm has the advantage of calculating the determinant of the original
* matrix in the process.
*
* My CMatrix class allows for general m*n matrices, it has these members:
* ldouble** x; // there's a typedef long double ldouble; in the header
* UINT row, col; // row count, column count
*
* My CMatTmp class is similar to CMatrix (it has the same members),
* but it represents a temporal matrix used in internal calculations
*
* My CVector class allows for n-dimensional vectors, it has these members:
* ldouble* x;
* UINT dim;
*/
CMatTmp CMatrix::DetInv(ldouble& det) const
{
// The matrix must be square.
if (row != col) throw 0;
CMatTmp Rc(row), Rn(row); // Start with identity row*row matrices
CVector cc(row), lf(row);
det = 1;
for (UINT j = 0; j < col; ++j)
{
// Get the j-th column vector and subtract one from its j-th component.
for (UINT i = 0; i < row; ++i)
cc.x[i] = x[i][j];
cc.x[j] -= 1;
// Test whether the Sherman-Morrison corrector can be applied.
lf = Rc * cc;
ldouble den = 1 + lf.x[j];
if (!abs(den))
{
det = 0;
return CMatTmp(row,col);
}
// Update the determinant.
det *= den;
// Apply the Sherman-Morrison corrector.
for (UINT i = 0; i < row; ++i)
for (UINT k = 0; k <= j; ++k)
Rn.x[i][k] -= lf.x[i] * Rc.x[j][k]/den;
// Copy all relevant data from Rn to Rc.
for (UINT i = 0; i < row; ++i)
for (UINT k = 0; k <= j; ++k)
Rc.x[i][k] = Rn.x[i][k];
}
return Rc;
}
Questions connexes
- 1. Comment calculer la matrice déterminante avec lapack ++ (2.5+)
- 2. Définir une matrice comme un tableau de tableaux et calculer sa matrice inverse en C++
- 3. Comment calculer la matrice de clé inverse dans l'algorithme de Hill Cipher?
- 4. Comment copier une matrice?
- 5. Comment construire cette matrice php?
- 6. Matrice statique ou matrice allouée dynamique
- 7. Comment calculer médiane?
- 8. Comment calculer l'heure?
- 9. comment calculer tan inverse?
- 10. Comment calculer les scores?
- 11. matrice de boutons
- 12. Report Matrice de remplissage
- 13. comment calculer compter en sql?
- 14. Inverser Python d'une matrice
- 15. Comment faire défiler les blocs de matrice?
- 16. comment prendre une matrice en python?
- 17. Comment tester si la matrice est diagonale?
- 18. Comment imprimer les colonnes d'une matrice JAMA?
- 19. Matrice adressable symétriquement
- 20. Que signifie matrice * vector contrairement à vector * matrice
- 21. convertir une matrice de listes à une matrice
- 22. Convertir une matrice décimale en une matrice binaire dans SciPy
- 23. Comment faire pour convertir une matrice 1-D en une matrice 2D
- 24. matrice triable Scriptaculous
- 25. Matrice de Python Matlab
- 26. C#: Initialisateur de matrice PointF()
- 27. Déterminer la matrice de transformation
- 28. matrice trouver grâce à l'optimisation
- 29. Calcul du pseudo-inverse d'une matrice en C++
- 30. jQuery.datePicker -calculer les jours
Vous voulez que nous fassions vos devoirs? ;) –
tag devoirs enlevé, cela ne semble pas explicitement comme les devoirs. Nettoyé le titre de la question et le libellé et ajouté quelques balises – mmcdole