1 /* update.c */
2
3 #include "../FrontMtx.h"
4
5 /*--------------------------------------------------------------------*/
6 /*
7 ------------------------------------------------------------
8 accumulate updates to front J, store them in the Chv object
9
10 created -- 98may04, cca
11 ------------------------------------------------------------
12 */
13 void
FrontMtx_update(FrontMtx * frontmtx,Chv * frontJ,IP * heads[],char status[],DV * tempDV,int msglvl,FILE * msgFile)14 FrontMtx_update (
15 FrontMtx *frontmtx,
16 Chv *frontJ,
17 IP *heads[],
18 char status[],
19 DV *tempDV,
20 int msglvl,
21 FILE *msgFile
22 ) {
23 SubMtx *mtxD, *mtxL, *mtxU ;
24 int I, J, nfront ;
25 IP *first, *ip, *last, *nextip ;
26 /*
27 --------------------------------------
28 loop over the fronts that may update J
29 --------------------------------------
30 */
31 if ( msglvl > 3 ) {
32 fprintf(msgFile, "\n\n inside FrontMtx_update(%d)", frontJ->id) ;
33 fflush(stdout) ;
34 }
35 J = frontJ->id ;
36 nfront = frontmtx->nfront ;
37 for ( ip = heads[J], heads[J] = first = last = NULL ;
38 ip != NULL ;
39 ip = nextip ) {
40 nextip = ip->next ;
41 I = ip->val ;
42 if ( status == NULL || status[I] == 'F' ) {
43 mtxD = FrontMtx_diagMtx(frontmtx, I) ;
44 if ( msglvl > 3 ) {
45 fprintf(msgFile, "\n update from I %d, mtxD = %p", I, mtxD) ;
46 fflush(stdout) ;
47 }
48 if ( mtxD != NULL ) {
49 /*
50 -------------------------------------------------
51 front I did have some rows and columns eliminated
52 -------------------------------------------------
53 */
54 mtxU = FrontMtx_upperMtx(frontmtx, I, nfront) ;
55 if ( msglvl > 3 ) {
56 fprintf(msgFile, "\n mtxU = %p", mtxU) ;
57 fflush(stdout) ;
58 }
59 if ( mtxU != NULL ) {
60 /*
61 ------------------------------
62 the U_{I,bnd{I}} matrix exists
63 ------------------------------
64 */
65 if ( FRONTMTX_IS_SYMMETRIC(frontmtx) ) {
66 Chv_updateS(frontJ, mtxD, mtxU, tempDV) ;
67 } else if ( FRONTMTX_IS_HERMITIAN(frontmtx) ) {
68 Chv_updateH(frontJ, mtxD, mtxU, tempDV) ;
69 /*
70 fprintf(msgFile, "\n after update from front %d", mtxD->rowid) ;
71 Chv_writeForHumanEye(frontJ, msgFile) ;
72 */
73 } else if ( FRONTMTX_IS_NONSYMMETRIC(frontmtx) ) {
74 mtxL = FrontMtx_lowerMtx(frontmtx, nfront, I) ;
75 if ( msglvl > 3 ) {
76 fprintf(msgFile, "\n mtxL = %p", mtxL) ;
77 fflush(stdout) ;
78 }
79 if ( mtxL != NULL ) {
80 /*
81 ------------------------------
82 the L_{bnd{I},I} matrix exists
83 ------------------------------
84 */
85 Chv_updateN(frontJ, mtxL, mtxD, mtxU, tempDV) ;
86 }
87 }
88 }
89 }
90 if ( last == NULL ) {
91 last = ip ;
92 }
93 ip->next = first ;
94 first = ip ;
95 if ( msglvl > 3 ) {
96 fprintf(msgFile, "\n update from I %d is finished", I) ;
97 fflush(stdout) ;
98 }
99 } else {
100 ip->next = heads[J] ;
101 heads[J] = ip ;
102 }
103 }
104 /*
105 if ( frontJ->id == frontmtx->nfront - 1 ) {
106 fprintf(msgFile, "\n\n last front after updates made") ;
107 Chv_writeForHumanEye(frontJ, msgFile) ;
108 fflush(msgFile) ;
109 }
110 */
111 if ( last != NULL ) {
112 /*
113 ------------------------------------
114 link the IP objects to the free list
115 ------------------------------------
116 */
117 last->next = heads[nfront] ;
118 heads[nfront] = first ;
119 }
120 if ( msglvl > 3 ) {
121 fprintf(msgFile, "\n\n leaving FrontMtx_update(%d)", frontJ->id) ;
122 fflush(stdout) ;
123 }
124 return ; }
125
126 /*--------------------------------------------------------------------*/
127