int main(void) { TSMatrix *a1, *a2, *result1, *result2; a1 = InitTriple(3, 3, 3); a2 = InitTriple(3, 3, 3); InputValue(a1); InputValue(a2); ShowMatrix(a1); ShowMatrix(a2); if ((result1 = AddMatrix(a1, a2)) != NULL) ShowMatrix(result1); if ((result2 = SubMatrix(a1, a2)) != NULL) ShowMatrix(result2); return 0; }
devs::Time init(const devs::Time& /* time */) { vle::utils::Package pack("vle.examples"); vpz::Vpz *file = new vpz::Vpz(pack.getExpFile("counter.vpz", vle::utils::PKG_BINARY)); utils::ModuleManager man; manager::Simulation sim(manager::LOG_NONE, manager::SIMULATION_NONE, NULL); value::Map *result = sim.run(file, man, NULL); assert(result); // Show the results std::for_each(result->begin(), result->end(), ShowMatrix()); // le modèle ne fait rien d'autre. return devs::infinity; }
/* UpdateCounts: using frames in seg i and alignment in states/mixes */ void UpdateCounts(int segNum, int segLen, IntVec states,IntVec *mixes) { int M=0,i,j,k,s,m,state,last; StreamElem *ste; MixPDF *mp = NULL; WtAcc *wa; MuAcc *ma; VaAcc *va; TrAcc *ta; Vector v; Observation obs; TMixRec *tmRec = NULL; float x,y; last = 1; /* last before 1st emitting state must be 1 */ ta = (TrAcc *)GetHook(hmmLink->transP); for (i=1; i<=segLen; i++){ state = states[i]; if (trace&T_CNT) printf(" Seg %d -> state %d\n",i,state); if (uFlags&(UPMEANS|UPVARS|UPMIXES)){ obs = GetSegObs(segStore, segNum, i); if (hset.hsKind == TIEDHS) PrecomputeTMix(&hset, &obs, 50.0, 0); ste = hmmLink->svec[state].info->pdf+1; for (s=1; s<=nStreams; s++,ste++){ if (hset.hsKind==DISCRETEHS){ m = obs.vq[s]; v = NULL; } else { v = obs.fv[s]; m = mixes[s][i]; } switch(hset.hsKind){ case TIEDHS: tmRec = &(hset.tmRecs[s]); M = tmRec->nMix; break; case PLAINHS: case SHAREDHS: case DISCRETEHS: M = ste->nMix; break; } if (m<1 || m > M) HError(2170,"UpdateCounts: mix/vq idx out of range[%d]",m); if (trace&T_CNT) printf(" stream %d -> mix %d[%d]\n",s,m,M); /* update mixture weight */ if (M>1 && (uFlags&UPMIXES)) { wa = (WtAcc *)ste->hook; wa->occ += 1.0; wa->c[m] += 1.0; if (trace&T_CNT) printf(" mix wt -> %.1f\n",wa->c[m]); } if (hset.hsKind==DISCRETEHS) continue; /* update state/mixture component */ switch(hset.hsKind){ case PLAINHS: case SHAREDHS: mp = ste->spdf.cpdf[m].mpdf; break; case TIEDHS: mp = tmRec->mixes[m]; break; } ma = (MuAcc *)GetHook(mp->mean); va = (VaAcc *)GetHook(mp->cov.var); ma->occ += 1.0; va->occ += 1.0; for (j=1; j<=hset.swidth[s]; j++) { x = v[j] - mp->mean[j]; ma->mu[j] += x; if (uFlags&UPVARS) switch(mp->ckind){ case DIAGC: va->cov.var[j] += x*x; break; case FULLC: for (k=1; k<=j; k++){ y = v[k]-mp->mean[k]; va->cov.inv[j][k] += x*y; } break; default: HError(2124,"UpdateCounts: bad cov kind %d\n", mp->ckind); } } if (trace&T_CNT) { ShowVector(" mean ->",ma->mu,6); if (uFlags&UPVARS) { if (mp->ckind==DIAGC) ShowVector(" var ->",va->cov.var,6); else ShowTriMat(" cov ->",va->cov.inv,6,6); } fflush(stdout); } } } /* update transition probs */ if (uFlags&UPTRANS){ ta->occ[last] += 1.0; ta->tran[last][state] += 1.0; last = state; if (i==segLen){ /* remember final state */ ta->occ[state] += 1.0; ta->tran[state][nStates] += 1.0; } if (trace&T_CNT) { ShowMatrix(" tran ->",ta->tran,6,6); fflush(stdout); } } } }
/* * 算法主搜索函数,Branch-And-Bound Algorithm Search * root 是当前的根结点,已归约,数据完善 */ PATH BABA(NODE root) { int i; static int minDist = INFINITY; static PATH minPath; EDGE selectedEdge; NODE *left, *right; puts("Current Root:\n------------"); ShowMatrix(root.matrix); printf("Root Bound:%d\n", root.bound); /* 如果当前矩阵大小为2,说明还有两条边没有选,而这两条边必定只能有一种组合, * 才能构成整体回路,所以事实上所有路线已经确定。 */ if (MatrixSize(root.matrix, root.path) == 2) { if (root.bound < minDist) { minDist = root.bound; minPath = MendPath(root.path, root.matrix); getch(); return (minPath); } } /* 根据左下界尽量大的原则选分枝边 */ selectedEdge = SelectBestEdge(root.matrix); printf("Selected Edge:(%d, %d)\n", selectedEdge.head + 1, selectedEdge.tail + 1); /* 建立左右分枝结点 */ left = (NODE *)malloc(sizeof(NODE)); right = (NODE *)malloc(sizeof(NODE)); if (left == NULL || right == NULL) { fprintf(stderr,"Error malloc.\n"); exit(-1); } /* 初始化左右分枝结点 */ left->bound = root.bound; /* 继承父结点的下界 */ left->matrix = LeftNode(root.matrix, selectedEdge); /* 删掉分枝边 */ left->path = root.path; /* 继承父结点的路径,没有增加新边 */ left->left = NULL; left->right = NULL; right->bound = root.bound; right->matrix = RightNode(root.matrix, selectedEdge, root.path);/* 删除行列和回路边 */ right->path = AddEdge(selectedEdge, root.path); /* 加入所选边 */ right->left = NULL; right->right = NULL; /* 归约左右分枝结点 */ left->bound += Simplify(&left->matrix); right->bound += Simplify(&right->matrix); /* 链接到根 */ root.left = left; root.right = right; /* 显示到监视器 */ puts("Right Branch:\n------------"); ShowMatrix(right->matrix); puts("Left Branch:\n-----------"); ShowMatrix(left->matrix); /* 如果右结点下界小于当前最佳答案,继续分枝搜索 */ if (right->bound < minDist) { BABA(*right); } /* 否则不搜索,因为这条枝已经不可能产生更佳路线 */ else { printf("Current minDist is %d, ", minDist); printf("Right Branch's Bound(= %d).\n", right->bound); printf("This branch is dead.\n"); } /* 如果右结点下界小于当前最佳答案,继续分枝搜索 */ if (left->bound < minDist) { BABA(*left); } /* 否则不搜索,因为这条枝已经不可能产生更佳路线 */ else { printf("Current minDist is %d, ", minDist); printf("Left Branch's Bound(= %d).\n", left->bound); printf("This branch is dead.\n"); } printf("The best answer now is %d\n", minDist); return (minPath); }
void TestMatrix(ostream& os) { // display a headline os << "Matrix test\r\n===========\r\n"; Matrix<int> A(3,3), B(3,3), C(3,3), D(3,3); A(0,0) = 1; A(0,1) = 3; A(0,2) = -4; A(1,0) = 1; A(1,1) = 1; A(1,2) = -2; A(2,0) = -1; A(2,1) = -2; A(2,2) = 5; B(0,0) = 8; B(0,1) = 3; B(0,2) = 0; B(1,0) = 3; B(1,1) = 10; B(1,2) = 2; B(2,0) = 0; B(2,1) = 2; B(2,2) = 6; D(0,0) = 1; D(0,1) = 2; D(0,2) = -1; D(1,0) = 2; D(1,1) = -1; D(1,2) = -3; D(2,0) = 0; D(2,1) = -2; D(2,2) = 4; os << "\r\nMatrix A = \r\n"; ShowMatrix(os,A); os << "\r\nMatrix B = \r\n"; ShowMatrix(os,B); C = A % B; os << "\r\nMatrix C (A % B) = \r\n"; ShowMatrix(os,C); C = A + B; os << "\r\nMatrix C (A + B) = \r\n"; ShowMatrix(os,C); C = A; C += B; os << "\r\nMatrix C (= A, += B) =\r\n"; ShowMatrix(os,C); C = A + 1; os << "\r\nMatrix C (= A + 1) =\r\n"; ShowMatrix(os,C); C += 1; os << "\r\nMatrix C (+= 1) =\r\n"; ShowMatrix(os,C); C = A - B; os << "\r\nMatrix C (A - B) = \r\n"; ShowMatrix(os,C); C = A; C -= B; os << "\r\nMatrix C (= A, -= B) =\r\n"; ShowMatrix(os,C); C = A - 1; os << "\r\nMatrix C (= A - 1) =\r\n"; ShowMatrix(os,C); C -= 1; os << "\r\nMatrix C (-= 1) =\r\n"; ShowMatrix(os,C); C = A * B; os << "\r\nMatrix C (A * B) = \r\n"; ShowMatrix(os,C); C = A; C *= B; os << "\r\nMatrix C (= A, *= B) =\r\n"; ShowMatrix(os,C); C = A * 2; os << "\r\nMatrix C (= A * 2) =\r\n"; ShowMatrix(os,C); C *= 2; os << "\r\nMatrix C (*= 2) =\r\n"; ShowMatrix(os,C); C = B / A; os << "\r\nMatrix C (B / A) = \r\n"; ShowMatrix(os,C); C = B; C /= A; os << "\r\nMatrix C (= B, /= A) =\r\n"; ShowMatrix(os,C); C = A / 2; os << "\r\nMatrix C (= A / 2) =\r\n"; ShowMatrix(os,C); C /= 2; os << "\r\nMatrix C (/= 2) =\r\n"; ShowMatrix(os,C); C = -A; os << "\r\nMatrix C (-A) = \r\n"; ShowMatrix(os,C); // test comparisons os << "\r\nMatrix A = \r\n"; ShowMatrix(os,A); os << "\r\nMatrix D = \r\n"; ShowMatrix(os,D); if (A.Equals(D)) os << "\r\nERROR: A should not equal D"; else os << "\r\nOKAY: A not equal D"; C = A; if (A.Equals(C)) os << "\r\nOKAY: A equals C\r\n"; else os << "\r\nERROR: A should equal C\r\n"; Matrix<bool> I(3,3); I = (A == D); os << "\r\nMatrix I = (A == D)\r\n"; ShowMatrix(os,I); I = (A != D); os << "\r\nMatrix I = (A != D)\r\n"; ShowMatrix(os,I); I = (A < D); os << "\r\nMatrix I = (A < D)\r\n"; ShowMatrix(os,I); I = (A <= D); os << "\r\nMatrix I = (A <= D)\r\n"; ShowMatrix(os,I); I = (A > D); os << "\r\nMatrix I = (A > D)\r\n"; ShowMatrix(os,I); I = (A >= D); os << "\r\nMatrix I = (A >= D)\r\n"; ShowMatrix(os,I); // check fill function C.Fill(9); os << "\r\nC filled with 9 =\r\n"; ShowMatrix(os,C); // check Apply functions C = Apply(A, Times2); os << "\r\nC = A.Apply(Times2)\r\n"; ShowMatrix(os,C); C.Apply(Times2); os << "\r\nApply(C,Times2)\r\n"; ShowMatrix(os,C); // check row and column vector functions Matrix<int> S(1,1); Matrix<int> r1A(3,1); Matrix<int> c0B(1,3); r1A = A.VectorRow(1); c0B = B.VectorCol(0); os << "\r\nMatrix S = \r\n"; ShowMatrix(os,S); os << "\r\nMatrix R1A = \r\n"; ShowMatrix(os,r1A); os << "\r\nMatrix C0B = \r\n"; ShowMatrix(os,c0B); if (r1A.IsRowVector()) os << "\r\nOKAY: R1A is row vector"; else os << "\r\nERROR: R1A should be a row vector"; if (!r1A.IsColVector()) os << "\r\nOKAY: R1A is not a column vector"; else os << "\r\nERROR: R1A should not be a column vector"; if (!c0B.IsRowVector()) os << "\r\nOKAY: C0B is not a row vector"; else os << "\r\nERROR: C0B should not be a row vector"; if (c0B.IsColVector()) os << "\r\nOKAY: C0B is column vector"; else os << "\r\nERROR: C0B should be a column vector"; if (c0B.IsVector()) os << "\r\nOKAY: C0B is a vector"; else os << "\r\nERROR: C0B should be a vector"; if (!A.IsVector()) os << "\r\nOKAY: A is not a vector"; else os << "\r\nERROR: A should not be a vector"; if (!c0B.IsSquare()) os << "\r\nOKAY: C0B is not square"; else os << "\r\nERROR: C0B should not be square"; if (A.IsSquare()) os << "\r\nOKAY: A is square"; else os << "\r\nERROR: A should be square"; B.Fill(0); if (B.IsZero()) os << "\r\nOKAY: B is zero"; else os << "\r\nERROR: B should be zero"; if (!A.IsZero()) os << "\r\nOKAY: A is not zero"; else os << "\r\nERROR: A should not be zero"; // test inner product int ip = r1A.InnerProduct(c0B); os << "\r\n\r\ninner product of R1A and C0B = " << ip << "\r\n"; // make some bigger matrices Matrix<int> M1(5,5), M2(5,5,3), M3(5,5), M4(5,5); const int junk[] = { 1, 5, 3, 0, 1, 0, 2, 0, 4, 5, 1, 0, 0, 2, 3, 7, 1, 3, 0, 0, 2, 1, 0, 4, 6 }; const int ident[] = { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }; const int tridi[] = { 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1 }; const int utri[] = { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1 }; const int ltri[] = { 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1 }; const int perm[] = { 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0 }; const int det[] = { 3, 5, 3, 8, 1, 2, 6, 3, 4, 5, 1, 4, 5, 2, 3, 7, 1, 3, 6, 8, 2, 4, 1, 4, 9 }; M1 = ident; M3 = M1 * 2; M4 = junk; os << "\r\nmatrix M1 = \r\n"; ShowMatrix(os,M1); os << "\r\nmatrix M2 = \r\n"; ShowMatrix(os,M2); os << "\r\nmatrix M3 = \r\n"; ShowMatrix(os,M3); os << "\r\nmatrix M4 = \r\n"; ShowMatrix(os,M4); if (M1.IsDiagonal()) os << "\r\nOKAY: M1 is diagonal"; else os << "\r\nERROR: M1 should be diagonal"; if (M1.IsIdentity()) os << "\r\nOKAY: M1 is an identity matrix"; else os << "\r\nERROR: M1 should be an identity matrix"; if (!M2.IsDiagonal()) os << "\r\nOKAY: M2 is not diagonal"; else os << "\r\nERROR: M2 should not be diagonal"; if (!M2.IsIdentity()) os << "\r\nOKAY: M2 is not an identity matrix"; else os << "\r\nERROR: M2 should not be an identity matrix"; if (M3.IsDiagonal()) os << "\r\nOKAY: M3 is diagonal"; else os << "\r\nERROR: M3 should be diagonal"; if (!M3.IsIdentity()) os << "\r\nOKAY: M3 is not an identity matrix"; else os << "\r\nERROR: M3 should not be an identity matrix"; if (!M4.IsDiagonal()) os << "\r\nOKAY: M4 is not diagonal"; else os << "\r\nERROR: M4 should not be diagonal"; if (!M4.IsIdentity()) os << "\r\nOKAY: M4 is not an identity matrix"; else os << "\r\nERROR: M4 should not be an identity matrix"; // tridiagonal tests M1 = tridi; os << "\r\n\r\nmatrix M1 = \r\n"; ShowMatrix(os,M1); if (M1.IsTridiagonal()) os << "\r\nOKAY: M1 is tridiagonal"; else os << "\r\nERROR: M1 should be tridiagonal"; if (!M4.IsTridiagonal()) os << "\r\nOKAY: M4 is not tridiagonal"; else os << "\r\nERROR: M1 should not be tridiagonal"; // upper triangular tests M1 = utri; os << "\r\n\r\nmatrix M1 = \r\n"; ShowMatrix(os,M1); if (M1.IsUpperTriangular()) os << "\r\nOKAY: M1 is upper-triangular"; else os << "\r\nERROR: M1 should be upper-triangular"; if (!M4.IsUpperTriangular()) os << "\r\nOKAY: M4 is not upper-triangular"; else os << "\r\nERROR: M4 should not be upper-triangular"; // lower triangular tests M1 = ltri; os << "\r\n\r\nmatrix M1 = \r\n"; ShowMatrix(os,M1); if (M1.IsLowerTriangular()) os << "\r\nOKAY: M1 is lower-triangular"; else os << "\r\nERROR: M1 should be lower-triangular"; if (!M4.IsLowerTriangular()) os << "\r\nOKAY: M4 is not lower-triangular"; else os << "\r\nERROR: M4 should not be lower-triangular"; // permutation tests M1 = perm; os << "\r\n\r\nmatrix M1 = \r\n"; ShowMatrix(os,M1); M2 = ident; os << "\r\n\r\nmatrix M2 = \r\n"; ShowMatrix(os,M2); if (M1.IsPermutation()) os << "\r\nOKAY: M1 is permutation matrix"; else os << "\r\nERROR: M1 should be permutation"; if (M2.IsPermutation()) os << "\r\nOKAY: M2 is permutation matrix"; else os << "\r\nERROR: M2 should be permutation"; if (!M4.IsPermutation()) os << "\r\nOKAY: M4 is not permutation"; else os << "\r\nERROR: M4 should not be permutation"; // check singularity function M1(0,1) = 0; os << "\r\n\r\nmatrix M1 = \r\n"; ShowMatrix(os,M1); if (M1.IsSingular()) os << "\r\nOKAY: M1 is singular"; else os << "\r\nERROR: M1 should be singular"; if (!M2.IsSingular()) os << "\r\nOKAY: M2 is not singular"; else os << "\r\nERROR: M2 should not be singular"; if (!M4.IsSingular()) os << "\r\nOKAY: M4 is not singular"; else os << "\r\nERROR: M4 should not be singular"; // change main window heading os <<endl <<"Matrix Tests (manipulations)" <<endl <<"============================" <<endl; // test minors and determinants os << "\r\n\r\nmatrix M4 = \r\n"; ShowMatrix(os,M4); os << "\r\nminor M4(1,1) = \r\n"; ShowMatrix(os,M4.Minor(1,1)); os << "\r\nminor M4(0,4) = \r\n"; ShowMatrix(os,M4.Minor(0,4)); Matrix<int> M5(2,2), M6(3,3); M5(0,0) = 1; M5(0,1) = 2; M5(1,0) = 3; M5(1,1) = 4; M6(0,0) = 1; M6(0,1) = 3; M6(0,2) = 2; M6(1,0) = 5; M6(1,1) = 4; M6(1,2) = 7; M6(2,0) = 6; M6(2,1) = 9; M6(2,2) = 8; M4 = det; Matrix<int> T4(5,5), T5(2,2), T6(3,3); T4 = M4.Transpose(); T5 = M5.Transpose(); T6 = M6.Transpose(); os << "\r\nmatrix M5 = \r\n"; ShowMatrix(os,M5); os << "\r\ndeterminant of M5 = " << M5.Determinant() << "\r\n"; os << "\r\nmatrix T5 = \r\n"; ShowMatrix(os,T5); os << "\r\ndeterminant of T5 = " << T5.Determinant() << "\r\n"; os << "\r\nmatrix M6 = \r\n"; ShowMatrix(os,M6); os << "\r\ndeterminant of M6 = " << M6.Determinant() << "\r\n"; os << "\r\nmatrix T6 = \r\n"; ShowMatrix(os,T6); os << "\r\ndeterminant of T6 = " << T6.Determinant() << "\r\n"; os << "\r\nmatrix M4 = \r\n"; ShowMatrix(os,M4); os << "\r\ndeterminant of M4 = " << M4.Determinant() << "\r\n"; os << "\r\nmatrix T4 = \r\n"; ShowMatrix(os,T4); os << "\r\ndeterminant of T4 = " << T4.Determinant() << "\r\n"; Matrix<int> R; os << "\r\nMatrix R (def. constr.) = \r\n"; ShowMatrix(os,R); R.Resize(10,10); os << "\r\nMatrix R (now 10x10) = \r\n"; ShowMatrix(os,R); // change main window heading os <<endl <<"Matrix Tests (double)" <<endl <<"=====================" <<endl; // check <double> Matrix os << "\r\nFLOATING POINT!"; Matrix<double> X(3,4), Y(4,3), Z(3,3); X(0,0) = 1.0; X(1,0) = 5.0; X(2,0) = 2.0; X(0,1) = 2.0; X(1,1) = 2.0; X(2,1) = 4.0; X(0,2) = 0.0; X(1,2) = 3.0; X(2,2) = 3.0; X(0,3) = 1.0; X(1,3) = 2.0; X(2,3) = 1.0; Y(0,0) = 0.0; Y(2,0) = 1.0; Y(0,1) = 1.0; Y(2,1) = 0.0; Y(0,2) = 2.0; Y(2,2) = 5.0; Y(1,0) = 1.0; Y(3,0) = 3.0; Y(1,1) = 3.0; Y(3,1) = 1.0; Y(1,2) = 2.0; Y(3,2) = 2.0; os << "\r\nMatrix X = \r\n"; ShowMatrix(os,X); os << "\r\nMatrix Y = \r\n"; ShowMatrix(os,Y); Z = X % Y; os << "\r\nMatrix Z (X % Y) = \r\n"; ShowMatrix(os,Z); // check transposition Matrix<double> tX; tX = X.Transpose(); os << "\r\nOriginal X =\r\n"; ShowMatrix(os,X); os << "\r\nTranspose X =\r\n"; ShowMatrix(os,tX); X(0,0) = 1; X(0,1) = 3; X(0,2) = -4; X(0,3) = 8; X(1,0) = 1; X(1,1) = 1; X(1,2) = -2; X(1,3) = 2; X(2,0) = -1; X(2,1) = -2; X(2,2) = 5; X(2,3) = -1; os << "\r\nOriginal X =\r\n"; ShowMatrix(os,X); Matrix<double> lX(X.LinSolve()); os << "\r\nX after elimination =\r\n"; ShowMatrix(os,X); os << "\r\nlinear equation solution =\r\n"; ShowMatrix(os,lX); X(0,0) = 1.0; X(1,0) = 3.0; X(2,0) = 5.0; X(0,1) = 2.0; X(1,1) = 5.0; X(2,1) = 6.0; X(0,2) = 0.0; X(1,2) = 4.0; X(2,2) = 3.0; X(0,3) = 0.1; X(1,3) = 12.5; X(2,3) = 10.3; os << "\r\nOriginal X =\r\n"; ShowMatrix(os,X); lX = X.LinSolve(); os << "\r\nX after elimination =\r\n"; ShowMatrix(os,X); os << "\r\nlinear equation solution =\r\n"; ShowMatrix(os,lX); Matrix<double> Adbl(3,3), Bdbl(3,1); Adbl(0,0) = 1.0; Adbl(0,1) = 2.0; Adbl(0,2) = 0.0; Adbl(1,0) = 3.0; Adbl(1,1) = 5.0; Adbl(1,2) = 4.0; Adbl(2,0) = 5.0; Adbl(2,1) = 6.0; Adbl(2,2) = 3.0; Bdbl(0,0) = 0.1; Bdbl(1,0) = 12.5; Bdbl(2,0) = 10.3; os << "\r\n\r\nmatrix Adbl = \r\n"; ShowMatrix(os,Adbl); os << "\r\nmatrix Bdbl = \r\n"; ShowMatrix(os,Bdbl); Matrix<double> alup(Adbl); // copy Adbl before LUP decomp os << "\r\nLU decomp of Adbl (before) = \r\n"; ShowMatrix(os,alup); Matrix<size_t> aperm = alup.LUPDecompose(); os << "\r\nLU decomp of Adbl (after) = \r\n"; ShowMatrix(os,alup); os << "\r\nPermutation of Adbl = \r\n"; ShowMatrix(os,aperm); Matrix<double> asol = alup.LUPSolve(aperm,Bdbl); os << "\r\nlinear solution of Adbl and Bdbl = \r\n"; ShowMatrix(os,asol); Matrix<double> ainv = alup.LUPInvert(aperm); os << "\r\ninverse of Adbl and Bdbl = \r\n"; ShowMatrix(os,ainv); Matrix<double> aid = Adbl % ainv; os << "\r\ninverse dot Adbl = \r\n"; ShowMatrix(os,aid); Grid<size_t> iperm = ainv.LUPDecompose(); Matrix<double> invinv = ainv.LUPInvert(iperm); os << "\r\ninverse of inverse =\r\n"; ShowMatrix(os,invinv); }