home *** CD-ROM | disk | FTP | other *** search
-
- /**************************************************************************
- **
- ** Copyright (C) 1993 David E. Steward & Zbigniew Leyk, all rights reserved.
- **
- ** Meschach Library
- **
- ** This Meschach Library is provided "as is" without any express
- ** or implied warranty of any kind with respect to this software.
- ** In particular the authors shall not be liable for any direct,
- ** indirect, special, incidental or consequential damages arising
- ** in any way from use of the software.
- **
- ** Everyone is granted permission to copy, modify and redistribute this
- ** Meschach Library, provided:
- ** 1. All copies contain this copyright notice.
- ** 2. All modified copies shall carry a notice stating who
- ** made the last modification and the date of such modification.
- ** 3. No charge is made for this software or works derived from it.
- ** This clause shall not be construed as constraining other software
- ** distributed on the same medium as this software, nor is a
- ** distribution fee considered a charge.
- **
- ***************************************************************************/
-
-
- /*
- Band matrix factorisation routines
- */
-
- /* bdfactor.c 18/11/93 */
- static char rcsid[] = "$Id: bdfactor.c,v 1.5 1994/05/17 23:18:32 des Exp $";
-
- #include <stdio.h>
- #include <math.h>
- #include "matrix2.h"
-
-
- /* generate band matrix
- for a matrix with n columns,
- lb subdiagonals and ub superdiagonals;
-
- Way of saving a band of a matrix:
- first we save subdiagonals (from 0 to lb-1);
- then main diagonal (in the lb row)
- and then superdiagonals (from lb+1 to lb+ub)
- in such a way that the elements which were previously
- in one column are now also in one column
- */
-
- BAND *bd_get(lb,ub,n)
- int lb, ub, n;
- {
- BAND *A;
-
- if (lb < 0 || ub < 0 || n <= 0)
- error(E_NEG,"bd_get");
-
- if ((A = NEW(BAND)) == (BAND *)NULL)
- error(E_MEM,"bd_get");
- else if (mem_info_is_on()) {
- mem_bytes(TYPE_BAND,0,sizeof(BAND));
- mem_numvar(TYPE_BAND,1);
- }
-
- lb = A->lb = min(n-1,lb);
- ub = A->ub = min(n-1,ub);
- A->mat = m_get(lb+ub+1,n);
- return A;
- }
-
- int bd_free(A)
- BAND *A;
- {
- if ( A == (BAND *)NULL || A->lb < 0 || A->ub < 0 )
- /* don't trust it */
- return (-1);
-
- if (A->mat) m_free(A->mat);
-
- if (mem_info_is_on()) {
- mem_bytes(TYPE_BAND,sizeof(BAND),0);
- mem_numvar(TYPE_BAND,-1);
- }
-
- free((char *)A);
- return 0;
- }
-
-
- /* resize band matrix */
-
- BAND *bd_resize(A,new_lb,new_ub,new_n)
- BAND *A;
- int new_lb,new_ub,new_n;
- {
- int lb,ub,i,j,l,shift,umin;
- Real **Av;
-
- if (new_lb < 0 || new_ub < 0 || new_n <= 0)
- error(E_NEG,"bd_resize");
- if ( ! A )
- return bd_get(new_lb,new_ub,new_n);
- if ( A->lb+A->ub+1 > A->mat->m )
- error(E_INTERN,"bd_resize");
-
- if ( A->lb == new_lb && A->ub == new_ub && A->mat->n == new_n )
- return A;
-
- lb = A->lb;
- ub = A->ub;
- Av = A->mat->me;
- umin = min(ub,new_ub);
-
- /* ensure that unused triangles at edges are zero'd */
-
- for ( i = 0; i < lb; i++ )
- for ( j = A->mat->n - lb + i; j < A->mat->n; j++ )
- Av[i][j] = 0.0;
- for ( i = lb+1,l=1; l <= umin; i++,l++ )
- for ( j = 0; j < l; j++ )
- Av[i][j] = 0.0;
-
- new_lb = A->lb = min(new_lb,new_n-1);
- new_ub = A->ub = min(new_ub,ne⇨Ä•% \ !@ C àÂ)- TheARMClub À $ X € 0 . @ € €qÉ• Ø : ð! 0" P" † € `E € €+ € —! Ü (" u€ ~ A 0D À ‰À €$ ¤ o☓& €' €( —" ¨" ¨! Y €3 æÐEà⇧ # „ À ¶ `… €2 ™ € €q €$ `É 4 O D ¦ ® €]6 [ @– ø2 €0 3 €2 ☓ H3€ZCœ Àœ ⇦3 À³!Ú Ó ¨3 À‡ y Ï Ã ⇩
- ø3 h 4 Ð À¬Ŵ[$ €* €,h4 @²"