home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / clib / progs / meschach / !Meschach / c / bdfactor < prev    next >
Encoding:
Text File  |  1994-05-17  |  13.1 KB  |  159 lines

  1.  
  2. /**************************************************************************
  3. **
  4. ** Copyright (C) 1993 David E. Steward & Zbigniew Leyk, all rights reserved.
  5. **
  6. **                 Meschach Library
  7. ** 
  8. ** This Meschach Library is provided "as is" without any express 
  9. ** or implied warranty of any kind with respect to this software. 
  10. ** In particular the authors shall not be liable for any direct, 
  11. ** indirect, special, incidental or consequential damages arising 
  12. ** in any way from use of the software.
  13. ** 
  14. ** Everyone is granted permission to copy, modify and redistribute this
  15. ** Meschach Library, provided:
  16. **  1.  All copies contain this copyright notice.
  17. **  2.  All modified copies shall carry a notice stating who
  18. **      made the last modification and the date of such modification.
  19. **  3.  No charge is made for this software or works derived from it.  
  20. **      This clause shall not be construed as constraining other software
  21. **      distributed on the same medium as this software, nor is a
  22. **      distribution fee considered a charge.
  23. **
  24. ***************************************************************************/
  25.  
  26.  
  27. /*
  28.   Band matrix factorisation routines
  29.   */
  30.  
  31. /* bdfactor.c  18/11/93 */
  32. static    char    rcsid[] = "$Id: bdfactor.c,v 1.5 1994/05/17 23:18:32 des Exp $";
  33.  
  34. #include    <stdio.h>
  35. #include    <math.h>
  36. #include        "matrix2.h"
  37.  
  38.  
  39. /* generate band matrix 
  40.    for a matrix  with n columns,
  41.    lb subdiagonals and ub superdiagonals;
  42.  
  43.    Way of saving a band of a matrix:
  44.    first we save subdiagonals (from 0 to lb-1);
  45.    then main diagonal (in the lb row)
  46.    and then superdiagonals (from lb+1 to lb+ub)
  47.    in such a way that the elements which were previously
  48.    in one column are now also in one column
  49. */
  50.  
  51. BAND *bd_get(lb,ub,n)
  52. int lb, ub, n;
  53. {
  54.    BAND *A;
  55.  
  56.    if (lb < 0 || ub < 0 || n <= 0)
  57.      error(E_NEG,"bd_get");
  58.  
  59.    if ((A = NEW(BAND)) == (BAND *)NULL)
  60.      error(E_MEM,"bd_get");
  61.    else if (mem_info_is_on()) {
  62.       mem_bytes(TYPE_BAND,0,sizeof(BAND));
  63.       mem_numvar(TYPE_BAND,1);
  64.    }
  65.  
  66.    lb = A->lb = min(n-1,lb);
  67.    ub = A->ub = min(n-1,ub);
  68.    A->mat = m_get(lb+ub+1,n);
  69.    return A;
  70. }
  71.  
  72. int bd_free(A)
  73. BAND *A;
  74. {
  75.    if ( A == (BAND *)NULL || A->lb < 0 || A->ub < 0 )
  76.      /* don't trust it */
  77.      return (-1);
  78.  
  79.    if (A->mat) m_free(A->mat);
  80.  
  81.    if (mem_info_is_on()) {
  82.       mem_bytes(TYPE_BAND,sizeof(BAND),0);
  83.       mem_numvar(TYPE_BAND,-1);
  84.    }
  85.  
  86.    free((char *)A);
  87.    return 0;
  88. }
  89.  
  90.  
  91. /* resize band matrix */
  92.  
  93. BAND *bd_resize(A,new_lb,new_ub,new_n)
  94. BAND *A;
  95. int new_lb,new_ub,new_n;
  96. {
  97.    int lb,ub,i,j,l,shift,umin;
  98.    Real **Av;
  99.  
  100.    if (new_lb < 0 || new_ub < 0 || new_n <= 0)
  101.      error(E_NEG,"bd_resize");
  102.    if ( ! A )
  103.      return bd_get(new_lb,new_ub,new_n);
  104.     if ( A->lb+A->ub+1 > A->mat->m )
  105.     error(E_INTERN,"bd_resize");
  106.  
  107.    if ( A->lb == new_lb && A->ub == new_ub && A->mat->n == new_n )
  108.     return A;
  109.  
  110.    lb = A->lb;
  111.    ub = A->ub;
  112.    Av = A->mat->me;
  113.    umin = min(ub,new_ub);
  114.  
  115.     /* ensure that unused triangles at edges are zero'd */
  116.  
  117.    for ( i = 0; i < lb; i++ )
  118.       for ( j = A->mat->n - lb + i; j < A->mat->n; j++ )
  119.     Av[i][j] = 0.0;  
  120.     for ( i = lb+1,l=1; l <= umin; i++,l++ )
  121.       for ( j = 0; j < l; j++ )
  122.     Av[i][j] = 0.0; 
  123.  
  124.    new_lb = A->lb = min(new_lb,new_n-1);
  125.    new_ub = A->ub = min(new_ub,ne⇨Ä•%    \ !@CàÂ)-TheARMClubÀ$X €0 .@€€qÉ• Ø:ð!0"P"†€`E€€+€ —!Ü("u€ ~A0DÀ ‰À€$¤o☓&€'€(—"¨"¨!Y€3æÐEà⇧# „À¶`…€2 ™€€q€$`É4OD¦ ® €]6[@–ø2€03€2☓H3€ZCœÀœ⇦3À³!Ú Ó¨3À‡y ÏÃ⇩
  126. ø3h4 ÐÀ¬Ŵ[$€*€,h4@²"
  127. —4T–@¦†b
  128. r
  129. F
  130. ¥pj¤ÀŒÀ¢•ìÀ¡€9À§€_Ç€fÀ¦«Z
  131. ¯ ×X6€€²€0€1PŷΠ
  132. `
  133. m§p™⇦C—C@"’°èCðD
  134. À'À!€DÄ"Ð⇦¸CÀð⇦0⇦"&T"¸D@&6‡B0⇩(E@*ç°⇩´"xE°‰fP⇧àÈE»èEÀ/  #…#€vÀ;€xp…ÉËhFÏ€h`¨F@6€m€nÀ7á—G¨GåÅ €€•€<ö@fl
  135. ¨TŶ⇩C$*™
  136. €G"`R€JàRd*`SÑ©øT☓*F¥
  137. pªR¬*€V€W«³
  138. Ô*€[Ŷy€ŵv½
  139. ¿
  140. Á
  141. rVÅ
  142. ØX$+„€fÑ
  143. Ç
  144. €i0®àZ’°`[Ñ­À· \°°¨X€r€sEºb]Ñ®€z@Àð®⇦WP­€gd+‘¯Z^öô+à_ ,@Ã"e±²ð°±`b€{EÆB⇧•€’ÅÉ¢d¸X€€⇦€H—d¨dÀ0
  145. ¸d− Ødt2ðÉÊ€Q€rÈh€S© À*heðÊÄ2À,Ô2À- –`– “zà– —PÌÀ1É À2ÐÌxfÑ Ó ª¸f€lØfÝ øf@8À8À9‘ÎÖí À;@<0ÏÔ3€{ flÀ>ÐÏ€  €Ŵ€ŵ€◰HhXhÐÐÀC@D&*6
  146. €€îÕŷTÀª£Õðê⇦u—uÔ:n¹‰]G¯ã×0ïvÅàØ’ìXv4;fiÁðí׉ll;ªÝŵñ¸ww“;Îé‰u@´Óðî8zPï€|ØwýàßðÀÀ•◰GÂÀ•⇦ÇÄ âqñÈx`ãÑñÀÇ@ÈcäQòÀÉðQ€“ÇÊ@Ëàå⇦y`æQó¸yä<v=~íÂ0ô⇩@Ò@ØgîÐô<=¢Sä=¹•Ý[•®¾Y•±@Ù£î1û‘öj·o•¸ÇÜ£í@æcõÑ÷ü=◰
  147. K°öðøD>L>*–•« öàóŴÐÇè£ôì=@â€ÅÐøl>t>8}©h}ðú€€j€a€ffi!
  148. P
  149. Æ!åÅ‘c€d„! ´Cøŷ€⇦×Èŷ@=÷‘à!¢ À9 04DÖ!lC&"ÄCÀ>
  150. "€|` èðLCàpX⇦\D2"’‰ÈG$$2)⇨†DR"+’„x⇨ &2©⇨ÜD9’‡Ðù⇨ E⇩"G@RÀR¤)ÀSd0rQ—⇩TE®"‘Ù⇩tE€¯☓E`,BYä,‹±i⇧€· .—⇧@]ä.‹Ŵ½⇦¾È_@`(…H…°i…<F"#›”’Ë@fd3‡’Ï@hd4“F8™‘Y™´F^#±’ÙHmä6‹Ù™ôF~#Á’áHqÇ‘X‰4Gfi#⇦‰ª#LG€€€lɶ¤[ò-    –…K(–à\‹.Y–íÞ%ñ‹yI½ä^‹/À¾ú%à_0—L&    `aÒ0y—DL&&›⇧IÆdc@Çäc@ÈddR29−¤LV&-›–IÌdfR3¹−äLv&=›flIÐdhM‰&I,MŒ&<M€¨ÉÔ¤j€«    €¬    €­    tM¾&a›±IÙälBÚdmÒ6yœ€¸Éõd{r7’7Ùœ`n uÀê¤oâo8†N$Nj'½•@ädrBåär‹9°9éfi|O☓O…NJ'p:!zÒ8Aݦ'¯;³€êÉí@îdw²8áw<fiO‰'É›åIóäy€Î    >'@è­@ö0>±A@údŶŵJ
  151. Ŷõ    Ð>@ù$~°?¡ŶòBQ?¹fl€üÉEe☓RB9¡H €þÉûç P€
  152. øflX ÌO(DP&(\P
  153. “ JŶ€Ó€x
  154. `fi@=÷ȧûôSø§ TTÀA€☓
  155. ÐP€⇦
  156. 0Q**€⇧
  157. €…
  158. ÀF:*ÀG%¤2R)©pRI©¬TZ*^*1—©ÔT7”†ÊN¥§òSTŷ*€¢
  159. pT$U„*M”§JTŶ©JU媋UÙª «òU@Xe¬RV9«¤UÖ*m”·J\e®RW¹«äUö*ôUðW    ¬ V
  160. +8¬‘XY¬4V+’”ÉJe岋YÙ¬tV>+¡”ÑJiÅi%µ²Zi­¼Vb+³”ÚÊm‘[Ù­ôV~+Á”áJq帋\Y® ¹ò\⇨®LW¨®\W²+Û”îÊw%¼2^€€€☓ .<\⇦¸0q¡âÂÅŶ… :.|\¹0r¡äÂÉŶ“ +Z.¼\⇦¹0s¨¹Ü\r.;–fiËÏ%èÂÐ¥èrtIº,]Œ.xºD]¦.U–« Y–­K×¾.a–± e–³KÚkÚ.oÄ]æ.uî.ò.{@ßåï@à ^
  161. /⇨–Å @ãåñ"ò0y¡òryȼ€Í  óòy    ½0z)½†^¤^V/­àõ{—½Ô^€Û r/»–ÞËï_ŷ/ øÇ–äËòÐ|y¾Ñ–éKõp}ɾؾt_¾/áÆ/å†_€ô ¬_Ú/àýÄ_`þR¹¿ù–ýKÿþ/ `
  162. 0€L,`0—Ì@æ—
  163. ÐŴ!€ @    8Á¤`¬`€€€‘ÌH¦$s‹¤dV2-−–LL3Ôdn29−‡LODe¦2P”Ê e⇩2e‹2ÀR )à)󛀫 ²2[ +ó”    Ë…eÊ2g−´ÌZ¦-ó„â2s@]à.›–ÙËôeð–Ì`0S—à0›—Àb¦1Àc&23−©Ì\f23œ−ÎÌg&43Œ)Í€ÓLjf5ÓŒyÍÄfÌf@mæ6›œÙÍôf~3Á−á P†9Î$g„3Íð†!:Lg :ײ3ØÎtgà;á−ñLy€ó…ô €õL{¼g >3flõÀ}&?³fléÏüg4ŒÍŴ&A³ iÐ<h"4Œ
  164. ÍŶ€
  165. lhthøÐ¢aDC⇨ŷ
  166. )€€B€†
  167. °³=àgA`h€¢
  168. 8ÚI°´@Ó<mµ0µ©Ú\m²6[ kðµ    Û0¶Ê6ÀÙ&m³¶€¶
  169. œÅ
  170. hÜð¶â6æ6uœ»MÞÀÞú6þ6Ŵ n
  171. 7HÜ<n€ÈÍä¦rs¹ÉÜÀætn>7 t3º)݆n©«´n^7±ÌnÔnn7änìnz7¿œà
  172. €áMñÇœäÍò¦yó¼⇨Þ—ÞTo®7ÙœíM÷øÞß…o |s¾H߬oÚ7ïœøÍüõœûMþfèßàÀŴN瀛ÀYà4p80Á©à\p28☓p…p€€N
  173. Xá´p,q¼p⇦áf85†N;†Î ⇦3Ä@8â$q€€Ê€¨ÀT§ª€«@V[]ÀWÂ:c‡²ÎY¤uÖ:Ú:Þ:â:0שë¸ëäuö:}‡¿ ° v€ÂÎa'±³Øiì<v@d0Ù@eà²Sà9ð€ÌØì ³>;¡‡Ñ(í8í©‡Õhí¼v,wf;Ôv¸ír;<wz;⇦îw w⇩;à¸Cr'¶ØíüvŒ;€é@uຠ»Øîº;à»#¼ï ¼Î;éÖ;í‡÷@|À|€ú÷ò;°ßéïüw<fi€ü€þ´ÀÚmxûâ>—û¨û¸ûä}ÀÞ}ü} ð0ø@áàð›øYü4~?€€€@`h0Pp‘X  1x €ÈÐd¨2☓€|€Ì°9 sô9
  174. ™‰JG§£ÔÑê¨uô:⇩͉jG·£ÜÑî¨w☓ßQðhx⇩Gp< y´<¢yÄó(zÄôÕ£ìÑöè⇦´Eê"Y®G {T>:ÒG`}Dûè}?Œ©Ý•‘?Úý£ÿQ    $ø‘€ ¤Ò)ŵ4Aª ]‘2Há£Ò)☓FH%$'¤‹°BZ"bHÀ ©ŷÜ‘rH;¤Ò)⇦4D⇩H‘6H€$Ò    @    h"=’3$S$¨"]’²H0>ŵ€⇩€ØÀl    µ%p[¹¥ÝzK¿%–ŷK–‰KÉ¥åÒKï%x.€è¦K@u    ¸.²K°]t–ø.//P^8/ ¹Àz    í%@|i¾T_º/å–öK@é¿`0—L    ¦S◰éÁaŒ0U—.L‘aÚ0u—>L!¦@⇨éÄ$ÅVL-&x1c—1Pcº1rL;&è1ý—@‘    €!@’    −‹LK&h2=−e¦L Ête Ë¶Lè2}−ÂLÀ—©ÌtfH3­−ÚLo¦8Ó†©Îtg"Ï´gê3ý−M4ŒŒ$Œ`Ñ4Œðh⇩4MŒ*M–¦LÓ¦©Óði Ô4jB©éÔ“jZ5µŒ^M±&€Y›€¡€ äÓò©ùô|⇩>Ufl®OÙ§îSøÉôiûß'Àø    P~€ó‘~Àú    Ð~z?ÅflÌflêO÷§üÓþ    ý§ÿSj¥u€J@- h@ð€⇩@M *P¨ ÔªõŴ
  175. A™ JP'¨Ô
  176. ªõŵ⇩AÍ jP7¨Ôªõ◰
  177. B
  178. ¡⇩PG¨$Ôª    õ☓⇩BÀª
  179. uŶÊBm¡ºPøBŶ¡ÆPe¨3Tj
  180. ÕŷzCÌ¡êPîPy¨=Tê@ 
  181. D¢8D!µ⇦Q€G⇨ŒD9E€U@&jÕ⇨ºDá¥(øD¥¢BQ­¨eT3걨YT1
  182. à”™P⇧ºEå¢vQ½(~QÁ(0