lu.c File Reference

#include "spConfig.h"
#include "spmatrix.h"
#include "spDefs.h"
#include "machine.h"

Include dependency graph for lu.c:

Go to the source code of this file.

Defines

#define spINSIDE_SPARSE

Functions

static void spFixThresold (char *eMatrix, double eps, double releps)
static void spGetNumRank (char *eMatrix, int *n)
void cerro ()
void C2F() lufact1 (double *val, int *lln, int *col, int *n, int *nel, long *fmat, double *eps, double *releps, int *nrank, int *ierr)
void Cout (char *str)
void C2F() lusolve1 (long *fmat, double *b, double *x)
void C2F() ludel1 (long *fmat)
static void spSize (char *eMatrix, int *n)
void C2F() lusize (long *fmat, int *n)
void GetSigD (MatrixPtr Matrix, int indsigd[], double sigd[])
void GetSigG (MatrixPtr Matrix, int indsigg[], double sigg[])
static void spLuget (char *eMatrix, int *indP, double *P, int *indl, double *l, int *indu, double *u, int *indQ, double *Q)
void C2F() luget1 (long *fmat, int *indP, double *P, int *indl, double *l, int *indu, double *u, int *indQ, double *Q)
static void spLusiz (char *eMatrix, int *lsize, int *usize)
void C2F() lusiz1 (long *fmat, int *lsize, int *usize)


Define Documentation

#define spINSIDE_SPARSE

Definition at line 31 of file lu.c.


Function Documentation

void cerro (  ) 

void Cout ( char *  str  ) 

Definition at line 7 of file cout.c.

References C2F, int, l, and out().

00009 {
00010   int l;
00011   l = strlen(str) + 1;
00012   C2F(out)(str,l);
00013 }

Here is the call graph for this function:

void GetSigD ( MatrixPtr  Matrix,
int  indsigd[],
double  sigd[] 
)

Definition at line 190 of file lu.c.

References I, and last.

Referenced by spLuget().

00191 {
00192   int I,J,mc=0,last=0;
00193   int Size=Matrix->Size;
00194 for (I = 1; I <= Size; I++)
00195   {
00196     indsigd[I-1]=1;
00197     indsigd[Size+I-1]=  Matrix->IntToExtColMap[I];
00198     sigd[I-1]=1.0;
00199   }
00200 /* counting missing colums */
00201 for (I = 1; I <= Size; I++) 
00202   if (Matrix->ExtToIntColMap[I]== -1) mc++;
00203 /* filling missing colums */
00204 if (mc != 0)
00205   {
00206     for (I = Size -(mc)+1  ; I <= Size; I++)
00207       {
00208         for ( J=last+1; J <=Size; J++)
00209           {
00210             if (Matrix->ExtToIntColMap[J]==-1) 
00211               { 
00212                 last=J;break;
00213               }
00214           }
00215         indsigd[I-1]=1;
00216         indsigd[Size+I-1]= last;
00217       }
00218   }
00219 }

Here is the caller graph for this function:

void GetSigG ( MatrixPtr  Matrix,
int  indsigg[],
double  sigg[] 
)

Definition at line 224 of file lu.c.

References I, and last.

Referenced by spLuget().

00225 {
00226   int Size=Matrix->Size;
00227   int I,J,mc=0,last=0;
00228   /* counting missing Rows*/
00229   for (I = 1; I <= Size; I++) 
00230     if (Matrix->ExtToIntRowMap[I]== -1) mc++;
00231 
00232   for (I = 1; I <= Size-mc ; I++)
00233   {
00234         indsigg[I-1]= 1;
00235         indsigg[Size+Matrix->IntToExtRowMap[I]-1]=I;
00236         sigg[I-1]=1;
00237   }
00238 /* filling missing Rows */
00239 if (mc != 0)
00240   {
00241     for (I = Size -(mc)+1  ; I <= Size; I++)
00242       {
00243         for ( J=last+1; J <=Size; J++)
00244           {
00245             if (Matrix->ExtToIntRowMap[J]==-1) 
00246               { 
00247 
00248                 last=J;break;
00249               }
00250           }
00251         indsigg[I-1]= 1;
00252         indsigg[Size+last-1]=I;
00253         sigg[I-1]=1;
00254       }
00255   }
00256 }

