1 /*
2  *  MATRIX COMPATIBILITY MODULE
3  *
4  *  Author:                     Advising professor:
5  *     Kenneth S. Kundert           Alberto Sangiovanni-Vincentelli
6  *     UC Berkeley
7  *
8  *  This module contains routines that make Sparse1.3 upward compatible
9  *  from Sparse1.2.  These routines are not suggested for use in new
10  *  software.
11  *
12  *  >>> User accessible functions contained in this file:
13  *  AllocateMatrix
14  *  DeallocateMatrix
15  *  CleanMatrix
16  *  ClearMatrix
17  *  AddElementToMatrix
18  *  AddRealElementToMatrix
19  *  AddImagElementToMatrix
20  *  AddComplexElementToMatrix
21  *  AddAdmittanceToMatrix
22  *  AddQuadToMatrix
23  *  AddOnesToMatrix
24  *  AddRealQuadElementToMatrix
25  *  AddImagQuadElementToMatrix
26  *  AddComplexQuadElementToMatrix
27  *  OrderAndDecomposeMatrix
28  *  DecomposeMatrix
29  *  SolveMatrix
30  *  SolveTransposedMatrix
31  *  DeleteRowAndColFromMatrix
32  *  PrintMatrix
33  *  OutputMatrixToFile
34  *  PreorderForModifiedNodal
35  *  ScaleMatrix
36  *  MultiplyMatrix
37  *  Determinant
38  *  MatrixRoundoffError
39  *  MatrixError
40  *  ClearMatrixError
41  *  GetMatrixSize
42  *  SetMatrixReal
43  *  SetMatrixComplex
44  *  MatrixFillinCount
45  *  MatrixElementCount
46  */
47 
48 
49 /*
50  *  Revision and copyright information.
51  *
52  *  Copyright (c) 1985,86,87,88
53  *  by Kenneth S. Kundert and the University of California.
54  *
55  *  Permission to use, copy, modify, and distribute this software and its
56  *  documentation for any purpose and without fee is hereby granted, provided
57  *  that the above copyright notice appear in all copies and supporting
58  *  documentation and that the authors and the University of California
59  *  are properly credited.  The authors and the University of California
60  *  make no representations as to the suitability of this software for
61  *  any purpose.  It is provided `as is', without express or implied warranty.
62  */
63 
64 #ifndef lint
65 static char copyright[] =
66     "Sparse1.3: Copyright (c) 1985,86,87,88 by Kenneth S. Kundert";
67 static char RCSid[] =
68     "@(#)$Header: spCompat.c,v 1.3 88/06/24 05:00:47 kundert Exp $";
69 #endif
70 
71 
72 
73 
74 /*
75  *  IMPORTS
76  *
77  *  >>> Import descriptions:
78  *  spConfig.h
79  *     Macros that customize the sparse matrix routines.
80  *  spMatrix.h
81  *     Macros and declarations to be imported by the user.
82  *  spDefs.h
83  *     Matrix type and macro definitions for the sparse matrix routines.
84  */
85 
86 #define spINSIDE_SPARSE
87 #include "spConfig.h"
88 #if spCOMPATIBILITY
89 #include "spMatrix.h"
90 #include "spDefs.h"
91 
92 #ifdef ultrix
93 extern void perror();
94 #endif
95 
96 
97 
98 /*
99  * FILE NAME DEFINITIONS
100  */
101 
102 #define  MATRIX_FILE            "./matrix"
103 #define  STATISTICS_FILE        "./stats"
104 
105 
106 
107 
108 /*
109  * ALLOCATE MATRIX
110  */
111 
112 char *
AllocateMatrix(Size,Complex,pError)113 AllocateMatrix( Size, Complex, pError )
114 
115 int Size, *pError;
116 BOOLEAN Complex;
117 {
118 /* Begin `AllocateMatrix'. */
119     return spCreate( Size, Complex, pError );
120 }
121 
122 
123 
124 
125 
126 /*
127  * DESTROY MATRIX
128  */
129 
130 void
DeallocateMatrix(Matrix)131 DeallocateMatrix( Matrix )
132 
133 char *Matrix;
134 {
135 /* Begin `DeallocateMatrix'. */
136     spDestroy( Matrix );
137     return;
138 }
139 
140 
141 
142 
143 
144 #if STRIP
145 /*
146  * CLEAN MATRIX
147  */
148 
149 void
CleanMatrix(Matrix)150 CleanMatrix( Matrix )
151 
152 char *Matrix;
153 {
154 /* Begin `CleanMatrix'. */
155     spStripFills( Matrix );
156     return;
157 }
158 #endif
159 
160 
161 
162 
163 
164 /*
165  * CLEAR MATRIX
166  */
167 
168 void
ClearMatrix(Matrix)169 ClearMatrix( Matrix )
170 
171 char *Matrix;
172 {
173 /* Begin `ClearMatrix'. */
174     spClear( Matrix );
175     return;
176 }
177 
178 
179 
180 
181 
182 
183 /*
184  *  SINGLE ELEMENT ADDITION TO MATRIX BY INDEX
185  */
186 
187 /*VARARGS4*/
188 
189 RealNumber *
AddElementToMatrix(Matrix,Row,Col,Real,Imag)190 AddElementToMatrix( Matrix, Row, Col, Real, Imag )
191 
192 char *Matrix;
193 int  Row, Col;
194 RealNumber  Real, Imag;
195 {
196 RealNumber  *pElement;
197 
198 /* Begin `AddElementToMatrix'. */
199     pElement = spGetElement( Matrix, Row, Col );
200 
201 /* Add Data to element. */
202     spADD_REAL_ELEMENT( pElement, Real );
203 #if spCOMPLEX
204     if (((MatrixPtr)Matrix)->Complex)
205         spADD_IMAG_ELEMENT( pElement, Imag );
206 #endif
207 
208     return pElement;
209 }
210 
211 
212 
213 
214 
215 
216 
217 /*
218  *  ADD ELEMENT TO MATRIX BY POINTER ROUTINES
219  *
220  *  These routines add elements to the matrix using pointers.  There use
221  *  is discouraged if the calling program is written in C.  If that is the
222  *  case, then the equivalent macros should be used.  These routines are
223  *  functionally equivalent to the macros, but will be slower.
224  *
225  *  >>> Arguments:
226  *  Element  <input>  (RealNumber *)
227  *     Pointer to the element that the data is to be added to.
228  *  Real  <input>  (RealNumber)
229  *     Real data to be added to elements.
230  *  Imag  <input>  (RealNumber)
231  *     Imag data to be added to elements.  If matrix is real, this argument
232  *     may be deleted.
233  */
234 
235 void
AddRealElementToMatrix(Element,Real)236 AddRealElementToMatrix( Element, Real )
237 
238 RealNumber *Element;
239 RealNumber  Real;
240 {
241 /* Begin `AddRealElementToMatrix'. */
242 
243    spADD_REAL_ELEMENT( Element, Real );
244    return;
245 }
246 
247 
248 
249 #if spCOMPLEX
250 
251 void
AddImagElementToMatrix(Element,Imag)252 AddImagElementToMatrix( Element, Imag )
253 
254 RealNumber *Element;
255 RealNumber  Imag;
256 {
257 /* Begin `AddImagElementToMatrix'. */
258 
259    spADD_IMAG_ELEMENT( Element, Imag );
260    return;
261 }
262 
263 
264 
265 
266 void
AddComplexElementToMatrix(Element,Real,Imag)267 AddComplexElementToMatrix( Element, Real, Imag )
268 
269 RealNumber *Element;
270 RealNumber  Real, Imag;
271 {
272 /* Begin `AddComplexElementToMatrix'. */
273 
274    spADD_COMPLEX_ELEMENT( Element, Real, Imag );
275    return;
276 }
277 
278 #endif
279 
280 
281 
282 
283 
284 
285 
286 
287 #if QUAD_ELEMENT
288 /*
289  *  ADDITION OF ADMITTANCE TO MATRIX BY INDEX
290  */
291 
292 /*VARARGS5*/
293 
294 void
AddAdmittanceToMatrix(Matrix,Node1,Node2,Template,Real,Imag)295 AddAdmittanceToMatrix( Matrix, Node1, Node2, Template, Real, Imag )
296 
297 char  *Matrix;
298 int  Node1, Node2;
299 struct  spTemplate  *Template;
300 RealNumber  Real, Imag;
301 {
302 /* Begin `AddAdmittanceToMatrix'. */
303     Template->Element1 = spGetElement( Matrix, Node1, Node1 );
304     Template->Element2 = spGetElement( Matrix, Node2, Node2 );
305     Template->Element3Negated = spGetElement( Matrix, Node2, Node1 );
306     Template->Element4Negated = spGetElement( Matrix, Node1, Node2 );
307 
308     if (Node1 == 0)
309         SWAP( RealNumber *, Template->Element1, Template->Element2 );
310 
311 /* Add Data to elements. */
312     spADD_REAL_QUAD( *Template, Real );
313 #if spCOMPLEX
314     if (((MatrixPtr)Matrix)->Complex)
315         spADD_IMAG_QUAD( *Template, Imag );
316 #endif
317 
318     return;
319 }
320 #endif /* QUAD_ELEMENT */
321 
322 
323 
324 
325 
326 
327 
328 
329 
330 #if QUAD_ELEMENT
331 /*
332  *  ADDITION OF FOUR ELEMENTS TO MATRIX BY INDEX
333  */
334 
335 /*VARARGS7*/
336 
337 void
AddQuadToMatrix(Matrix,Row1,Row2,Col1,Col2,Template,Real,Imag)338 AddQuadToMatrix( Matrix, Row1, Row2, Col1, Col2, Template, Real, Imag )
339 
340 char  *Matrix;
341 int  Row1, Row2, Col1, Col2;
342 struct  spTemplate  *Template;
343 RealNumber  Real, Imag;
344 {
345 /* Begin `AddQuadToMatrix'. */
346     Template->Element1 = spGetElement( Matrix, Row1, Col1 );
347     Template->Element2 = spGetElement( Matrix, Row2, Col2 );
348     Template->Element3Negated = spGetElement( Matrix, Row2, Col1 );
349     Template->Element4Negated = spGetElement( Matrix, Row1, Col2 );
350 
351     if (Template->Element1 == &((MatrixPtr)Matrix)->TrashCan.Real)
352         SWAP( RealNumber *, Template->Element1, Template->Element2 );
353 
354 /* Add Data to elements. */
355     spADD_REAL_QUAD( *Template, Real );
356 #if spCOMPLEX
357     if (((MatrixPtr)Matrix)->Complex)
358         spADD_IMAG_QUAD( *Template, Imag );
359 #endif
360 
361     return;
362 }
363 #endif /* QUAD_ELEMENT */
364 
365 
366 
367 
368 
369 
370 
371 
372 
373 #if QUAD_ELEMENT
374 /*
375  *  ADDITION OF FOUR STRUCTURAL ONES TO MATRIX BY INDEX
376  *
377  *  Performs similar function to AddQuadToMatrix except this routine is
378  *  meant for components that do not have an admittance representation.
379  *
380  *  The following stamp is used:
381  *         Pos  Neg  Eqn
382  *  Pos  [  .    .    1  ]
383  *  Neg  [  .    .   -1  ]
384  *  Eqn  [  1   -1    .  ]
385  *
386  *  >>> Arguments:
387  *  Matrix  <input>  (char *)
388  *     Pointer to the matrix that component is to be entered in.
389  *  Pos  <input>  (int)
390  *     See stamp above. Must be in the range of [0..Size]
391  *     unless the options EXPANDABLE or TRANSLATE are used. Zero is the
392  *     ground row.  In no case may Pos be less than zero.
393  *  Neg  <input>  (int)
394  *     See stamp above. Must be in the range of [0..Size]
395  *     unless the options EXPANDABLE or TRANSLATE are used. Zero is the
396  *     ground row.  In no case may Neg be less than zero.
397  *  Eqn  <input>  (int)
398  *     See stamp above. Must be in the range of [0..Size]
399  *     unless the options EXPANDABLE or TRANSLATE are used. Zero is the
400  *     ground row.  In no case may Eqn be less than zero.
401  *  Template  <output>  (struct spTemplate *)
402  *     Collection of pointers to four elements that are later used to directly
403  *     address elements.  User must supply the template, this routine will
404  *     fill it.
405  *
406  *  Possible errors:
407  *  NO_MEMORY
408  *  RANGE
409  *  Error is not cleared in this routine.
410  */
411 
412 void
AddOnesToMatrix(Matrix,Pos,Neg,Eqn,Template)413 AddOnesToMatrix(Matrix, Pos, Neg, Eqn, Template)
414 
415 char  *Matrix;
416 int  Pos, Neg, Eqn;
417 struct  spTemplate  *Template;
418 {
419 /* Begin `AddOnesToMatrix'. */
420     Template->Element4Negated = spGetElement( Matrix, Neg, Eqn );
421     Template->Element3Negated = spGetElement( Matrix, Eqn, Neg );
422     Template->Element2 = spGetElement( Matrix, Pos, Eqn );
423     Template->Element1 = spGetElement( Matrix, Eqn, Pos );
424 
425     spADD_REAL_QUAD( *Template, 1.0 );
426     return;
427 }
428 #endif /* QUAD_ELEMENT */
429 
430 
431 
432 
433 
434 
435 
436 
437 
438 
439 
440 
441 #if QUAD_ELEMENT
442 /*
443  *  QUADRUPLE REAL ELEMENT ADDITION TO MATRIX BY POINTER
444  *
445  *  Adds Data to four real elements specified by the Template.
446  *  It is better to use the equivalent macro.
447  *
448  *  >>> Arguments:
449  *  Template  <input>  (struct spTemplate *)
450  *     Pointer to the group of pointers to four elements.
451  *  Real  <input>  (RealNumber)
452  *     Real data to be added to elements.
453  */
454 
455 void
AddRealQuadElementToMatrix(Template,Real)456 AddRealQuadElementToMatrix( Template, Real )
457 
458 struct  spTemplate  *Template;
459 RealNumber  Real;
460 {
461 /* Begin `AddRealQuadElementToMatrix'. */
462     spADD_REAL_QUAD( *Template, Real );
463     return;
464 }
465 #endif /* QUAD_ELEMENT */
466 
467 
468 
469 
470 
471 
472 
473 
474 
475 
476 
477 #if QUAD_ELEMENT AND spCOMPLEX
478 /*
479  *  QUADRUPLE IMAGINARY ELEMENT ADDITION TO MATRIX BY POINTER
480  *
481  *  Adds data to four imaginary elements specified by the Template.
482  *  It is better to use the equivalent macro.
483  *
484  *  >>> Arguments:
485  *  Template  <input>  (struct spTemplate *)
486  *     Pointer to the group of pointers to four elements.
487  *  Imag  <input>  (RealNumber)
488  *     Imaginary data to be added to elements.
489  */
490 
491 void
AddImagQuadElementToMatrix(Template,Imag)492 AddImagQuadElementToMatrix( Template, Imag )
493 
494 struct  spTemplate  *Template;
495 RealNumber  Imag;
496 {
497 /* Begin `AddImagQuadElementToMatrix'. */
498     spADD_IMAG_QUAD( *Template, Imag );
499     return;
500 }
501 #endif /* QUAD_ELEMENT AND spCOMPLEX */
502 
503 
504 
505 
506 
507 
508 
509 
510 
511 
512 
513 #if QUAD_ELEMENT AND spCOMPLEX
514 /*
515  *  QUADRUPLE COMPLEX ELEMENT ADDITION TO MATRIX BY POINTER
516  *
517  *  Adds Data to four complex elements specified by the Template.
518  *  It is better to use the equivalent macro.
519  *
520  *  >>> Arguments:
521  *  Template  <input>  (struct spTemplate *)
522  *     Pointer to the group of pointers to four elements.
523  *  Real  <input>  (RealNumber)
524  *     Real data to be added to elements.
525  *  Imag  <input>  (RealNumber)
526  *     Imaginary data to be added to elements.
527  */
528 
529 void
AddComplexQuadElementToMatrix(Template,Real,Imag)530 AddComplexQuadElementToMatrix( Template, Real, Imag )
531 
532 struct  spTemplate  *Template;
533 RealNumber  Real, Imag;
534 {
535 /* Begin `AddComplexQuadElementToMatrix'. */
536     spADD_COMPLEX_QUAD( *Template, Real, Imag );
537     return;
538 }
539 #endif /* QUAD_ELEMENT AND spCOMPLEX */
540 
541 
542 
543 
544 
545 /*
546  *   ORDER AND DECOMPOSE MATRIX
547  */
548 
549 #if NOT STABILITY AND NOT PSEUDOCONDITION
550 /*VARARGS4*/
551 #endif
552 
553 int
OrderAndDecomposeMatrix(eMatrix,RHS,RelThreshold,AbsThreshold,Growth,PseudoCondition,LargestElement)554 OrderAndDecomposeMatrix( eMatrix, RHS, RelThreshold, AbsThreshold,
555                          Growth, PseudoCondition, LargestElement )
556 
557 char *eMatrix;
558 RealNumber  RHS[], RelThreshold, AbsThreshold;
559 RealNumber  *Growth, *PseudoCondition, *LargestElement;
560 {
561 int Error;
562 RealNumber LargestBefore, LargestAfter;
563 
564 /* Begin `OrderAndDecomposeMatrix'. */
565 
566 #if STABILITY
567     LargestBefore = spLargestElement( eMatrix );
568 #endif
569     Error = spOrderAndFactor( eMatrix, RHS, RelThreshold, AbsThreshold, YES );
570     if (Error >= FATAL) return Error;
571 #if PSEUDOCONDITION
572     if (PseudoCondition != NULL) *PseudoCondition = spPseudoCondition(eMatrix);
573 #endif
574 #if STABILITY
575     LargestAfter = spLargestElement( eMatrix );
576     if (Growth != NULL)
577     {   if (LargestBefore != 0.0)
578             *Growth = LargestAfter/LargestBefore;
579         else
580             *Growth = 0.0;
581     }
582     if (LargestElement != NULL) *LargestElement = LargestAfter;
583 #endif
584     return Error;
585 }
586 
587 
588 
589 
590 /*
591  *   DECOMPOSE MATRIX
592  */
593 
594 #if NOT STABILITY AND NOT PSEUDOCONDITION
595 /*VARARGS1*/
596 #endif
597 
598 int
DecomposeMatrix(eMatrix,Growth,PseudoCondition,LargestElement)599 DecomposeMatrix( eMatrix, Growth, PseudoCondition, LargestElement )
600 
601 RealNumber  *Growth, *PseudoCondition, *LargestElement;
602 char *eMatrix;
603 {
604 int Error;
605 RealNumber LargestBefore, LargestAfter;
606 
607 /* Begin `DecomposeMatrix'. */
608 
609 #if STABILITY
610     LargestBefore = spLargestElement( eMatrix );
611 #endif
612     Error = spFactor( eMatrix );
613     if (Error >= FATAL) return Error;
614 #if PSEUDOCONDITION
615     if (PseudoCondition != NULL) *PseudoCondition = spPseudoCondition(eMatrix);
616 #endif
617 #if STABILITY
618     LargestAfter = spLargestElement( eMatrix );
619     if (Growth != NULL)
620     {   if (LargestBefore != 0.0)
621             *Growth = LargestAfter/LargestBefore;
622         else
623             *Growth = 0.0;
624     }
625     if (LargestElement != NULL) *LargestElement = LargestAfter;
626 #endif
627     return Error;
628 }
629 
630 
631 
632 
633 
634 /*
635  *   SOLVE MATRIX
636  */
637 
638 /*VARARGS3*//*ARGSUSED*/
639 
640 void
SolveMatrix(eMatrix,RHS,Solution,iRHS,iSolution)641 SolveMatrix( eMatrix, RHS, Solution, iRHS, iSolution )
642 
643 char *eMatrix;
644 RealVector  RHS, Solution, iRHS, iSolution;
645 {
646 #if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
647     spSolve( eMatrix, RHS, Solution, iRHS, iSolution );
648 #else
649     spSolve( eMatrix, RHS, Solution );
650 #endif
651 }
652 
653 
654 #if TRANSPOSE
655 /*VARARGS3*//*ARGSUSED*/
656 
657 void
SolveTransposedMatrix(eMatrix,RHS,Solution,iRHS,iSolution)658 SolveTransposedMatrix( eMatrix, RHS, Solution, iRHS, iSolution )
659 
660 char *eMatrix;
661 RealVector  RHS, Solution, iRHS, iSolution;
662 {
663 #if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
664     spSolveTransposed( eMatrix, RHS, Solution, iRHS, iSolution );
665 #else
666     spSolveTransposed( eMatrix, RHS, Solution );
667 #endif
668 }
669 #endif
670 
671 
672 
673 
674 #if TRANSLATE AND DELETE
675 /*
676  *  DELETE A ROW AND COLUMN FROM THE MATRIX
677  */
678 
679 void
DeleteRowAndColFromMatrix(eMatrix,Row,Col)680 DeleteRowAndColFromMatrix( eMatrix, Row, Col )
681 
682 char *eMatrix;
683 int  Row, Col;
684 {
685     spDeleteRowAndCol( eMatrix, Row, Col );
686     return;
687 }
688 #endif
689 
690 
691 
692 
693 /*
694  *   PRINT MATRIX
695  */
696 
697 void
PrintMatrix(eMatrix,Compressed,PrintReordered)698 PrintMatrix( eMatrix, Compressed, PrintReordered )
699 
700 char *eMatrix;
701 BOOLEAN  Compressed, PrintReordered;
702 {
703     spPrint( eMatrix, PrintReordered, NOT Compressed, YES );
704 }
705 
706 
707 
708 
709 
710 /*
711  *  OUTPUT MATRIX TO FILE
712  */
713 
714 void
OutputMatrixToFile(eMatrix,Label,Reordered,Data,Header)715 OutputMatrixToFile( eMatrix, Label, Reordered, Data, Header )
716 
717 char *eMatrix, *Label;
718 BOOLEAN Reordered, Data, Header;
719 {
720 char ErrMsg[BUFSIZ];
721 
722 /* Begin `OutputMatrixToFile'. */
723 
724     if (NOT spFileMatrix( eMatrix, MATRIX_FILE, Label, Reordered, Data, Header))
725     {   (void)sprintf(ErrMsg, "sparse: file `%s'", MATRIX_FILE);
726         perror( ErrMsg );
727     }
728     return;
729 }
730 
731 
732 
733 
734 /*
735  *  OUTPUT VECTOR TO FILE
736  */
737 /*VARARGS*//*ARGSUSED*/
738 
739 void
OutputVectorToFile(eMatrix,RHS,iRHS)740 OutputVectorToFile( eMatrix, RHS, iRHS )
741 
742 char *eMatrix;
743 RealVector RHS, iRHS;
744 {
745 char ErrMsg[BUFSIZ];
746 
747 /* Begin `OutputVectorToFile'. */
748     if (RHS == NULL) return;
749 
750     if (NOT spFileVector( eMatrix, MATRIX_FILE, RHS IMAG_RHS ))
751     {   (void)sprintf(ErrMsg, "sparse: file `%s'", MATRIX_FILE);
752         perror( ErrMsg );
753     }
754     return;
755 }
756 
757 
758 
759 
760 /*
761  *  OUTPUT STATISTICS TO FILE
762  */
763 
764 void
OutputStatisticsToFile(eMatrix,Label)765 OutputStatisticsToFile( eMatrix, Label )
766 
767 char *eMatrix, *Label;
768 {
769 char ErrMsg[BUFSIZ];
770 extern int pFileStats;
771 
772 /* Begin `OutputStatisticsToFile'. */
773 
774     if (NOT spFileStats( eMatrix, STATISTICS_FILE, Label ))
775     {   (void)sprintf(ErrMsg, "sparse: file `%s'", STATISTICS_FILE);
776         perror( ErrMsg );
777     }
778     return;
779 }
780 
781 
782 
783 
784 
785 #if MODIFIED_NODAL
786 /*
787  *  PREORDER MODIFIED NODE ADMITTANCE MATRIX TO REMOVE ZEROS FROM DIAGONAL
788  */
789 
790 void
PreorderForModifiedNodal(eMatrix)791 PreorderForModifiedNodal( eMatrix )
792 
793 char *eMatrix;
794 {
795 /* Begin `PreorderForModifiedNodal'. */
796 
797     spMNA_Preorder( eMatrix );
798 }
799 #endif
800 
801 
802 
803 
804 
805 
806 #if SCALING
807 /*
808  *  SCALE MATRIX
809  */
810 
811 void
ScaleMatrix(eMatrix,RHS_ScaleFactors,SolutionScaleFactors)812 ScaleMatrix( eMatrix, RHS_ScaleFactors, SolutionScaleFactors )
813 
814 char *eMatrix;
815 RealVector  RHS_ScaleFactors, SolutionScaleFactors;
816 {
817 /* Begin `ScaleMatrix'. */
818 
819     spScale( eMatrix, RHS_ScaleFactors, SolutionScaleFactors );
820 }
821 #endif
822 
823 
824 
825 
826 
827 #if MULTIPLICATION
828 /*
829  *  MATRIX MULTIPLICATION
830  */
831  /*VARARGS3*//*ARGSUSED*/
832 
833 void
MatrixMultiply(eMatrix,RHS,Solution,iRHS,iSolution)834 MatrixMultiply( eMatrix, RHS, Solution, iRHS, iSolution )
835 
836 char *eMatrix;
837 RealVector RHS, Solution, iRHS, iSolution;
838 {
839 /* Begin `MatrixMultiply'. */
840 
841 #if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
842     spMultiply( eMatrix, RHS, Solution, iRHS, iSolution );
843 #else
844     spMultiply( eMatrix, RHS, Solution );
845 #endif
846 }
847 #endif
848 
849 
850 
851 
852 
853 #if DETERMINANT
854 /*
855  *   CALCULATE DETERMINANT
856  */
857 
858 void
Determinant(eMatrix,pExponent,pDeterminant,piDeterminant)859 Determinant (eMatrix, pExponent, pDeterminant, piDeterminant )
860 
861 char *eMatrix;
862 register  RealNumber *pDeterminant, *piDeterminant;
863 int  *pExponent;
864 {
865 /* Begin `Determinant'. */
866 
867 #if spCOMPLEX
868     spDeterminant (eMatrix, pExponent, pDeterminant, piDeterminant );
869 #else
870     spDeterminant (eMatrix, pExponent, pDeterminant );
871 #endif
872 }
873 #endif
874 
875 
876 
877 
878 
879 
880 #if STABILITY
881 /*
882  *  CALCULATE ROUNDOFF ERROR ESTIMATION
883  *
884  *  This function is not implemented.
885  */
886 
887 RealNumber
MatrixRoundoffError(eMatrix)888 MatrixRoundoffError( eMatrix )
889 
890 char *eMatrix;
891 {
892 /* Begin `MatrixRoundoffError'. */
893     return 0.0;
894 /*  return spRoundoff( eMatrix, Rho );  */
895 }
896 #endif
897 
898 
899 
900 
901 
902 
903 /*
904  *  RETURN MATRIX ERROR STATUS
905  */
906 
907 int
MatrixError(Matrix)908 MatrixError( Matrix )
909 
910 char  *Matrix;
911 {
912 /* Begin `MatrixError'. */
913 
914     return spError( Matrix );
915 }
916 
917 
918 
919 
920 
921 
922 /*
923  *  CLEAR MATRIX ERROR FLAG
924  */
925 
926 int
ClearMatrixError(Matrix)927 ClearMatrixError( Matrix )
928 
929 char  *Matrix;
930 {
931 int  Error;
932 
933 /* Begin `ClearMatrixError'. */
934     if (Matrix == NULL) return RANGE;
935     Error = ((MatrixPtr)Matrix)->Error;
936     ((MatrixPtr)Matrix)->Error = spOKAY;
937     return Error;
938 }
939 
940 
941 
942 
943 
944 
945 /*
946  *   MATRIX SIZE
947  */
948 
949 int
GetMatrixSize(Matrix,External)950 GetMatrixSize( Matrix, External )
951 
952 char  *Matrix;
953 BOOLEAN  External;
954 {
955 /* Begin `GetMatrixSize'. */
956 
957     return spGetSize( Matrix, External );
958 }
959 
960 
961 
962 
963 
964 
965 
966 /*
967  *   SET MATRIX COMPLEX OR REAL
968  */
969 
970 void
SetMatrixReal(Matrix)971 SetMatrixReal( Matrix )
972 
973 char *Matrix;
974 {
975 /* Begin `SetMatrixReal'. */
976 
977     spSetReal( Matrix );
978 }
979 
980 
981 void
SetMatrixComplex(Matrix)982 SetMatrixComplex( Matrix )
983 
984 char  *Matrix;
985 {
986 /* Begin `SetMatrixComplex'. */
987     spSetComplex( Matrix );
988 }
989 
990 
991 
992 
993 
994 
995 
996 
997 /*
998  *   ELEMENT OR FILL-IN COUNT
999  */
1000 
1001 int
MatrixFillinCount(Matrix)1002 MatrixFillinCount( Matrix )
1003 
1004 char *Matrix;
1005 {
1006 /* Begin `MatrixFillinCount'. */
1007     return spFillinCount( Matrix );
1008 }
1009 
1010 
1011 int
MatrixElementCount(Matrix)1012 MatrixElementCount( Matrix )
1013 
1014 char  *Matrix;
1015 {
1016 /* Begin `MatrixElementCount'. */
1017     return spElementCount( Matrix );
1018 }
1019 
1020 #endif /* spCOMPATIBILITY */
1021