void matrix::fun(vector<float> r, vector<float> p, int m, int n) { int i, j; //double *R = new double[m*n]; //double *P = new double[m * 1]; //double *RT = new double[n*m]; //double *a = new double[n*n]; //double *b = new double[m * 1]; //float *Q = new float[n * 1]; vector<float> R; vector<float> P; vector<float> RT; vector<float> a; vector<float> tb; //vector<float> Q; for (i = 0; i<r.size(); i++) { //R[i] = r[i]; R.push_back(r[i]); //P[i] = p[i]; //P.push_back(p[i]); } for (i = 0; i < p.size();i++) P.push_back(p[i]); transpose(R, m, n, RT); trmul(RT, R, n, m, n, a); trmul(RT, P, n, m, 1, tb); int flag= chlk(a, n, 1, tb); if (!flag) printf("Error!"); else for (i = 0; i < n; i++) { //x[i] = b[i]; x.push_back(tb[i]); } //return Q; }
main() { int i, j; double a[4][4] = { {0.2368, 0.2471, 0.2568, 1.2671}, {1.1161, 0.1254, 0.1397, 0.1490}, {0.1582, 1.1675, 0.1768, 0.1871}, {0.1968, 0.2071, 1.2168, 0.2271} }; double b[4][4], c[4][4]; for (i = 0; i <= 3; i++) for (j = 0; j <= 3; j++) { b[i][j] = a[i][j]; } i = rinv(a, 4); if (i != 0) { printf("MAT A IS:\n"); for (i = 0; i <= 3; i++) { for (j = 0; j <= 3; j++) { printf("%13.6e ", b[i][j]); } printf("\n"); } printf("\n"); printf("MAT A- IS:\n"); for (i = 0; i <= 3; i++) { for (j = 0; j <= 3; j++) { printf("%13.6e ", a[i][j]); } printf("\n"); } printf("\n"); printf("MAT AA- IS:\n"); trmul(b, a, 4, 4, 4, c); for (i = 0; i <= 3; i++) { for (j = 0; j <= 3; j++) { printf("%13.6e ", c[i][j]); } printf("\n"); } } }
main() { int i, j; double a[4][3] = { {1.0, 1.0, -1.0}, {2.0, 1.0, 0.0}, {1.0, -1.0, 0.0}, { -1.0, 2.0, 1.0} }; double b[3][4] = { {1.0, 1.0, -1.0, -1.0}, { 2.0, 1.0, 0.0, 2.0 }, {1.0, -1.0, 0.0, 1.0} }; double u[4][4], v[3][3], c[4][3], d[3][4]; double eps; eps = 0.000001; i = muav(a, 4, 3, u, v, eps, 5); printf("\n"); printf("EXAMPLE(1)\n"); printf("\n"); printf("i=%d\n", i); printf("\n"); printf("MAT U IS:\n"); for (i = 0; i <= 3; i++) { for (j = 0; j <= 3; j++) { printf("%13.6e ", u[i][j]); } printf("\n"); } printf("\n"); printf("MAT V IS:\n"); for (i = 0; i <= 2; i++) { for (j = 0; j <= 2; j++) { printf("%13.6e ", v[i][j]); } printf("\n"); } printf("\n"); printf("MAT A IS:\n"); for (i = 0; i <= 3; i++) { for (j = 0; j <= 2; j++) { printf("%13.6e ", a[i][j]); } printf("\n"); } printf("\n\n"); printf("MAT UAV IS:\n"); trmul(u, a, 4, 4, 3, c); trmul(c, v, 4, 3, 3, a); for (i = 0; i <= 3; i++) { for (j = 0; j <= 2; j++) { printf("%13.6e ", a[i][j]); } printf("\n"); } printf("\n\n"); printf("EXAMPLE(2)\n"); printf("\n"); i = muav(b, 3, 4, v, u, eps, 5); printf("i=%d\n", i); printf("\n"); printf("MAT U IS:\n"); for (i = 0; i <= 2; i++) { for (j = 0; j <= 2; j++) { printf("%13.6e ", v[i][j]); } printf("\n"); } printf("\n"); printf("MAT V IS:\n"); for (i = 0; i <= 3; i++) { for (j = 0; j <= 3; j++) { printf("%13.6e ", u[i][j]); } printf("\n"); } printf("\n"); printf("MAT B IS:\n"); for (i = 0; i <= 2; i++) { for (j = 0; j <= 3; j++) { printf("%13.6e ", b[i][j]); } printf("\n"); } printf("\n\n"); printf("MAT UBV IS:\n"); trmul(v, b, 3, 3, 4, d); trmul(d, u, 3, 4, 4, b); for (i = 0; i <= 2; i++) { for (j = 0; j <= 3; j++) { printf("%13.6e ", b[i][j]); } printf("\n"); } printf("\n"); }