Changeset 1223
- Timestamp:
- 10/21/10 18:24:36 (14 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/design/lq_ctrl.h
r1221 r1223 14 14 15 15 int mbcol = _mB.cols(); 16 int totsize = utsize + mbcol;17 int sqs = utsize*utsize;18 16 int i, j, k; 19 17 20 18 double pvt; 21 double tmp[utsize*totsize];22 19 double *utA = _utA._data(); 23 20 double *mB = _mB._data(); … … 27 24 double *mC = _mC._data(); 28 25 29 //fill tmp array 30 for(i = 0; i < sqs; i++) 31 tmp[i] = utA[i]; 32 for(i = sqs; i < utsize*totsize; i++) 33 tmp[i] = mB[i-sqs]; 26 //copy data 27 for(i = 0; i < utsize*mbcol; i++) 28 mC[i] = mB[i]; 34 29 35 30 for(i = utsize-1; i >= 0; i--){ //Gauss elimination 36 pvt = tmp[i + utsize*i]; //get pivot37 for(j = utsize; j < totsize; j++) tmp[i + utsize*j] /= pvt; //normalize row - only part on the right31 pvt = utA[i + utsize*i]; //get pivot 32 for(j = 0; j < mbcol; j++) mC[i + utsize*j] /= pvt; //normalize row - only part on the right 38 33 for(j = 0;j < i; j++){ //subtract normalized row from above ones 39 pvt = tmp[j + utsize*i]; //get pivot40 for(k = utsize; k < totsize; k++) //goes from utsize - do not need make matrix on the left = I41 tmp[j + utsize*k] -= pvt * tmp[i + utsize*k]; //create zero col above34 pvt = utA[j + utsize*i]; //get pivot 35 for(k = 0; k < mbcol; k++) //goes from utsize - do not need make matrix on the left = I 36 mC[j + utsize*k] -= pvt * mC[i + utsize*k]; //create zero col above 42 37 } 43 38 44 } 45 46 for(i = 0; i < utsize*mbcol; i++) 47 mC[i] = tmp[i+sqs]; 39 } 48 40 49 41 return true;