Пример #1
0
/*
   ------------------------------------
   purpose -- compute any updates to ZJ

   created -- 98mar26, cca
   ------------------------------------
*/
static void
computeBackwardUpdates (
   FrontMtx   *frontmtx,
   SubMtx     *ZJ,
   int        J,
   IP         *heads[],
   char       frontIsDone[],
   SubMtx     *p_mtx[],
   int        msglvl,
   FILE       *msgFile
) {
SubMtx   *UJK, *XK ;
int    K ;
IP     *ip, *nextip ;
/*
   -------------------------------
   loop over the remaining updates
   -------------------------------
*/
for ( ip = heads[J], heads[J] = NULL ;
      ip != NULL ;
      ip = nextip ) {
   K = ip->val ; nextip = ip->next ;
   if ( msglvl > 3 ) {
      fprintf(msgFile,
              "\n\n frontIsDone[%d] = %c", K, frontIsDone[K]) ;
      fflush(msgFile) ;
   }
   if ( frontIsDone[K] == 'Y' ) {
      if ( (XK = p_mtx[K]) != NULL ) {
/*
         --------------------------------
         X_K exists and has been computed
         --------------------------------
*/
         if ( msglvl > 3 ) {
            fprintf(msgFile, "\n\n before solve: XK = %p", XK) ;
            SubMtx_writeForHumanEye(XK, msgFile) ;
            fflush(msgFile) ;
         }
         if ( (UJK = FrontMtx_upperMtx(frontmtx, J, K)) != NULL ) {
            if ( msglvl > 3 ) {
               fprintf(msgFile, "\n\n UJK = %p", UJK) ;
               SubMtx_writeForHumanEye(UJK, msgFile) ;
               fflush(msgFile) ;
            }
            SubMtx_solveupd(ZJ, UJK, XK) ;
         }
         if ( msglvl > 3 ) {
            fprintf(msgFile, "\n\n after update: ZJ = %p", ZJ) ;
            SubMtx_writeForHumanEye(ZJ, msgFile) ;
            fflush(msgFile) ;
         }
      }
   } else {
/*
      ------------------------
      X_K is not yet available
      ------------------------
*/
      ip->next = heads[J] ;
      heads[J] = ip ;
   }
}
return ; }
Пример #2
0
/*
   ------------------------------------
   purpose -- compute any updates to BJ

   created -- 98mar26, cca
   ------------------------------------
*/
static void
computeForwardUpdates (
   FrontMtx   *frontmtx,
   SubMtx     *BJ,
   int        J,
   IP         *heads[],
   char       frontIsDone[],
   SubMtx     *p_mtx[],
   int        msglvl,
   FILE       *msgFile
) {
SubMtx   *LJI, *UIJ, *YI ;
int    I ;
IP     *ip, *nextip ;
/*
   -------------------------------
   loop over the remaining updates
   -------------------------------
*/
for ( ip = heads[J], heads[J] = NULL ;
      ip != NULL ;
      ip = nextip ) {
   I = ip->val ; nextip = ip->next ;
   if ( msglvl > 3 ) {
      fprintf(msgFile,
              "\n\n frontIsDone[%d] = %c, p_mtx[%d] = %p", 
              I, frontIsDone[I], I, p_mtx[I]) ;
      fflush(msgFile) ;
   }
   if ( frontIsDone[I] == 'Y' ) {
      if ( (YI = p_mtx[I]) != NULL ) {
/*
         --------------------------------
         Y_I exists and has been computed
         --------------------------------
*/
         if ( msglvl > 3 ) {
            fprintf(msgFile, "\n\n before solve: YI = %p", YI) ;
            SubMtx_writeForHumanEye(YI, msgFile) ;
            fflush(msgFile) ;
         }
         if ( FRONTMTX_IS_NONSYMMETRIC(frontmtx) ) {
            if ( (LJI = FrontMtx_lowerMtx(frontmtx, J, I)) != NULL ) {
               if ( msglvl > 3 ) {
                  fprintf(msgFile, "\n\n LJI = %p", LJI) ;
                  SubMtx_writeForHumanEye(LJI, msgFile) ;
                  fflush(msgFile) ;
               }
               SubMtx_solveupd(BJ, LJI, YI) ;
            }
         } else {
            if ( (UIJ = FrontMtx_upperMtx(frontmtx, I, J)) != NULL ) {
               if ( msglvl > 3 ) {
                  fprintf(msgFile, "\n\n UIJ = %p", UIJ) ;
                  SubMtx_writeForHumanEye(UIJ, msgFile) ;
                  fflush(msgFile) ;
               }
               if ( FRONTMTX_IS_SYMMETRIC(frontmtx) ) {
                  SubMtx_solveupdT(BJ, UIJ, YI) ;
               } else if ( FRONTMTX_IS_HERMITIAN(frontmtx) ) {
                  SubMtx_solveupdH(BJ, UIJ, YI) ;
               }
            }
         }
         if ( msglvl > 3 ) {
            fprintf(msgFile, "\n\n after update: BJ = %p", BJ) ;
            SubMtx_writeForHumanEye(BJ, msgFile) ;
            fflush(msgFile) ;
         }
      }
   } else {
/*
      ------------------------
      Y_I is not yet available
      ------------------------
*/
      ip->next = heads[J] ;
      heads[J] = ip ;
   }
}
return ; }
Пример #3
0
/*
   ---------------------------------------
   visit front J during the backward solve
 
   created -- 98mar27, cca
   ---------------------------------------
*/
void
FrontMtx_backwardVisit (
   FrontMtx        *frontmtx,
   int             J,
   int             nrhs,
   int             *owners,
   int             myid,
   SubMtxManager   *mtxmanager,
   SubMtxList      *aggList,
   SubMtx          *p_mtx[],
   char            frontIsDone[],
   IP              *heads[],
   SubMtx          *p_agg[],
   char            status[],
   int             msglvl,
   FILE            *msgFile
) {
char     aggDone, updDone ;
SubMtx     *UJJ, *ZJ ;
int      nJ ;
 
if ( msglvl > 1 ) {
   fprintf(msgFile, "\n inside FrontMtx_backwardVisit(%d), nJ = %d",
           J, FrontMtx_frontSize(frontmtx, J)) ;
   fflush(msgFile) ;
}
if ( (nJ = FrontMtx_frontSize(frontmtx, J)) == 0 ) {
/*
   -----------------------------------------------------
   front has no eliminated rows or columns, quick return
   -----------------------------------------------------
*/
   if ( owners == NULL || owners[J] == myid ) {
      frontIsDone[J] = 'Y'  ;
   }
   status[J] = 'F' ;
   return ;
}
if ( msglvl > 1 ) {
   fprintf(msgFile, "\n heads[%d] = %p", J, heads[J]) ;
   fflush(msgFile) ;
}
if ( heads[J] != NULL ) {
/*
   -------------------------------------
   there are internal updates to perform
   -------------------------------------
*/
   if ( (ZJ = p_agg[J]) == NULL ) {
/*
      ---------------------------
      create the aggregate object
      ---------------------------
*/
      ZJ = p_agg[J] = initBJ(frontmtx->type, J, nJ, nrhs, 
                             mtxmanager, msglvl, msgFile) ;
   }
   if ( msglvl > 3 ) {
      fprintf(msgFile, "\n\n ZJ = %p", ZJ) ;
      SubMtx_writeForHumanEye(ZJ, msgFile) ;
      fflush(msgFile) ;
   }
/*
   ---------------------------
   compute any waiting updates
   ---------------------------
*/
   computeBackwardUpdates(frontmtx, ZJ, J, heads, frontIsDone, p_mtx,
                          msglvl, msgFile) ;
}
if ( heads[J] == NULL ) {
   updDone = 'Y' ;
} else {
   updDone = 'N' ;
}
if ( msglvl > 1 ) {
   fprintf(msgFile, "\n updDone = %c", updDone) ;
   fflush(msgFile) ;
}
if ( aggList != NULL && owners[J] == myid ) {
/*
   -----------------------
   assemble any aggregates
   -----------------------
*/
   aggDone = 'N' ;
   if ( (ZJ = p_agg[J]) == NULL ) {
      fprintf(stderr,
             "\n 2. fatal error in backwardVisit(%d), ZJ = NULL", J) ;
      exit(-1) ;
   }
   assembleAggregates(J, ZJ, aggList, mtxmanager, 
                             msglvl, msgFile) ;
   if ( SubMtxList_isCountZero(aggList, J) == 1 ) {
      if ( msglvl > 3 ) {
         fprintf(msgFile, "\n\n aggregate count is zero") ;
         fflush(msgFile) ;
      }
      assembleAggregates(J, ZJ, aggList, mtxmanager, 
                                msglvl, msgFile) ;
      aggDone = 'Y' ;
   }
} else {
   aggDone = 'Y' ;
}
if ( msglvl > 1 ) {
   fprintf(msgFile, "\n aggDone = %c", aggDone) ;
   fflush(msgFile) ;
}
if ( updDone == 'Y' && aggDone == 'Y' ) {
   ZJ = p_agg[J] ;
   if ( owners == NULL || owners[J] == myid ) {
/*
      -------------------------------------
      owned front, ready for interior solve
      -------------------------------------
*/
      UJJ = FrontMtx_upperMtx(frontmtx, J, J) ;
      if ( UJJ != NULL ) {
         SubMtx_solve(UJJ, ZJ) ;
      }
      if ( msglvl > 1 ) {
         fprintf(msgFile, "\n\n after backward solve") ;
         SubMtx_writeForHumanEye(ZJ, msgFile) ;
         fflush(msgFile) ;
      }
/*
      ------------------------------------------------
      move YJ (stored in BJ) into p_mtx[],
      signal front as done, and set status to finished
      ------------------------------------------------
*/
      p_agg[J]       = NULL ;
      p_mtx[J]       = ZJ   ;
      frontIsDone[J] = 'Y'  ;
   } else if ( ZJ != NULL ) {
/*
      --------------------------------------
      unowned front, put into aggregate list
      --------------------------------------
*/
      SubMtxList_addObjectToList(aggList, ZJ, J) ;
      p_agg[J]  = NULL ;
   }
   status[J] = 'F'  ;
}
if ( msglvl > 1 ) {
   fprintf(msgFile, "\n status[%d] = %c", J, status[J]) ;
   fflush(msgFile) ;
}
return ; }
Пример #4
0
/*
   ----------------------------------------------------------------
   purpose -- for each U_{J,bnd{J}} matrix, remove from hash table,
              split into their U_{J,K} submatrices and insert 
              into the hash table.

   created -- 98may04, cca
   ----------------------------------------------------------------
*/
void
FrontMtx_splitUpperMatrices (
   FrontMtx   *frontmtx,
   int        msglvl,
   FILE       *msgFile
) {
SubMtx          *mtxUJ, *mtxUJJ, *mtxUJK ;
SubMtxManager   *manager ;
double          *entUJ, *entUJK ;
int             count, first, ii, inc1, inc2, jcol, jj, J, K, nbytes,
                ncolJ, ncolUJ, ncolUJK, nentUJ, nentUJK, neqns, nfront, 
                nJ, nrowUJ, nrowUJK, offset, v ;
int             *colindJ, *colindUJ, *colindUJK, *colmap, *indicesUJ,
                *indicesUJK, *locmap, *rowindUJ, *rowindUJK, *sizesUJ, 
                *sizesUJK ;
I2Ohash         *upperhash ;
/*
   ---------------
   check the input
   ---------------
*/
if ( frontmtx == NULL || (msglvl > 0 && msgFile == NULL) ) {
   fprintf(stderr, 
           "\n fatal error in FrontMtx_splitUpperMatrices(%p,%d,%p)"
           "\n bad input\n", frontmtx, msglvl, msgFile) ;
   spoolesFatal();
}
nfront    = FrontMtx_nfront(frontmtx) ;
neqns     = FrontMtx_neqns(frontmtx) ;
upperhash = frontmtx->upperhash ;
manager   = frontmtx->manager   ;
/*
   -----------------------------------
   construct the column and local maps
   -----------------------------------
*/
colmap = IVinit(neqns, -1) ;
locmap = IVinit(neqns, -1) ;
for ( J = 0 ; J < nfront ; J++ ) {
   if ( (nJ = FrontMtx_frontSize(frontmtx, J)) > 0 ) {
      FrontMtx_columnIndices(frontmtx, J, &ncolJ, &colindJ) ;
      if ( ncolJ > 0 && colindJ != NULL ) {
         for ( ii = 0 ; ii < nJ ; ii++ ) {
            v = colindJ[ii] ;
            colmap[v] = J ;
            locmap[v] = ii ;
         } 
      }
   }
}
if ( msglvl > 2 ) {
   fprintf(msgFile, "\n\n colmap[]") ;
   IVfprintf(msgFile, neqns, colmap) ;
   fprintf(msgFile, "\n\n locmap[]") ;
   IVfprintf(msgFile, neqns, locmap) ;
   fflush(msgFile) ;
}
/*
   ---------------------------------------------
   move the U_{J,J} matrices into the hash table
   ---------------------------------------------
*/
for ( J = 0 ; J < nfront ; J++ ) {
   if ( (mtxUJJ = FrontMtx_upperMtx(frontmtx, J, J)) != NULL ) {
      I2Ohash_insert(frontmtx->upperhash, J, J, mtxUJJ) ;
   }
}
/*
   ------------------------------------------------------------
   now split the U_{J,bnd{J}} matrices into U_{J,K} matrices.
   note: columns of U_{J,bnd{J}} are assumed to be in ascending
   order with respect to the column ordering of the matrix.
   ------------------------------------------------------------
*/
for ( J = 0 ; J < nfront ; J++ ) {
   mtxUJ = FrontMtx_upperMtx(frontmtx, J, nfront) ;
   if ( msglvl > 2 ) {
      fprintf(msgFile, "\n\n ### J = %d, mtxUJ = %p", J, mtxUJ) ;
      fflush(msgFile) ;
   }
   if ( mtxUJ != NULL ) {
      if ( msglvl > 2 ) {
         SubMtx_writeForHumanEye(mtxUJ, msgFile) ;
         fflush(msgFile) ;
      }
      SubMtx_columnIndices(mtxUJ, &ncolUJ, &colindUJ) ;
      SubMtx_rowIndices(mtxUJ, &nrowUJ, &rowindUJ) ;
      if ( msglvl > 2 ) {
         fprintf(msgFile, "\n  column indices for J") ;
         IVfprintf(msgFile, ncolUJ, colindUJ) ;
         fprintf(msgFile, "\n  row indices for UJ") ;
         IVfprintf(msgFile, nrowUJ, rowindUJ) ;
         fflush(msgFile) ;
      }
      if ( (K = colmap[colindUJ[0]]) == colmap[colindUJ[ncolUJ-1]] ) {
         if ( msglvl > 2 ) {
            fprintf(msgFile, "\n  front %d supports only %d", J, K) ;
            fflush(msgFile) ;
         }
/*
         -------------------------------------------------
         U_{J,bnd{J}} is one submatrix, bnd{J} \subseteq K
         set row and column indices and change column id
         -------------------------------------------------
*/
         IVramp(nrowUJ, rowindUJ, 0, 1) ;
         for ( ii = 0 ; ii < ncolUJ ; ii++ ) {
            colindUJ[ii] = locmap[colindUJ[ii]] ;
         }
         SubMtx_setFields(mtxUJ, mtxUJ->type, mtxUJ->mode, J, K,
                          mtxUJ->nrow, mtxUJ->ncol, mtxUJ->nent) ;
/*
         mtxUJ->colid = K ;
*/
         if ( msglvl > 2 ) {
            fprintf(msgFile, "\n\n ##  inserting U(%d,%d) ", J, K) ;
            SubMtx_writeForHumanEye(mtxUJ, msgFile) ;
            fflush(msgFile) ;
         }
         I2Ohash_insert(upperhash, J, K, (void *) mtxUJ) ;
      } else {
/*
         -----------------------------------
         split U_{J,bnd{J}} into submatrices
         -----------------------------------
*/
         nJ = FrontMtx_frontSize(frontmtx, J) ;
         if ( SUBMTX_IS_DENSE_COLUMNS(mtxUJ) ) {
            SubMtx_denseInfo(mtxUJ, 
                           &nrowUJ, &ncolUJ, &inc1, &inc2, &entUJ) ;
         } else if ( SUBMTX_IS_SPARSE_COLUMNS(mtxUJ) ) {
            SubMtx_sparseColumnsInfo(mtxUJ, &ncolUJ, &nentUJ, 
                                   &sizesUJ, &indicesUJ, &entUJ) ;
            offset = 0 ;
            count  = sizesUJ[0] ;
         }
         first = 0 ;
         K = colmap[colindUJ[0]] ;
         for ( jcol = 1 ; jcol <= ncolUJ ; jcol++ ) {
            if ( msglvl > 2 ) {
               fprintf(msgFile, "\n jcol = %d", jcol) ;
               if ( jcol < ncolUJ ) {
                  fprintf(msgFile, ", colmap[%d] = %d", 
                          colindUJ[jcol], colmap[colindUJ[jcol]]);
               }
               fflush(msgFile) ;
            }
            if ( jcol == ncolUJ || K != colmap[colindUJ[jcol]] ) {
               ncolUJK = jcol - first ;
               if ( SUBMTX_IS_DENSE_COLUMNS(mtxUJ) ) {
                  nentUJK = nJ*ncolUJK ;
               } else if ( SUBMTX_IS_SPARSE_COLUMNS(mtxUJ) ) {
                  if ( count == 0 ) {
                     goto no_entries ;
                  }
                  nentUJK = count ;
               }
               nbytes = SubMtx_nbytesNeeded(mtxUJ->type, mtxUJ->mode,
                                            nJ, ncolUJK, nentUJK) ;
               if ( msglvl > 2 ) {
                  fprintf(msgFile, 
                          "\n ncolUJK %d, nentUJK %d, nbytes %d",
                          ncolUJK, nentUJK, nbytes) ;
                  fflush(msgFile) ;
               }
               mtxUJK = SubMtxManager_newObjectOfSizeNbytes(manager, 
                                                          nbytes) ;
               SubMtx_init(mtxUJK, mtxUJ->type, mtxUJ->mode, J, K,
                         nJ, ncolUJK, nentUJK) ;
               if ( SUBMTX_IS_DENSE_COLUMNS(mtxUJ) ) {
                  SubMtx_denseInfo(mtxUJK, 
                         &nrowUJK, &ncolUJK, &inc1, &inc2, &entUJK) ;
                  if ( FRONTMTX_IS_REAL(frontmtx) ) {
                     DVcopy(nentUJK, entUJK, entUJ + first*nJ) ;
                  } else if ( FRONTMTX_IS_COMPLEX(frontmtx) ) {
                     DVcopy(2*nentUJK, entUJK, entUJ + 2*first*nJ) ;
                  }
               } else if ( SUBMTX_IS_SPARSE_COLUMNS(mtxUJ) ) {
                  SubMtx_sparseColumnsInfo(mtxUJK, &ncolUJK, &nentUJK, 
                                   &sizesUJK, &indicesUJK, &entUJK) ;
                  IVcopy(ncolUJK, sizesUJK, sizesUJ + first) ;
                  IVcopy(nentUJK, indicesUJK, indicesUJ + offset) ;
                  if ( FRONTMTX_IS_REAL(frontmtx) ) {
                     DVcopy(nentUJK, entUJK, entUJ + offset) ;
                  } else if ( FRONTMTX_IS_COMPLEX(frontmtx) ) {
                     DVcopy(2*nentUJK, entUJK, entUJ + 2*offset) ;
                  }
                  count  =  0 ;
                  offset += nentUJK ;
               }
/*
               -------------------------------------
               initialize the row and column indices
               -------------------------------------
*/
               if ( msglvl > 2 ) {
                  fprintf(msgFile, "\n setting row and column indices");
                  fflush(msgFile) ;
               }
               SubMtx_rowIndices(mtxUJK, &nrowUJK, &rowindUJK) ;
               IVramp(nJ, rowindUJK, 0, 1) ;
               SubMtx_columnIndices(mtxUJK, &ncolUJK, &colindUJK) ;
               for ( ii = 0, jj = first ; ii < ncolUJK ; ii++, jj++ ) {
                  colindUJK[ii] = locmap[colindUJ[jj]] ;
               }
/*
               ----------------------------------
               insert U_{J,K} into the hash table
               ----------------------------------
*/
               if ( msglvl > 2 ) {
                   fprintf(msgFile, 
                           "\n\n ##  inserting U(%d,%d) ", J, K) ;
                   SubMtx_writeForHumanEye(mtxUJK, msgFile) ;
                   fflush(msgFile) ;
               }
               I2Ohash_insert(upperhash, J, K, (void *) mtxUJK) ;
/*
               -----------------------------------
               we jump to here if there were no
               entries to be stored in the matrix.
               -----------------------------------
*/
   no_entries :
/*
               ----------------------------------------------------
               reset first and K to new first location and front id
               ----------------------------------------------------
*/
               first = jcol ;
               if ( jcol < ncolUJ ) {
                  K = colmap[colindUJ[jcol]] ;
               }
            } 
            if ( jcol < ncolUJ && SUBMTX_IS_SPARSE_COLUMNS(mtxUJ) ) {
               count += sizesUJ[jcol] ;
            }
         }
/*
         --------------------------------------------
         give U_{J,bnd{J}} back to the matrix manager
         --------------------------------------------
*/
         SubMtxManager_releaseObject(manager, mtxUJ) ;
      }
   }
}
/*
   ------------------------
   free the working storage
   ------------------------
*/
IVfree(colmap) ;
IVfree(locmap) ;

return ; }
Пример #5
0
/*
   ----------------------------------------------------
   store the factor entries of the reduced front matrix

   created -- 98may25, cca
   ----------------------------------------------------
*/
void
FrontMtx_QR_storeFront (
   FrontMtx   *frontmtx,
   int        J,
   A2         *frontJ,
   int        msglvl,
   FILE       *msgFile
) {
A2       tempA2 ;
double   fac, ifac, imag, real, rfac ;
double   *entDJJ, *entUJJ, *entUJN, *row ;
int      inc1, inc2, irow, jcol, ncol, ncolJ, nD, nentD, nentUJJ, 
         nfront, nrow, nU ;
int      *colind, *colindJ, *firstlocs, *sizes ;
SubMtx   *mtx ;
/*
   ---------------
   check the input
   ---------------
*/
if (  frontmtx == NULL || frontJ == NULL
   || (msglvl > 0 && msgFile == NULL) ) {
   fprintf(stderr, "\n fatal error in FrontMtx_QR_storeFront()"
           "\n bad input\n") ;
   exit(-1) ;
}
nfront = FrontMtx_nfront(frontmtx) ;
FrontMtx_columnIndices(frontmtx, J, &ncolJ, &colindJ) ;
nrow   = A2_nrow(frontJ) ;
ncol   = A2_ncol(frontJ) ;
A2_setDefaultFields(&tempA2) ;
nD = FrontMtx_frontSize(frontmtx, J) ;
nU = ncol - nD ;
/*
   --------------------------------------
   scale the rows and square the diagonal
   --------------------------------------
*/
row = A2_entries(frontJ) ;
if ( A2_IS_REAL(frontJ) ) {
   for ( irow = 0 ; irow < nD ; irow++ ) {
      if ( row[irow] != 0.0 ) {
         fac = 1./row[irow] ;
         for ( jcol = irow + 1 ; jcol < ncol ; jcol++ ) {
            row[jcol] *= fac ;
         }
         row[irow] = row[irow] * row[irow] ;
      }
      row += ncol ;
   }
} else if ( A2_IS_COMPLEX(frontJ) ) {
   for ( irow = 0 ; irow < nD ; irow++ ) {
      real = row[2*irow] ; imag = row[2*irow+1] ;
      if (  real != 0.0 || imag != 0.0 ) {
         Zrecip(real, imag, &rfac, &ifac) ;
         ZVscale(ncol - irow - 1, & row[2*irow+2], rfac, ifac) ;
         row[2*irow]   = real*real + imag*imag ;
         row[2*irow+1] = 0.0 ;
      }
      row += 2*ncol ;
   }
}
if ( msglvl > 3 ) {
   fprintf(msgFile, "\n after scaling rows of A") ;
   A2_writeForHumanEye(frontJ, msgFile) ;
   fflush(msgFile) ;
}
/*
   -------------------------
   copy the diagonal entries
   -------------------------
*/
mtx = FrontMtx_diagMtx(frontmtx, J) ;
SubMtx_diagonalInfo(mtx, &nentD, &entDJJ) ;
A2_subA2(&tempA2, frontJ, 0, nD-1, 0, nD-1) ;
A2_copyEntriesToVector(&tempA2, nentD, entDJJ, 
                       A2_DIAGONAL, A2_BY_ROWS) ;
SubMtx_columnIndices(mtx, &ncol, &colind) ;
IVcopy(nD, colind, colindJ) ;
if ( msglvl > 3 ) {
   fprintf(msgFile, "\n diagonal factor matrix") ;
   SubMtx_writeForHumanEye(mtx, msgFile) ;
   fflush(msgFile) ;
}
if ( (mtx = FrontMtx_upperMtx(frontmtx, J, J)) != NULL ) {
/*
   ------------------------
   copy the U_{J,J} entries
   ------------------------
*/
   SubMtx_denseSubcolumnsInfo(mtx, &nD, &nentUJJ, 
                           &firstlocs, &sizes, &entUJJ) ;
   A2_copyEntriesToVector(&tempA2, nentUJJ, entUJJ, 
                          A2_STRICT_UPPER, A2_BY_COLUMNS) ;
   SubMtx_columnIndices(mtx, &ncol, &colind) ;
   IVcopy(nD, colind, colindJ) ;
   if ( msglvl > 3 ) {
      fprintf(msgFile, "\n UJJ factor matrix") ;
      SubMtx_writeForHumanEye(mtx, msgFile) ;
      fflush(msgFile) ;
   }
}
if ( ncolJ > nD ) {
/*
   -----------------------------
   copy the U_{J,bnd{J}} entries
   -----------------------------
*/
   mtx = FrontMtx_upperMtx(frontmtx, J, nfront) ;
   SubMtx_denseInfo(mtx, &nD, &nU, &inc1, &inc2, &entUJN) ;
   A2_subA2(&tempA2, frontJ, 0, nD-1, nD, ncolJ-1) ;
   A2_copyEntriesToVector(&tempA2, nD*nU, entUJN, 
                          A2_ALL_ENTRIES, A2_BY_COLUMNS) ;
   SubMtx_columnIndices(mtx, &ncol, &colind) ;
   IVcopy(nU, colind, colindJ + nD) ;
   if ( msglvl > 3 ) {
      fprintf(msgFile, "\n UJN factor matrix") ;
      SubMtx_writeForHumanEye(mtx, msgFile) ;
      fflush(msgFile) ;
   }
}
return ; }
Пример #6
0
/*
   --------------------------------------------------
   clear the data fields, releasing allocated storage

   created -- 98may04, cca
   --------------------------------------------------
*/
void
FrontMtx_clearData ( 
   FrontMtx   *frontmtx 
) {
SubMtx   *mtx ;
int      ii, J, K, nadj, nfront ;
int      *adj ;
/*
   ---------------
   check the input
   ---------------
*/
if ( frontmtx == NULL ) {
   fprintf(stderr, "\n fatal error in FrontMtx_clearData(%p)"
           "\n bad input\n", frontmtx) ;
   exit(-1) ;
}
nfront = frontmtx->nfront ;
/*
   ----------------------
   free the owned storage
   ----------------------
*/
if ( frontmtx->frontsizesIV != NULL ) {
   IV_free(frontmtx->frontsizesIV) ;
}
if ( frontmtx->rowadjIVL != NULL ) {
   IVL_free(frontmtx->rowadjIVL) ;
}
if ( frontmtx->coladjIVL != NULL ) {
   IVL_free(frontmtx->coladjIVL) ;
}
if ( frontmtx->p_mtxDJJ != NULL ) {
   for ( J = 0 ; J < nfront ; J++ ) {
      if ( (mtx = frontmtx->p_mtxDJJ[J]) != NULL ) {
         SubMtx_free(mtx) ;
      }
   }
   FREE(frontmtx->p_mtxDJJ) ;
}
if ( frontmtx->tree != NULL ) {
   if (  frontmtx->frontETree == NULL 
      || frontmtx->frontETree->tree != frontmtx->tree ) {
      Tree_free(frontmtx->tree) ;
   }
   frontmtx->tree = NULL ;
}
if ( frontmtx->dataMode == FRONTMTX_1D_MODE ) {
   if ( frontmtx->p_mtxUJJ != NULL ) {
      for ( J = 0 ; J < nfront ; J++ ) {
         if ( (mtx = frontmtx->p_mtxUJJ[J]) != NULL ) {
            SubMtx_free(mtx) ;
         }
      }
      FREE(frontmtx->p_mtxUJJ) ;
   }
   if ( frontmtx->p_mtxUJN != NULL ) {
      for ( J = 0 ; J < nfront ; J++ ) {
         if ( (mtx = frontmtx->p_mtxUJN[J]) != NULL ) {
            SubMtx_free(mtx) ;
         }
      }
      FREE(frontmtx->p_mtxUJN) ;
   }
   if ( frontmtx->p_mtxLJJ != NULL ) {
      for ( J = 0 ; J < nfront ; J++ ) {
         if ( (mtx = frontmtx->p_mtxLJJ[J]) != NULL ) {
            SubMtx_free(mtx) ;
         }
      }
      FREE(frontmtx->p_mtxLJJ) ;
   }
   if ( frontmtx->p_mtxLNJ != NULL ) {
      for ( J = 0 ; J < nfront ; J++ ) {
         if ( (mtx = frontmtx->p_mtxLNJ[J]) != NULL ) {
            SubMtx_free(mtx) ;
         }
      }
      FREE(frontmtx->p_mtxLNJ) ;
   }
} else if ( frontmtx->dataMode == FRONTMTX_2D_MODE ) {
   for ( J = 0 ; J < nfront ; J++ ) {
      FrontMtx_upperAdjFronts(frontmtx, J, &nadj, &adj) ;
      for ( ii = 0 ; ii < nadj ; ii++ ) {
         K = adj[ii] ;
         if ( (mtx = FrontMtx_upperMtx(frontmtx, J, K)) != NULL ) {
            SubMtx_free(mtx) ;
         }
      }
   }
   if ( FRONTMTX_IS_NONSYMMETRIC(frontmtx) ) {
      for ( J = 0 ; J < nfront ; J++ ) {
         FrontMtx_lowerAdjFronts(frontmtx, J, &nadj, &adj) ;
         for ( ii = 0 ; ii < nadj ; ii++ ) {
            K = adj[ii] ;
            if ( (mtx = FrontMtx_lowerMtx(frontmtx, K, J)) != NULL ) {
               SubMtx_free(mtx) ;
            }
         }
      }
   }
   if ( frontmtx->lowerblockIVL != NULL ) {
      IVL_free(frontmtx->lowerblockIVL) ;
   }
   if ( frontmtx->upperblockIVL != NULL ) {
      IVL_free(frontmtx->upperblockIVL) ;
   }
   if ( frontmtx->lowerhash != NULL ) {
      I2Ohash_free(frontmtx->lowerhash) ;
   }
   if ( frontmtx->upperhash != NULL ) {
      I2Ohash_free(frontmtx->upperhash) ;
   }
}
if ( frontmtx->lock != NULL ) {
/*
   -------------------------
   destroy and free the lock
   -------------------------
*/
   Lock_free(frontmtx->lock) ;
}
/*
   ----------------------
   set the default fields
   ----------------------
*/
FrontMtx_setDefaultFields(frontmtx) ;

return ; }