Matrix calculation library

xiaoxiao2021-03-06  59

#ifndef _matrix_h _ / ********************************* * Matrix.h * * Matrix Computing Library * * Edit 2004- 8-9 * * version 1.0 * ***************************************** Battery ATV calculations Around ABV Calculation A × B Abaddv Calculation A Babsubv Calculation A-BINPUTAV Enter Matrix PrintAV Output Matrix Reverse INT A_1V (Double * in, Double * Out, INT N) Transmission Int ATV (Double * in, Double * Out, Int M, int N) matrix multiply int abv (Double * a, Double * B, Double * OUT, INT AM, INT AN, INT BM, INT BN) matrix plus int ABADDV (Double * A, Double * B, DOUBLE * OUT, INT M, INT N) Seasonable INT ABSUBV (Double * A, Double * B, Double * OUT, INT M, INT N) Output PrintAV (Double * A, INT M, INT N) Enter INPUTAV (Double * a, int m, int N) * /

/ * Transparent a matrix, there is a one-dimensional array in in the matrix, and the output also exists a one-dimensional array OUT matrix column number and dimension by n, and the call can use the array, the two-dimensional array modification mode ATV (Double IN [ N] [N], Double Out [N] [M], INT M, INT N) One-dimensional modulation mode ATV (Double In [K], Double Out [K], INT M, INT N) pointer call mode ATV ( Double * in, double * out, int m, int n) * / #include #include

INT ATV ​​(Double * in, Double * OUT, INT M, INT N) {INT I, J;

For (i = 0; i

Return 1;}

/ * Matrix multiplied OUT AM AN for the number of rows of matrix A and column number BM Nn as the number of rows and number matrix columns and dimensions of the column number matrix column and dimension by n, which can use array, two-dimensional array modification mode AVV ( Double A [AM] [AN], Double B [AM] [BN], Double Out [AM] [BN], INT AM, INT AM] [BN) One-dimensional modulation mode AVV (Double A [K] , Double B [L], Double Out [J], Int AM, INT AN, INT BM, INT BN) Pointer Call Way AVV (Double * A, Double * B, Double * OUT, INT AM, INT A, INT BM , int BN) * /

INT ABV (Double * Matrixa, Double * Matrixb, Double * OUT, INT AM, INT AN, INT BM, INT BN) {INT I, J, K; Double Temp; IF (AN! = BM) {RETURN 0;} / * Matrix can not be calculated * / for (i = 0; i

/ * Enter a matrix of M * N, or output M * N array and one-dimensional array Press M * n output * / int INPUTAV (Double * Matrixa, Int m, int N) {INT I, J; For (i = 0; i

} Return 1;

/ * Enter a M * N matrix, or output M * N array and one-dimensional array Press M * N output * / printav (Double * Matrixa, Int m, int N) {INT I, J; for (i = 0 i

Void initiones (double * q, int N) / * forming unit matrix * / {INT I, J; for (i = 0; i

Void Swap (Double * R, INT i, INT line, INT N) / * Ranking * / {INT J; Double M; For (j = 0; j

INT SOLVE (Double * P, Double * q, INT N) forms a triangular matrix * / {INT I, J, K, M, LINE; Double Max, Temp, SaveP; For (i = 0; i max) / * to find the absolute value maximum * / {line = j; max = fabs (p [j * n i]); TEMP = P [j * n i];}}}} (MAX <= 1e-5) / * Triangular matrix to the angle element equal to 0, no solution * / {return 0;} if (line! = i) {swap (p, i, line , N); SWAP (q, i, line, n);} for (k = 0; k 0; I -) {for (j = i-1; j> = 0; J -) {savep = p [j * n i] P [j * n i] = p [j * n i] -P [i * n i] * savep; for (k = 0; k

转载请注明原文地址:https://www.9cbs.com/read-112625.html

New Post(0)