Here is the caller graph for this function:

void C2F() ludel1 ( long fmat  ) 

Definition at line 153 of file lu.c.

References spDestroy().

00155 {
00156   spDestroy((char*) *fmat);
00157 }

Here is the call graph for this function:

void C2F() lufact1 ( double *  val,
int lln,
int col,
int n,
int nel,
long fmat,
double*  eps,
double*  releps,
int nrank,
int ierr 
)

Definition at line 78 of file lu.c.

References cerro(), eps, error, i, i1, ierr, j, long, n, nel, spADD_REAL_ELEMENT, spCreate(), spFactor(), spFixThresold(), spGetElement(), spGetNumRank(), spNO_MEMORY, spOKAY, spREAL, spSINGULAR, spSMALL_PIVOT, spZERO_DIAG, and val.

00082 {
00083   int error,i,i0,i1,k,j;
00084   spREAL *pelement;
00085   *ierr = 0;
00086   *fmat = (long)spCreate(*n,0,&error);
00087     if (error != spOKAY) {
00088         *ierr = 1;
00089         return;
00090     }
00091 
00092 
00093   i0=0;
00094   i1=i0;
00095   i=1;
00096   for (k = 0 ;k < *nel; k++) {
00097       i0=i0+1;
00098       while (i0-i1 > lln[i-1]) {
00099           i1=i0;
00100           i=i+1;
00101           i0=i0+1;
00102       }
00103       j=col[k];
00104       pelement = spGetElement((char*) *fmat,i,j);
00105       if (pelement == 0) {
00106           *ierr=2;
00107           return;
00108       }
00109       spADD_REAL_ELEMENT(pelement,(spREAL)(val[k]));
00110 
00111   }
00112   /* Fix the AbsThresold with scilex %eps */
00113   spFixThresold((char*) *fmat,*eps,*releps);
00114   /* spPrint((char *) *fmat,1,1,1); */
00115   error = spFactor((char*) *fmat);
00116   spGetNumRank((char *) *fmat,nrank);
00117   switch (error) {
00118   case spZERO_DIAG:
00119     cerro("zero_diag: A zero was encountered on the diagonal the matrix ");
00120     break;
00121   case spNO_MEMORY:
00122     *ierr=3;
00123     break;
00124   case spSINGULAR:
00125     *ierr=-1; /*Singular matrix" */
00126     break;
00127   case spSMALL_PIVOT:
00128     *ierr=-2; /* matrix is singular at precision level */
00129     break;
00130   }
00131 }

Here is the call graph for this function:

void C2F() luget1 ( long fmat,
int indP,
double *  P,
int indl,
double*  l,
int indu,
double*  u,
int indQ,
double*  Q 
)

Definition at line 315 of file lu.c.

References l, P, and spLuget().

00319 {
00320   spLuget((char *) *fmat,indP,P,indl,l,indu,u,indQ,Q);
00321 }

Here is the call graph for this function:

void C2F() lusiz1 ( long fmat,
int lsize,
int usize 
)

Definition at line 355 of file lu.c.

References spLusiz().

00358 {
00359   spLusiz((char *) *fmat,lsize,usize);
00360 }

Here is the call graph for this function:

void C2F() lusize ( long fmat,
int n 
)

Definition at line 173 of file lu.c.

References n, and spSize().

00176 {
00177   spSize((char *) *fmat,n);
00178 }

Here is the call graph for this function:

void C2F() lusolve1 ( long fmat,
double *  b,
double *  x 
)

Definition at line 141 of file lu.c.

References b, spREAL, spSolve(), and x.

00144 {
00145     spSolve((char*) *fmat,(spREAL*)b,(spREAL*)x);
00146 }

