Example #1
0
void
spSolveTransposed( char *eMatrix, RealVector  RHS, RealVector  Solution IMAG_VECTORS )
{
    MatrixPtr  Matrix = (MatrixPtr)eMatrix;
    register  ElementPtr  pElement;
    register  RealVector  Intermediate;
    register  int  I, *pExtOrder, Size;
    ElementPtr  pPivot;
    RealNumber  Temp;


    /* Begin `spSolveTransposed'. */
    ASSERT( IS_VALID(Matrix) AND IS_FACTORED(Matrix) );

#if spCOMPLEX
    if (Matrix->Complex)
    {
        SolveComplexTransposedMatrix( Matrix, RHS, Solution IMAG_VECTORS );
        return;
    }
#endif

#if REAL
    Size = Matrix->Size;
    Intermediate = Matrix->Intermediate;

    /* Correct array pointers for ARRAY_OFFSET. */
#if NOT ARRAY_OFFSET
    --RHS;
    --Solution;
#endif

    /* Initialize Intermediate vector. */
    pExtOrder = &Matrix->IntToExtColMap[Size];
    for (I = Size; I > 0; I--)
    {
        Intermediate[I] = RHS[*(pExtOrder--)];
    }

    /* Forward elimination. */
    for (I = 1; I <= Size; I++)
    {
        /* This step of the elimination is skipped if Temp equals zero. */
        if ((Temp = Intermediate[I]) != 0.0)
        {
            pElement = Matrix->Diag[I]->NextInRow;
            while (pElement != NULL)
            {
                Intermediate[pElement->Col] -= Temp * pElement->Real;
                pElement = pElement->NextInRow;
            }

        }
    }

    /* Backward Substitution. */
    for (I = Size; I > 0; I--)
    {
        pPivot = Matrix->Diag[I];
        Temp = Intermediate[I];
        pElement = pPivot->NextInCol;
        while (pElement != NULL)
        {
            Temp -= pElement->Real * Intermediate[pElement->Row];
            pElement = pElement->NextInCol;
        }
        Intermediate[I] = Temp * pPivot->Real;
    }

    /* Unscramble Intermediate vector while placing data in to Solution vector. */
    pExtOrder = &Matrix->IntToExtRowMap[Size];
    for (I = Size; I > 0; I--)
    {
        Solution[*(pExtOrder--)] = Intermediate[I];
    }

    return;
#endif /* REAL */
}
Example #2
0
void
spSolveTransposed(MatrixPtr Matrix, RealVector RHS, RealVector Solution,
		  RealVector iRHS, RealVector iSolution)
{
    ElementPtr  pElement;
    RealVector  Intermediate;
    int  I, *pExtOrder, Size;
    ElementPtr  pPivot;
    RealNumber  Temp;

    /* Begin `spSolveTransposed'. */
    assert( IS_VALID(Matrix) && IS_FACTORED(Matrix) );

    if (Matrix->Complex)
    {
	SolveComplexTransposedMatrix( Matrix, RHS, Solution , iRHS, iSolution );
        return;
    }

    Size = Matrix->Size;
    Intermediate = Matrix->Intermediate;

    /* Initialize Intermediate vector. */
    pExtOrder = &Matrix->IntToExtColMap[Size];
    for (I = Size; I > 0; I--)
        Intermediate[I] = RHS[*(pExtOrder--)];

    /* Forward elimination. */
    for (I = 1; I <= Size; I++)
    {
   
	/* This step of the elimination is skipped if Temp equals zero. */
        if ((Temp = Intermediate[I]) != 0.0)
        {
	    pElement = Matrix->Diag[I]->NextInRow;
            while (pElement != NULL)
            {
		Intermediate[pElement->Col] -= Temp * pElement->Real;
                pElement = pElement->NextInRow;
            }

        }
    }

    /* Backward Substitution. */
    for (I = Size; I > 0; I--)
    {
	pPivot = Matrix->Diag[I];
        Temp = Intermediate[I];
        pElement = pPivot->NextInCol;
        while (pElement != NULL)
        {
	    Temp -= pElement->Real * Intermediate[pElement->Row];
            pElement = pElement->NextInCol;
        }
        Intermediate[I] = Temp * pPivot->Real;
    }

    /* Unscramble Intermediate vector while placing data in to
       Solution vector. */
    pExtOrder = &Matrix->IntToExtRowMap[Size];
    for (I = Size; I > 0; I--)
        Solution[*(pExtOrder--)] = Intermediate[I];

    return;
}