Matrix4 Matrix4::co() { Matrix4 transpo(tran()); Matrix4 comatrix; for(int i = 0; i < line; i++) for(int j = 0; j < column; j++) { comatrix[i][j] = COEF(i+j)*transpo.subMatrix(i,j).det(); } return comatrix; }
* * Register interface file for Exynos Scaler driver * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include "scaler.h" #define COEF(val_l, val_h) ((((val_h) & 0x1FF) << 16) | ((val_l) & 0x1FF)) /* Scaling coefficient value */ static const __u32 sc_coef_8t[7][16][4] = { { /* 8:8 or zoom-in */ {COEF( 0, 0), COEF( 0, 0), COEF(128, 0), COEF( 0, 0)}, {COEF( 0, 1), COEF( -2, 7), COEF(127, -6), COEF( 2, -1)}, {COEF( 0, 1), COEF( -5, 16), COEF(125, -12), COEF( 4, -1)}, {COEF( 0, 2), COEF( -8, 25), COEF(120, -15), COEF( 5, -1)}, {COEF(-1, 3), COEF(-10, 35), COEF(114, -18), COEF( 6, -1)}, {COEF(-1, 4), COEF(-13, 46), COEF(107, -20), COEF( 6, -1)}, {COEF(-1, 5), COEF(-16, 57), COEF( 99, -21), COEF( 7, -2)}, {COEF(-1, 5), COEF(-18, 68), COEF( 89, -20), COEF( 6, -1)}, {COEF(-1, 6), COEF(-20, 79), COEF( 79, -20), COEF( 6, -1)}, {COEF(-1, 6), COEF(-20, 89), COEF( 68, -18), COEF( 5, -1)}, {COEF(-2, 7), COEF(-21, 99), COEF( 57, -16), COEF( 5, -1)}, {COEF(-1, 6), COEF(-20, 107), COEF( 46, -13), COEF( 4, -1)}, {COEF(-1, 6), COEF(-18, 114), COEF( 35, -10), COEF( 3, -1)}, {COEF(-1, 5), COEF(-15, 120), COEF( 25, -8), COEF( 2, 0)}, {COEF(-1, 4), COEF(-12, 125), COEF( 16, -5), COEF( 1, 0)}, {COEF(-1, 2), COEF( -6, 127), COEF( 7, -2), COEF( 1, 0)}
main() { double A[21][22], CO[21][4][4], DCO[21][4][3], X[21], C[21], AF[20], BF[20]; double CF[20], DF[20], AP[20], BP[20], CP[20], DP[20], AQ[20], BQ[20]; double CQ[20], DQ[20]; double T,H, XU, XL, A1, B1, C1, D1, A2, B2, C2, D2; double A3, B3, C3, D3, A4, B4, C4, D4, CC, S, SS; double FPL,FPR,PPL,PPR,QPL,QPR; int N, N1, N2, N3, I, J, K, II, JJ, J0, J1, J2,KK, K2, K3, JJ1, JJ2, OK; FILE *OUP[1]; void INPUT(int *, int *, double *, double *, double *, double *, double *, double *); void OUTPUT(FILE **); double F(double); double P(double); double Q(double); int MINO(int, int); int MAXO(int, int); int INTE(int, int); void DPHICO(int, int, double *, double *, double *, double, int); void PHICO(int, int, double *, double *, double *, double *, double, int); double XINT(double, double, double, double, double, double, double, double, double, double, double, double, double, double); void COEF(int, int, int, double, double, double *, double *, double *, double *, double *, double); INPUT(&OK, &N, &FPL, &FPR, &PPL, &PPR, &QPL, &QPR); if (OK) { OUTPUT(OUP); /* STEP 1 */ H = 1.0/(N+1.0); N1 = N+1; N2 = N+2; N3 = N+3; /* Initialize matrix A at zero, note that A[I, N+3] = B[I] */ for (I=1; I<=N2; I++) for (J=1; J<=N3; J++) A[I-1][J-1] = 0.0; /* STEP 2 */ /* X[1]=0,...,X[I] = (I-1)*H,...,X[N+1] = 1 - H, X[N+2] = 1 */ for (I=1; I<=N2; I++) X[I-1] = (I-1.0)*H; /* STEPS 3 and 4 are implemented in what follows. Initialize coefficients CO[I,J,K], DCO[I,J,K] */ for (I=1; I<=N2; I++) for (J=1; J<=4; J++) { for (K=1; K<=4; K++) { CO[I-1][J-1][K-1] = 0.0; if (K != 4) DCO[I-1][J-1][K-1] = 0.0; } /* JJ corresponds the coefficients of phi and phi' to the proper interval involving J */ JJ = I+J-3; PHICO(I, JJ, &CO[I-1][J-1][0], &CO[I-1][J-1][1], &CO[I-1][J-1][2], &CO[I-1][J-1][3], H, N); DPHICO(I, JJ, &DCO[I-1][J-1][0], &DCO[I-1][J-1][1], &DCO[I-1][J-1][2], H, N); } /* Output the basis functions. */ fprintf(*OUP, "Basis Function: A + B*X + C*X**2 + D*X**3\n\n"); fprintf(*OUP, " A B C D\n\n"); for (I=1; I<=N2; I++) { fprintf(*OUP, "phi( %d )\n\n", I); for (J=1; J<=4; J++) if ((I != 1) || ((J != 1) && (J != 2))) if ((I != 2) || (J != 2)) if ((I != N1) || (J != 4)) if ((I != N2) || ((J != 3) && (J != 4))) { JJ1 = I+J-3; JJ2 = I+J-2; fprintf(*OUP, "On (X( %d ), X( %d ) ", JJ1, JJ2); for (K=1; K<=4; K++) fprintf(*OUP, " %12.8f ", CO[I-1][J-1][K-1]); fprintf(*OUP, "\n\n"); } } /* Obtain coefficients for F, P, Q - NOTE _ the fourth and fifth arguements in COEF are the derivatives of F, P, or Q evaluated at 0 and 1 respectively. */ COEF(1, N2, N1, FPL, FPR, AF, BF, CF, DF, X, H); COEF(2, N2, N1, PPL, PPR, AP, BP, CP, DP, X, H); COEF(3, N2, N1, QPL, QPR, AQ, BQ, CQ, DQ, X, H); /* STEPS 5 - 9 are implemented in what follows */ for (I=1; I<=N2; I++) { /* indices for limits of integration for A[I,I] and B[I] */ J1 = MINO(I+2,N+2); J0 = MAXO(I-2,1); J2 = J1 - 1; /* integrate over each subinterval where phi(I) nonzero */ for (JJ=J0; JJ<=J2; JJ++) { /* limits of integration for each call */ XU = X[JJ]; XL = X[JJ-1]; /* coefficients of bases */ K = INTE(I,JJ); A1 = DCO[I-1][K-1][0]; B1 = DCO[I-1][K-1][1]; C1 = DCO[I-1][K-1][2]; D1 = 0.0; A2 = CO[I-1][K-1][0]; B2 = CO[I-1][K-1][1]; C2 = CO[I-1][K-1][2]; D2 = CO[I-1][K-1][3]; /* call subprogram for integrations */ A[I-1][I-1] = A[I-1][I-1]+ XINT(XU,XL,AP[JJ-1],BP[JJ-1],CP[JJ-1],DP[JJ-1], A1,B1,C1,D1,A1,B1,C1,D1)+ XINT(XU,XL,AQ[JJ-1],BQ[JJ-1],CQ[JJ-1],DQ[JJ-1], A2,B2,C2,D2,A2,B2,C2,D2); A[I-1][N+2] = A[I-1][N+2] + XINT(XU,XL,AF[JJ-1],BF[JJ-1],CF[JJ-1],DF[JJ-1], A2,B2,C2,D2,1.0,0.0,0.0,0.0); } /* compute A[I,J] for J = I+1, ..., Min(I+3,N+2) */ K3 = I+1; if (K3 <= N2) { K2 = MINO(I+3,N+2); for (J=K3; J<=K2; J++) { J0 = MAXO(J-2,1); for (JJ=J0; JJ<=J2; JJ++) { XU = X[JJ]; XL = X[JJ-1]; K = INTE(I,JJ); A1 = DCO[I-1][K-1][0]; B1 = DCO[I-1][K-1][1]; C1 = DCO[I-1][K-1][2]; D1 = 0.0; A2 = CO[I-1][K-1][0]; B2 = CO[I-1][K-1][1]; C2 = CO[I-1][K-1][2]; D2 = CO[I-1][K-1][3]; K = INTE(J,JJ); A3 = DCO[J-1][K-1][0]; B3 = DCO[J-1][K-1][1]; C3 = DCO[J-1][K-1][2]; D3 = 0.0; A4 = CO[J-1][K-1][0]; B4 = CO[J-1][K-1][1]; C4 = CO[J-1][K-1][2]; D4 = CO[J-1][K-1][3]; A[I-1][J-1] = A[I-1][J-1] + XINT(XU,XL,AP[JJ-1],BP[JJ-1], CP[JJ-1],DP[JJ-1],A1,B1,C1,D1, A3,B3,C3,D3)+ XINT(XU,XL,AQ[JJ-1],BQ[JJ-1], CQ[JJ-1],DQ[JJ-1],A2,B2,C2,D2, A4,B4,C4,D4); } A[J-1][I-1] = A[I-1][J-1]; } } } /* STEP 10 */ for (I=1; I<=N1; I++) { for (J=I+1; J<=N2; J++) { CC = A[J-1][I-1]/A[I-1][I-1]; for (K=I+1; K<=N3; K++) A[J-1][K-1] = A[J-1][K-1]-CC*A[I-1][K-1]; A[J-1][I-1] = 0.0; } } C[N2-1] = A[N2-1][N3-1]/A[N2-1][N2-1]; for (I=1; I<=N1; I++) { J = N1-I+1; C[J-1] = A[J-1][N3-1]; for (KK=J+1; KK<=N2; KK++) C[J-1] = C[J-1]-A[J-1][KK-1]*C[KK-1]; C[J-1] = C[J-1]/A[J-1][J-1]; } /* STEP 11 */ /* output coefficients */ fprintf(*OUP, "\nCoefficients: c(1), c(2), ... , c(n)\n\n"); for (I=1; I<=N2; I++) fprintf(*OUP, " %12.6e \n", C[I-1]); fprintf(*OUP, "\n"); /* compute and output value of the approximation at the nodes */ fprintf(*OUP, "The approximation evaluated at the nodes:\n\n"); fprintf(*OUP, " Node Value\n\n"); for (I=1; I<=N2; I++) { S = 0.0; for (J=1; J<=N2; J++) { J0 = MAXO(J-2,1); J1 = MINO(J+2,N+2); SS = 0.0; if ((I < J0) || (I >= J1)) S = S + C[J-1]*SS; else { K = INTE(J,I); SS = ((CO[J-1][K-1][3]*X[I-1]+CO[J-1][K-1][2])*X[I-1]+ CO[J-1][K-1][1])*X[I-1]+CO[J-1][K-1][0]; S = S + C[J-1]*SS; } } fprintf(*OUP, "%12.8f %12.8f\n", X[I-1], S); } /* STEP 12 */ fclose(*OUP); } return 0; }