Here is the call graph for this function:

static void spFixThresold ( char *  eMatrix,
double  eps,
double  releps 
) [static]

Definition at line 56 of file lu.c.

Referenced by lufact1().

00059 {
00060   MatrixPtr  Matrix = (MatrixPtr)eMatrix;
00061   Matrix->AbsThreshold = eps;
00062   Matrix->RelThreshold = releps;
00063 }

Here is the caller graph for this function:

static void spGetNumRank ( char *  eMatrix,
int n 
) [static]

Definition at line 67 of file lu.c.

Referenced by lufact1().

00070 {
00071   MatrixPtr  Matrix = (MatrixPtr)eMatrix;
00072   *n = Matrix->NumRank;
00073 }

Here is the caller graph for this function:

static void spLuget ( char *  eMatrix,
int indP,
double *  P,
int indl,
double*  l,
int indu,
double*  u,
int indQ,
double*  Q 
) [static]

Definition at line 260 of file lu.c.

References MatrixElement::Col, GetSigD(), GetSigG(), I, MatrixElement::NextInRow, NULL, and MatrixElement::Real.

Referenced by luget1().

00264 {
00265 int I,J;
00266 int lsize,usize;
00267 
00268 MatrixPtr Matrix = (MatrixPtr) eMatrix;
00269 ElementPtr  pElement;
00270 int Size;
00271 Size = Matrix->Size;
00272 GetSigD(Matrix,indQ,Q);
00273 GetSigG(Matrix,indP,P);
00274 for (J = 1; J <= Size ; J++)
00275   {
00276     indl[J-1] = 0;
00277     indu[J-1] = 0;
00278 }
00279 lsize=0;
00280 usize=0;
00281 for (I = 1; I <= Size ; I++)
00282   {
00283     indu[I-1]=indu[I-1]+1;
00284     indu[Size+usize]=I;
00285     u[usize]=1.0;
00286     usize=usize+1;
00287 
00288     pElement = Matrix->FirstInRow[I];
00289     while ( pElement != NULL )
00290       {
00291           J = pElement->Col;
00292           if (I >= J) {
00293               indl[I-1] = indl[I-1]+1;
00294               indl[Size+lsize]=J;
00295               l[lsize]=(double) pElement->Real ;
00296               lsize=lsize+1;
00297 
00298           }
00299           else {
00300               indu[I-1] = indu[I-1]+1;
00301               indu[Size+usize]=J;
00302               u[usize]=(double) pElement->Real ;
00303               usize=usize+1;
00304 
00305           }
00306         pElement = pElement->NextInRow;
00307       };
00308   };
00309 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void spLusiz ( char *  eMatrix,
int lsize,
int usize 
) [static]

Definition at line 331 of file lu.c.

References MatrixElement::NextInCol, NULL, and MatrixElement::Row.

Referenced by lusiz1().

00334 {
00335 int J;
00336 MatrixPtr Matrix = (MatrixPtr) eMatrix;
00337 ElementPtr  pElement;
00338 int Size;
00339 Size = Matrix->Size;
00340 *lsize=0;
00341 *usize=Size;
00342 for (J = 1; J <= Size ; J++)
00343   {
00344     pElement = Matrix->FirstInCol[J];
00345     while ( pElement != NULL )
00346       {
00347         if (pElement->Row >= J) 
00348             *lsize=*lsize+1;
00349         else
00350             *usize=*usize+1;
00351         pElement = pElement->NextInCol;
00352     };
00353   };
00354 }  

Here is the caller graph for this function:

static void spSize ( char *  eMatrix,
int n 
) [static]

Definition at line 165 of file lu.c.

Referenced by lusize().

00168 {
00169   MatrixPtr  Matrix = (MatrixPtr)eMatrix;
00170   *n=Matrix->Size;
00171 }

Here is the caller graph for this function:


Generated on Sun Mar 4 16:12:54 2007 for Scilab [trunk] by  doxygen 1.5.1