📄 spcombin.c.rxr
字号:
/* * MATRIX UTILITY MODULE * * Author: Advising professor: * Kenneth S. Kundert Alberto Sangiovanni-Vincentelli * UC Berkeley * * This file contains various optional utility routines. * * >>> User accessible functions contained in this file: * spCombine * * >>> Other functions contained in this file: *//* * Revision and copyright information. * * Copyright (c) 1985,86,87,88,89,90 * by Kenneth S. Kundert and the University of California. * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby granted, * provided that the copyright notices appear in all copies and * supporting documentation and that the authors and the University of * California are properly credited. The authors and the University of * California make no representations as to the suitability of this * software for any purpose. It is provided `as is', without express * or implied warranty. */#ifdef notdefstatic char copyright[] = "Sparse1.3: Copyright (c) 1985,86,87,88,89,90 by Kenneth S. Kundert";static char RCSid[] = "@(#)$Header: spUtils.c,v 1.3 88/06/24 05:03:37 kundert Exp $";#endif/* * IMPORTS * * >>> Import descriptions: * spConfig.h * Macros that customize the sparse matrix routines. * spMatrix.h * Macros and declarations to be imported by the user. * spDefs.h * Matrix type and macro definitions for the sparse matrix routines. */#define spINSIDE_SPARSE#include "spconfig.h"#include "spmatrix.h"#include "spdefs.h"#ifdef PARALLEL_ARCH#define COMBINE 1#endif /* PARALLEL_ARCH */#if COMBINE#ifdef __STDC__#if spSEPARATED_COMPLEX_VECTORSstatic void CombineComplexMatrix( MatrixPtr, RealVector, RealVector, RealVector, RealVector );#elsestatic void CombineComplexMatrix( MatrixPtr, RealVector, RealVector );#endifstatic void ClearBuffer( MatrixPtr, int, int, ElementPtr );static void ClearComplexBuffer( MatrixPtr, int, int, ElementPtr );#else /* __STDC__ */static void CombineComplexMatrix();static void ClearBuffer();static void ClearComplexBuffer();#endif /* __STDC__ *//* * COMBINE MATRICES ON A MULTIPROCESSOR * * >>> Arguments: * eMatrix <input> (char *) * Pointer to the matrix to be combined. * * >>> Local variables: * Size (int) * Local version of the size of the matrix. * pElement (ElementPtr) * Pointer to an element in the matrix. */voidspCombine( eMatrix, RHS, Spare IMAG_VECTORS )char *eMatrix;RealVector RHS, Spare IMAG_VECTORS;{MatrixPtr Matrix = (MatrixPtr)eMatrix;register ElementPtr pElement;register int I, Size;int numElems;RealVector Buffer;long type = MT_COMBINE, length = Matrix->Size + 1;/* Begin `spCombine'. */ ASSERT( IS_VALID(Matrix) AND NOT Matrix->Factored ); if (NOT Matrix->RowsLinked) spcLinkRows( Matrix ); if (NOT Matrix->InternalVectorsAllocated) spcCreateInternalVectors( Matrix );#if spCOMPLEX if (Matrix->Complex) CombineComplexMatrix( Matrix, RHS, Spare IMAG_VECTORS );#endif#if REAL Buffer = Matrix->Intermediate; Size = Matrix->Size; for (I = 1; I <= Size; I++) {/* Gather row into dense vector. */ numElems = 0; pElement = Matrix->FirstInRow[I]; while (pElement != NULL) { Buffer[ numElems++ ] = pElement->Real; pElement = pElement->NextInRow; }/* Combine all the local copies. */ DGOP_( &type, (double *)Buffer, &numElems, "+" );/* Scatter back into the sparse matrix. */ numElems = 0; pElement = Matrix->FirstInRow[I]; while (pElement != NULL) { pElement->Real = Buffer[ numElems++ ]; pElement = pElement->NextInRow; } }/* Sum all RHS's together */ DGOP_( &type, RHS, &length, "+" ); return;#endif /* REAL */}#if spCOMPLEXstatic voidCombineComplexMatrix( Matrix, RHS, Spare IMAG_VECTORS )MatrixPtr Matrix;RealVector RHS, Spare IMAG_VECTORS;{register ElementPtr pElement;register int I, Size;int numElems;register RealVector Buffer;long type = MT_COMBINE, length = Matrix->Size + 1;/* Begin `CombineComplexMatrix'. */ ASSERT(Matrix->Complex); Buffer = Matrix->Intermediate; Size = Matrix->Size; for (I = 1; I <= Size; I++) {/* Gather row into dense vector. */ numElems = 0; pElement = Matrix->FirstInRow[I]; while (pElement != NULL) { Buffer[ numElems++ ] = pElement->Real; Buffer[ numElems++ ] = pElement->Imag; pElement = pElement->NextInRow; }/* Combine all the local copies. */ DGOP_( &type, (double *)Buffer, &numElems, "+" );/* Scatter back into the sparse matrix. */ numElems = 0; pElement = Matrix->FirstInRow[I]; while (pElement != NULL) { pElement->Real = Buffer[ numElems++ ]; pElement->Imag = Buffer[ numElems++ ]; pElement = pElement->NextInRow; } }/* Sum all RHS's together */#if spSEPARATED_COMPLEX_VECTORS DGOP_( &type, RHS, &length, "+" ); DGOP_( &type, iRHS, &length, "+" );#else length *= 2; DGOP_( &type, RHS, &length, "+" );#endif return;}#endif /* spCOMPLEX */#endif /* COMBINE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -