ma27s.c 140 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056
  1. /* ma27s.f -- translated by f2c (version 20200916).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. /* Table of constant values */
  13. static integer c__1 = 1;
  14. static integer c__2 = 2;
  15. /* COPYRIGHT (c) 1982 AEA Technology */
  16. /* ######DATE 20 September 2001 */
  17. /* September 2001: threadsafe version of MA27 */
  18. /* 19/3/03. Array ICNTL in MA27G made assumed size. */
  19. /* Subroutine */ int ma27i_(integer *icntl, real *cntl)
  20. {
  21. /* Stream number for error messages */
  22. /* Parameter adjustments */
  23. --cntl;
  24. --icntl;
  25. /* Function Body */
  26. icntl[1] = 6;
  27. /* Stream number for diagnostic messages */
  28. icntl[2] = 6;
  29. /* Control the level of diagnostic printing. */
  30. /* 0 no printing */
  31. /* 1 printing of scalar parameters and first parts of arrays. */
  32. /* 2 printing of scalar parameters and whole of arrays. */
  33. icntl[3] = 0;
  34. /* The largest integer such that all integers I in the range */
  35. /* -ICNTL(4).LE.I.LE.ICNTL(4) can be handled by the shortest integer */
  36. /* type in use. */
  37. icntl[4] = 2139062143;
  38. /* Minimum number of eliminations in a step that is automatically */
  39. /* accepted. if two adjacent steps can be combined and each has less */
  40. /* eliminations then they are combined. */
  41. icntl[5] = 1;
  42. /* Control whether direct or indirect access is used by MA27C/CD. */
  43. /* Indirect access is employed in forward and back substitution */
  44. /* respectively if the size of a block is less than */
  45. /* ICNTL(IFRLVL+MIN(10,NPIV)) and ICNTL(IFRLVL+10+MIN(10,NPIV)) */
  46. /* respectively, where NPIV is the number of pivots in the block. */
  47. icntl[6] = 32639;
  48. icntl[7] = 32639;
  49. icntl[8] = 32639;
  50. icntl[9] = 32639;
  51. icntl[10] = 14;
  52. icntl[11] = 9;
  53. icntl[12] = 8;
  54. icntl[13] = 8;
  55. icntl[14] = 9;
  56. icntl[15] = 10;
  57. icntl[16] = 32639;
  58. icntl[17] = 32639;
  59. icntl[18] = 32639;
  60. icntl[19] = 32689;
  61. icntl[20] = 24;
  62. icntl[21] = 11;
  63. icntl[22] = 9;
  64. icntl[23] = 8;
  65. icntl[24] = 9;
  66. icntl[25] = 10;
  67. /* Not used */
  68. icntl[26] = 0;
  69. icntl[27] = 0;
  70. icntl[28] = 0;
  71. icntl[29] = 0;
  72. icntl[30] = 0;
  73. /* Control threshold pivoting. */
  74. cntl[1] = .1f;
  75. /* If a column of the reduced matrix has relative density greater than */
  76. /* CNTL(2), it is forced into the root. All such columns are taken to */
  77. /* have sparsity pattern equal to their merged patterns, so the fill */
  78. /* and operation counts may be overestimated. */
  79. cntl[2] = 1.f;
  80. /* An entry with absolute value less than CNTL(3) is never accepted as */
  81. /* a 1x1 pivot or as the off-diagonal of a 2x2 pivot. */
  82. cntl[3] = 0.f;
  83. /* Not used */
  84. cntl[4] = 0.f;
  85. cntl[5] = 0.f;
  86. return 0;
  87. } /* ma27i_ */
  88. /* Subroutine */ int ma27a_(integer *n, integer *nz, integer *irn, integer *
  89. icn, integer *iw, integer *liw, integer *ikeep, integer *iw1, integer
  90. *nsteps, integer *iflag, integer *icntl, real *cntl, integer *info,
  91. real *ops)
  92. {
  93. /* Format strings */
  94. static char fmt_10[] = "(/,/,\002 ENTERING MA27A WITH N NZ "
  95. " LIW IFLAG\002,/,21x,i7,i7,i9,i7)";
  96. static char fmt_20[] = "(\002 MATRIX NON-ZEROS\002,/,4(i9,i6),/,(i9,i6,i"
  97. "9,i6,i9,i6,i9,i6))";
  98. static char fmt_30[] = "(\002 IKEEP(.,1)=\002,10i6,/,(12x,10i6))";
  99. static char fmt_80[] = "(\002 **** ERROR RETURN FROM MA27A **** INFO("
  100. "1)=\002,i3)";
  101. static char fmt_90[] = "(\002 VALUE OF N OUT OF RANGE ... =\002,i10)";
  102. static char fmt_110[] = "(\002 VALUE OF NZ OUT OF RANGE .. =\002,i10)";
  103. static char fmt_150[] = "(\002 LIW TOO SMALL, MUST BE INCREASED FROM\002"
  104. ",i10,\002 TO AT LEAST\002,i10)";
  105. static char fmt_170[] = "(/,\002 LEAVING MA27A WITH NSTEPS INFO(1) "
  106. "OPS IERROR\002,\002 NRLTOT NIRTOT\002,/,20x,2i7,f7.0,3i7,/,20x"
  107. ",\002 NRLNEC NIRNEC NRLADU NIRADU NCMPA\002,/,20x,6i7)";
  108. static char fmt_180[] = "(\002 IKEEP(.,2)=\002,10i6,/,(12x,10i6))";
  109. static char fmt_190[] = "(\002 IKEEP(.,3)=\002,10i6,/,(12x,10i6))";
  110. /* System generated locals */
  111. integer ikeep_dim1, ikeep_offset, iw1_dim1, iw1_offset, i__1;
  112. /* Builtin functions */
  113. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  114. /* Local variables */
  115. static integer i__, k, l1, l2;
  116. extern /* Subroutine */ int ma27g_(integer *, integer *, integer *,
  117. integer *, integer *, integer *, integer *, integer *, integer *,
  118. integer *, integer *, integer *), ma27h_(integer *, integer *,
  119. integer *, integer *, integer *, integer *, integer *, integer *,
  120. integer *, integer *, integer *, integer *, real *), ma27j_(
  121. integer *, integer *, integer *, integer *, integer *, integer *,
  122. integer *, integer *, integer *, integer *, integer *, integer *,
  123. integer *), ma27k_(integer *, integer *, integer *, integer *,
  124. integer *, integer *, integer *, integer *, integer *, integer *),
  125. ma27l_(integer *, integer *, integer *, integer *, integer *,
  126. integer *, integer *, integer *, integer *), ma27m_(integer *,
  127. integer *, integer *, integer *, integer *, integer *, integer *,
  128. integer *, integer *, integer *, integer *, integer *, integer *,
  129. real *);
  130. static integer iwfr, lliw;
  131. /* Fortran I/O blocks */
  132. static cilist io___2 = { 0, 0, 0, fmt_10, 0 };
  133. static cilist io___4 = { 0, 0, 0, fmt_20, 0 };
  134. static cilist io___5 = { 0, 0, 0, fmt_30, 0 };
  135. static cilist io___10 = { 0, 0, 0, fmt_80, 0 };
  136. static cilist io___11 = { 0, 0, 0, fmt_90, 0 };
  137. static cilist io___12 = { 0, 0, 0, fmt_80, 0 };
  138. static cilist io___13 = { 0, 0, 0, fmt_110, 0 };
  139. static cilist io___14 = { 0, 0, 0, fmt_80, 0 };
  140. static cilist io___15 = { 0, 0, 0, fmt_150, 0 };
  141. static cilist io___16 = { 0, 0, 0, fmt_170, 0 };
  142. static cilist io___17 = { 0, 0, 0, fmt_30, 0 };
  143. static cilist io___18 = { 0, 0, 0, fmt_180, 0 };
  144. static cilist io___19 = { 0, 0, 0, fmt_190, 0 };
  145. /* THIS SUBROUTINE COMPUTES A MINIMUM DEGREE ORDERING OR ACCEPTS A GIVEN */
  146. /* ORDERING. IT COMPUTES ASSOCIATED ASSEMBLY AND ELIMINATION */
  147. /* INFORMATION FOR MA27B/BD. */
  148. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  149. /* NZ MUST BE SET TO THE NUMBER OF NON-ZEROS INPUT. IT IS NOT */
  150. /* ALTERED. */
  151. /* IRN(I),I=1,2,...,NZ MUST BE SET TO THE ROW NUMBERS OF THE */
  152. /* NON-ZEROS. IT IS NOT ALTERED UNLESS IT IS EQUIVALENCED */
  153. /* TO IW (SEE DESCRIPTION OF IW). */
  154. /* ICN(I),I=1,2,...,NZ MUST BE SET TO THE COLUMN NUMBERS OF THE */
  155. /* NON-ZEROS. IT IS NOT ALTERED UNLESS IT IS EQUIVALENCED */
  156. /* TO IW (SEE DESCRIPTION OF IW). */
  157. /* IW NEED NOT BE SET ON INPUT. IT IS USED FOR WORKSPACE. */
  158. /* IRN(1) MAY BE EQUIVALENCED TO IW(1) AND ICN(1) MAY BE */
  159. /* EQUIVALENCED TO IW(K), WHERE K.GT.NZ. */
  160. /* LIW MUST BE SET TO THE LENGTH OF IW. IT MUST BE AT LEAST 2*NZ+3*N */
  161. /* FOR THE IFLAG=0 ENTRY AND AT LEAST NZ+3*N FOR THE IFLAG=1 */
  162. /* ENTRY. IT IS NOT ALTERED. */
  163. /* IKEEP NEED NOT BE SET UNLESS AN ORDERING IS GIVEN, IN WHICH CASE */
  164. /* IKEEP(I,1) MUST BE SET TO THE POSITION OF VARIABLE I IN THE */
  165. /* ORDER. ON OUTPUT IKEEP CONTAINS INFORMATION NEEDED BY MA27B/BD. */
  166. /* IKEEP(I,1) HOLDS THE POSITION OF VARIABLE I IN THE PIVOT ORDER. */
  167. /* IKEEP(I,2), IKEEP(I,3) HOLD THE NUMBER OF ELIMINATIONS, ASSEMBLIES */
  168. /* AT MAJOR STEP I, I=1,2,...,NSTEPS. NOTE THAT WHEN AN ORDER IS */
  169. /* GIVEN IT MAY BE REPLACED BY ANOTHER ORDER THAT GIVES IDENTICAL */
  170. /* NUMERICAL RESULTS. */
  171. /* IW1 IS USED FOR WORKSPACE. */
  172. /* NSTEPS NEED NOT BE SET. ON OUTPUT IT CONTAINS THE NUMBER OF MAJOR */
  173. /* STEPS NEEDED FOR A DEFINITE MATRIX AND MUST BE PASSED UNCHANGED */
  174. /* TO MA27B/BD. */
  175. /* IFLAG MUST SET TO ZERO IF THE USER WANTS THE PIVOT ORDER CHOSEN */
  176. /* AUTOMATICALLY AND TO ONE IF HE WANTS TO SPECIFY IT IN IKEEP. */
  177. /* ICNTL is an INTEGER array of length 30 containing user options */
  178. /* with integer values (defaults set in MA27I/ID) */
  179. /* ICNTL(1) (LP) MUST BE SET TO THE STREAM NUMBER FOR ERROR MESSAGES. */
  180. /* ERROR MESSAGES ARE SUPPRESSED IF ICNTL(1) IS NOT POSITIVE. */
  181. /* IT IS NOT ALTERED. */
  182. /* ICNTL(2) (MP) MUST BE SET TO THE STREAM NUMBER FOR DIAGNOSTIC */
  183. /* MESSAGES. DIAGNOSTIC MESSAGES ARE SUPPRESSED IF ICNTL(2) IS NOT */
  184. /* POSITIVE. IT IS NOT ALTERED. */
  185. /* ICNTL(3) (LDIAG) CONTROLS THE LEVEL OF DIAGNOSTIC PRINTING. */
  186. /* 0 NO PRINTING */
  187. /* 1 PRINTING OF SCALAR PARAMETERS AND FIRST PARTS OF ARRAYS. */
  188. /* 2 PRINTING OF SCALAR PARAMETERS AND WHOLE OF ARRAYS. */
  189. /* ICNTL(4) (IOVFLO) IS THE LARGEST INTEGER SUCH THAT ALL INTEGERS */
  190. /* I IN THE RANGE -IOVFLO.LE.I.LE.IOVFLO CAN BE HANDLED BY THE */
  191. /* SHORTEST INTEGER TYPE IN USE. */
  192. /* ICNT(5) (NEMIN) MUST BE SET TO THE MINIMUM NUMBER OF ELIMINATIONS */
  193. /* IN A STEP THAT IS AUTOMATICALLY ACCEPTED. IF TWO ADJACENT STEPS */
  194. /* CAN BE COMBINED AND EACH HAS LESS ELIMINATIONS THEN THEY ARE */
  195. /* COMBINED. */
  196. /* ICNTL(IFRLVL+I) I=1,20, (IFRLVL) MUST BE SET TO CONTROL WHETHER */
  197. /* DIRECT OR INDIRECT ACCESS IS USED BY MA27C/CD. INDIRECT ACCESS */
  198. /* IS EMPLOYED IN FORWARD AND BACK SUBSTITUTION RESPECTIVELY IF THE */
  199. /* SIZE OF A BLOCK IS LESS THAN ICNTL(IFRLVL+(MIN(10,NPIV)) AND */
  200. /* ICNTL(IFRLVL+10+MIN(10,NPIV)) RESPECTIVELY, WHERE NPIV IS THE */
  201. /* NUMBER OF PIVOTS IN THE BLOCK. */
  202. /* ICNTL(I) I=26,30 are not used. */
  203. /* CNTL is an REAL array of length 5 containing user options */
  204. /* with real values (defaults set in MA27I/ID) */
  205. /* CNTL(1) (U) IS USED TO CONTROL THRESHOLD PIVOTING. IT IS NOT */
  206. /* ALTERED. */
  207. /* CNTL(2) (FRATIO) has default value 1.0. If a column of the */
  208. /* reduced matrix has relative density greater than CNTL(2), it */
  209. /* is forced into the root. All such columns are taken to have */
  210. /* sparsity pattern equal to their merged patterns, so the fill */
  211. /* and operation counts may be overestimated. */
  212. /* CNTL(3) (PIVTOL) has default value 0.0. An entry with absolute */
  213. /* value less than CNTL(3) is never accepted as a 1x1 pivot or */
  214. /* as the off-diagonal of a 2x2 pivot. */
  215. /* CNTL(I) I=4,5 are not used. */
  216. /* INFO is an INTEGER array of length 20 which is used to return */
  217. /* information to the user. */
  218. /* INFO(1) (IFLAG) is an error return code, zero for success, greater */
  219. /* than zero for a warning and less than zero for errors, see */
  220. /* INFO(2). */
  221. /* INFO(2) (IERROR) HOLDS ADDITIONAL INFORMATION IN THE EVENT OF ERRORS. */
  222. /* IF INFO(1)=-3 INFO(2) HOLDS A LENGTH THAT MAY SUFFICE FOR IW. */
  223. /* IF INFO(1)=-4 INFO(2) HOLDS A LENGTH THAT MAY SUFFICE FOR A. */
  224. /* IF INFO(1)=-5 INFO(2) IS SET TO THE PIVOT STEP AT WHICH SINGULARITY */
  225. /* WAS DETECTED. */
  226. /* IF INFO(1)=-6 INFO(2) IS SET TO THE PIVOT STEP AT WHICH A CHANGE OF */
  227. /* PIVOT SIGN WAS FOUND. */
  228. /* IF INFO(1)= 1 INFO(2) HOLDS THE NUMBER OF FAULTY ENTRIES. */
  229. /* IF INFO(1)= 2 INFO(2) IS SET TO THE NUMBER OF SIGNS CHANGES IN */
  230. /* THE PIVOTS. */
  231. /* IF INFO(1)=3 INFO(2) IS SET TO THE RANK OF THE MATRIX. */
  232. /* INFO(3) and INFO(4) (NRLTOT and NIRTOT) REAL AND INTEGER STRORAGE */
  233. /* RESPECTIVELY REQUIRED FOR THE FACTORIZATION IF NO COMPRESSES ARE */
  234. /* ALLOWED. */
  235. /* INFO(5) and INFO(6) (NRLNEC and NIRNEC) REAL AND INTEGER STORAGE */
  236. /* RESPECTIVELY REQUIRED FOR THE FACTORIZATION IF COMPRESSES ARE */
  237. /* ALLOWED AND THE MATRIX IS DEFINITE. */
  238. /* INFO(7) and INFO(8) (NRLADU and NIRADU) REAL AND INTEGER STORAGE */
  239. /* RESPECTIVELY FOR THE MATRIX FACTORS AS CALCULATED BY MA27A/AD */
  240. /* FOR THE DEFINITE CASE. */
  241. /* INFO(9) and INFO(10) (NRLBDU and NIRBDU) REAL AND INTEGER STORAGE */
  242. /* RESPECTIVELY FOR THE MATRIX FACTORS AS FOUND BY MA27B/BD. */
  243. /* INFO(11) (NCMPA) ACCUMULATES THE NUMBER OF TIMES THE ARRAY IW IS */
  244. /* COMPRESSED BY MA27A/AD. */
  245. /* INFO(12) and INFO(13) (NCMPBR and NCMPBI) ACCUMULATE THE NUMBER */
  246. /* OF COMPRESSES OF THE REALS AND INTEGERS PERFORMED BY MA27B/BD. */
  247. /* INFO(14) (NTWO) IS USED BY MA27B/BD TO RECORD THE NUMBER OF 2*2 */
  248. /* PIVOTS USED. */
  249. /* INFO(15) (NEIG) IS USED BY ME27B/BD TO RECORD THE NUMBER OF */
  250. /* NEGATIVE EIGENVALUES OF A. */
  251. /* INFO(16) to INFO(20) are not used. */
  252. /* OPS ACCUMULATES THE NO. OF MULTIPLY/ADD PAIRS NEEDED TO CREATE THE */
  253. /* TRIANGULAR FACTORIZATION, IN THE DEFINITE CASE. */
  254. /* .. Scalar Arguments .. */
  255. /* .. */
  256. /* .. Array Arguments .. */
  257. /* .. */
  258. /* .. Local Scalars .. */
  259. /* .. */
  260. /* .. External Subroutines .. */
  261. /* .. */
  262. /* .. Intrinsic Functions .. */
  263. /* .. */
  264. /* .. Executable Statements .. */
  265. /* Parameter adjustments */
  266. iw1_dim1 = *n;
  267. iw1_offset = 1 + iw1_dim1;
  268. iw1 -= iw1_offset;
  269. ikeep_dim1 = *n;
  270. ikeep_offset = 1 + ikeep_dim1;
  271. ikeep -= ikeep_offset;
  272. --irn;
  273. --icn;
  274. --iw;
  275. --icntl;
  276. --cntl;
  277. --info;
  278. /* Function Body */
  279. for (i__ = 1; i__ <= 15; ++i__) {
  280. info[i__] = 0;
  281. /* L5: */
  282. }
  283. if (icntl[3] <= 0 || icntl[2] <= 0) {
  284. goto L40;
  285. }
  286. /* PRINT INPUT VARIABLES. */
  287. io___2.ciunit = icntl[2];
  288. s_wsfe(&io___2);
  289. do_fio(&c__1, (char *)&(*n), (ftnlen)sizeof(integer));
  290. do_fio(&c__1, (char *)&(*nz), (ftnlen)sizeof(integer));
  291. do_fio(&c__1, (char *)&(*liw), (ftnlen)sizeof(integer));
  292. do_fio(&c__1, (char *)&(*iflag), (ftnlen)sizeof(integer));
  293. e_wsfe();
  294. *nsteps = 0;
  295. k = min(8,*nz);
  296. if (icntl[3] > 1) {
  297. k = *nz;
  298. }
  299. if (k > 0) {
  300. io___4.ciunit = icntl[2];
  301. s_wsfe(&io___4);
  302. i__1 = k;
  303. for (i__ = 1; i__ <= i__1; ++i__) {
  304. do_fio(&c__1, (char *)&irn[i__], (ftnlen)sizeof(integer));
  305. do_fio(&c__1, (char *)&icn[i__], (ftnlen)sizeof(integer));
  306. }
  307. e_wsfe();
  308. }
  309. k = min(10,*n);
  310. if (icntl[3] > 1) {
  311. k = *n;
  312. }
  313. if (*iflag == 1 && k > 0) {
  314. io___5.ciunit = icntl[2];
  315. s_wsfe(&io___5);
  316. i__1 = k;
  317. for (i__ = 1; i__ <= i__1; ++i__) {
  318. do_fio(&c__1, (char *)&ikeep[i__ + ikeep_dim1], (ftnlen)sizeof(
  319. integer));
  320. }
  321. e_wsfe();
  322. }
  323. L40:
  324. if (*n < 1 || *n > icntl[4]) {
  325. goto L70;
  326. }
  327. if (*nz < 0) {
  328. goto L100;
  329. }
  330. lliw = *liw - (*n << 1);
  331. l1 = lliw + 1;
  332. l2 = l1 + *n;
  333. if (*iflag == 1) {
  334. goto L50;
  335. }
  336. if (*liw < (*nz << 1) + *n * 3 + 1) {
  337. goto L130;
  338. }
  339. /* SORT */
  340. ma27g_(n, nz, &irn[1], &icn[1], &iw[1], &lliw, &iw1[iw1_offset], &iw1[(
  341. iw1_dim1 << 1) + 1], &iw[l1], &iwfr, &icntl[1], &info[1]);
  342. /* ANALYZE USING MINIMUM DEGREE ORDERING */
  343. ma27h_(n, &iw1[iw1_offset], &iw[1], &lliw, &iwfr, &iw[l1], &iw[l2], &
  344. ikeep[(ikeep_dim1 << 1) + 1], &ikeep[ikeep_dim1 * 3 + 1], &ikeep[
  345. ikeep_offset], &icntl[4], &info[11], &cntl[2]);
  346. goto L60;
  347. /* SORT USING GIVEN ORDER */
  348. L50:
  349. if (*liw < *nz + *n * 3 + 1) {
  350. goto L120;
  351. }
  352. ma27j_(n, nz, &irn[1], &icn[1], &ikeep[ikeep_offset], &iw[1], &lliw, &iw1[
  353. iw1_offset], &iw1[(iw1_dim1 << 1) + 1], &iw[l1], &iwfr, &icntl[1],
  354. &info[1]);
  355. /* ANALYZE USING GIVEN ORDER */
  356. ma27k_(n, &iw1[iw1_offset], &iw[1], &lliw, &iwfr, &ikeep[ikeep_offset], &
  357. ikeep[(ikeep_dim1 << 1) + 1], &iw[l1], &iw[l2], &info[11]);
  358. /* PERFORM DEPTH-FIRST SEARCH OF ASSEMBLY TREE */
  359. L60:
  360. ma27l_(n, &iw1[iw1_offset], &iw[l1], &ikeep[ikeep_offset], &ikeep[(
  361. ikeep_dim1 << 1) + 1], &ikeep[ikeep_dim1 * 3 + 1], &iw[l2],
  362. nsteps, &icntl[5]);
  363. /* EVALUATE STORAGE AND OPERATION COUNT REQUIRED BY MA27B/BD IN THE */
  364. /* DEFINITE CASE. */
  365. /* SET IW(1) SO THAT ARRAYS IW AND IRN CAN BE TESTED FOR EQUIVALENCE */
  366. /* IN MA27M/MD. */
  367. if (*nz >= 1) {
  368. iw[1] = irn[1] + 1;
  369. }
  370. ma27m_(n, nz, &irn[1], &icn[1], &ikeep[ikeep_offset], &ikeep[ikeep_dim1 *
  371. 3 + 1], &ikeep[(ikeep_dim1 << 1) + 1], &iw[l2], nsteps, &iw1[
  372. iw1_offset], &iw1[(iw1_dim1 << 1) + 1], &iw[1], &info[1], ops);
  373. goto L160;
  374. L70:
  375. info[1] = -1;
  376. if (icntl[1] > 0) {
  377. io___10.ciunit = icntl[1];
  378. s_wsfe(&io___10);
  379. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  380. e_wsfe();
  381. }
  382. if (icntl[1] > 0) {
  383. io___11.ciunit = icntl[1];
  384. s_wsfe(&io___11);
  385. do_fio(&c__1, (char *)&(*n), (ftnlen)sizeof(integer));
  386. e_wsfe();
  387. }
  388. goto L160;
  389. L100:
  390. info[1] = -2;
  391. if (icntl[1] > 0) {
  392. io___12.ciunit = icntl[1];
  393. s_wsfe(&io___12);
  394. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  395. e_wsfe();
  396. }
  397. if (icntl[1] > 0) {
  398. io___13.ciunit = icntl[1];
  399. s_wsfe(&io___13);
  400. do_fio(&c__1, (char *)&(*nz), (ftnlen)sizeof(integer));
  401. e_wsfe();
  402. }
  403. goto L160;
  404. L120:
  405. info[2] = *nz + *n * 3 + 1;
  406. goto L140;
  407. L130:
  408. info[2] = (*nz << 1) + *n * 3 + 1;
  409. L140:
  410. info[1] = -3;
  411. if (icntl[1] > 0) {
  412. io___14.ciunit = icntl[1];
  413. s_wsfe(&io___14);
  414. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  415. e_wsfe();
  416. }
  417. if (icntl[1] > 0) {
  418. io___15.ciunit = icntl[1];
  419. s_wsfe(&io___15);
  420. do_fio(&c__1, (char *)&(*liw), (ftnlen)sizeof(integer));
  421. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  422. e_wsfe();
  423. }
  424. L160:
  425. if (icntl[3] <= 0 || icntl[2] <= 0 || info[1] < 0) {
  426. goto L200;
  427. }
  428. /* PRINT PARAMETER VALUES ON EXIT. */
  429. io___16.ciunit = icntl[2];
  430. s_wsfe(&io___16);
  431. do_fio(&c__1, (char *)&(*nsteps), (ftnlen)sizeof(integer));
  432. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  433. do_fio(&c__1, (char *)&(*ops), (ftnlen)sizeof(real));
  434. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  435. do_fio(&c__1, (char *)&info[3], (ftnlen)sizeof(integer));
  436. do_fio(&c__1, (char *)&info[4], (ftnlen)sizeof(integer));
  437. do_fio(&c__1, (char *)&info[5], (ftnlen)sizeof(integer));
  438. do_fio(&c__1, (char *)&info[6], (ftnlen)sizeof(integer));
  439. do_fio(&c__1, (char *)&info[7], (ftnlen)sizeof(integer));
  440. do_fio(&c__1, (char *)&info[8], (ftnlen)sizeof(integer));
  441. do_fio(&c__1, (char *)&info[11], (ftnlen)sizeof(integer));
  442. e_wsfe();
  443. k = min(9,*n);
  444. if (icntl[3] > 1) {
  445. k = *n;
  446. }
  447. if (k > 0) {
  448. io___17.ciunit = icntl[2];
  449. s_wsfe(&io___17);
  450. i__1 = k;
  451. for (i__ = 1; i__ <= i__1; ++i__) {
  452. do_fio(&c__1, (char *)&ikeep[i__ + ikeep_dim1], (ftnlen)sizeof(
  453. integer));
  454. }
  455. e_wsfe();
  456. }
  457. k = min(k,*nsteps);
  458. if (k > 0) {
  459. io___18.ciunit = icntl[2];
  460. s_wsfe(&io___18);
  461. i__1 = k;
  462. for (i__ = 1; i__ <= i__1; ++i__) {
  463. do_fio(&c__1, (char *)&ikeep[i__ + (ikeep_dim1 << 1)], (ftnlen)
  464. sizeof(integer));
  465. }
  466. e_wsfe();
  467. }
  468. if (k > 0) {
  469. io___19.ciunit = icntl[2];
  470. s_wsfe(&io___19);
  471. i__1 = k;
  472. for (i__ = 1; i__ <= i__1; ++i__) {
  473. do_fio(&c__1, (char *)&ikeep[i__ + ikeep_dim1 * 3], (ftnlen)
  474. sizeof(integer));
  475. }
  476. e_wsfe();
  477. }
  478. L200:
  479. return 0;
  480. } /* ma27a_ */
  481. /* Subroutine */ int ma27b_(integer *n, integer *nz, integer *irn, integer *
  482. icn, real *a, integer *la, integer *iw, integer *liw, integer *ikeep,
  483. integer *nsteps, integer *maxfrt, integer *iw1, integer *icntl, real *
  484. cntl, integer *info)
  485. {
  486. /* Format strings */
  487. static char fmt_10[] = "(/,/,\002 ENTERING MA27B WITH N NZ "
  488. " LA LIW\002,\002 NSTEPS U\002,/,21x,i7,i7,i9,i9,i7,1"
  489. "pe10.2)";
  490. static char fmt_20[] = "(\002 MATRIX NON-ZEROS\002,/,1x,2(1p,e16.3,2i6),"
  491. "/,(1x,1p,e16.3,2i6,1p,e16.3,2i6))";
  492. static char fmt_30[] = "(\002 IKEEP(.,1)=\002,10i6,/,(12x,10i6))";
  493. static char fmt_40[] = "(\002 IKEEP(.,2)=\002,10i6,/,(12x,10i6))";
  494. static char fmt_50[] = "(\002 IKEEP(.,3)=\002,10i6,/,(12x,10i6))";
  495. static char fmt_65[] = "(\002 *** WARNING MESSAGE FROM SUBROUTINE MA27"
  496. "B\002,\002 *** INFO(1) =\002,i2,/,5x,\002MATRIX IS SINGULAR. RA"
  497. "NK=\002,i5)";
  498. static char fmt_80[] = "(\002 **** ERROR RETURN FROM MA27B **** INFO("
  499. "1)=\002,i3)";
  500. static char fmt_90[] = "(\002 VALUE OF N OUT OF RANGE ... =\002,i10)";
  501. static char fmt_110[] = "(\002 VALUE OF NZ OUT OF RANGE .. =\002,i10)";
  502. static char fmt_140[] = "(\002 LIW TOO SMALL, MUST BE INCREASED FROM\002"
  503. ",i10,\002 TO\002,\002 AT LEAST\002,i10)";
  504. static char fmt_170[] = "(\002 LA TOO SMALL, MUST BE INCREASED FROM \002"
  505. ",i10,\002 TO\002,\002 AT LEAST\002,i10)";
  506. static char fmt_190[] = "(\002 ZERO PIVOT AT STAGE\002,i10,\002 WHEN INP"
  507. "UT MATRIX DECLARED DEFINITE\002)";
  508. static char fmt_210[] = "(\002 CHANGE IN SIGN OF PIVOT ENCOUNTERED\002"
  509. ",\002 WHEN FACTORING ALLEGEDLY DEFINITE MATRIX\002)";
  510. static char fmt_230[] = "(/,\002 LEAVING MA27B WITH\002,/,10x,\002 MAX"
  511. "FRT INFO(1) NRLBDU NIRBDU NCMPBR\002,\002 NCMPBI NTWO IERRO"
  512. "R\002,/,11x,8i7)";
  513. static char fmt_250[] = "(\002 BLOCK PIVOT =\002,i8,\002 NROWS =\002,i8"
  514. ",\002 NCOLS =\002,i8)";
  515. static char fmt_260[] = "(\002 COLUMN INDICES =\002,10i6,/,(17x,10i6))";
  516. static char fmt_270[] = "(\002 REAL ENTRIES .. EACH ROW STARTS ON A NEW "
  517. "LINE\002)";
  518. static char fmt_280[] = "(1p,5e13.3)";
  519. /* System generated locals */
  520. integer ikeep_dim1, ikeep_offset, i__1, i__2, i__3;
  521. /* Builtin functions */
  522. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  523. /* Local variables */
  524. static integer i__, k, j1, j2, jj, kz, nz1, len, iblk, kblk;
  525. extern /* Subroutine */ int ma27n_(integer *, integer *, integer *, real *
  526. , integer *, integer *, integer *, integer *, integer *, integer *
  527. , integer *, integer *, integer *), ma27o_(integer *, integer *,
  528. real *, integer *, integer *, integer *, integer *, integer *,
  529. integer *, integer *, integer *, integer *, integer *, real *,
  530. integer *);
  531. static integer ipos, iapos, ncols, irows, nrows;
  532. /* Fortran I/O blocks */
  533. static cilist io___20 = { 0, 0, 0, fmt_10, 0 };
  534. static cilist io___22 = { 0, 0, 0, fmt_20, 0 };
  535. static cilist io___24 = { 0, 0, 0, fmt_30, 0 };
  536. static cilist io___26 = { 0, 0, 0, fmt_40, 0 };
  537. static cilist io___27 = { 0, 0, 0, fmt_50, 0 };
  538. static cilist io___29 = { 0, 0, 0, fmt_65, 0 };
  539. static cilist io___30 = { 0, 0, 0, fmt_80, 0 };
  540. static cilist io___31 = { 0, 0, 0, fmt_90, 0 };
  541. static cilist io___32 = { 0, 0, 0, fmt_80, 0 };
  542. static cilist io___33 = { 0, 0, 0, fmt_110, 0 };
  543. static cilist io___34 = { 0, 0, 0, fmt_80, 0 };
  544. static cilist io___35 = { 0, 0, 0, fmt_140, 0 };
  545. static cilist io___36 = { 0, 0, 0, fmt_80, 0 };
  546. static cilist io___37 = { 0, 0, 0, fmt_170, 0 };
  547. static cilist io___38 = { 0, 0, 0, fmt_80, 0 };
  548. static cilist io___39 = { 0, 0, 0, "(A)", 0 };
  549. static cilist io___40 = { 0, 0, 0, fmt_80, 0 };
  550. static cilist io___41 = { 0, 0, 0, fmt_190, 0 };
  551. static cilist io___42 = { 0, 0, 0, fmt_80, 0 };
  552. static cilist io___43 = { 0, 0, 0, fmt_210, 0 };
  553. static cilist io___44 = { 0, 0, 0, fmt_230, 0 };
  554. static cilist io___52 = { 0, 0, 0, fmt_250, 0 };
  555. static cilist io___54 = { 0, 0, 0, fmt_260, 0 };
  556. static cilist io___56 = { 0, 0, 0, fmt_270, 0 };
  557. static cilist io___59 = { 0, 0, 0, fmt_280, 0 };
  558. /* THIS SUBROUTINE COMPUTES THE FACTORISATION OF THE MATRIX INPUT IN */
  559. /* A,IRN,ICN USING INFORMATION (IN IKEEP) FROM MA27A/AD. */
  560. /* N MUST BE SET TO THE ORDER OF THE MATRIX. IT IS NOT ALTERED. */
  561. /* NZ MUST BE SET TO THE NUMBER OF NON-ZEROS INPUT. IT IS NOT */
  562. /* ALTERED. */
  563. /* IRN,ICN,A. ENTRY K (K=1,NZ) OF IRN,ICN MUST BE SET TO THE ROW */
  564. /* AND COLUMN INDEX RESPECTIVELY OF THE NON-ZERO IN A. */
  565. /* IRN AND ICN ARE UNALTERED BY MA27B/BD. */
  566. /* ON EXIT, ENTRIES 1 TO NRLBDU OF A HOLD REAL INFORMATION */
  567. /* ON THE FACTORS AND SHOULD BE PASSED UNCHANGED TO MA27C/CD. */
  568. /* LA LENGTH OF ARRAY A. AN INDICATION OF A SUITABLE VALUE, */
  569. /* SUFFICIENT FOR FACTORIZATION OF A DEFINITE MATRIX, WILL */
  570. /* HAVE BEEN PROVIDED IN NRLNEC AND NRLTOT BY MA27A/AD. */
  571. /* IT IS NOT ALTERED BY MA27B/BD. */
  572. /* IW NEED NOT BE SET ON ENTRY. USED AS A WORK ARRAY BY MA27B/BD. */
  573. /* ON EXIT, ENTRIES 1 TO NIRBDU HOLD INTEGER INFORMATION ON THE */
  574. /* FACTORS AND SHOULD BE PASSED UNCHANGED TO MA27C/CD. */
  575. /* LIW LENGTH OF ARRAY IW. AN INDICATION OF A SUITABLE VALUE WILL */
  576. /* HAVE BEEN PROVIDED IN NIRNEC AND NIRTOT BY MA27A/AD. */
  577. /* IT IS NOT ALTERED BY MA27B/BD. */
  578. /* IKEEP MUST BE UNCHANGED SINCE THE CALL TO MA27A/AD. */
  579. /* IT IS NOT ALTERED BY MA27B/BD. */
  580. /* NSTEPS MUST BE UNCHANGED SINCE THE CALL TO MA27A/AD. */
  581. /* IT IS NOT ALTERED BY MA27B/BD. */
  582. /* MAXFRT NEED NOT BE SET AND MUST BE PASSED UNCHANGED TO MA27C/CD. */
  583. /* IT IS THE MAXIMUM SIZE OF THE FRONTAL MATRIX GENERATED DURING */
  584. /* THE DECOMPOSITION. */
  585. /* IW1 USED AS WORKSPACE BY MA27B/BD. */
  586. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  587. /* CNTL is a REAL array of length 5, see MA27A/AD. */
  588. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  589. /* .. Scalar Arguments .. */
  590. /* .. */
  591. /* .. Array Arguments .. */
  592. /* .. */
  593. /* .. Local Scalars .. */
  594. /* .. */
  595. /* .. External Subroutines .. */
  596. /* .. */
  597. /* .. Intrinsic Functions .. */
  598. /* .. */
  599. /* .. Executable Statements .. */
  600. /* Parameter adjustments */
  601. --iw1;
  602. ikeep_dim1 = *n;
  603. ikeep_offset = 1 + ikeep_dim1;
  604. ikeep -= ikeep_offset;
  605. --irn;
  606. --icn;
  607. --a;
  608. --iw;
  609. --icntl;
  610. --cntl;
  611. --info;
  612. /* Function Body */
  613. info[1] = 0;
  614. if (icntl[3] <= 0 || icntl[2] <= 0) {
  615. goto L60;
  616. }
  617. /* PRINT INPUT PARAMETERS. */
  618. io___20.ciunit = icntl[2];
  619. s_wsfe(&io___20);
  620. do_fio(&c__1, (char *)&(*n), (ftnlen)sizeof(integer));
  621. do_fio(&c__1, (char *)&(*nz), (ftnlen)sizeof(integer));
  622. do_fio(&c__1, (char *)&(*la), (ftnlen)sizeof(integer));
  623. do_fio(&c__1, (char *)&(*liw), (ftnlen)sizeof(integer));
  624. do_fio(&c__1, (char *)&(*nsteps), (ftnlen)sizeof(integer));
  625. do_fio(&c__1, (char *)&cntl[1], (ftnlen)sizeof(real));
  626. e_wsfe();
  627. kz = min(6,*nz);
  628. if (icntl[3] > 1) {
  629. kz = *nz;
  630. }
  631. if (*nz > 0) {
  632. io___22.ciunit = icntl[2];
  633. s_wsfe(&io___22);
  634. i__1 = kz;
  635. for (k = 1; k <= i__1; ++k) {
  636. do_fio(&c__1, (char *)&a[k], (ftnlen)sizeof(real));
  637. do_fio(&c__1, (char *)&irn[k], (ftnlen)sizeof(integer));
  638. do_fio(&c__1, (char *)&icn[k], (ftnlen)sizeof(integer));
  639. }
  640. e_wsfe();
  641. }
  642. k = min(9,*n);
  643. if (icntl[3] > 1) {
  644. k = *n;
  645. }
  646. if (k > 0) {
  647. io___24.ciunit = icntl[2];
  648. s_wsfe(&io___24);
  649. i__1 = k;
  650. for (i__ = 1; i__ <= i__1; ++i__) {
  651. do_fio(&c__1, (char *)&ikeep[i__ + ikeep_dim1], (ftnlen)sizeof(
  652. integer));
  653. }
  654. e_wsfe();
  655. }
  656. k = min(k,*nsteps);
  657. if (k > 0) {
  658. io___26.ciunit = icntl[2];
  659. s_wsfe(&io___26);
  660. i__1 = k;
  661. for (i__ = 1; i__ <= i__1; ++i__) {
  662. do_fio(&c__1, (char *)&ikeep[i__ + (ikeep_dim1 << 1)], (ftnlen)
  663. sizeof(integer));
  664. }
  665. e_wsfe();
  666. }
  667. if (k > 0) {
  668. io___27.ciunit = icntl[2];
  669. s_wsfe(&io___27);
  670. i__1 = k;
  671. for (i__ = 1; i__ <= i__1; ++i__) {
  672. do_fio(&c__1, (char *)&ikeep[i__ + ikeep_dim1 * 3], (ftnlen)
  673. sizeof(integer));
  674. }
  675. e_wsfe();
  676. }
  677. L60:
  678. if (*n < 1 || *n > icntl[4]) {
  679. goto L70;
  680. }
  681. if (*nz < 0) {
  682. goto L100;
  683. }
  684. if (*liw < *nz) {
  685. goto L120;
  686. }
  687. if (*la < *nz + *n) {
  688. goto L150;
  689. }
  690. if (*nsteps < 1 || *nsteps > *n) {
  691. goto L175;
  692. }
  693. /* SORT */
  694. ma27n_(n, nz, &nz1, &a[1], la, &irn[1], &icn[1], &iw[1], liw, &ikeep[
  695. ikeep_offset], &iw1[1], &icntl[1], &info[1]);
  696. if (info[1] == -3) {
  697. goto L130;
  698. }
  699. if (info[1] == -4) {
  700. goto L160;
  701. }
  702. /* FACTORIZE */
  703. ma27o_(n, &nz1, &a[1], la, &iw[1], liw, &ikeep[ikeep_offset], &ikeep[
  704. ikeep_dim1 * 3 + 1], nsteps, maxfrt, &ikeep[(ikeep_dim1 << 1) + 1]
  705. , &iw1[1], &icntl[1], &cntl[1], &info[1]);
  706. if (info[1] == -3) {
  707. goto L130;
  708. }
  709. if (info[1] == -4) {
  710. goto L160;
  711. }
  712. if (info[1] == -5) {
  713. goto L180;
  714. }
  715. if (info[1] == -6) {
  716. goto L200;
  717. }
  718. /* **** WARNING MESSAGE **** */
  719. if (info[1] == 3 && icntl[2] > 0) {
  720. io___29.ciunit = icntl[2];
  721. s_wsfe(&io___29);
  722. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  723. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  724. e_wsfe();
  725. }
  726. goto L220;
  727. /* **** ERROR RETURNS **** */
  728. L70:
  729. info[1] = -1;
  730. if (icntl[1] > 0) {
  731. io___30.ciunit = icntl[1];
  732. s_wsfe(&io___30);
  733. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  734. e_wsfe();
  735. }
  736. if (icntl[1] > 0) {
  737. io___31.ciunit = icntl[1];
  738. s_wsfe(&io___31);
  739. do_fio(&c__1, (char *)&(*n), (ftnlen)sizeof(integer));
  740. e_wsfe();
  741. }
  742. goto L220;
  743. L100:
  744. info[1] = -2;
  745. if (icntl[1] > 0) {
  746. io___32.ciunit = icntl[1];
  747. s_wsfe(&io___32);
  748. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  749. e_wsfe();
  750. }
  751. if (icntl[1] > 0) {
  752. io___33.ciunit = icntl[1];
  753. s_wsfe(&io___33);
  754. do_fio(&c__1, (char *)&(*nz), (ftnlen)sizeof(integer));
  755. e_wsfe();
  756. }
  757. goto L220;
  758. L120:
  759. info[1] = -3;
  760. info[2] = *nz;
  761. L130:
  762. if (icntl[1] > 0) {
  763. io___34.ciunit = icntl[1];
  764. s_wsfe(&io___34);
  765. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  766. e_wsfe();
  767. }
  768. if (icntl[1] > 0) {
  769. io___35.ciunit = icntl[1];
  770. s_wsfe(&io___35);
  771. do_fio(&c__1, (char *)&(*liw), (ftnlen)sizeof(integer));
  772. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  773. e_wsfe();
  774. }
  775. goto L220;
  776. L150:
  777. info[1] = -4;
  778. info[2] = *nz + *n;
  779. L160:
  780. if (icntl[1] > 0) {
  781. io___36.ciunit = icntl[1];
  782. s_wsfe(&io___36);
  783. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  784. e_wsfe();
  785. }
  786. if (icntl[1] > 0) {
  787. io___37.ciunit = icntl[1];
  788. s_wsfe(&io___37);
  789. do_fio(&c__1, (char *)&(*la), (ftnlen)sizeof(integer));
  790. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  791. e_wsfe();
  792. }
  793. goto L220;
  794. L175:
  795. info[1] = -7;
  796. if (icntl[1] > 0) {
  797. io___38.ciunit = icntl[1];
  798. s_wsfe(&io___38);
  799. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  800. e_wsfe();
  801. }
  802. if (icntl[1] > 0) {
  803. io___39.ciunit = icntl[1];
  804. s_wsfe(&io___39);
  805. do_fio(&c__1, " NSTEPS is out of range", (ftnlen)23);
  806. e_wsfe();
  807. }
  808. goto L220;
  809. L180:
  810. if (icntl[1] > 0) {
  811. io___40.ciunit = icntl[1];
  812. s_wsfe(&io___40);
  813. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  814. e_wsfe();
  815. }
  816. if (icntl[1] > 0) {
  817. io___41.ciunit = icntl[1];
  818. s_wsfe(&io___41);
  819. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  820. e_wsfe();
  821. }
  822. goto L220;
  823. L200:
  824. if (icntl[1] > 0) {
  825. io___42.ciunit = icntl[1];
  826. s_wsfe(&io___42);
  827. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  828. e_wsfe();
  829. }
  830. if (icntl[1] > 0) {
  831. io___43.ciunit = icntl[1];
  832. s_wsfe(&io___43);
  833. e_wsfe();
  834. }
  835. L220:
  836. if (icntl[3] <= 0 || icntl[2] <= 0 || info[1] < 0) {
  837. goto L310;
  838. }
  839. /* PRINT OUTPUT PARAMETERS. */
  840. io___44.ciunit = icntl[2];
  841. s_wsfe(&io___44);
  842. do_fio(&c__1, (char *)&(*maxfrt), (ftnlen)sizeof(integer));
  843. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  844. do_fio(&c__1, (char *)&info[9], (ftnlen)sizeof(integer));
  845. do_fio(&c__1, (char *)&info[10], (ftnlen)sizeof(integer));
  846. do_fio(&c__1, (char *)&info[12], (ftnlen)sizeof(integer));
  847. do_fio(&c__1, (char *)&info[13], (ftnlen)sizeof(integer));
  848. do_fio(&c__1, (char *)&info[14], (ftnlen)sizeof(integer));
  849. do_fio(&c__1, (char *)&info[2], (ftnlen)sizeof(integer));
  850. e_wsfe();
  851. if (info[1] < 0) {
  852. goto L310;
  853. }
  854. /* PRINT OUT MATRIX FACTORS FROM MA27B/BD. */
  855. kblk = abs(iw[1]);
  856. if (kblk == 0) {
  857. goto L310;
  858. }
  859. if (icntl[3] == 1) {
  860. kblk = 1;
  861. }
  862. ipos = 2;
  863. iapos = 1;
  864. i__1 = kblk;
  865. for (iblk = 1; iblk <= i__1; ++iblk) {
  866. ncols = iw[ipos];
  867. nrows = iw[ipos + 1];
  868. j1 = ipos + 2;
  869. if (ncols > 0) {
  870. goto L240;
  871. }
  872. ncols = -ncols;
  873. nrows = 1;
  874. --j1;
  875. L240:
  876. io___52.ciunit = icntl[2];
  877. s_wsfe(&io___52);
  878. do_fio(&c__1, (char *)&iblk, (ftnlen)sizeof(integer));
  879. do_fio(&c__1, (char *)&nrows, (ftnlen)sizeof(integer));
  880. do_fio(&c__1, (char *)&ncols, (ftnlen)sizeof(integer));
  881. e_wsfe();
  882. j2 = j1 + ncols - 1;
  883. ipos = j2 + 1;
  884. io___54.ciunit = icntl[2];
  885. s_wsfe(&io___54);
  886. i__2 = j2;
  887. for (jj = j1; jj <= i__2; ++jj) {
  888. do_fio(&c__1, (char *)&iw[jj], (ftnlen)sizeof(integer));
  889. }
  890. e_wsfe();
  891. io___56.ciunit = icntl[2];
  892. s_wsfe(&io___56);
  893. e_wsfe();
  894. len = ncols;
  895. i__2 = nrows;
  896. for (irows = 1; irows <= i__2; ++irows) {
  897. j1 = iapos;
  898. j2 = iapos + len - 1;
  899. io___59.ciunit = icntl[2];
  900. s_wsfe(&io___59);
  901. i__3 = j2;
  902. for (jj = j1; jj <= i__3; ++jj) {
  903. do_fio(&c__1, (char *)&a[jj], (ftnlen)sizeof(real));
  904. }
  905. e_wsfe();
  906. --len;
  907. iapos = j2 + 1;
  908. /* L290: */
  909. }
  910. /* L300: */
  911. }
  912. L310:
  913. return 0;
  914. } /* ma27b_ */
  915. /* Subroutine */ int ma27c_(integer *n, real *a, integer *la, integer *iw,
  916. integer *liw, real *w, integer *maxfrt, real *rhs, integer *iw1,
  917. integer *nsteps, integer *icntl, integer *info)
  918. {
  919. /* Format strings */
  920. static char fmt_10[] = "(/,/,\002 ENTERING MA27C WITH N LA "
  921. "LIW MAXFRT\002,\002 NSTEPS\002,/,21x,5i7)";
  922. static char fmt_30[] = "(\002 BLOCK PIVOT =\002,i8,\002 NROWS =\002,i8"
  923. ",\002 NCOLS =\002,i8)";
  924. static char fmt_40[] = "(\002 COLUMN INDICES =\002,10i6,/,(17x,10i6))";
  925. static char fmt_50[] = "(\002 REAL ENTRIES .. EACH ROW STARTS ON A NEW L"
  926. "INE\002)";
  927. static char fmt_60[] = "(1p,5e13.3)";
  928. static char fmt_100[] = "(\002 RHS\002,1p,5e13.3,/,(4x,1p,5e13.3))";
  929. static char fmt_160[] = "(/,/,\002 LEAVING MA27C WITH\002)";
  930. /* System generated locals */
  931. integer i__1, i__2, i__3;
  932. /* Builtin functions */
  933. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  934. /* Local variables */
  935. static integer i__, k, j1, j2, jj, len, iblk, kblk, nblk;
  936. extern /* Subroutine */ int ma27q_(integer *, real *, integer *, integer *
  937. , integer *, real *, integer *, real *, integer *, integer *,
  938. integer *, integer *), ma27r_(integer *, real *, integer *,
  939. integer *, integer *, real *, integer *, real *, integer *,
  940. integer *, integer *, integer *);
  941. static integer ipos, iapos, ncols, latop, irows, nrows;
  942. /* Fortran I/O blocks */
  943. static cilist io___60 = { 0, 0, 0, fmt_10, 0 };
  944. static cilist io___68 = { 0, 0, 0, fmt_30, 0 };
  945. static cilist io___70 = { 0, 0, 0, fmt_40, 0 };
  946. static cilist io___72 = { 0, 0, 0, fmt_50, 0 };
  947. static cilist io___75 = { 0, 0, 0, fmt_60, 0 };
  948. static cilist io___77 = { 0, 0, 0, fmt_100, 0 };
  949. static cilist io___81 = { 0, 0, 0, fmt_160, 0 };
  950. static cilist io___82 = { 0, 0, 0, fmt_100, 0 };
  951. /* THIS SUBROUTINE USES THE FACTORISATION OF THE MATRIX IN A,IW TO */
  952. /* SOLVE A SYSTEM OF EQUATIONS. */
  953. /* N MUST BE SET TO THE ORDER OF THE MATRIX. IT IS NOT ALTERED. */
  954. /* A,IW HOLD INFORMATION ON THE FACTORS AND MUST BE UNCHANGED SINCE */
  955. /* THE CALL TO MA27B/BD. THEY ARE NOT ALTERED BY MA27C/CDD. */
  956. /* LA,LIW MUST BE SET TO THE LENGTHS OF A,IW RESPECTIVELY. THEY */
  957. /* ARE NOT ALTERED. */
  958. /* W USED AS A WORK ARRAY. */
  959. /* MAXFRT IS THE LENGTH OF W AND MUST BE PASSED UNCHANGED FROM THE */
  960. /* CALL TO MA27B/BD. IT IS NOT ALTERED. */
  961. /* RHS MUST BE SET TO THE RIGHT HAND SIDE FOR THE EQUATIONS BEING */
  962. /* SOLVED. ON EXIT, THIS ARRAY WILL HOLD THE SOLUTION. */
  963. /* IW1 USED AS A WORK ARRAY. */
  964. /* NSTEPS IS THE LENGTH OF IW1 WHICH MUST BE AT LEAST THE ABSOLUTE */
  965. /* VALUE OF IW(1). IT IS NOT ALTERED. */
  966. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  967. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  968. /* .. Scalar Arguments .. */
  969. /* .. */
  970. /* .. Array Arguments .. */
  971. /* .. */
  972. /* .. Local Scalars .. */
  973. /* .. */
  974. /* .. External Subroutines .. */
  975. /* .. */
  976. /* .. Intrinsic Functions .. */
  977. /* .. */
  978. /* .. Executable Statements .. */
  979. /* Parameter adjustments */
  980. --rhs;
  981. --a;
  982. --iw;
  983. --w;
  984. --iw1;
  985. --icntl;
  986. --info;
  987. /* Function Body */
  988. info[1] = 0;
  989. if (icntl[3] <= 0 || icntl[2] <= 0) {
  990. goto L110;
  991. }
  992. /* PRINT INPUT PARAMETERS. */
  993. io___60.ciunit = icntl[2];
  994. s_wsfe(&io___60);
  995. do_fio(&c__1, (char *)&(*n), (ftnlen)sizeof(integer));
  996. do_fio(&c__1, (char *)&(*la), (ftnlen)sizeof(integer));
  997. do_fio(&c__1, (char *)&(*liw), (ftnlen)sizeof(integer));
  998. do_fio(&c__1, (char *)&(*maxfrt), (ftnlen)sizeof(integer));
  999. do_fio(&c__1, (char *)&(*nsteps), (ftnlen)sizeof(integer));
  1000. e_wsfe();
  1001. /* PRINT OUT MATRIX FACTORS FROM MA27B/BD. */
  1002. kblk = abs(iw[1]);
  1003. if (kblk == 0) {
  1004. goto L90;
  1005. }
  1006. if (icntl[3] == 1) {
  1007. kblk = 1;
  1008. }
  1009. ipos = 2;
  1010. iapos = 1;
  1011. i__1 = kblk;
  1012. for (iblk = 1; iblk <= i__1; ++iblk) {
  1013. ncols = iw[ipos];
  1014. nrows = iw[ipos + 1];
  1015. j1 = ipos + 2;
  1016. if (ncols > 0) {
  1017. goto L20;
  1018. }
  1019. ncols = -ncols;
  1020. nrows = 1;
  1021. --j1;
  1022. L20:
  1023. io___68.ciunit = icntl[2];
  1024. s_wsfe(&io___68);
  1025. do_fio(&c__1, (char *)&iblk, (ftnlen)sizeof(integer));
  1026. do_fio(&c__1, (char *)&nrows, (ftnlen)sizeof(integer));
  1027. do_fio(&c__1, (char *)&ncols, (ftnlen)sizeof(integer));
  1028. e_wsfe();
  1029. j2 = j1 + ncols - 1;
  1030. ipos = j2 + 1;
  1031. io___70.ciunit = icntl[2];
  1032. s_wsfe(&io___70);
  1033. i__2 = j2;
  1034. for (jj = j1; jj <= i__2; ++jj) {
  1035. do_fio(&c__1, (char *)&iw[jj], (ftnlen)sizeof(integer));
  1036. }
  1037. e_wsfe();
  1038. io___72.ciunit = icntl[2];
  1039. s_wsfe(&io___72);
  1040. e_wsfe();
  1041. len = ncols;
  1042. i__2 = nrows;
  1043. for (irows = 1; irows <= i__2; ++irows) {
  1044. j1 = iapos;
  1045. j2 = iapos + len - 1;
  1046. io___75.ciunit = icntl[2];
  1047. s_wsfe(&io___75);
  1048. i__3 = j2;
  1049. for (jj = j1; jj <= i__3; ++jj) {
  1050. do_fio(&c__1, (char *)&a[jj], (ftnlen)sizeof(real));
  1051. }
  1052. e_wsfe();
  1053. --len;
  1054. iapos = j2 + 1;
  1055. /* L70: */
  1056. }
  1057. /* L80: */
  1058. }
  1059. L90:
  1060. k = min(10,*n);
  1061. if (icntl[3] > 1) {
  1062. k = *n;
  1063. }
  1064. if (*n > 0) {
  1065. io___77.ciunit = icntl[2];
  1066. s_wsfe(&io___77);
  1067. i__1 = k;
  1068. for (i__ = 1; i__ <= i__1; ++i__) {
  1069. do_fio(&c__1, (char *)&rhs[i__], (ftnlen)sizeof(real));
  1070. }
  1071. e_wsfe();
  1072. }
  1073. L110:
  1074. if (iw[1] < 0) {
  1075. goto L130;
  1076. }
  1077. nblk = iw[1];
  1078. if (nblk > 0) {
  1079. goto L140;
  1080. }
  1081. /* WE HAVE A ZERO MATRIX */
  1082. i__1 = *n;
  1083. for (i__ = 1; i__ <= i__1; ++i__) {
  1084. rhs[i__] = 0.f;
  1085. /* L120: */
  1086. }
  1087. goto L150;
  1088. L130:
  1089. nblk = -iw[1];
  1090. /* FORWARD SUBSTITUTION */
  1091. L140:
  1092. i__1 = *liw - 1;
  1093. ma27q_(n, &a[1], la, &iw[2], &i__1, &w[1], maxfrt, &rhs[1], &iw1[1], &
  1094. nblk, &latop, &icntl[1]);
  1095. /* BACK SUBSTITUTION. */
  1096. i__1 = *liw - 1;
  1097. ma27r_(n, &a[1], la, &iw[2], &i__1, &w[1], maxfrt, &rhs[1], &iw1[1], &
  1098. nblk, &latop, &icntl[1]);
  1099. L150:
  1100. if (icntl[3] <= 0 || icntl[2] <= 0) {
  1101. goto L170;
  1102. }
  1103. /* PRINT OUTPUT PARAMETERS. */
  1104. io___81.ciunit = icntl[2];
  1105. s_wsfe(&io___81);
  1106. e_wsfe();
  1107. if (*n > 0) {
  1108. io___82.ciunit = icntl[2];
  1109. s_wsfe(&io___82);
  1110. i__1 = k;
  1111. for (i__ = 1; i__ <= i__1; ++i__) {
  1112. do_fio(&c__1, (char *)&rhs[i__], (ftnlen)sizeof(real));
  1113. }
  1114. e_wsfe();
  1115. }
  1116. L170:
  1117. return 0;
  1118. } /* ma27c_ */
  1119. /* Subroutine */ int ma27g_(integer *n, integer *nz, integer *irn, integer *
  1120. icn, integer *iw, integer *lw, integer *ipe, integer *iq, integer *
  1121. flag__, integer *iwfr, integer *icntl, integer *info)
  1122. {
  1123. /* Format strings */
  1124. static char fmt_60[] = "(\002 *** WARNING MESSAGE FROM SUBROUTINE MA27"
  1125. "A\002,\002 *** INFO(1) =\002,i2)";
  1126. static char fmt_70[] = "(i6,\002TH NON-ZERO (IN ROW\002,i6,\002 AND COLU"
  1127. "MN\002,i6,\002) IGNORED\002)";
  1128. /* System generated locals */
  1129. integer i__1, i__2;
  1130. /* Builtin functions */
  1131. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  1132. /* Local variables */
  1133. static integer i__, j, k, l, k1, k2, n1, id, jn, lr, last, ndup;
  1134. /* Fortran I/O blocks */
  1135. static cilist io___87 = { 0, 0, 0, fmt_60, 0 };
  1136. static cilist io___88 = { 0, 0, 0, fmt_70, 0 };
  1137. /* SORT PRIOR TO CALLING ANALYSIS ROUTINE MA27H/HD. */
  1138. /* GIVEN THE POSITIONS OF THE OFF-DIAGONAL NON-ZEROS OF A SYMMETRIC */
  1139. /* MATRIX, CONSTRUCT THE SPARSITY PATTERN OF THE OFF-DIAGONAL */
  1140. /* PART OF THE WHOLE MATRIX (UPPER AND LOWER TRIANGULAR PARTS). */
  1141. /* EITHER ONE OF A PAIR (I,J),(J,I) MAY BE USED TO REPRESENT */
  1142. /* THE PAIR. DIAGONAL ELEMENTS AND DUPLICATES ARE IGNORED. */
  1143. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  1144. /* NZ MUST BE SET TO THE NUMBER OF NON-ZEROS INPUT. IT IS NOT */
  1145. /* ALTERED. */
  1146. /* IRN(I),I=1,2,...,NZ MUST BE SET TO THE ROW NUMBERS OF THE */
  1147. /* NON-ZEROS ON INPUT. IT IS NOT ALTERED UNLESS IT IS EQUIVALENCED */
  1148. /* TO IW (SEE DESCRIPTION OF IW). */
  1149. /* ICN(I),I=1,2,...,NZ MUST BE SET TO THE COLUMN NUMBERS OF THE */
  1150. /* NON-ZEROS ON INPUT. IT IS NOT ALTERED UNLESS IT IS EQUIVALENCED */
  1151. /* TO IW (SEE DESCRIPTION OF IW). */
  1152. /* IW NEED NOT BE SET ON INPUT. ON OUTPUT IT CONTAINS LISTS OF */
  1153. /* COLUMN INDICES, EACH LIST BEING HEADED BY ITS LENGTH. */
  1154. /* IRN(1) MAY BE EQUIVALENCED TO IW(1) AND ICN(1) MAY BE */
  1155. /* EQUIVALENCED TO IW(K), WHERE K.GT.NZ. */
  1156. /* LW MUST BE SET TO THE LENGTH OF IW. IT MUST BE AT LEAST 2*NZ+N. */
  1157. /* IT IS NOT ALTERED. */
  1158. /* IPE NEED NOT BE SET ON INPUT. ON OUTPUT IPE(I) POINTS TO THE START OF */
  1159. /* THE ENTRY IN IW FOR ROW I, OR IS ZERO IF THERE IS NO ENTRY. */
  1160. /* IQ NEED NOT BE SET. ON OUTPUT IQ(I),I=1,N CONTAINS THE NUMBER OF */
  1161. /* OFF-DIAGONAL N0N-ZEROS IN ROW I INCLUDING DUPLICATES. */
  1162. /* FLAG IS USED FOR WORKSPACE TO HOLD FLAGS TO PERMIT DUPLICATE ENTRIES */
  1163. /* TO BE IDENTIFIED QUICKLY. */
  1164. /* IWFR NEED NOT BE SET ON INPUT. ON OUTPUT IT POINTS TO THE FIRST */
  1165. /* UNUSED LOCATION IN IW. */
  1166. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  1167. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  1168. /* .. Scalar Arguments .. */
  1169. /* .. */
  1170. /* .. Array Arguments .. */
  1171. /* .. */
  1172. /* .. Local Scalars .. */
  1173. /* .. */
  1174. /* .. Executable Statements .. */
  1175. /* INITIALIZE INFO(2) AND COUNT IN IPE THE */
  1176. /* NUMBERS OF NON-ZEROS IN THE ROWS AND MOVE ROW AND COLUMN */
  1177. /* NUMBERS INTO IW. */
  1178. /* Parameter adjustments */
  1179. --flag__;
  1180. --iq;
  1181. --ipe;
  1182. --irn;
  1183. --icn;
  1184. --iw;
  1185. --icntl;
  1186. --info;
  1187. /* Function Body */
  1188. info[2] = 0;
  1189. i__1 = *n;
  1190. for (i__ = 1; i__ <= i__1; ++i__) {
  1191. ipe[i__] = 0;
  1192. /* L10: */
  1193. }
  1194. lr = *nz;
  1195. if (*nz == 0) {
  1196. goto L120;
  1197. }
  1198. i__1 = *nz;
  1199. for (k = 1; k <= i__1; ++k) {
  1200. i__ = irn[k];
  1201. j = icn[k];
  1202. if (i__ < j) {
  1203. if (i__ >= 1 && j <= *n) {
  1204. goto L90;
  1205. }
  1206. } else if (i__ > j) {
  1207. if (j >= 1 && i__ <= *n) {
  1208. goto L90;
  1209. }
  1210. } else {
  1211. if (i__ >= 1 && i__ <= *n) {
  1212. goto L80;
  1213. }
  1214. }
  1215. ++info[2];
  1216. info[1] = 1;
  1217. if (info[2] <= 1 && icntl[2] > 0) {
  1218. io___87.ciunit = icntl[2];
  1219. s_wsfe(&io___87);
  1220. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  1221. e_wsfe();
  1222. }
  1223. if (info[2] <= 10 && icntl[2] > 0) {
  1224. io___88.ciunit = icntl[2];
  1225. s_wsfe(&io___88);
  1226. do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer));
  1227. do_fio(&c__1, (char *)&i__, (ftnlen)sizeof(integer));
  1228. do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer));
  1229. e_wsfe();
  1230. }
  1231. L80:
  1232. i__ = 0;
  1233. j = 0;
  1234. goto L100;
  1235. L90:
  1236. ++ipe[i__];
  1237. ++ipe[j];
  1238. L100:
  1239. iw[k] = j;
  1240. ++lr;
  1241. iw[lr] = i__;
  1242. /* L110: */
  1243. }
  1244. /* ACCUMULATE ROW COUNTS TO GET POINTERS TO ROW STARTS IN BOTH IPE AND IQ */
  1245. /* AND INITIALIZE FLAG */
  1246. L120:
  1247. iq[1] = 1;
  1248. n1 = *n - 1;
  1249. if (n1 <= 0) {
  1250. goto L140;
  1251. }
  1252. i__1 = n1;
  1253. for (i__ = 1; i__ <= i__1; ++i__) {
  1254. flag__[i__] = 0;
  1255. if (ipe[i__] == 0) {
  1256. ipe[i__] = -1;
  1257. }
  1258. iq[i__ + 1] = ipe[i__] + iq[i__] + 1;
  1259. ipe[i__] = iq[i__];
  1260. /* L130: */
  1261. }
  1262. L140:
  1263. last = ipe[*n] + iq[*n];
  1264. flag__[*n] = 0;
  1265. if (lr >= last) {
  1266. goto L160;
  1267. }
  1268. k1 = lr + 1;
  1269. i__1 = last;
  1270. for (k = k1; k <= i__1; ++k) {
  1271. iw[k] = 0;
  1272. /* L150: */
  1273. }
  1274. L160:
  1275. ipe[*n] = iq[*n];
  1276. *iwfr = last + 1;
  1277. if (*nz == 0) {
  1278. goto L230;
  1279. }
  1280. /* RUN THROUGH PUTTING THE MATRIX ELEMENTS IN THE RIGHT PLACE */
  1281. /* BUT WITH SIGNS INVERTED. IQ IS USED FOR HOLDING RUNNING POINTERS */
  1282. /* AND IS LEFT HOLDING POINTERS TO ROW ENDS. */
  1283. i__1 = *nz;
  1284. for (k = 1; k <= i__1; ++k) {
  1285. j = iw[k];
  1286. if (j <= 0) {
  1287. goto L220;
  1288. }
  1289. l = k;
  1290. iw[k] = 0;
  1291. i__2 = *nz;
  1292. for (id = 1; id <= i__2; ++id) {
  1293. if (l > *nz) {
  1294. goto L170;
  1295. }
  1296. l += *nz;
  1297. goto L180;
  1298. L170:
  1299. l -= *nz;
  1300. L180:
  1301. i__ = iw[l];
  1302. iw[l] = 0;
  1303. if (i__ < j) {
  1304. goto L190;
  1305. }
  1306. l = iq[j] + 1;
  1307. iq[j] = l;
  1308. jn = iw[l];
  1309. iw[l] = -i__;
  1310. goto L200;
  1311. L190:
  1312. l = iq[i__] + 1;
  1313. iq[i__] = l;
  1314. jn = iw[l];
  1315. iw[l] = -j;
  1316. L200:
  1317. j = jn;
  1318. if (j <= 0) {
  1319. goto L220;
  1320. }
  1321. /* L210: */
  1322. }
  1323. L220:
  1324. ;
  1325. }
  1326. /* RUN THROUGH RESTORING SIGNS, REMOVING DUPLICATES AND SETTING THE */
  1327. /* MATE OF EACH NON-ZERO. */
  1328. /* NDUP COUNTS THE NUMBER OF DUPLICATE ELEMENTS. */
  1329. L230:
  1330. ndup = 0;
  1331. i__1 = *n;
  1332. for (i__ = 1; i__ <= i__1; ++i__) {
  1333. k1 = ipe[i__] + 1;
  1334. k2 = iq[i__];
  1335. if (k1 <= k2) {
  1336. goto L240;
  1337. }
  1338. /* ROW IS EMPTY. SET POINTER TO ZERO. */
  1339. ipe[i__] = 0;
  1340. iq[i__] = 0;
  1341. goto L280;
  1342. /* ON ENTRY TO THIS LOOP FLAG(J).LT.I FOR J=1,2,...,N. DURING THE LOOP */
  1343. /* FLAG(J) IS SET TO I IF A NON-ZERO IN COLUMN J IS FOUND. THIS */
  1344. /* PERMITS DUPLICATES TO BE RECOGNIZED QUICKLY. */
  1345. L240:
  1346. i__2 = k2;
  1347. for (k = k1; k <= i__2; ++k) {
  1348. j = -iw[k];
  1349. if (j <= 0) {
  1350. goto L270;
  1351. }
  1352. l = iq[j] + 1;
  1353. iq[j] = l;
  1354. iw[l] = i__;
  1355. iw[k] = j;
  1356. if (flag__[j] != i__) {
  1357. goto L250;
  1358. }
  1359. ++ndup;
  1360. iw[l] = 0;
  1361. iw[k] = 0;
  1362. L250:
  1363. flag__[j] = i__;
  1364. /* L260: */
  1365. }
  1366. L270:
  1367. iq[i__] -= ipe[i__];
  1368. if (ndup == 0) {
  1369. iw[k1 - 1] = iq[i__];
  1370. }
  1371. L280:
  1372. ;
  1373. }
  1374. if (ndup == 0) {
  1375. goto L310;
  1376. }
  1377. /* COMPRESS IW TO REMOVE DUMMY ENTRIES CAUSED BY DUPLICATES. */
  1378. *iwfr = 1;
  1379. i__1 = *n;
  1380. for (i__ = 1; i__ <= i__1; ++i__) {
  1381. k1 = ipe[i__] + 1;
  1382. if (k1 == 1) {
  1383. goto L300;
  1384. }
  1385. k2 = iq[i__] + ipe[i__];
  1386. l = *iwfr;
  1387. ipe[i__] = *iwfr;
  1388. ++(*iwfr);
  1389. i__2 = k2;
  1390. for (k = k1; k <= i__2; ++k) {
  1391. if (iw[k] == 0) {
  1392. goto L290;
  1393. }
  1394. iw[*iwfr] = iw[k];
  1395. ++(*iwfr);
  1396. L290:
  1397. ;
  1398. }
  1399. iw[l] = *iwfr - l - 1;
  1400. L300:
  1401. ;
  1402. }
  1403. L310:
  1404. return 0;
  1405. } /* ma27g_ */
  1406. /* Subroutine */ int ma27h_(integer *n, integer *ipe, integer *iw, integer *
  1407. lw, integer *iwfr, integer *nv, integer *nxt, integer *lst, integer *
  1408. ipd, integer *flag__, integer *iovflo, integer *ncmpa, real *fratio)
  1409. {
  1410. /* System generated locals */
  1411. integer i__1, i__2, i__3, i__4, i__5;
  1412. real r__1;
  1413. /* Builtin functions */
  1414. integer i_nint(real *);
  1415. /* Local variables */
  1416. static integer i__, k, l, k1, k2, id, ie, ke, md, me, ip, jp, kp, is, js,
  1417. ks, ln, ls, ml, ms, np, ns, jp1, jp2, kp0, kp1, kp2, np0, idl,
  1418. idn, len, nel, nflg;
  1419. extern /* Subroutine */ int ma27u_(integer *, integer *, integer *,
  1420. integer *, integer *, integer *);
  1421. static integer lwfr, root, limit, nvpiv, nvroot;
  1422. /* ANALYSIS SUBROUTINE */
  1423. /* GIVEN REPRESENTATION OF THE WHOLE MATRIX (EXCLUDING DIAGONAL) */
  1424. /* PERFORM MINIMUM DEGREE ORDERING, CONSTRUCTING TREE POINTERS. */
  1425. /* IT WORKS WITH SUPERVARIABLES WHICH ARE COLLECTIONS OF ONE OR MORE */
  1426. /* VARIABLES, STARTING WITH SUPERVARIABLE I CONTAINING VARIABLE I FOR */
  1427. /* I = 1,2,...,N. ALL VARIABLES IN A SUPERVARIABLE ARE ELIMINATED */
  1428. /* TOGETHER. EACH SUPERVARIABLE HAS AS NUMERICAL NAME THAT OF ONE */
  1429. /* OF ITS VARIABLES (ITS PRINCIPAL VARIABLE). */
  1430. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  1431. /* IPE(I) MUST BE SET TO POINT TO THE POSITION IN IW OF THE */
  1432. /* START OF ROW I OR HAVE THE VALUE ZERO IF ROW I HAS NO OFF- */
  1433. /* DIAGONAL NON-ZEROS. DURING EXECUTION IT IS USED AS FOLLOWS. IF */
  1434. /* SUPERVARIABLE I IS ABSORBED INTO SUPERVARIABLE J THEN IPE(I)=-J. */
  1435. /* IF SUPERVARIABLE I IS ELIMINATED THEN IPE(I) EITHER POINTS TO THE */
  1436. /* LIST OF SUPERVARIABLES FOR CREATED ELEMENT I OR IS ZERO IF */
  1437. /* THE CREATED ELEMENT IS NULL. IF ELEMENT I */
  1438. /* IS ABSORBED INTO ELEMENT J THEN IPE(I)=-J. */
  1439. /* IW MUST BE SET ON ENTRY TO HOLD LISTS OF VARIABLES BY */
  1440. /* ROWS, EACH LIST BEING HEADED BY ITS LENGTH. */
  1441. /* DURING EXECUTION THESE LISTS ARE REVISED AND HOLD */
  1442. /* LISTS OF ELEMENTS AND SUPERVARIABLES. THE ELEMENTS */
  1443. /* ALWAYS HEAD THE LISTS. WHEN A SUPERVARIABLE */
  1444. /* IS ELIMINATED ITS LIST IS REPLACED BY A LIST OF SUPERVARIABLES */
  1445. /* IN THE NEW ELEMENT. */
  1446. /* LW MUST BE SET TO THE LENGTH OF IW. IT IS NOT ALTERED. */
  1447. /* IWFR MUST BE SET TO THE POSITION IN IW OF THE FIRST FREE VARIABLE. */
  1448. /* IT IS REVISED DURING EXECUTION AND CONTINUES TO HAVE THIS MEANING. */
  1449. /* NV(JS) NEED NOT BE SET. DURING EXECUTION IT IS ZERO IF */
  1450. /* JS IS NOT A PRINCIPAL VARIABLE AND IF IT IS IT HOLDS */
  1451. /* THE NUMBER OF VARIABLES IN SUPERVARIABLE JS. FOR ELIMINATED */
  1452. /* VARIABLES IT IS SET TO THE DEGREE AT THE TIME OF ELIMINATION. */
  1453. /* NXT(JS) NEED NOT BE SET. DURING EXECUTION IT IS THE NEXT */
  1454. /* SUPERVARIABLE HAVING THE SAME DEGREE AS JS, OR ZERO */
  1455. /* IF IT IS LAST IN ITS LIST. */
  1456. /* LST(JS) NEED NOT BE SET. DURING EXECUTION IT IS THE */
  1457. /* LAST SUPERVARIABLE HAVING THE SAME DEGREE AS JS OR */
  1458. /* -(ITS DEGREE) IF IT IS FIRST IN ITS LIST. */
  1459. /* IPD(ID) NEED NOT BE SET. DURING EXECUTION IT */
  1460. /* IS THE FIRST SUPERVARIABLE WITH DEGREE ID OR ZERO */
  1461. /* IF THERE ARE NONE. */
  1462. /* FLAG IS USED AS WORKSPACE FOR ELEMENT AND SUPERVARIABLE FLAGS. */
  1463. /* WHILE THE CODE IS FINDING THE DEGREE OF SUPERVARIABLE IS */
  1464. /* FLAG HAS THE FOLLOWING VALUES. */
  1465. /* A) FOR THE CURRENT PIVOT/NEW ELEMENT ME */
  1466. /* FLAG(ME)=-1 */
  1467. /* B) FOR VARIABLES JS */
  1468. /* FLAG(JS)=-1 IF JS IS NOT A PRINCIPAL VARIABLE */
  1469. /* FLAG(JS)=0 IF JS IS A SUPERVARIABLE IN THE NEW ELEMENT */
  1470. /* FLAG(JS)=NFLG IF JS IS A SUPERVARIABLE NOT IN THE NEW */
  1471. /* ELEMENT THAT HAS BEEN COUNTED IN THE DEGREE */
  1472. /* CALCULATION */
  1473. /* FLAG(JS).GT.NFLG IF JS IS A SUPERVARIABLE NOT IN THE NEW */
  1474. /* ELEMENT THAT HAS NOT BEEN COUNTED IN THE DEGREE */
  1475. /* CALCULATION */
  1476. /* C) FOR ELEMENTS IE */
  1477. /* FLAG(IE)=-1 IF ELEMENT IE HAS BEEN MERGED INTO ANOTHER */
  1478. /* FLAG(IE)=-NFLG IF ELEMENT IE HAS BEEN USED IN THE DEGREE */
  1479. /* CALCULATION FOR IS. */
  1480. /* FLAG(IE).LT.-NFLG IF ELEMENT IE HAS NOT BEEN USED IN THE */
  1481. /* DEGREE CALCULATION FOR IS */
  1482. /* IOVFLO see ICNTL(4) in MA27A/AD. */
  1483. /* NCMPA see INFO(11) in MA27A/AD. */
  1484. /* FRATIO see CNTL(2) in MA27A/AD. */
  1485. /* .. Scalar Arguments .. */
  1486. /* .. */
  1487. /* .. Array Arguments .. */
  1488. /* .. */
  1489. /* .. Local Scalars .. */
  1490. /* LIMIT Limit on number of variables for putting node in root. */
  1491. /* NVROOT Number of variables in the root node */
  1492. /* ROOT Index of the root node (N+1 if none chosen yet). */
  1493. /* .. */
  1494. /* .. External Subroutines .. */
  1495. /* .. */
  1496. /* .. Intrinsic Functions .. */
  1497. /* .. */
  1498. /* If a column of the reduced matrix has relative density greater than */
  1499. /* CNTL(2), it is forced into the root. All such columns are taken to */
  1500. /* have sparsity pattern equal to their merged patterns, so the fill */
  1501. /* and operation counts may be overestimated. */
  1502. /* IS,JS,KS,LS,MS,NS ARE USED TO REFER TO SUPERVARIABLES. */
  1503. /* IE,JE,KE ARE USED TO REFER TO ELEMENTS. */
  1504. /* IP,JP,KP,K,NP ARE USED TO POINT TO LISTS OF ELEMENTS. */
  1505. /* OR SUPERVARIABLES. */
  1506. /* ID IS USED FOR THE DEGREE OF A SUPERVARIABLE. */
  1507. /* MD IS USED FOR THE CURRENT MINIMUM DEGREE. */
  1508. /* IDN IS USED FOR THE NO. OF VARIABLES IN A NEWLY CREATED ELEMENT */
  1509. /* NEL IS USED TO HOLD THE NO. OF VARIABLES THAT HAVE BEEN */
  1510. /* ELIMINATED. */
  1511. /* ME=MS IS THE NAME OF THE SUPERVARIABLE ELIMINATED AND */
  1512. /* OF THE ELEMENT CREATED IN THE MAIN LOOP. */
  1513. /* NFLG IS USED FOR THE CURRENT FLAG VALUE IN ARRAY FLAG. IT STARTS */
  1514. /* WITH THE VALUE IOVFLO AND IS REDUCED BY 1 EACH TIME IT IS USED */
  1515. /* UNTIL IT HAS THE VALUE 2 WHEN IT IS RESET TO THE VALUE IOVFLO. */
  1516. /* .. Executable Statements .. */
  1517. /* INITIALIZATIONS */
  1518. /* Parameter adjustments */
  1519. --flag__;
  1520. --ipd;
  1521. --lst;
  1522. --nxt;
  1523. --nv;
  1524. --ipe;
  1525. --iw;
  1526. /* Function Body */
  1527. i__1 = *n;
  1528. for (i__ = 1; i__ <= i__1; ++i__) {
  1529. ipd[i__] = 0;
  1530. nv[i__] = 1;
  1531. flag__[i__] = *iovflo;
  1532. /* L10: */
  1533. }
  1534. md = 1;
  1535. *ncmpa = 0;
  1536. nflg = *iovflo;
  1537. nel = 0;
  1538. root = *n + 1;
  1539. nvroot = 0;
  1540. /* LINK TOGETHER VARIABLES HAVING SAME DEGREE */
  1541. i__1 = *n;
  1542. for (is = 1; is <= i__1; ++is) {
  1543. k = ipe[is];
  1544. if (k <= 0) {
  1545. goto L20;
  1546. }
  1547. id = iw[k] + 1;
  1548. ns = ipd[id];
  1549. if (ns > 0) {
  1550. lst[ns] = is;
  1551. }
  1552. nxt[is] = ns;
  1553. ipd[id] = is;
  1554. lst[is] = -id;
  1555. goto L30;
  1556. /* WE HAVE A VARIABLE THAT CAN BE ELIMINATED AT ONCE BECAUSE THERE IS */
  1557. /* NO OFF-DIAGONAL NON-ZERO IN ITS ROW. */
  1558. L20:
  1559. ++nel;
  1560. flag__[is] = -1;
  1561. nxt[is] = 0;
  1562. lst[is] = 0;
  1563. L30:
  1564. ;
  1565. }
  1566. /* START OF MAIN LOOP */
  1567. i__1 = *n;
  1568. for (ml = 1; ml <= i__1; ++ml) {
  1569. /* LEAVE LOOP IF ALL VARIABLES HAVE BEEN ELIMINATED. */
  1570. if (nel + nvroot + 1 >= *n) {
  1571. goto L350;
  1572. }
  1573. /* FIND NEXT SUPERVARIABLE FOR ELIMINATION. */
  1574. i__2 = *n;
  1575. for (id = md; id <= i__2; ++id) {
  1576. ms = ipd[id];
  1577. if (ms > 0) {
  1578. goto L50;
  1579. }
  1580. /* L40: */
  1581. }
  1582. L50:
  1583. md = id;
  1584. /* NVPIV HOLDS THE NUMBER OF VARIABLES IN THE PIVOT. */
  1585. nvpiv = nv[ms];
  1586. /* REMOVE CHOSEN VARIABLE FROM LINKED LIST */
  1587. ns = nxt[ms];
  1588. nxt[ms] = 0;
  1589. lst[ms] = 0;
  1590. if (ns > 0) {
  1591. lst[ns] = -id;
  1592. }
  1593. ipd[id] = ns;
  1594. me = ms;
  1595. nel += nvpiv;
  1596. /* IDN HOLDS THE DEGREE OF THE NEW ELEMENT. */
  1597. idn = 0;
  1598. /* RUN THROUGH THE LIST OF THE PIVOTAL SUPERVARIABLE, SETTING TREE */
  1599. /* POINTERS AND CONSTRUCTING NEW LIST OF SUPERVARIABLES. */
  1600. /* KP IS A POINTER TO THE CURRENT POSITION IN THE OLD LIST. */
  1601. kp = ipe[me];
  1602. flag__[ms] = -1;
  1603. /* IP POINTS TO THE START OF THE NEW LIST. */
  1604. ip = *iwfr;
  1605. /* LEN HOLDS THE LENGTH OF THE LIST ASSOCIATED WITH THE PIVOT. */
  1606. len = iw[kp];
  1607. i__2 = len;
  1608. for (kp1 = 1; kp1 <= i__2; ++kp1) {
  1609. ++kp;
  1610. ke = iw[kp];
  1611. /* JUMP IF KE IS AN ELEMENT THAT HAS NOT BEEN MERGED INTO ANOTHER. */
  1612. if (flag__[ke] <= -2) {
  1613. goto L60;
  1614. }
  1615. /* JUMP IF KE IS AN ELEMENT THAT HAS BEEN MERGED INTO ANOTHER OR IS */
  1616. /* A SUPERVARIABLE THAT HAS BEEN ELIMINATED. */
  1617. if (flag__[ke] <= 0) {
  1618. if (ipe[ke] != -root) {
  1619. goto L140;
  1620. }
  1621. /* KE has been merged into the root */
  1622. ke = root;
  1623. if (flag__[ke] <= 0) {
  1624. goto L140;
  1625. }
  1626. }
  1627. /* WE HAVE A SUPERVARIABLE. PREPARE TO SEARCH REST OF LIST. */
  1628. jp = kp - 1;
  1629. ln = len - kp1 + 1;
  1630. ie = ms;
  1631. goto L70;
  1632. /* SEARCH VARIABLE LIST OF ELEMENT KE, USING JP AS A POINTER TO IT. */
  1633. L60:
  1634. ie = ke;
  1635. jp = ipe[ie];
  1636. ln = iw[jp];
  1637. /* SEARCH FOR DIFFERENT SUPERVARIABLES AND ADD THEM TO THE NEW LIST, */
  1638. /* COMPRESSING WHEN NECESSARY. THIS LOOP IS EXECUTED ONCE FOR */
  1639. /* EACH ELEMENT IN THE LIST AND ONCE FOR ALL THE SUPERVARIABLES */
  1640. /* IN THE LIST. */
  1641. L70:
  1642. i__3 = ln;
  1643. for (jp1 = 1; jp1 <= i__3; ++jp1) {
  1644. ++jp;
  1645. is = iw[jp];
  1646. /* JUMP IF IS IS NOT A PRINCIPAL VARIABLE OR HAS ALREADY BEEN COUNTED. */
  1647. if (flag__[is] <= 0) {
  1648. if (ipe[is] == -root) {
  1649. /* IS has been merged into the root */
  1650. is = root;
  1651. iw[jp] = root;
  1652. if (flag__[is] <= 0) {
  1653. goto L130;
  1654. }
  1655. } else {
  1656. goto L130;
  1657. }
  1658. }
  1659. flag__[is] = 0;
  1660. if (*iwfr < *lw) {
  1661. goto L100;
  1662. }
  1663. /* PREPARE FOR COMPRESSING IW BY ADJUSTING POINTERS AND */
  1664. /* LENGTHS SO THAT THE LISTS BEING SEARCHED IN THE INNER AND OUTER */
  1665. /* LOOPS CONTAIN ONLY THE REMAINING ENTRIES. */
  1666. ipe[ms] = kp;
  1667. iw[kp] = len - kp1;
  1668. ipe[ie] = jp;
  1669. iw[jp] = ln - jp1;
  1670. /* COMPRESS IW */
  1671. i__4 = ip - 1;
  1672. ma27u_(n, &ipe[1], &iw[1], &i__4, &lwfr, ncmpa);
  1673. /* COPY NEW LIST FORWARD */
  1674. jp2 = *iwfr - 1;
  1675. *iwfr = lwfr;
  1676. if (ip > jp2) {
  1677. goto L90;
  1678. }
  1679. i__4 = jp2;
  1680. for (jp = ip; jp <= i__4; ++jp) {
  1681. iw[*iwfr] = iw[jp];
  1682. ++(*iwfr);
  1683. /* L80: */
  1684. }
  1685. /* ADJUST POINTERS FOR THE NEW LIST AND THE LISTS BEING SEARCHED. */
  1686. L90:
  1687. ip = lwfr;
  1688. jp = ipe[ie];
  1689. kp = ipe[me];
  1690. /* STORE IS IN NEW LIST. */
  1691. L100:
  1692. iw[*iwfr] = is;
  1693. idn += nv[is];
  1694. ++(*iwfr);
  1695. /* REMOVE IS FROM DEGREE LINKED LIST */
  1696. ls = lst[is];
  1697. lst[is] = 0;
  1698. ns = nxt[is];
  1699. nxt[is] = 0;
  1700. if (ns > 0) {
  1701. lst[ns] = ls;
  1702. }
  1703. if (ls < 0) {
  1704. ls = -ls;
  1705. ipd[ls] = ns;
  1706. } else if (ls > 0) {
  1707. nxt[ls] = ns;
  1708. }
  1709. L130:
  1710. ;
  1711. }
  1712. /* JUMP IF WE HAVE JUST BEEN SEARCHING THE VARIABLES AT THE END OF */
  1713. /* THE LIST OF THE PIVOT. */
  1714. if (ie == ms) {
  1715. goto L150;
  1716. }
  1717. /* SET TREE POINTER AND FLAG TO INDICATE ELEMENT IE IS ABSORBED INTO */
  1718. /* NEW ELEMENT ME. */
  1719. ipe[ie] = -me;
  1720. flag__[ie] = -1;
  1721. L140:
  1722. ;
  1723. }
  1724. /* STORE THE DEGREE OF THE PIVOT. */
  1725. L150:
  1726. nv[ms] = idn + nvpiv;
  1727. /* JUMP IF NEW ELEMENT IS NULL. */
  1728. if (*iwfr == ip) {
  1729. goto L330;
  1730. }
  1731. k1 = ip;
  1732. k2 = *iwfr - 1;
  1733. /* RUN THROUGH NEW LIST OF SUPERVARIABLES REVISING EACH ASSOCIATED LIST, */
  1734. /* RECALCULATING DEGREES AND REMOVING DUPLICATES. */
  1735. r__1 = *fratio * (*n - nel);
  1736. limit = i_nint(&r__1);
  1737. i__2 = k2;
  1738. for (k = k1; k <= i__2; ++k) {
  1739. is = iw[k];
  1740. if (is == root) {
  1741. goto L310;
  1742. }
  1743. if (nflg > 2) {
  1744. goto L170;
  1745. }
  1746. /* RESET FLAG VALUES TO +/-IOVFLO. */
  1747. i__3 = *n;
  1748. for (i__ = 1; i__ <= i__3; ++i__) {
  1749. if (flag__[i__] > 0) {
  1750. flag__[i__] = *iovflo;
  1751. }
  1752. if (flag__[i__] <= -2) {
  1753. flag__[i__] = -(*iovflo);
  1754. }
  1755. /* L160: */
  1756. }
  1757. nflg = *iovflo;
  1758. /* REDUCE NFLG BY ONE TO CATER FOR THIS SUPERVARIABLE. */
  1759. L170:
  1760. --nflg;
  1761. /* BEGIN WITH THE DEGREE OF THE NEW ELEMENT. ITS VARIABLES MUST ALWAYS */
  1762. /* BE COUNTED DURING THE DEGREE CALCULATION AND THEY ARE ALREADY */
  1763. /* FLAGGED WITH THE VALUE 0. */
  1764. id = idn;
  1765. /* RUN THROUGH THE LIST ASSOCIATED WITH SUPERVARIABLE IS */
  1766. kp1 = ipe[is] + 1;
  1767. /* NP POINTS TO THE NEXT ENTRY IN THE REVISED LIST. */
  1768. np = kp1;
  1769. kp2 = iw[kp1 - 1] + kp1 - 1;
  1770. i__3 = kp2;
  1771. for (kp = kp1; kp <= i__3; ++kp) {
  1772. ke = iw[kp];
  1773. /* TEST WHETHER KE IS AN ELEMENT, A REDUNDANT ENTRY OR A SUPERVARIABLE. */
  1774. if (flag__[ke] == -1) {
  1775. if (ipe[ke] != -root) {
  1776. goto L220;
  1777. }
  1778. /* KE has been merged into the root */
  1779. ke = root;
  1780. iw[kp] = root;
  1781. if (flag__[ke] == -1) {
  1782. goto L220;
  1783. }
  1784. }
  1785. if (flag__[ke] >= 0) {
  1786. goto L230;
  1787. }
  1788. /* SEARCH LIST OF ELEMENT KE, REVISING THE DEGREE WHEN NEW VARIABLES */
  1789. /* FOUND. */
  1790. jp1 = ipe[ke] + 1;
  1791. jp2 = iw[jp1 - 1] + jp1 - 1;
  1792. idl = id;
  1793. i__4 = jp2;
  1794. for (jp = jp1; jp <= i__4; ++jp) {
  1795. js = iw[jp];
  1796. /* JUMP IF JS HAS ALREADY BEEN COUNTED. */
  1797. if (flag__[js] <= nflg) {
  1798. goto L190;
  1799. }
  1800. id += nv[js];
  1801. flag__[js] = nflg;
  1802. L190:
  1803. ;
  1804. }
  1805. /* JUMP IF ONE OR MORE NEW SUPERVARIABLES WERE FOUND. */
  1806. if (id > idl) {
  1807. goto L210;
  1808. }
  1809. /* CHECK WHETHER EVERY VARIABLE OF ELEMENT KE IS IN NEW ELEMENT ME. */
  1810. i__4 = jp2;
  1811. for (jp = jp1; jp <= i__4; ++jp) {
  1812. js = iw[jp];
  1813. if (flag__[js] != 0) {
  1814. goto L210;
  1815. }
  1816. /* L200: */
  1817. }
  1818. /* SET TREE POINTER AND FLAG TO INDICATE THAT ELEMENT KE IS ABSORBED */
  1819. /* INTO NEW ELEMENT ME. */
  1820. ipe[ke] = -me;
  1821. flag__[ke] = -1;
  1822. goto L220;
  1823. /* STORE ELEMENT KE IN THE REVISED LIST FOR SUPERVARIABLE IS AND FLAG IT. */
  1824. L210:
  1825. iw[np] = ke;
  1826. flag__[ke] = -nflg;
  1827. ++np;
  1828. L220:
  1829. ;
  1830. }
  1831. np0 = np;
  1832. goto L250;
  1833. /* TREAT THE REST OF THE LIST ASSOCIATED WITH SUPERVARIABLE IS. IT */
  1834. /* CONSISTS ENTIRELY OF SUPERVARIABLES. */
  1835. L230:
  1836. kp0 = kp;
  1837. np0 = np;
  1838. i__3 = kp2;
  1839. for (kp = kp0; kp <= i__3; ++kp) {
  1840. ks = iw[kp];
  1841. if (flag__[ks] <= nflg) {
  1842. if (ipe[ks] == -root) {
  1843. ks = root;
  1844. iw[kp] = root;
  1845. if (flag__[ks] <= nflg) {
  1846. goto L240;
  1847. }
  1848. } else {
  1849. goto L240;
  1850. }
  1851. }
  1852. /* ADD TO DEGREE, FLAG SUPERVARIABLE KS AND ADD IT TO NEW LIST. */
  1853. id += nv[ks];
  1854. flag__[ks] = nflg;
  1855. iw[np] = ks;
  1856. ++np;
  1857. L240:
  1858. ;
  1859. }
  1860. /* MOVE FIRST SUPERVARIABLE TO END OF LIST, MOVE FIRST ELEMENT TO END */
  1861. /* OF ELEMENT PART OF LIST AND ADD NEW ELEMENT TO FRONT OF LIST. */
  1862. L250:
  1863. if (id >= limit) {
  1864. goto L295;
  1865. }
  1866. iw[np] = iw[np0];
  1867. iw[np0] = iw[kp1];
  1868. iw[kp1] = me;
  1869. /* STORE THE NEW LENGTH OF THE LIST. */
  1870. iw[kp1 - 1] = np - kp1 + 1;
  1871. /* CHECK WHETHER ROW IS IS IDENTICAL TO ANOTHER BY LOOKING IN LINKED */
  1872. /* LIST OF SUPERVARIABLES WITH DEGREE ID AT THOSE WHOSE LISTS HAVE */
  1873. /* FIRST ENTRY ME. NOTE THAT THOSE CONTAINING ME COME FIRST SO THE */
  1874. /* SEARCH CAN BE TERMINATED WHEN A LIST NOT STARTING WITH ME IS */
  1875. /* FOUND. */
  1876. js = ipd[id];
  1877. i__3 = *n;
  1878. for (l = 1; l <= i__3; ++l) {
  1879. if (js <= 0) {
  1880. goto L300;
  1881. }
  1882. kp1 = ipe[js] + 1;
  1883. if (iw[kp1] != me) {
  1884. goto L300;
  1885. }
  1886. /* JS HAS SAME DEGREE AND IS ACTIVE. CHECK IF IDENTICAL TO IS. */
  1887. kp2 = kp1 - 1 + iw[kp1 - 1];
  1888. i__4 = kp2;
  1889. for (kp = kp1; kp <= i__4; ++kp) {
  1890. ie = iw[kp];
  1891. /* JUMP IF IE IS A SUPERVARIABLE OR AN ELEMENT NOT IN THE LIST OF IS. */
  1892. if ((i__5 = flag__[ie], abs(i__5)) > nflg) {
  1893. goto L270;
  1894. }
  1895. /* L260: */
  1896. }
  1897. goto L290;
  1898. L270:
  1899. js = nxt[js];
  1900. /* L280: */
  1901. }
  1902. /* SUPERVARIABLE AMALGAMATION. ROW IS IS IDENTICAL TO ROW JS. */
  1903. /* REGARD ALL VARIABLES IN THE TWO SUPERVARIABLES AS BEING IN IS. SET */
  1904. /* TREE POINTER, FLAG AND NV ENTRIES. */
  1905. L290:
  1906. ipe[js] = -is;
  1907. nv[is] += nv[js];
  1908. nv[js] = 0;
  1909. flag__[js] = -1;
  1910. /* REPLACE JS BY IS IN LINKED LIST. */
  1911. ns = nxt[js];
  1912. ls = lst[js];
  1913. if (ns > 0) {
  1914. lst[ns] = is;
  1915. }
  1916. if (ls > 0) {
  1917. nxt[ls] = is;
  1918. }
  1919. lst[is] = ls;
  1920. nxt[is] = ns;
  1921. lst[js] = 0;
  1922. nxt[js] = 0;
  1923. if (ipd[id] == js) {
  1924. ipd[id] = is;
  1925. }
  1926. goto L310;
  1927. /* Treat IS as full. Merge it into the root node. */
  1928. L295:
  1929. if (nvroot == 0) {
  1930. root = is;
  1931. ipe[is] = 0;
  1932. } else {
  1933. iw[k] = root;
  1934. ipe[is] = -root;
  1935. nv[root] += nv[is];
  1936. nv[is] = 0;
  1937. flag__[is] = -1;
  1938. }
  1939. nvroot = nv[root];
  1940. goto L310;
  1941. /* INSERT IS INTO LINKED LIST OF SUPERVARIABLES OF SAME DEGREE. */
  1942. L300:
  1943. ns = ipd[id];
  1944. if (ns > 0) {
  1945. lst[ns] = is;
  1946. }
  1947. nxt[is] = ns;
  1948. ipd[id] = is;
  1949. lst[is] = -id;
  1950. md = min(md,id);
  1951. L310:
  1952. ;
  1953. }
  1954. /* RESET FLAGS FOR SUPERVARIABLES IN NEWLY CREATED ELEMENT AND */
  1955. /* REMOVE THOSE ABSORBED INTO OTHERS. */
  1956. i__2 = k2;
  1957. for (k = k1; k <= i__2; ++k) {
  1958. is = iw[k];
  1959. if (nv[is] == 0) {
  1960. goto L320;
  1961. }
  1962. flag__[is] = nflg;
  1963. iw[ip] = is;
  1964. ++ip;
  1965. L320:
  1966. ;
  1967. }
  1968. *iwfr = k1;
  1969. flag__[me] = -nflg;
  1970. /* MOVE FIRST ENTRY TO END TO MAKE ROOM FOR LENGTH. */
  1971. iw[ip] = iw[k1];
  1972. iw[k1] = ip - k1;
  1973. /* SET POINTER FOR NEW ELEMENT AND RESET IWFR. */
  1974. ipe[me] = k1;
  1975. *iwfr = ip + 1;
  1976. goto L335;
  1977. L330:
  1978. ipe[me] = 0;
  1979. L335:
  1980. /* L340: */
  1981. ;
  1982. }
  1983. /* Absorb any remaining variables into the root */
  1984. L350:
  1985. i__1 = *n;
  1986. for (is = 1; is <= i__1; ++is) {
  1987. if (nxt[is] != 0 || lst[is] != 0) {
  1988. if (nvroot == 0) {
  1989. root = is;
  1990. ipe[is] = 0;
  1991. } else {
  1992. ipe[is] = -root;
  1993. }
  1994. nvroot += nv[is];
  1995. nv[is] = 0;
  1996. }
  1997. /* L360: */
  1998. }
  1999. /* Link any remaining elements to the root */
  2000. i__1 = *n;
  2001. for (ie = 1; ie <= i__1; ++ie) {
  2002. if (ipe[ie] > 0) {
  2003. ipe[ie] = -root;
  2004. }
  2005. /* L370: */
  2006. }
  2007. if (nvroot > 0) {
  2008. nv[root] = nvroot;
  2009. }
  2010. return 0;
  2011. } /* ma27h_ */
  2012. /* Subroutine */ int ma27u_(integer *n, integer *ipe, integer *iw, integer *
  2013. lw, integer *iwfr, integer *ncmpa)
  2014. {
  2015. /* System generated locals */
  2016. integer i__1, i__2;
  2017. /* Local variables */
  2018. static integer i__, k, k1, k2, ir, lwfr;
  2019. /* COMPRESS LISTS HELD BY MA27H/HD AND MA27K/KD IN IW AND ADJUST POINTERS */
  2020. /* IN IPE TO CORRESPOND. */
  2021. /* N IS THE MATRIX ORDER. IT IS NOT ALTERED. */
  2022. /* IPE(I) POINTS TO THE POSITION IN IW OF THE START OF LIST I OR IS */
  2023. /* ZERO IF THERE IS NO LIST I. ON EXIT IT POINTS TO THE NEW POSITION. */
  2024. /* IW HOLDS THE LISTS, EACH HEADED BY ITS LENGTH. ON OUTPUT THE SAME */
  2025. /* LISTS ARE HELD, BUT THEY ARE NOW COMPRESSED TOGETHER. */
  2026. /* LW HOLDS THE LENGTH OF IW. IT IS NOT ALTERED. */
  2027. /* IWFR NEED NOT BE SET ON ENTRY. ON EXIT IT POINTS TO THE FIRST FREE */
  2028. /* LOCATION IN IW. */
  2029. /* ON RETURN IT IS SET TO THE FIRST FREE LOCATION IN IW. */
  2030. /* NCMPA see INFO(11) in MA27A/AD. */
  2031. /* .. Scalar Arguments .. */
  2032. /* .. */
  2033. /* .. Array Arguments .. */
  2034. /* .. */
  2035. /* .. Local Scalars .. */
  2036. /* .. */
  2037. /* .. Executable Statements .. */
  2038. /* Parameter adjustments */
  2039. --ipe;
  2040. --iw;
  2041. /* Function Body */
  2042. ++(*ncmpa);
  2043. /* PREPARE FOR COMPRESSING BY STORING THE LENGTHS OF THE */
  2044. /* LISTS IN IPE AND SETTING THE FIRST ENTRY OF EACH LIST TO */
  2045. /* -(LIST NUMBER). */
  2046. i__1 = *n;
  2047. for (i__ = 1; i__ <= i__1; ++i__) {
  2048. k1 = ipe[i__];
  2049. if (k1 <= 0) {
  2050. goto L10;
  2051. }
  2052. ipe[i__] = iw[k1];
  2053. iw[k1] = -i__;
  2054. L10:
  2055. ;
  2056. }
  2057. /* COMPRESS */
  2058. /* IWFR POINTS JUST BEYOND THE END OF THE COMPRESSED FILE. */
  2059. /* LWFR POINTS JUST BEYOND THE END OF THE UNCOMPRESSED FILE. */
  2060. *iwfr = 1;
  2061. lwfr = *iwfr;
  2062. i__1 = *n;
  2063. for (ir = 1; ir <= i__1; ++ir) {
  2064. if (lwfr > *lw) {
  2065. goto L70;
  2066. }
  2067. /* SEARCH FOR THE NEXT NEGATIVE ENTRY. */
  2068. i__2 = *lw;
  2069. for (k = lwfr; k <= i__2; ++k) {
  2070. if (iw[k] < 0) {
  2071. goto L30;
  2072. }
  2073. /* L20: */
  2074. }
  2075. goto L70;
  2076. /* PICK UP ENTRY NUMBER, STORE LENGTH IN NEW POSITION, SET NEW POINTER */
  2077. /* AND PREPARE TO COPY LIST. */
  2078. L30:
  2079. i__ = -iw[k];
  2080. iw[*iwfr] = ipe[i__];
  2081. ipe[i__] = *iwfr;
  2082. k1 = k + 1;
  2083. k2 = k + iw[*iwfr];
  2084. ++(*iwfr);
  2085. if (k1 > k2) {
  2086. goto L50;
  2087. }
  2088. /* COPY LIST TO NEW POSITION. */
  2089. i__2 = k2;
  2090. for (k = k1; k <= i__2; ++k) {
  2091. iw[*iwfr] = iw[k];
  2092. ++(*iwfr);
  2093. /* L40: */
  2094. }
  2095. L50:
  2096. lwfr = k2 + 1;
  2097. /* L60: */
  2098. }
  2099. L70:
  2100. return 0;
  2101. } /* ma27u_ */
  2102. /* Subroutine */ int ma27j_(integer *n, integer *nz, integer *irn, integer *
  2103. icn, integer *perm, integer *iw, integer *lw, integer *ipe, integer *
  2104. iq, integer *flag__, integer *iwfr, integer *icntl, integer *info)
  2105. {
  2106. /* Format strings */
  2107. static char fmt_60[] = "(\002 *** WARNING MESSAGE FROM SUBROUTINE MA27"
  2108. "A\002,\002 *** INFO(1) =\002,i2)";
  2109. static char fmt_70[] = "(i6,\002TH NON-ZERO (IN ROW\002,i6,\002 AND COLU"
  2110. "MN\002,i6,\002) IGNORED\002)";
  2111. /* System generated locals */
  2112. integer i__1, i__2;
  2113. /* Builtin functions */
  2114. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  2115. /* Local variables */
  2116. static integer i__, j, k, l, k1, k2, id, in, len, lbig, jdummy;
  2117. /* Fortran I/O blocks */
  2118. static cilist io___144 = { 0, 0, 0, fmt_60, 0 };
  2119. static cilist io___145 = { 0, 0, 0, fmt_70, 0 };
  2120. /* SORT PRIOR TO CALLING ANALYSIS ROUTINE MA27K/KD. */
  2121. /* GIVEN THE POSITIONS OF THE OFF-DIAGONAL NON-ZEROS OF A SYMMETRIC */
  2122. /* MATRIX AND A PERMUTATION, CONSTRUCT THE SPARSITY PATTERN */
  2123. /* OF THE STRICTLY UPPER TRIANGULAR PART OF THE PERMUTED MATRIX. */
  2124. /* EITHER ONE OF A PAIR (I,J),(J,I) MAY BE USED TO REPRESENT */
  2125. /* THE PAIR. DIAGONAL ELEMENTS ARE IGNORED. NO CHECK IS MADE */
  2126. /* FOR DUPLICATE ELEMENTS UNLESS ANY ROW HAS MORE THAN ICNTL(4) */
  2127. /* NON-ZEROS, IN WHICH CASE DUPLICATES ARE REMOVED. */
  2128. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  2129. /* NZ MUST BE SET TO THE NUMBER OF NON-ZEROS INPUT. IT IS NOT */
  2130. /* ALTERED. */
  2131. /* IRN(I),I=1,2,...,NZ MUST BE SET TO THE ROW INDICES OF THE */
  2132. /* NON-ZEROS ON INPUT. IT IS NOT ALTERED UNLESS EQUIVALENCED WITH IW. */
  2133. /* IRN(1) MAY BE EQUIVALENCED WITH IW(1). */
  2134. /* ICN(I),I=1,2,...,NZ MUST BE SET TO THE COLUMN INDICES OF THE */
  2135. /* NON-ZEROS ON INPUT. IT IS NOT ALTERED UNLESS EQUIVALENCED */
  2136. /* WITH IW.ICN(1) MAY BE EQUIVELENCED WITH IW(K),K.GT.NZ. */
  2137. /* PERM(I) MUST BE SET TO HOLD THE POSITION OF VARIABLE I IN THE */
  2138. /* PERMUTED ORDER. IT IS NOT ALTERED. */
  2139. /* IW NEED NOT BE SET ON INPUT. ON OUTPUT IT CONTAINS LISTS OF */
  2140. /* COLUMN NUMBERS, EACH LIST BEING HEADED BY ITS LENGTH. */
  2141. /* LW MUST BE SET TO THE LENGTH OF IW. IT MUST BE AT LEAST */
  2142. /* MAX(NZ,N+(NO. OF OFF-DIAGONAL NON-ZEROS)). IT IS NOT ALTERED. */
  2143. /* IPE NEED NOT BE SET ON INPUT. ON OUTPUT IPE(I) POINTS TO THE START OF */
  2144. /* THE ENTRY IN IW FOR ROW I, OR IS ZERO IF THERE IS NO ENTRY. */
  2145. /* IQ NEED NOT BE SET. ON OUTPUT IQ(I) CONTAINS THE NUMBER OF */
  2146. /* OFF-DIAGONAL NON-ZEROS IN ROW I, INCLUDING DUPLICATES. */
  2147. /* FLAG IS USED FOR WORKSPACE TO HOLD FLAGS TO PERMIT DUPLICATE */
  2148. /* ENTRIES TO BE IDENTIFIED QUICKLY. */
  2149. /* IWFR NEED NOT BE SET ON INPUT. ON OUTPUT IT POINTS TO THE FIRST */
  2150. /* UNUSED LOCATION IN IW. */
  2151. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  2152. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  2153. /* .. Scalar Arguments .. */
  2154. /* .. */
  2155. /* .. Array Arguments .. */
  2156. /* .. */
  2157. /* .. Local Scalars .. */
  2158. /* .. */
  2159. /* .. Intrinsic Functions .. */
  2160. /* .. */
  2161. /* .. Executable Statements .. */
  2162. /* INITIALIZE INFO(1), INFO(2) AND IQ */
  2163. /* Parameter adjustments */
  2164. --flag__;
  2165. --iq;
  2166. --ipe;
  2167. --perm;
  2168. --irn;
  2169. --icn;
  2170. --iw;
  2171. --icntl;
  2172. --info;
  2173. /* Function Body */
  2174. info[1] = 0;
  2175. info[2] = 0;
  2176. i__1 = *n;
  2177. for (i__ = 1; i__ <= i__1; ++i__) {
  2178. iq[i__] = 0;
  2179. /* L10: */
  2180. }
  2181. /* COUNT THE NUMBERS OF NON-ZEROS IN THE ROWS, PRINT WARNINGS ABOUT */
  2182. /* OUT-OF-RANGE INDICES AND TRANSFER GENUINE ROW NUMBERS */
  2183. /* (NEGATED) INTO IW. */
  2184. if (*nz == 0) {
  2185. goto L110;
  2186. }
  2187. i__1 = *nz;
  2188. for (k = 1; k <= i__1; ++k) {
  2189. i__ = irn[k];
  2190. j = icn[k];
  2191. iw[k] = -i__;
  2192. if (i__ < j) {
  2193. if (i__ >= 1 && j <= *n) {
  2194. goto L80;
  2195. }
  2196. } else if (i__ > j) {
  2197. if (j >= 1 && i__ <= *n) {
  2198. goto L80;
  2199. }
  2200. } else {
  2201. iw[k] = 0;
  2202. if (i__ >= 1 && i__ <= *n) {
  2203. goto L100;
  2204. }
  2205. }
  2206. ++info[2];
  2207. info[1] = 1;
  2208. iw[k] = 0;
  2209. if (info[2] <= 1 && icntl[2] > 0) {
  2210. io___144.ciunit = icntl[2];
  2211. s_wsfe(&io___144);
  2212. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  2213. e_wsfe();
  2214. }
  2215. if (info[2] <= 10 && icntl[2] > 0) {
  2216. io___145.ciunit = icntl[2];
  2217. s_wsfe(&io___145);
  2218. do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer));
  2219. do_fio(&c__1, (char *)&i__, (ftnlen)sizeof(integer));
  2220. do_fio(&c__1, (char *)&j, (ftnlen)sizeof(integer));
  2221. e_wsfe();
  2222. }
  2223. goto L100;
  2224. L80:
  2225. if (perm[j] > perm[i__]) {
  2226. goto L90;
  2227. }
  2228. ++iq[j];
  2229. goto L100;
  2230. L90:
  2231. ++iq[i__];
  2232. L100:
  2233. ;
  2234. }
  2235. /* ACCUMULATE ROW COUNTS TO GET POINTERS TO ROW ENDS */
  2236. /* IN IPE. */
  2237. L110:
  2238. *iwfr = 1;
  2239. lbig = 0;
  2240. i__1 = *n;
  2241. for (i__ = 1; i__ <= i__1; ++i__) {
  2242. l = iq[i__];
  2243. lbig = max(l,lbig);
  2244. *iwfr += l;
  2245. ipe[i__] = *iwfr - 1;
  2246. /* L120: */
  2247. }
  2248. /* PERFORM IN-PLACE SORT */
  2249. if (*nz == 0) {
  2250. goto L250;
  2251. }
  2252. i__1 = *nz;
  2253. for (k = 1; k <= i__1; ++k) {
  2254. i__ = -iw[k];
  2255. if (i__ <= 0) {
  2256. goto L160;
  2257. }
  2258. l = k;
  2259. iw[k] = 0;
  2260. i__2 = *nz;
  2261. for (id = 1; id <= i__2; ++id) {
  2262. j = icn[l];
  2263. if (perm[i__] < perm[j]) {
  2264. goto L130;
  2265. }
  2266. l = ipe[j];
  2267. ipe[j] = l - 1;
  2268. in = iw[l];
  2269. iw[l] = i__;
  2270. goto L140;
  2271. L130:
  2272. l = ipe[i__];
  2273. ipe[i__] = l - 1;
  2274. in = iw[l];
  2275. iw[l] = j;
  2276. L140:
  2277. i__ = -in;
  2278. if (i__ <= 0) {
  2279. goto L160;
  2280. }
  2281. /* L150: */
  2282. }
  2283. L160:
  2284. ;
  2285. }
  2286. /* MAKE ROOM IN IW FOR ROW LENGTHS AND INITIALIZE FLAG. */
  2287. k = *iwfr - 1;
  2288. l = k + *n;
  2289. *iwfr = l + 1;
  2290. i__1 = *n;
  2291. for (i__ = 1; i__ <= i__1; ++i__) {
  2292. flag__[i__] = 0;
  2293. j = *n + 1 - i__;
  2294. len = iq[j];
  2295. if (len <= 0) {
  2296. goto L180;
  2297. }
  2298. i__2 = len;
  2299. for (jdummy = 1; jdummy <= i__2; ++jdummy) {
  2300. iw[l] = iw[k];
  2301. --k;
  2302. --l;
  2303. /* L170: */
  2304. }
  2305. L180:
  2306. ipe[j] = l;
  2307. --l;
  2308. /* L190: */
  2309. }
  2310. if (lbig >= icntl[4]) {
  2311. goto L210;
  2312. }
  2313. /* PLACE ROW LENGTHS IN IW */
  2314. i__1 = *n;
  2315. for (i__ = 1; i__ <= i__1; ++i__) {
  2316. k = ipe[i__];
  2317. iw[k] = iq[i__];
  2318. if (iq[i__] == 0) {
  2319. ipe[i__] = 0;
  2320. }
  2321. /* L200: */
  2322. }
  2323. goto L250;
  2324. /* REMOVE DUPLICATE ENTRIES */
  2325. L210:
  2326. *iwfr = 1;
  2327. i__1 = *n;
  2328. for (i__ = 1; i__ <= i__1; ++i__) {
  2329. k1 = ipe[i__] + 1;
  2330. k2 = ipe[i__] + iq[i__];
  2331. if (k1 <= k2) {
  2332. goto L220;
  2333. }
  2334. ipe[i__] = 0;
  2335. goto L240;
  2336. L220:
  2337. ipe[i__] = *iwfr;
  2338. ++(*iwfr);
  2339. i__2 = k2;
  2340. for (k = k1; k <= i__2; ++k) {
  2341. j = iw[k];
  2342. if (flag__[j] == i__) {
  2343. goto L230;
  2344. }
  2345. iw[*iwfr] = j;
  2346. ++(*iwfr);
  2347. flag__[j] = i__;
  2348. L230:
  2349. ;
  2350. }
  2351. k = ipe[i__];
  2352. iw[k] = *iwfr - k - 1;
  2353. L240:
  2354. ;
  2355. }
  2356. L250:
  2357. return 0;
  2358. } /* ma27j_ */
  2359. /* Subroutine */ int ma27k_(integer *n, integer *ipe, integer *iw, integer *
  2360. lw, integer *iwfr, integer *ips, integer *ipv, integer *nv, integer *
  2361. flag__, integer *ncmpa)
  2362. {
  2363. /* System generated locals */
  2364. integer i__1, i__2, i__3, i__4, i__5;
  2365. /* Local variables */
  2366. static integer i__, j, ie, je, me, ip, jp, ln, ml, js, ms, jp1, jp2;
  2367. extern /* Subroutine */ int ma27u_(integer *, integer *, integer *,
  2368. integer *, integer *, integer *);
  2369. static integer lwfr, minjs, kdummy;
  2370. /* USING A GIVEN PIVOTAL SEQUENCE AND A REPRESENTATION OF THE MATRIX THAT */
  2371. /* INCLUDES ONLY NON-ZEROS OF THE STRICTLY UPPER-TRIANGULAR PART */
  2372. /* OF THE PERMUTED MATRIX, CONSTRUCT TREE POINTERS. */
  2373. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  2374. /* IPE(I) MUST BE SET TO POINT TO THE POSITION IN IW OF THE */
  2375. /* START OF ROW I OR HAVE THE VALUE ZERO IF ROW I HAS NO OFF- */
  2376. /* DIAGONAL NON-ZEROS. DURING EXECUTION IT IS USED AS FOLLOWS. */
  2377. /* IF VARIABLE I IS ELIMINATED THEN IPE(I) POINTS TO THE LIST */
  2378. /* OF VARIABLES FOR CREATED ELEMENT I. IF ELEMENT I IS */
  2379. /* ABSORBED INTO NEWLY CREATED ELEMENT J THEN IPE(I)=-J. */
  2380. /* IW MUST BE SET ON ENTRY TO HOLD LISTS OF VARIABLES BY */
  2381. /* ROWS, EACH LIST BEING HEADED BY ITS LENGTH. WHEN A VARIABLE */
  2382. /* IS ELIMINATED ITS LIST IS REPLACED BY A LIST OF VARIABLES */
  2383. /* IN THE NEW ELEMENT. */
  2384. /* LW MUST BE SET TO THE LENGTH OF IW. IT IS NOT ALTERED. */
  2385. /* IWFR MUST BE SET TO THE POSITION IN IW OF THE FIRST FREE VARIABLE. */
  2386. /* IT IS REVISED DURING EXECUTION, CONTINUING TO HAVE THIS MEANING. */
  2387. /* IPS(I) MUST BE SET TO THE POSITION OF VARIABLE I IN THE REQUIRED */
  2388. /* ORDERING. IT IS NOT ALTERED. */
  2389. /* IPV NEED NOT BE SET. IPV(K) IS SET TO HOLD THE K TH VARIABLE */
  2390. /* IN PIVOT ORDER. */
  2391. /* NV NEED NOT BE SET. IF VARIABLE J HAS NOT BEEN ELIMINATED THEN */
  2392. /* THE LAST ELEMENT WHOSE LEADING VARIABLE (VARIABLE EARLIEST */
  2393. /* IN THE PIVOT SEQUENCE) IS J IS ELEMENT NV(J). IF ELEMENT J */
  2394. /* EXISTS THEN THE LAST ELEMENT HAVING THE SAME LEADING */
  2395. /* VARIABLE IS NV(J). IN BOTH CASES NV(J)=0 IF THERE IS NO SUCH */
  2396. /* ELEMENT. IF ELEMENT J HAS BEEN MERGED INTO A LATER ELEMENT */
  2397. /* THEN NV(J) IS THE DEGREE AT THE TIME OF ELIMINATION. */
  2398. /* FLAG IS USED AS WORKSPACE FOR VARIABLE FLAGS. */
  2399. /* FLAG(JS)=ME IF JS HAS BEEN INCLUDED IN THE LIST FOR ME. */
  2400. /* NCMPA see INFO(11) in MA27A/AD. */
  2401. /* .. Scalar Arguments .. */
  2402. /* .. */
  2403. /* .. Array Arguments .. */
  2404. /* .. */
  2405. /* .. Local Scalars .. */
  2406. /* .. */
  2407. /* .. External Subroutines .. */
  2408. /* .. */
  2409. /* .. Intrinsic Functions .. */
  2410. /* .. */
  2411. /* .. Executable Statements .. */
  2412. /* INITIALIZATIONS */
  2413. /* Parameter adjustments */
  2414. --flag__;
  2415. --nv;
  2416. --ipv;
  2417. --ips;
  2418. --ipe;
  2419. --iw;
  2420. /* Function Body */
  2421. i__1 = *n;
  2422. for (i__ = 1; i__ <= i__1; ++i__) {
  2423. flag__[i__] = 0;
  2424. nv[i__] = 0;
  2425. j = ips[i__];
  2426. ipv[j] = i__;
  2427. /* L10: */
  2428. }
  2429. *ncmpa = 0;
  2430. /* START OF MAIN LOOP */
  2431. i__1 = *n;
  2432. for (ml = 1; ml <= i__1; ++ml) {
  2433. /* ME=MS IS THE NAME OF THE VARIABLE ELIMINATED AND */
  2434. /* OF THE ELEMENT CREATED IN THE MAIN LOOP. */
  2435. ms = ipv[ml];
  2436. me = ms;
  2437. flag__[ms] = me;
  2438. /* MERGE ROW MS WITH ALL THE ELEMENTS HAVING MS AS LEADING VARIABLE. */
  2439. /* IP POINTS TO THE START OF THE NEW LIST. */
  2440. ip = *iwfr;
  2441. /* MINJS IS SET TO THE POSITION IN THE ORDER OF THE LEADING VARIABLE */
  2442. /* IN THE NEW LIST. */
  2443. minjs = *n;
  2444. ie = me;
  2445. i__2 = *n;
  2446. for (kdummy = 1; kdummy <= i__2; ++kdummy) {
  2447. /* SEARCH VARIABLE LIST OF ELEMENT IE. */
  2448. /* JP POINTS TO THE CURRENT POSITION IN THE LIST BEING SEARCHED. */
  2449. jp = ipe[ie];
  2450. /* LN IS THE LENGTH OF THE LIST BEING SEARCHED. */
  2451. ln = 0;
  2452. if (jp <= 0) {
  2453. goto L60;
  2454. }
  2455. ln = iw[jp];
  2456. /* SEARCH FOR DIFFERENT VARIABLES AND ADD THEM TO LIST, */
  2457. /* COMPRESSING WHEN NECESSARY */
  2458. i__3 = ln;
  2459. for (jp1 = 1; jp1 <= i__3; ++jp1) {
  2460. ++jp;
  2461. /* PLACE NEXT VARIABLE IN JS. */
  2462. js = iw[jp];
  2463. /* JUMP IF VARIABLE HAS ALREADY BEEN INCLUDED. */
  2464. if (flag__[js] == me) {
  2465. goto L50;
  2466. }
  2467. flag__[js] = me;
  2468. if (*iwfr < *lw) {
  2469. goto L40;
  2470. }
  2471. /* PREPARE FOR COMPRESSING IW BY ADJUSTING POINTER TO AND LENGTH OF */
  2472. /* THE LIST FOR IE TO REFER TO THE REMAINING ENTRIES. */
  2473. ipe[ie] = jp;
  2474. iw[jp] = ln - jp1;
  2475. /* COMPRESS IW. */
  2476. i__4 = ip - 1;
  2477. ma27u_(n, &ipe[1], &iw[1], &i__4, &lwfr, ncmpa);
  2478. /* COPY NEW LIST FORWARD */
  2479. jp2 = *iwfr - 1;
  2480. *iwfr = lwfr;
  2481. if (ip > jp2) {
  2482. goto L30;
  2483. }
  2484. i__4 = jp2;
  2485. for (jp = ip; jp <= i__4; ++jp) {
  2486. iw[*iwfr] = iw[jp];
  2487. ++(*iwfr);
  2488. /* L20: */
  2489. }
  2490. L30:
  2491. ip = lwfr;
  2492. jp = ipe[ie];
  2493. /* ADD VARIABLE JS TO NEW LIST. */
  2494. L40:
  2495. iw[*iwfr] = js;
  2496. /* Computing MIN */
  2497. i__4 = minjs, i__5 = ips[js];
  2498. minjs = min(i__4,i__5);
  2499. ++(*iwfr);
  2500. L50:
  2501. ;
  2502. }
  2503. /* RECORD ABSORPTION OF ELEMENT IE INTO NEW ELEMENT. */
  2504. L60:
  2505. ipe[ie] = -me;
  2506. /* PICK UP NEXT ELEMENT WITH LEADING VARIABLE MS. */
  2507. je = nv[ie];
  2508. /* STORE DEGREE OF IE. */
  2509. nv[ie] = ln + 1;
  2510. ie = je;
  2511. /* LEAVE LOOP IF THERE ARE NO MORE ELEMENTS. */
  2512. if (ie == 0) {
  2513. goto L80;
  2514. }
  2515. /* L70: */
  2516. }
  2517. L80:
  2518. if (*iwfr > ip) {
  2519. goto L90;
  2520. }
  2521. /* DEAL WITH NULL NEW ELEMENT. */
  2522. ipe[me] = 0;
  2523. nv[me] = 1;
  2524. goto L100;
  2525. /* LINK NEW ELEMENT WITH OTHERS HAVING SAME LEADING VARIABLE. */
  2526. L90:
  2527. minjs = ipv[minjs];
  2528. nv[me] = nv[minjs];
  2529. nv[minjs] = me;
  2530. /* MOVE FIRST ENTRY IN NEW LIST TO END TO ALLOW ROOM FOR LENGTH AT */
  2531. /* FRONT. SET POINTER TO FRONT. */
  2532. iw[*iwfr] = iw[ip];
  2533. iw[ip] = *iwfr - ip;
  2534. ipe[me] = ip;
  2535. ++(*iwfr);
  2536. L100:
  2537. ;
  2538. }
  2539. return 0;
  2540. } /* ma27k_ */
  2541. /* Subroutine */ int ma27l_(integer *n, integer *ipe, integer *nv, integer *
  2542. ips, integer *ne, integer *na, integer *nd, integer *nsteps, integer *
  2543. nemin)
  2544. {
  2545. /* System generated locals */
  2546. integer i__1, i__2;
  2547. /* Local variables */
  2548. static integer i__, k, l, ib, if__, il, is, nr, ison;
  2549. /* TREE SEARCH */
  2550. /* GIVEN SON TO FATHER TREE POINTERS, PERFORM DEPTH-FIRST */
  2551. /* SEARCH TO FIND PIVOT ORDER AND NUMBER OF ELIMINATIONS */
  2552. /* AND ASSEMBLIES AT EACH STAGE. */
  2553. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  2554. /* IPE(I) MUST BE SET EQUAL TO -(FATHER OF NODE I) OR ZERO IF */
  2555. /* NODE IS A ROOT. IT IS ALTERED TO POINT TO ITS NEXT */
  2556. /* YOUNGER BROTHER IF IT HAS ONE, BUT OTHERWISE IS NOT */
  2557. /* CHANGED. */
  2558. /* NV(I) MUST BE SET TO ZERO IF NO VARIABLES ARE ELIMINATED AT NODE */
  2559. /* I AND TO THE DEGREE OTHERWISE. ONLY LEAF NODES CAN HAVE */
  2560. /* ZERO VALUES OF NV(I). NV IS NOT ALTERED. */
  2561. /* IPS(I) NEED NOT BE SET. IT IS USED TEMPORARILY TO HOLD */
  2562. /* -(ELDEST SON OF NODE I) IF IT HAS ONE AND 0 OTHERWISE. IT IS */
  2563. /* EVENTUALLY SET TO HOLD THE POSITION OF NODE I IN THE ORDER. */
  2564. /* NE(IS) NEED NOT BE SET. IT IS SET TO THE NUMBER OF VARIABLES */
  2565. /* ELIMINATED AT STAGE IS OF THE ELIMINATION. */
  2566. /* NA(IS) NEED NOT BE SET. IT IS SET TO THE NUMBER OF ELEMENTS */
  2567. /* ASSEMBLED AT STAGE IS OF THE ELIMINATION. */
  2568. /* ND(IS) NEED NOT BE SET. IT IS SET TO THE DEGREE AT STAGE IS OF */
  2569. /* THE ELIMINATION. */
  2570. /* NSTEPS NEED NOT BE SET. IT IS SET TO THE NUMBER OF ELIMINATION */
  2571. /* STEPS. */
  2572. /* NEMIN see ICNTL(5) in MA27A/AD. */
  2573. /* .. Scalar Arguments .. */
  2574. /* .. */
  2575. /* .. Array Arguments .. */
  2576. /* .. */
  2577. /* .. Local Scalars .. */
  2578. /* .. */
  2579. /* .. Executable Statements .. */
  2580. /* INITIALIZE IPS AND NE. */
  2581. /* Parameter adjustments */
  2582. --nd;
  2583. --na;
  2584. --ne;
  2585. --ips;
  2586. --nv;
  2587. --ipe;
  2588. /* Function Body */
  2589. i__1 = *n;
  2590. for (i__ = 1; i__ <= i__1; ++i__) {
  2591. ips[i__] = 0;
  2592. ne[i__] = 0;
  2593. /* L10: */
  2594. }
  2595. /* SET IPS(I) TO -(ELDEST SON OF NODE I) AND IPE(I) TO NEXT YOUNGER */
  2596. /* BROTHER OF NODE I IF IT HAS ONE. */
  2597. /* FIRST PASS IS FOR NODES WITHOUT ELIMINATIONS. */
  2598. i__1 = *n;
  2599. for (i__ = 1; i__ <= i__1; ++i__) {
  2600. if (nv[i__] > 0) {
  2601. goto L20;
  2602. }
  2603. if__ = -ipe[i__];
  2604. is = -ips[if__];
  2605. if (is > 0) {
  2606. ipe[i__] = is;
  2607. }
  2608. ips[if__] = -i__;
  2609. L20:
  2610. ;
  2611. }
  2612. /* NR IS DECREMENTED FOR EACH ROOT NODE. THESE ARE STORED IN */
  2613. /* NE(I),I=NR,N. */
  2614. nr = *n + 1;
  2615. /* SECOND PASS TO ADD NODES WITH ELIMINATIONS. */
  2616. i__1 = *n;
  2617. for (i__ = 1; i__ <= i__1; ++i__) {
  2618. if (nv[i__] <= 0) {
  2619. goto L50;
  2620. }
  2621. /* NODE IF IS THE FATHER OF NODE I. */
  2622. if__ = -ipe[i__];
  2623. if (if__ == 0) {
  2624. goto L40;
  2625. }
  2626. is = -ips[if__];
  2627. /* JUMP IF NODE IF HAS NO SONS YET. */
  2628. if (is <= 0) {
  2629. goto L30;
  2630. }
  2631. /* SET POINTER TO NEXT BROTHER */
  2632. ipe[i__] = is;
  2633. /* NODE I IS ELDEST SON OF NODE IF. */
  2634. L30:
  2635. ips[if__] = -i__;
  2636. goto L50;
  2637. /* WE HAVE A ROOT */
  2638. L40:
  2639. --nr;
  2640. ne[nr] = i__;
  2641. L50:
  2642. ;
  2643. }
  2644. /* DEPTH-FIRST SEARCH. */
  2645. /* IL HOLDS THE CURRENT TREE LEVEL. ROOTS ARE AT LEVEL N, THEIR SONS */
  2646. /* ARE AT LEVEL N-1, ETC. */
  2647. /* IS HOLDS THE CURRENT ELIMINATION STAGE. WE ACCUMULATE THE NUMBER */
  2648. /* OF ELIMINATIONS AT STAGE IS DIRECTLY IN NE(IS). THE NUMBER OF */
  2649. /* ASSEMBLIES IS ACCUMULATED TEMPORARILY IN NA(IL), FOR TREE */
  2650. /* LEVEL IL, AND IS TRANSFERED TO NA(IS) WHEN WE REACH THE */
  2651. /* APPROPRIATE STAGE IS. */
  2652. is = 1;
  2653. /* I IS THE CURRENT NODE. */
  2654. i__ = 0;
  2655. i__1 = *n;
  2656. for (k = 1; k <= i__1; ++k) {
  2657. if (i__ > 0) {
  2658. goto L60;
  2659. }
  2660. /* PICK UP NEXT ROOT. */
  2661. i__ = ne[nr];
  2662. ne[nr] = 0;
  2663. ++nr;
  2664. il = *n;
  2665. na[*n] = 0;
  2666. /* GO TO SON FOR AS LONG AS POSSIBLE, CLEARING FATHER-SON POINTERS */
  2667. /* IN IPS AS EACH IS USED AND SETTING NA(IL)=0 FOR ALL LEVELS */
  2668. /* REACHED. */
  2669. L60:
  2670. i__2 = *n;
  2671. for (l = 1; l <= i__2; ++l) {
  2672. if (ips[i__] >= 0) {
  2673. goto L80;
  2674. }
  2675. ison = -ips[i__];
  2676. ips[i__] = 0;
  2677. i__ = ison;
  2678. --il;
  2679. na[il] = 0;
  2680. /* L70: */
  2681. }
  2682. /* RECORD POSITION OF NODE I IN THE ORDER. */
  2683. L80:
  2684. ips[i__] = k;
  2685. ++ne[is];
  2686. /* JUMP IF NODE HAS NO ELIMINATIONS. */
  2687. if (nv[i__] <= 0) {
  2688. goto L120;
  2689. }
  2690. if (il < *n) {
  2691. ++na[il + 1];
  2692. }
  2693. na[is] = na[il];
  2694. nd[is] = nv[i__];
  2695. /* CHECK FOR STATIC CONDENSATION */
  2696. if (na[is] != 1) {
  2697. goto L90;
  2698. }
  2699. if (nd[is - 1] - ne[is - 1] == nd[is]) {
  2700. goto L100;
  2701. }
  2702. /* CHECK FOR SMALL NUMBERS OF ELIMINATIONS IN BOTH LAST TWO STEPS. */
  2703. L90:
  2704. if (ne[is] >= *nemin) {
  2705. goto L110;
  2706. }
  2707. if (na[is] == 0) {
  2708. goto L110;
  2709. }
  2710. if (ne[is - 1] >= *nemin) {
  2711. goto L110;
  2712. }
  2713. /* COMBINE THE LAST TWO STEPS */
  2714. L100:
  2715. na[is - 1] = na[is - 1] + na[is] - 1;
  2716. nd[is - 1] = nd[is] + ne[is - 1];
  2717. ne[is - 1] = ne[is] + ne[is - 1];
  2718. ne[is] = 0;
  2719. goto L120;
  2720. L110:
  2721. ++is;
  2722. L120:
  2723. ib = ipe[i__];
  2724. if (ib >= 0) {
  2725. /* NODE I HAS A BROTHER OR IS A ROOT */
  2726. if (ib > 0) {
  2727. na[il] = 0;
  2728. }
  2729. i__ = ib;
  2730. } else {
  2731. /* GO TO FATHER OF NODE I */
  2732. i__ = -ib;
  2733. ++il;
  2734. }
  2735. /* L160: */
  2736. }
  2737. *nsteps = is - 1;
  2738. return 0;
  2739. } /* ma27l_ */
  2740. /* Subroutine */ int ma27m_(integer *n, integer *nz, integer *irn, integer *
  2741. icn, integer *perm, integer *na, integer *ne, integer *nd, integer *
  2742. nsteps, integer *lstki, integer *lstkr, integer *iw, integer *info,
  2743. real *ops)
  2744. {
  2745. /* System generated locals */
  2746. integer i__1, i__2, i__3;
  2747. /* Local variables */
  2748. static integer i__, k, nz1, nz2, nfr, iold, jold, iorg, jorg, inew, itop,
  2749. lstk, nstk, irow;
  2750. static real delim;
  2751. static integer nelim, itree, istki, nassr, istkr, nirnec, nrlnec, niradu,
  2752. nrladu, numorg, nirtot, nrltot;
  2753. /* STORAGE AND OPERATION COUNT EVALUATION. */
  2754. /* EVALUATE NUMBER OF OPERATIONS AND SPACE REQUIRED BY FACTORIZATION */
  2755. /* USING MA27B/BD. THE VALUES GIVEN ARE EXACT ONLY IF NO NUMERICAL */
  2756. /* PIVOTING IS PERFORMED AND THEN ONLY IF IRN(1) WAS NOT */
  2757. /* EQUIVALENCED TO IW(1) BY THE USER BEFORE CALLING MA27A/AD. IF */
  2758. /* THE EQUIVALENCE HAS BEEN MADE ONLY AN UPPER BOUND FOR NIRNEC */
  2759. /* AND NRLNEC CAN BE CALCULATED ALTHOUGH THE OTHER COUNTS WILL */
  2760. /* STILL BE EXACT. */
  2761. /* N MUST BE SET TO THE MATRIX ORDER. IT IS NOT ALTERED. */
  2762. /* NZ MUST BE SET TO THE NUMBER OF NON-ZEROS INPUT. IT IS NOT ALTERED. */
  2763. /* IRN,ICN. UNLESS IRN(1) HAS BEEN EQUIVALENCED TO IW(1) */
  2764. /* IRN,ICN MUST BE SET TO THE ROW AND COLUMN INDICES OF THE */
  2765. /* NON-ZEROS ON INPUT. THEY ARE NOT ALTERED BY MA27M/MD. */
  2766. /* PERM MUST BE SET TO THE POSITION IN THE PIVOT ORDER OF EACH ROW. */
  2767. /* IT IS NOT ALTERED. */
  2768. /* NA,NE,ND MUST BE SET TO HOLD, FOR EACH TREE NODE, THE NUMBER OF STACK */
  2769. /* ELEMENTS ASSEMBLED, THE NUMBER OF ELIMINATIONS AND THE SIZE OF */
  2770. /* THE ASSEMBLED FRONT MATRIX RESPECTIVELY. THEY ARE NOT ALTERED. */
  2771. /* NSTEPS MUST BE SET TO HOLD THE NUMBER OF TREE NODES. IT IS NOT */
  2772. /* ALTERED. */
  2773. /* LSTKI IS USED AS A WORK ARRAY BY MA27M/MD. */
  2774. /* LSTKR. IF IRN(1) IS EQUIVALENCED TO IW(1) THEN LSTKR(I) */
  2775. /* MUST HOLD THE TOTAL NUMBER OF OFF-DIAGONAL ENTRIES (INCLUDING */
  2776. /* DUPLICATES) IN ROW I (I=1,..,N) OF THE ORIGINAL MATRIX. IT */
  2777. /* IS USED AS WORKSPACE BY MA27M/MD. */
  2778. /* IW IS A WORKSPACE ARRAY USED BY OTHER SUBROUTINES AND PASSED TO THIS */
  2779. /* SUBROUTINE ONLY SO THAT A TEST FOR EQUIVALENCE WITH IRN CAN BE */
  2780. /* MADE. */
  2781. /* COUNTS FOR OPERATIONS AND STORAGE ARE ACCUMULATED IN VARIABLES */
  2782. /* OPS,NRLTOT,NIRTOT,NRLNEC,NIRNEC,NRLADU,NRLNEC,NIRNEC. */
  2783. /* OPS NUMBER OF MULTIPLICATIONS AND ADDITIONS DURING FACTORIZATION. */
  2784. /* NRLADU,NIRADU REAL AND INTEGER STORAGE RESPECTIVELY FOR THE */
  2785. /* MATRIX FACTORS. */
  2786. /* NRLTOT,NIRTOT REAL AND INTEGER STRORAGE RESPECTIVELY REQUIRED */
  2787. /* FOR THE FACTORIZATION IF NO COMPRESSES ARE ALLOWED. */
  2788. /* NRLNEC,NIRNEC REAL AND INTEGER STORAGE RESPECTIVELY REQUIRED FOR */
  2789. /* THE FACTORIZATION IF COMPRESSES ARE ALLOWED. */
  2790. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  2791. /* OPS ACCUMULATES THE NO. OF MULTIPLY/ADD PAIRS NEEDED TO CREATE THE */
  2792. /* TRIANGULAR FACTORIZATION, IN THE DEFINITE CASE. */
  2793. /* .. Scalar Arguments .. */
  2794. /* .. */
  2795. /* .. Array Arguments .. */
  2796. /* .. */
  2797. /* .. Local Scalars .. */
  2798. /* .. */
  2799. /* .. Intrinsic Functions .. */
  2800. /* .. */
  2801. /* .. Executable Statements .. */
  2802. /* Parameter adjustments */
  2803. --lstkr;
  2804. --lstki;
  2805. --perm;
  2806. --irn;
  2807. --icn;
  2808. --nd;
  2809. --ne;
  2810. --na;
  2811. --iw;
  2812. --info;
  2813. /* Function Body */
  2814. if (*nz == 0) {
  2815. goto L20;
  2816. }
  2817. /* JUMP IF IW AND IRN HAVE NOT BEEN EQUIVALENCED. */
  2818. if (irn[1] != iw[1]) {
  2819. goto L20;
  2820. }
  2821. /* RESET IRN(1). */
  2822. irn[1] = iw[1] - 1;
  2823. /* THE TOTAL NUMBER OF OFF-DIAGONAL ENTRIES IS ACCUMULATED IN NZ2. */
  2824. /* LSTKI IS SET TO HOLD THE TOTAL NUMBER OF ENTRIES (INCUDING */
  2825. /* THE DIAGONAL) IN EACH ROW IN PERMUTED ORDER. */
  2826. nz2 = 0;
  2827. i__1 = *n;
  2828. for (iold = 1; iold <= i__1; ++iold) {
  2829. inew = perm[iold];
  2830. lstki[inew] = lstkr[iold] + 1;
  2831. nz2 += lstkr[iold];
  2832. /* L10: */
  2833. }
  2834. /* NZ1 IS THE NUMBER OF ENTRIES IN ONE TRIANGLE INCLUDING THE DIAGONAL. */
  2835. /* NZ2 IS THE TOTAL NUMBER OF ENTRIES INCLUDING THE DIAGONAL. */
  2836. nz1 = nz2 / 2 + *n;
  2837. nz2 += *n;
  2838. goto L60;
  2839. /* COUNT (IN LSTKI) NON-ZEROS IN ORIGINAL MATRIX BY PERMUTED ROW (UPPER */
  2840. /* TRIANGLE ONLY). INITIALIZE COUNTS. */
  2841. L20:
  2842. i__1 = *n;
  2843. for (i__ = 1; i__ <= i__1; ++i__) {
  2844. lstki[i__] = 1;
  2845. /* L30: */
  2846. }
  2847. /* ACCUMULATE NUMBER OF NON-ZEROS WITH INDICES IN RANGE IN NZ1 */
  2848. /* DUPLICATES ON THE DIAGONAL ARE IGNORED BUT NZ1 INCLUDES ANY */
  2849. /* DIAGONALS NOT PRESENT ON INPUT. */
  2850. /* ACCUMULATE ROW COUNTS IN LSTKI. */
  2851. nz1 = *n;
  2852. if (*nz == 0) {
  2853. goto L50;
  2854. }
  2855. i__1 = *nz;
  2856. for (i__ = 1; i__ <= i__1; ++i__) {
  2857. iold = irn[i__];
  2858. jold = icn[i__];
  2859. /* JUMP IF INDEX IS OUT OF RANGE. */
  2860. if (iold < 1 || iold > *n) {
  2861. goto L40;
  2862. }
  2863. if (jold < 1 || jold > *n) {
  2864. goto L40;
  2865. }
  2866. if (iold == jold) {
  2867. goto L40;
  2868. }
  2869. ++nz1;
  2870. /* Computing MIN */
  2871. i__2 = perm[iold], i__3 = perm[jold];
  2872. irow = min(i__2,i__3);
  2873. ++lstki[irow];
  2874. L40:
  2875. ;
  2876. }
  2877. L50:
  2878. nz2 = nz1;
  2879. /* ISTKR,ISTKI CURRENT NUMBER OF STACK ENTRIES IN */
  2880. /* REAL AND INTEGER STORAGE RESPECTIVELY. */
  2881. /* OPS,NRLADU,NIRADU,NIRTOT,NRLTOT,NIRNEC,NRLNEC,NZ2 ARE DEFINED ABOVE. */
  2882. /* NZ2 CURRENT NUMBER OF ORIGINAL MATRIX ENTRIES NOT YET PROCESSED. */
  2883. /* NUMORG CURRENT TOTAL NUMBER OF ROWS ELIMINATED. */
  2884. /* ITOP CURRENT NUMBER OF ELEMENTS ON THE STACK. */
  2885. L60:
  2886. istki = 0;
  2887. istkr = 0;
  2888. *ops = 0.f;
  2889. nrladu = 0;
  2890. /* ONE LOCATION IS NEEDED TO RECORD THE NUMBER OF BLOCKS */
  2891. /* ACTUALLY USED. */
  2892. niradu = 1;
  2893. nirtot = nz1;
  2894. nrltot = nz1;
  2895. nirnec = nz2;
  2896. nrlnec = nz2;
  2897. numorg = 0;
  2898. itop = 0;
  2899. /* EACH PASS THROUGH THIS LOOP PROCESSES A NODE OF THE TREE. */
  2900. i__1 = *nsteps;
  2901. for (itree = 1; itree <= i__1; ++itree) {
  2902. nelim = ne[itree];
  2903. delim = (real) nelim;
  2904. nfr = nd[itree];
  2905. nstk = na[itree];
  2906. /* ADJUST STORAGE COUNTS ON ASSEMBLY OF CURRENT FRONTAL MATRIX. */
  2907. nassr = nfr * (nfr + 1) / 2;
  2908. if (nstk != 0) {
  2909. nassr = nassr - lstkr[itop] + 1;
  2910. }
  2911. /* Computing MAX */
  2912. i__2 = nrltot, i__3 = nrladu + nassr + istkr + nz1;
  2913. nrltot = max(i__2,i__3);
  2914. /* Computing MAX */
  2915. i__2 = nirtot, i__3 = niradu + nfr + 2 + istki + nz1;
  2916. nirtot = max(i__2,i__3);
  2917. /* Computing MAX */
  2918. i__2 = nrlnec, i__3 = nrladu + nassr + istkr + nz2;
  2919. nrlnec = max(i__2,i__3);
  2920. /* Computing MAX */
  2921. i__2 = nirnec, i__3 = niradu + nfr + 2 + istki + nz2;
  2922. nirnec = max(i__2,i__3);
  2923. /* DECREASE NZ2 BY THE NUMBER OF ENTRIES IN ROWS BEING ELIMINATED AT */
  2924. /* THIS STAGE. */
  2925. i__2 = nelim;
  2926. for (iorg = 1; iorg <= i__2; ++iorg) {
  2927. jorg = numorg + iorg;
  2928. nz2 -= lstki[jorg];
  2929. /* L70: */
  2930. }
  2931. numorg += nelim;
  2932. /* JUMP IF THERE ARE NO STACK ASSEMBLIES AT THIS NODE. */
  2933. if (nstk <= 0) {
  2934. goto L90;
  2935. }
  2936. /* REMOVE ELEMENTS FROM THE STACK. THERE ARE ITOP ELEMENTS ON THE */
  2937. /* STACK WITH THE APPROPRIATE ENTRIES IN LSTKR,LSTKI GIVING */
  2938. /* THE REAL AND INTEGER STORAGE RESPECTIVELY FOR EACH STACK */
  2939. /* ELEMENT. */
  2940. i__2 = nstk;
  2941. for (k = 1; k <= i__2; ++k) {
  2942. lstk = lstkr[itop];
  2943. istkr -= lstk;
  2944. lstk = lstki[itop];
  2945. istki -= lstk;
  2946. --itop;
  2947. /* L80: */
  2948. }
  2949. /* ACCUMULATE NON-ZEROS IN FACTORS AND NUMBER OF OPERATIONS. */
  2950. L90:
  2951. nrladu += nelim * ((nfr << 1) - nelim + 1) / 2;
  2952. niradu = niradu + 2 + nfr;
  2953. if (nelim == 1) {
  2954. --niradu;
  2955. }
  2956. *ops += (nfr * delim * (nfr + 1) - ((nfr << 1) + 1) * delim * (delim
  2957. + 1) / 2 + delim * (delim + 1) * (delim * 2 + 1) / 6) / 2;
  2958. if (itree == *nsteps) {
  2959. goto L100;
  2960. }
  2961. /* JUMP IF ALL OF FRONTAL MATRIX HAS BEEN ELIMINATED. */
  2962. if (nfr == nelim) {
  2963. goto L100;
  2964. }
  2965. /* STACK REMAINDER OF ELEMENT. */
  2966. ++itop;
  2967. lstkr[itop] = (nfr - nelim) * (nfr - nelim + 1) / 2;
  2968. lstki[itop] = nfr - nelim + 1;
  2969. istki += lstki[itop];
  2970. istkr += lstkr[itop];
  2971. /* WE DO NOT NEED TO ADJUST THE COUNTS FOR THE REAL STORAGE BECAUSE */
  2972. /* THE REMAINDER OF THE FRONTAL MATRIX IS SIMPLY MOVED IN THE */
  2973. /* STORAGE FROM FACTORS TO STACK AND NO EXTRA STORAGE IS REQUIRED. */
  2974. /* Computing MAX */
  2975. i__2 = nirtot, i__3 = niradu + istki + nz1;
  2976. nirtot = max(i__2,i__3);
  2977. /* Computing MAX */
  2978. i__2 = nirnec, i__3 = niradu + istki + nz2;
  2979. nirnec = max(i__2,i__3);
  2980. L100:
  2981. ;
  2982. }
  2983. /* ADJUST THE STORAGE COUNTS TO ALLOW FOR THE USE OF THE REAL AND */
  2984. /* INTEGER STORAGE FOR PURPOSES OTHER THAN PURELY THE */
  2985. /* FACTORIZATION ITSELF. */
  2986. /* THE SECOND TWO TERMS ARE THE MINUMUM AMOUNT REQUIRED BY MA27N/ND. */
  2987. /* Computing MAX */
  2988. i__1 = nrlnec, i__2 = *n + max(*nz,nz1);
  2989. nrlnec = max(i__1,i__2);
  2990. /* Computing MAX */
  2991. i__1 = nrltot, i__2 = *n + max(*nz,nz1);
  2992. nrltot = max(i__1,i__2);
  2993. nrlnec = min(nrlnec,nrltot);
  2994. nirnec = max(*nz,nirnec);
  2995. nirtot = max(*nz,nirtot);
  2996. nirnec = min(nirnec,nirtot);
  2997. info[3] = nrltot;
  2998. info[4] = nirtot;
  2999. info[5] = nrlnec;
  3000. info[6] = nirnec;
  3001. info[7] = nrladu;
  3002. info[8] = niradu;
  3003. return 0;
  3004. } /* ma27m_ */
  3005. /* Subroutine */ int ma27n_(integer *n, integer *nz, integer *nz1, real *a,
  3006. integer *la, integer *irn, integer *icn, integer *iw, integer *liw,
  3007. integer *perm, integer *iw2, integer *icntl, integer *info)
  3008. {
  3009. /* Format strings */
  3010. static char fmt_40[] = "(\002 *** WARNING MESSAGE FROM SUBROUTINE MA27"
  3011. "B\002,\002 *** INFO(1) =\002,i2)";
  3012. static char fmt_50[] = "(i6,\002TH NON-ZERO (IN ROW\002,i6,\002 AND COLU"
  3013. "MN\002,i6,\002) IGNORED\002)";
  3014. /* System generated locals */
  3015. integer i__1, i__2;
  3016. /* Builtin functions */
  3017. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  3018. /* Local variables */
  3019. static integer i__, k, j1, j2, ia, ii, jj, ich, iiw, iold, jold, inew;
  3020. static real anow;
  3021. static integer jnew, ipos, jpos;
  3022. static real anext;
  3023. /* Fortran I/O blocks */
  3024. static cilist io___212 = { 0, 0, 0, fmt_40, 0 };
  3025. static cilist io___213 = { 0, 0, 0, fmt_50, 0 };
  3026. /* SORT PRIOR TO FACTORIZATION USING MA27O/OD. */
  3027. /* THIS SUBROUTINE REORDERS THE USER'S INPUT SO THAT THE UPPER TRIANGLE */
  3028. /* OF THE PERMUTED MATRIX, INCLUDING THE DIAGONAL, IS */
  3029. /* HELD ORDERED BY ROWS AT THE END OF THE STORAGE FOR A AND IW. */
  3030. /* IT IGNORES ENTRIES WITH ONE OR BOTH INDICES OUT OF RANGE AND */
  3031. /* ACCUMULATES DIAGONAL ENTRIES. */
  3032. /* IT ADDS EXPLICIT ZEROS ON THE DIAGONAL WHERE NECESSARY. */
  3033. /* N - MUST BE SET TO THE ORDER OF THE MATRIX. */
  3034. /* IT IS NOT ALTERED BY MA27N/ND. */
  3035. /* NZ - ON ENTRY NZ MUST BE SET TO THE NUMBER */
  3036. /* OF NON-ZEROS INPUT. NOT ALTERED BY MA27N/ND. */
  3037. /* NZ1 - ON EXIT NZ1 WILL BE EQUAL TO THE NUMBER OF ENTRIES IN THE */
  3038. /* SORTED MATRIX. */
  3039. /* A - ON ENTRY A(I) MUST */
  3040. /* HOLD THE VALUE OF THE ORIGINAL MATRIX ELEMENT IN POSITION */
  3041. /* (IRN(I),ICN(I)),I=1,NZ. ON EXIT A(LA-NZ1+I),I=1,NZ1 HOLDS */
  3042. /* THE UPPER TRIANGLE OF THE PERMUTED MATRIX BY ROWS WITH */
  3043. /* THE DIAGONAL ENTRY FIRST ALTHOUGH THERE IS NO FURTHER */
  3044. /* ORDERING WITHIN THE ROWS THEMSELVES. */
  3045. /* LA - LENGTH OF ARRAY A. MUST BE AT LEAST N+MAX(NZ,NZ1). */
  3046. /* IT IS NOT ALTERED BY MA27N/ND. */
  3047. /* IRN - IRN(I) MUST BE SET TO */
  3048. /* HOLD THE ROW INDEX OF ENTRY A(I),I=1,NZ. IRN WILL BE */
  3049. /* UNALTERED BY MA27N/ND, UNLESS IT IS EQUIVALENCED WITH IW. */
  3050. /* ICN - ICN(I) MUST BE SET TO */
  3051. /* HOLD THE COLUMN INDEX OF ENTRY A(I),I=1,NZ. ICN WILL BE */
  3052. /* UNALTERED BY MA27N/ND, UNLESS IT IS EQUIVALENCED WITH IW. */
  3053. /* IW - USED AS WORKSPACE AND ON */
  3054. /* EXIT, ENTRIES IW(LIW-NZ1+I),I=1,NZ1 HOLD THE COLUMN INDICES */
  3055. /* (THE ORIGINAL UNPERMUTED INDICES) OF THE CORRESPONDING ENTRY */
  3056. /* OF A WITH THE FIRST ENTRY FOR EACH ROW FLAGGED NEGATIVE. */
  3057. /* IRN(1) MAY BE EQUIVALENCED WITH IW(1) AND ICN(1) MAY BE */
  3058. /* EQUIVALENCED WITH IW(K) WHERE K.GT.NZ. */
  3059. /* LIW - LENGTH OF ARRAY IW. MUST BE AT LEAST AS */
  3060. /* GREAT AS THE MAXIMUM OF NZ AND NZ1. */
  3061. /* NOT ALTERED BY MA27N/ND. */
  3062. /* PERM - PERM(I) HOLDS THE */
  3063. /* POSITION IN THE TENTATIVE PIVOT ORDER OF ROW I IN THE */
  3064. /* ORIGINAL MATRIX,I=1,N. NOT ALTERED BY MA27N/ND. */
  3065. /* IW2 - USED AS WORKSPACE. */
  3066. /* SEE COMMENTS IN CODE IMMEDIATELY PRIOR TO */
  3067. /* EACH USE. */
  3068. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  3069. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  3070. /* INFO(1) - ON EXIT FROM MA27N/ND, A ZERO VALUE OF */
  3071. /* INFO(1) INDICATES THAT NO ERROR HAS BEEN DETECTED. */
  3072. /* POSSIBLE NON-ZERO VALUES ARE .. */
  3073. /* +1 WARNING. INDICES OUT OF RANGE. THESE ARE IGNORED, */
  3074. /* THEIR NUMBER IS RECORDED IN INFO(2) OF MA27E/ED AND */
  3075. /* MESSAGES IDENTIFYING THE FIRST TEN ARE OUTPUT ON UNIT */
  3076. /* ICNTL(2). */
  3077. /* -3 INTEGER ARRAY IW IS TOO SMALL. */
  3078. /* -4 REAL ARRAY A IS TOO SMALL. */
  3079. /* .. Parameters .. */
  3080. /* .. */
  3081. /* .. Scalar Arguments .. */
  3082. /* .. */
  3083. /* .. Array Arguments .. */
  3084. /* .. */
  3085. /* .. Local Scalars .. */
  3086. /* .. */
  3087. /* .. Intrinsic Functions .. */
  3088. /* .. */
  3089. /* .. Executable Statements .. */
  3090. /* Parameter adjustments */
  3091. --iw2;
  3092. --perm;
  3093. --a;
  3094. --irn;
  3095. --icn;
  3096. --iw;
  3097. --icntl;
  3098. --info;
  3099. /* Function Body */
  3100. info[1] = 0;
  3101. /* INITIALIZE WORK ARRAY (IW2) IN PREPARATION FOR */
  3102. /* COUNTING NUMBERS OF NON-ZEROS IN THE ROWS AND INITIALIZE */
  3103. /* LAST N ENTRIES IN A WHICH WILL HOLD THE DIAGONAL ENTRIES */
  3104. ia = *la;
  3105. i__1 = *n;
  3106. for (iold = 1; iold <= i__1; ++iold) {
  3107. iw2[iold] = 1;
  3108. a[ia] = 0.f;
  3109. --ia;
  3110. /* L10: */
  3111. }
  3112. /* SCAN INPUT COPYING ROW INDICES FROM IRN TO THE FIRST NZ POSITIONS */
  3113. /* IN IW. THE NEGATIVE OF THE INDEX IS HELD TO FLAG ENTRIES FOR */
  3114. /* THE IN-PLACE SORT. ENTRIES IN IW CORRESPONDING TO DIAGONALS AND */
  3115. /* ENTRIES WITH OUT-OF-RANGE INDICES ARE SET TO ZERO. */
  3116. /* FOR DIAGONAL ENTRIES, REALS ARE ACCUMULATED IN THE LAST N */
  3117. /* LOCATIONS OF A. */
  3118. /* THE NUMBER OF ENTRIES IN EACH ROW OF THE PERMUTED MATRIX IS */
  3119. /* ACCUMULATED IN IW2. */
  3120. /* INDICES OUT OF RANGE ARE IGNORED AFTER BEING COUNTED AND */
  3121. /* AFTER APPROPRIATE MESSAGES HAVE BEEN PRINTED. */
  3122. info[2] = 0;
  3123. /* NZ1 IS THE NUMBER OF NON-ZEROS HELD AFTER INDICES OUT OF RANGE HAVE */
  3124. /* BEEN IGNORED AND DIAGONAL ENTRIES ACCUMULATED. */
  3125. *nz1 = *n;
  3126. if (*nz == 0) {
  3127. goto L80;
  3128. }
  3129. i__1 = *nz;
  3130. for (k = 1; k <= i__1; ++k) {
  3131. iold = irn[k];
  3132. if (iold > *n || iold <= 0) {
  3133. goto L30;
  3134. }
  3135. jold = icn[k];
  3136. if (jold > *n || jold <= 0) {
  3137. goto L30;
  3138. }
  3139. inew = perm[iold];
  3140. jnew = perm[jold];
  3141. if (inew != jnew) {
  3142. goto L20;
  3143. }
  3144. ia = *la - *n + iold;
  3145. a[ia] += a[k];
  3146. goto L60;
  3147. L20:
  3148. inew = min(inew,jnew);
  3149. /* INCREMENT NUMBER OF ENTRIES IN ROW INEW. */
  3150. ++iw2[inew];
  3151. iw[k] = -iold;
  3152. ++(*nz1);
  3153. goto L70;
  3154. /* ENTRY OUT OF RANGE. IT WILL BE IGNORED AND A FLAG SET. */
  3155. L30:
  3156. info[1] = 1;
  3157. ++info[2];
  3158. if (info[2] <= 1 && icntl[2] > 0) {
  3159. io___212.ciunit = icntl[2];
  3160. s_wsfe(&io___212);
  3161. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  3162. e_wsfe();
  3163. }
  3164. if (info[2] <= 10 && icntl[2] > 0) {
  3165. io___213.ciunit = icntl[2];
  3166. s_wsfe(&io___213);
  3167. do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer));
  3168. do_fio(&c__1, (char *)&irn[k], (ftnlen)sizeof(integer));
  3169. do_fio(&c__1, (char *)&icn[k], (ftnlen)sizeof(integer));
  3170. e_wsfe();
  3171. }
  3172. L60:
  3173. iw[k] = 0;
  3174. L70:
  3175. ;
  3176. }
  3177. /* CALCULATE POINTERS (IN IW2) TO THE POSITION IMMEDIATELY AFTER THE END */
  3178. /* OF EACH ROW. */
  3179. L80:
  3180. if (*nz < *nz1 && *nz1 != *n) {
  3181. goto L100;
  3182. }
  3183. /* ROOM IS INCLUDED FOR THE DIAGONALS. */
  3184. k = 1;
  3185. i__1 = *n;
  3186. for (i__ = 1; i__ <= i__1; ++i__) {
  3187. k += iw2[i__];
  3188. iw2[i__] = k;
  3189. /* L90: */
  3190. }
  3191. goto L120;
  3192. /* ROOM IS NOT INCLUDED FOR THE DIAGONALS. */
  3193. L100:
  3194. k = 1;
  3195. i__1 = *n;
  3196. for (i__ = 1; i__ <= i__1; ++i__) {
  3197. k = k + iw2[i__] - 1;
  3198. iw2[i__] = k;
  3199. /* L110: */
  3200. }
  3201. /* FAIL IF INSUFFICIENT SPACE IN ARRAYS A OR IW. */
  3202. L120:
  3203. if (*nz1 > *liw) {
  3204. goto L210;
  3205. }
  3206. if (*nz1 + *n > *la) {
  3207. goto L220;
  3208. }
  3209. /* NOW RUN THROUGH NON-ZEROS IN ORDER PLACING THEM IN THEIR NEW */
  3210. /* POSITION AND DECREMENTING APPROPRIATE IW2 ENTRY. IF WE ARE */
  3211. /* ABOUT TO OVERWRITE AN ENTRY NOT YET MOVED, WE MUST DEAL WITH */
  3212. /* THIS AT THIS TIME. */
  3213. if (*nz1 == *n) {
  3214. goto L180;
  3215. }
  3216. i__1 = *nz;
  3217. for (k = 1; k <= i__1; ++k) {
  3218. iold = -iw[k];
  3219. if (iold <= 0) {
  3220. goto L140;
  3221. }
  3222. jold = icn[k];
  3223. anow = a[k];
  3224. iw[k] = 0;
  3225. i__2 = *nz;
  3226. for (ich = 1; ich <= i__2; ++ich) {
  3227. inew = perm[iold];
  3228. jnew = perm[jold];
  3229. inew = min(inew,jnew);
  3230. if (inew == perm[jold]) {
  3231. jold = iold;
  3232. }
  3233. jpos = iw2[inew] - 1;
  3234. iold = -iw[jpos];
  3235. anext = a[jpos];
  3236. a[jpos] = anow;
  3237. iw[jpos] = jold;
  3238. iw2[inew] = jpos;
  3239. if (iold == 0) {
  3240. goto L140;
  3241. }
  3242. anow = anext;
  3243. jold = icn[jpos];
  3244. /* L130: */
  3245. }
  3246. L140:
  3247. ;
  3248. }
  3249. if (*nz >= *nz1) {
  3250. goto L180;
  3251. }
  3252. /* MOVE UP ENTRIES TO ALLOW FOR DIAGONALS. */
  3253. ipos = *nz1;
  3254. jpos = *nz1 - *n;
  3255. i__1 = *n;
  3256. for (ii = 1; ii <= i__1; ++ii) {
  3257. i__ = *n - ii + 1;
  3258. j1 = iw2[i__];
  3259. j2 = jpos;
  3260. if (j1 > jpos) {
  3261. goto L160;
  3262. }
  3263. i__2 = j2;
  3264. for (jj = j1; jj <= i__2; ++jj) {
  3265. iw[ipos] = iw[jpos];
  3266. a[ipos] = a[jpos];
  3267. --ipos;
  3268. --jpos;
  3269. /* L150: */
  3270. }
  3271. L160:
  3272. iw2[i__] = ipos + 1;
  3273. --ipos;
  3274. /* L170: */
  3275. }
  3276. /* RUN THROUGH ROWS INSERTING DIAGONAL ENTRIES AND FLAGGING BEGINNING */
  3277. /* OF EACH ROW BY NEGATING FIRST COLUMN INDEX. */
  3278. L180:
  3279. i__1 = *n;
  3280. for (iold = 1; iold <= i__1; ++iold) {
  3281. inew = perm[iold];
  3282. jpos = iw2[inew] - 1;
  3283. ia = *la - *n + iold;
  3284. a[jpos] = a[ia];
  3285. iw[jpos] = -iold;
  3286. /* L190: */
  3287. }
  3288. /* MOVE SORTED MATRIX TO THE END OF THE ARRAYS. */
  3289. ipos = *nz1;
  3290. ia = *la;
  3291. iiw = *liw;
  3292. i__1 = *nz1;
  3293. for (i__ = 1; i__ <= i__1; ++i__) {
  3294. a[ia] = a[ipos];
  3295. iw[iiw] = iw[ipos];
  3296. --ipos;
  3297. --ia;
  3298. --iiw;
  3299. /* L200: */
  3300. }
  3301. goto L230;
  3302. /* **** ERROR RETURN **** */
  3303. L210:
  3304. info[1] = -3;
  3305. info[2] = *nz1;
  3306. goto L230;
  3307. L220:
  3308. info[1] = -4;
  3309. info[2] = *nz1 + *n;
  3310. L230:
  3311. return 0;
  3312. } /* ma27n_ */
  3313. /* Subroutine */ int ma27o_(integer *n, integer *nz, real *a, integer *la,
  3314. integer *iw, integer *liw, integer *perm, integer *nstk, integer *
  3315. nsteps, integer *maxfrt, integer *nelim, integer *iw2, integer *icntl,
  3316. real *cntl, integer *info)
  3317. {
  3318. /* Format strings */
  3319. static char fmt_310[] = "(\002 *** WARNING MESSAGE FROM SUBROUTINE MA27"
  3320. "B\002,\002 *** INFO(1) =\002,i2,/,\002 PIVOT\002,i6,\002 HAS DI"
  3321. "FFERENT SIGN FROM THE PREVIOUS ONE\002)";
  3322. /* System generated locals */
  3323. integer i__1, i__2, i__3, i__4, i__5;
  3324. real r__1, r__2, r__3, r__4;
  3325. /* Builtin functions */
  3326. integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
  3327. /* Local variables */
  3328. static integer i__, j, k, j1, j2, k1, k2, jj, kk, lt;
  3329. static real uu;
  3330. static integer jj1, jjj, ifr, ibeg, iend, neig;
  3331. static real amax;
  3332. static integer iell, jcol, nblk;
  3333. extern /* Subroutine */ int ma27p_(real *, integer *, integer *, integer *
  3334. , integer *, integer *, integer *, integer *);
  3335. static integer iass, iorg, apos, astk, jmax, jnew;
  3336. static real rmax;
  3337. static integer ipiv;
  3338. static real tmax;
  3339. static integer ipos, istk, jpiv, jpos, kmax, irow, krow, nass, npiv, ntwo;
  3340. static real swop;
  3341. static integer apos1, apos2, apos3, astk2, istk2, laell, iexch, liell,
  3342. newel, jlast, azero, lnass;
  3343. static real amult;
  3344. static integer ipmnp, jnext, lnpiv, iswop, iwpos, lapos2;
  3345. static real amult1, amult2;
  3346. static integer npivp1, pospv1, pospv2, ncmpbi, posfac, ncmpbr, nirbdu,
  3347. nrlbdu, ioldps;
  3348. static real detpiv, thresh;
  3349. static integer ainput, jfirst, idummy, jdummy, jmxmip, kdummy, iinput,
  3350. isnpiv, nfront, numass, numorg, numstk, pivsiz, ltopst, ntotpv;
  3351. /* Fortran I/O blocks */
  3352. static cilist io___280 = { 0, 0, 0, fmt_310, 0 };
  3353. /* FACTORIZATION SUBROUTINE */
  3354. /* THIS SUBROUTINE OPERATES ON THE INPUT MATRIX ORDERED BY MA27N/ND AND */
  3355. /* PRODUCES THE FACTORS OF U AND D ('A'=UTRANSPOSE*D*U) FOR USE IN */
  3356. /* SUBSEQUENT SOLUTIONS. GAUSSIAN ELIMINATION IS USED WITH PIVOTS */
  3357. /* CHOSEN FROM THE DIAGONAL. TO ENSURE STABILITY, BLOCK PIVOTS OF */
  3358. /* ORDER 2 WILL BE USED IF THE DIAGONAL ENTRY IS NOT LARGE ENOUGH. */
  3359. /* N - MUST BE SET TO THE ORDER OF THE MATRIX. IT IS NOT ALTERED. */
  3360. /* NZ - MUST BE SET TO THE NUMBER OF NON-ZEROS IN UPPER TRIANGLE OF */
  3361. /* PERMUTED MATRIX. NOT ALTERED BY MA27O/OD. */
  3362. /* A - MUST BE SET ON INPUT TO MATRIX HELD BY ROWS REORDERED BY */
  3363. /* PERMUTATION FROM MA27A/AD IN A(LA-NZ+I),I=1,NZ. ON */
  3364. /* EXIT FROM MA27O/OD, THE FACTORS OF U AND D ARE HELD IN */
  3365. /* POSITIONS 1 TO POSFAC-1. */
  3366. /* LA - LENGTH OF ARRAY A. A VALUE FOR LA */
  3367. /* SUFFICIENT FOR DEFINITE SYSTEMS */
  3368. /* WILL HAVE BEEN PROVIDED BY MA27A/AD. NOT ALTERED BY MA27O/OD. */
  3369. /* IW - MUST BE SET SO THAT,ON INPUT, IW(LIW-NZ+I),I=1,NZ */
  3370. /* HOLDS THE COLUMN INDEX OF THE ENTRY IN A(LA-NZ+I). ON EXIT, */
  3371. /* IW HOLDS INTEGER INDEXING INFORMATION ON THE FACTORS. */
  3372. /* THE ABSOLUTE VALUE OF THE FIRST ENTRY IN IW WILL BE SET TO */
  3373. /* THE NUMBER OF BLOCK PIVOTS ACTUALLY USED. THIS MAY BE */
  3374. /* DIFFERENT FROM NSTEPS SINCE NUMERICAL CONSIDERATIONS */
  3375. /* MAY PREVENT US CHOOSING A PIVOT AT EACH STAGE. IF THIS ENTRY */
  3376. /* IN IW IS NEGATIVE, THEN AT LEAST ONE TWO BY TWO */
  3377. /* PIVOT HAS BEEN USED DURING THE DECOMPOSITION. */
  3378. /* INTEGER INFORMATION ON EACH BLOCK PIVOT ROW FOLLOWS. FOR */
  3379. /* EACH BLOCK PIVOT ROW THE COLUMN INDICES ARE PRECEDED BY A */
  3380. /* COUNT OF THE NUMBER OF ROWS AND COLUMNS IN THE BLOCK PIVOT */
  3381. /* WHERE, IF ONLY ONE ROW IS PRESENT, ONLY THE NUMBER OF */
  3382. /* COLUMNS TOGETHER WITH A NEGATIVE FLAG IS HELD. THE FIRST */
  3383. /* COLUMN INDEX FOR A TWO BY TWO PIVOT IS FLAGGED NEGATIVE. */
  3384. /* LIW - LENGTH OF ARRAY IW. A VALUE FOR LIW SUFFICIENT FOR */
  3385. /* DEFINITE SYSTEMS */
  3386. /* WILL HAVE BEEN PROVIDED BY MA27A/AD. NOT ALTERED BY MA27O/OD */
  3387. /* PERM - PERM(I) MUST BE SET TO POSITION OF ROW/COLUMN I IN THE */
  3388. /* TENTATIVE PIVOT ORDER GENERATED BY MA27A/AD. */
  3389. /* IT IS NOT ALTERED BY MA27O/OD. */
  3390. /* NSTK - MUST BE LEFT UNCHANGED SINCE OUTPUT FROM MA27A/AD. NSTK(I) */
  3391. /* GIVES THE NUMBER OF GENERATED STACK ELEMENTS ASSEMBLED AT */
  3392. /* STAGE I. IT IS NOT ALTERED BY MA27O/OD. */
  3393. /* NSTEPS - LENGTH OF ARRAYS NSTK AND NELIM. VALUE IS GIVEN ON OUTPUT */
  3394. /* FROM MA27A/AD (WILL NEVER EXCEED N). IT IS NOT ALTERED BY */
  3395. /* MA27O/OD. */
  3396. /* MAXFRT - NEED NOT BE SET ON INPUT. ON OUTPUT */
  3397. /* MAXFRT WILL BE SET TO THE MAXIMUM FRONT SIZE ENCOUNTERED */
  3398. /* DURING THE DECOMPOSITION. */
  3399. /* NELIM - MUST BE UNCHANGED SINCE OUTPUT FROM MA27A/AD. NELIM(I) */
  3400. /* GIVES THE NUMBER OF ORIGINAL ROWS ASSEMBLED AT STAGE I. */
  3401. /* IT IS NOT ALTERED BY MA27O/OD. */
  3402. /* IW2 - INTEGER ARRAY OF LENGTH N. USED AS WORKSPACE BY MA27O/OD. */
  3403. /* ALTHOUGH WE COULD HAVE USED A SHORT WORD INTEGER IN THE IBM */
  3404. /* VERSION, WE HAVE NOT DONE SO BECAUSE THERE IS A SPARE */
  3405. /* FULL INTEGER ARRAY (USED IN THE SORT BEFORE MA27O/OD) */
  3406. /* AVAILABLE WHEN MA27O/OD IS CALLED FROM MA27B/BD. */
  3407. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  3408. /* CNTL is a REAL array of length 5, see MA27A/AD. */
  3409. /* INFO is an INTEGER array of length 20, see MA27A/AD. */
  3410. /* INFO(1) - INTEGER VARIABLE. DIAGNOSTIC FLAG. A ZERO VALUE ON EXIT */
  3411. /* INDICATES SUCCESS. POSSIBLE NEGATIVE VALUES ARE ... */
  3412. /* -3 INSUFFICIENT STORAGE FOR IW. */
  3413. /* -4 INSUFFICIENT STORAGE FOR A. */
  3414. /* -5 ZERO PIVOT FOUND IN FACTORIZATION OF DEFINITE MATRIX. */
  3415. /* .. Parameters .. */
  3416. /* .. */
  3417. /* .. Scalar Arguments .. */
  3418. /* .. */
  3419. /* .. Array Arguments .. */
  3420. /* .. */
  3421. /* .. Local Scalars .. */
  3422. /* .. */
  3423. /* .. External Subroutines .. */
  3424. /* .. */
  3425. /* .. Intrinsic Functions .. */
  3426. /* .. */
  3427. /* .. Statement Functions .. */
  3428. /* .. */
  3429. /* .. Statement Function definitions .. */
  3430. /* THE FOLLOWING ARITHMETIC FUNCTION GIVES THE DISPLACEMENT FROM */
  3431. /* THE START OF THE ASSEMBLED MATRIX(OF ORDER IX) OF THE DIAGONAL */
  3432. /* ENTRY IN ITS ROW IY. */
  3433. /* .. */
  3434. /* .. Executable Statements .. */
  3435. /* INITIALIZATION. */
  3436. /* NBLK IS THE NUMBER OF BLOCK PIVOTS USED. */
  3437. /* Parameter adjustments */
  3438. --iw2;
  3439. --perm;
  3440. --a;
  3441. --iw;
  3442. --nelim;
  3443. --nstk;
  3444. --icntl;
  3445. --cntl;
  3446. --info;
  3447. /* Function Body */
  3448. nblk = 0;
  3449. ntwo = 0;
  3450. neig = 0;
  3451. ncmpbi = 0;
  3452. ncmpbr = 0;
  3453. *maxfrt = 0;
  3454. nrlbdu = 0;
  3455. nirbdu = 0;
  3456. /* A PRIVATE VARIABLE UU IS SET TO CNTL(1), SO THAT CNTL(1) WILL REMAIN */
  3457. /* UNALTERED. */
  3458. uu = dmin(cntl[1],.5f);
  3459. uu = dmax(uu,-.5f);
  3460. i__1 = *n;
  3461. for (i__ = 1; i__ <= i__1; ++i__) {
  3462. iw2[i__] = 0;
  3463. /* L10: */
  3464. }
  3465. /* IWPOS IS POINTER TO FIRST FREE POSITION FOR FACTORS IN IW. */
  3466. /* POSFAC IS POINTER FOR FACTORS IN A. AT EACH PASS THROUGH THE */
  3467. /* MAJOR LOOP POSFAC INITIALLY POINTS TO THE FIRST FREE LOCATION */
  3468. /* IN A AND THEN IS SET TO THE POSITION OF THE CURRENT PIVOT IN A. */
  3469. /* ISTK IS POINTER TO TOP OF STACK IN IW. */
  3470. /* ISTK2 IS POINTER TO BOTTOM OF STACK IN IW (NEEDED BY COMPRESS). */
  3471. /* ASTK IS POINTER TO TOP OF STACK IN A. */
  3472. /* ASTK2 IS POINTER TO BOTTOM OF STACK IN A (NEEDED BY COMPRESS). */
  3473. /* IINPUT IS POINTER TO CURRENT POSITION IN ORIGINAL ROWS IN IW. */
  3474. /* AINPUT IS POINTER TO CURRENT POSITION IN ORIGINAL ROWS IN A. */
  3475. /* AZERO IS POINTER TO LAST POSITION ZEROED IN A. */
  3476. /* NTOTPV IS THE TOTAL NUMBER OF PIVOTS SELECTED. THIS IS USED */
  3477. /* TO DETERMINE WHETHER THE MATRIX IS SINGULAR. */
  3478. iwpos = 2;
  3479. posfac = 1;
  3480. istk = *liw - *nz + 1;
  3481. istk2 = istk - 1;
  3482. astk = *la - *nz + 1;
  3483. astk2 = astk - 1;
  3484. iinput = istk;
  3485. ainput = astk;
  3486. azero = 0;
  3487. ntotpv = 0;
  3488. /* NUMASS IS THE ACCUMULATED NUMBER OF ROWS ASSEMBLED SO FAR. */
  3489. numass = 0;
  3490. /* EACH PASS THROUGH THIS MAIN LOOP PERFORMS ALL THE OPERATIONS */
  3491. /* ASSOCIATED WITH ONE SET OF ASSEMBLY/ELIMINATIONS. */
  3492. i__1 = *nsteps;
  3493. for (iass = 1; iass <= i__1; ++iass) {
  3494. /* NASS WILL BE SET TO THE NUMBER OF FULLY ASSEMBLED VARIABLES IN */
  3495. /* CURRENT NEWLY CREATED ELEMENT. */
  3496. nass = nelim[iass];
  3497. /* NEWEL IS A POINTER INTO IW TO CONTROL OUTPUT OF INTEGER INFORMATION */
  3498. /* FOR NEWLY CREATED ELEMENT. */
  3499. newel = iwpos + 1;
  3500. /* SYMBOLICALLY ASSEMBLE INCOMING ROWS AND GENERATED STACK ELEMENTS */
  3501. /* ORDERING THE RESULTANT ELEMENT ACCORDING TO PERMUTATION PERM. WE */
  3502. /* ASSEMBLE THE STACK ELEMENTS FIRST BECAUSE THESE WILL ALREADY BE */
  3503. /* ORDERED. */
  3504. /* SET HEADER POINTER FOR MERGE OF INDEX LISTS. */
  3505. jfirst = *n + 1;
  3506. /* INITIALIZE NUMBER OF VARIABLES IN CURRENT FRONT. */
  3507. nfront = 0;
  3508. numstk = nstk[iass];
  3509. ltopst = 1;
  3510. lnass = 0;
  3511. /* JUMP IF NO STACK ELEMENTS ARE BEING ASSEMBLED AT THIS STAGE. */
  3512. if (numstk == 0) {
  3513. goto L80;
  3514. }
  3515. j2 = istk - 1;
  3516. lnass = nass;
  3517. ltopst = (iw[istk] + 1) * iw[istk] / 2;
  3518. i__2 = numstk;
  3519. for (iell = 1; iell <= i__2; ++iell) {
  3520. /* ASSEMBLE ELEMENT IELL PLACING */
  3521. /* THE INDICES INTO A LINKED LIST IN IW2 ORDERED */
  3522. /* ACCORDING TO PERM. */
  3523. jnext = jfirst;
  3524. jlast = *n + 1;
  3525. j1 = j2 + 2;
  3526. j2 = j1 - 1 + iw[j1 - 1];
  3527. /* RUN THROUGH INDEX LIST OF STACK ELEMENT IELL. */
  3528. i__3 = j2;
  3529. for (jj = j1; jj <= i__3; ++jj) {
  3530. j = iw[jj];
  3531. /* JUMP IF ALREADY ASSEMBLED */
  3532. if (iw2[j] > 0) {
  3533. goto L60;
  3534. }
  3535. jnew = perm[j];
  3536. /* IF VARIABLE WAS PREVIOUSLY FULLY SUMMED BUT WAS NOT PIVOTED ON */
  3537. /* EARLIER BECAUSE OF NUMERICAL TEST, INCREMENT NUMBER OF FULLY */
  3538. /* SUMMED ROWS/COLUMNS IN FRONT. */
  3539. if (jnew <= numass) {
  3540. ++nass;
  3541. }
  3542. /* FIND POSITION IN LINKED LIST FOR NEW VARIABLE. NOTE THAT WE START */
  3543. /* FROM WHERE WE LEFT OFF AFTER ASSEMBLY OF PREVIOUS VARIABLE. */
  3544. i__4 = *n;
  3545. for (idummy = 1; idummy <= i__4; ++idummy) {
  3546. if (jnext == *n + 1) {
  3547. goto L30;
  3548. }
  3549. if (perm[jnext] > jnew) {
  3550. goto L30;
  3551. }
  3552. jlast = jnext;
  3553. jnext = iw2[jlast];
  3554. /* L20: */
  3555. }
  3556. L30:
  3557. if (jlast != *n + 1) {
  3558. goto L40;
  3559. }
  3560. jfirst = j;
  3561. goto L50;
  3562. L40:
  3563. iw2[jlast] = j;
  3564. L50:
  3565. iw2[j] = jnext;
  3566. jlast = j;
  3567. /* INCREMENT NUMBER OF VARIABLES IN THE FRONT. */
  3568. ++nfront;
  3569. L60:
  3570. ;
  3571. }
  3572. /* L70: */
  3573. }
  3574. lnass = nass - lnass;
  3575. /* NOW INCORPORATE ORIGINAL ROWS. NOTE THAT THE COLUMNS IN THESE ROWS */
  3576. /* NEED NOT BE IN ORDER. WE ALSO PERFORM */
  3577. /* A SWOP SO THAT THE DIAGONAL ENTRY IS THE FIRST IN ITS */
  3578. /* ROW. THIS ALLOWS US TO AVOID STORING THE INVERSE OF ARRAY PERM. */
  3579. L80:
  3580. numorg = nelim[iass];
  3581. j1 = iinput;
  3582. i__2 = numorg;
  3583. for (iorg = 1; iorg <= i__2; ++iorg) {
  3584. j = -iw[j1];
  3585. i__3 = *liw;
  3586. for (idummy = 1; idummy <= i__3; ++idummy) {
  3587. jnew = perm[j];
  3588. /* JUMP IF VARIABLE ALREADY INCLUDED. */
  3589. if (iw2[j] > 0) {
  3590. goto L130;
  3591. }
  3592. /* HERE WE MUST ALWAYS START OUR SEARCH AT THE BEGINNING. */
  3593. jlast = *n + 1;
  3594. jnext = jfirst;
  3595. i__4 = *n;
  3596. for (jdummy = 1; jdummy <= i__4; ++jdummy) {
  3597. if (jnext == *n + 1) {
  3598. goto L100;
  3599. }
  3600. if (perm[jnext] > jnew) {
  3601. goto L100;
  3602. }
  3603. jlast = jnext;
  3604. jnext = iw2[jlast];
  3605. /* L90: */
  3606. }
  3607. L100:
  3608. if (jlast != *n + 1) {
  3609. goto L110;
  3610. }
  3611. jfirst = j;
  3612. goto L120;
  3613. L110:
  3614. iw2[jlast] = j;
  3615. L120:
  3616. iw2[j] = jnext;
  3617. /* INCREMENT NUMBER OF VARIABLES IN FRONT. */
  3618. ++nfront;
  3619. L130:
  3620. ++j1;
  3621. if (j1 > *liw) {
  3622. goto L150;
  3623. }
  3624. j = iw[j1];
  3625. if (j < 0) {
  3626. goto L150;
  3627. }
  3628. /* L140: */
  3629. }
  3630. L150:
  3631. ;
  3632. }
  3633. /* NOW RUN THROUGH LINKED LIST IW2 PUTTING INDICES OF VARIABLES IN NEW */
  3634. /* ELEMENT INTO IW AND SETTING IW2 ENTRY TO POINT TO THE RELATIVE */
  3635. /* POSITION OF THE VARIABLE IN THE NEW ELEMENT. */
  3636. if (newel + nfront < istk) {
  3637. goto L160;
  3638. }
  3639. /* COMPRESS IW. */
  3640. ma27p_(&a[1], &iw[1], &istk, &istk2, &iinput, &c__2, &ncmpbr, &ncmpbi)
  3641. ;
  3642. if (newel + nfront < istk) {
  3643. goto L160;
  3644. }
  3645. info[2] = *liw + 1 + newel + nfront - istk;
  3646. goto L770;
  3647. L160:
  3648. j = jfirst;
  3649. i__2 = nfront;
  3650. for (ifr = 1; ifr <= i__2; ++ifr) {
  3651. ++newel;
  3652. iw[newel] = j;
  3653. jnext = iw2[j];
  3654. iw2[j] = newel - (iwpos + 1);
  3655. j = jnext;
  3656. /* L170: */
  3657. }
  3658. /* ASSEMBLE REALS INTO FRONTAL MATRIX. */
  3659. *maxfrt = max(*maxfrt,nfront);
  3660. iw[iwpos] = nfront;
  3661. /* FIRST ZERO OUT FRONTAL MATRIX AS APPROPRIATE FIRST CHECKING TO SEE */
  3662. /* IF THERE IS SUFFICIENT SPACE. */
  3663. laell = (nfront + 1) * nfront / 2;
  3664. apos2 = posfac + laell - 1;
  3665. if (numstk != 0) {
  3666. lnass = lnass * ((nfront << 1) - lnass + 1) / 2;
  3667. }
  3668. if (posfac + lnass - 1 >= astk) {
  3669. goto L180;
  3670. }
  3671. if (apos2 < astk + ltopst - 1) {
  3672. goto L190;
  3673. }
  3674. /* COMPRESS A. */
  3675. L180:
  3676. ma27p_(&a[1], &iw[1], &astk, &astk2, &ainput, &c__1, &ncmpbr, &ncmpbi)
  3677. ;
  3678. if (posfac + lnass - 1 >= astk) {
  3679. goto L780;
  3680. }
  3681. if (apos2 >= astk + ltopst - 1) {
  3682. goto L780;
  3683. }
  3684. L190:
  3685. if (apos2 <= azero) {
  3686. goto L220;
  3687. }
  3688. apos = azero + 1;
  3689. /* Computing MIN */
  3690. i__2 = apos2, i__3 = astk - 1;
  3691. lapos2 = min(i__2,i__3);
  3692. if (lapos2 < apos) {
  3693. goto L210;
  3694. }
  3695. i__2 = lapos2;
  3696. for (k = apos; k <= i__2; ++k) {
  3697. a[k] = 0.f;
  3698. /* L200: */
  3699. }
  3700. L210:
  3701. azero = apos2;
  3702. /* JUMP IF THERE ARE NO STACK ELEMENTS TO ASSEMBLE. */
  3703. L220:
  3704. if (numstk == 0) {
  3705. goto L260;
  3706. }
  3707. /* PLACE REALS CORRESPONDING TO STACK ELEMENTS IN CORRECT POSITIONS IN A. */
  3708. i__2 = numstk;
  3709. for (iell = 1; iell <= i__2; ++iell) {
  3710. j1 = istk + 1;
  3711. j2 = istk + iw[istk];
  3712. i__3 = j2;
  3713. for (jj = j1; jj <= i__3; ++jj) {
  3714. irow = iw[jj];
  3715. irow = iw2[irow];
  3716. apos = posfac + (irow - 1) * (2 * nfront - irow + 2) / 2;
  3717. i__4 = j2;
  3718. for (jjj = jj; jjj <= i__4; ++jjj) {
  3719. j = iw[jjj];
  3720. apos2 = apos + iw2[j] - irow;
  3721. a[apos2] += a[astk];
  3722. a[astk] = 0.f;
  3723. ++astk;
  3724. /* L230: */
  3725. }
  3726. /* L240: */
  3727. }
  3728. /* INCREMENT STACK POINTER. */
  3729. istk = j2 + 1;
  3730. /* L250: */
  3731. }
  3732. /* INCORPORATE REALS FROM ORIGINAL ROWS. */
  3733. L260:
  3734. i__2 = numorg;
  3735. for (iorg = 1; iorg <= i__2; ++iorg) {
  3736. j = -iw[iinput];
  3737. /* WE CAN DO THIS BECAUSE THE DIAGONAL IS NOW THE FIRST ENTRY. */
  3738. irow = iw2[j];
  3739. apos = posfac + (irow - 1) * (2 * nfront - irow + 2) / 2;
  3740. /* THE FOLLOWING LOOP GOES FROM 1 TO NZ BECAUSE THERE MAY BE DUPLICATES. */
  3741. i__3 = *nz;
  3742. for (idummy = 1; idummy <= i__3; ++idummy) {
  3743. apos2 = apos + iw2[j] - irow;
  3744. a[apos2] += a[ainput];
  3745. ++ainput;
  3746. ++iinput;
  3747. if (iinput > *liw) {
  3748. goto L280;
  3749. }
  3750. j = iw[iinput];
  3751. if (j < 0) {
  3752. goto L280;
  3753. }
  3754. /* L270: */
  3755. }
  3756. L280:
  3757. ;
  3758. }
  3759. /* RESET IW2 AND NUMASS. */
  3760. numass += numorg;
  3761. j1 = iwpos + 2;
  3762. j2 = iwpos + nfront + 1;
  3763. i__2 = j2;
  3764. for (k = j1; k <= i__2; ++k) {
  3765. j = iw[k];
  3766. iw2[j] = 0;
  3767. /* L290: */
  3768. }
  3769. /* PERFORM PIVOTING ON ASSEMBLED ELEMENT. */
  3770. /* NPIV IS THE NUMBER OF PIVOTS SO FAR SELECTED. */
  3771. /* LNPIV IS THE NUMBER OF PIVOTS SELECTED AFTER THE LAST PASS THROUGH */
  3772. /* THE THE FOLLOWING LOOP. */
  3773. lnpiv = -1;
  3774. npiv = 0;
  3775. i__2 = nass;
  3776. for (kdummy = 1; kdummy <= i__2; ++kdummy) {
  3777. if (npiv == nass) {
  3778. goto L660;
  3779. }
  3780. if (npiv == lnpiv) {
  3781. goto L660;
  3782. }
  3783. lnpiv = npiv;
  3784. npivp1 = npiv + 1;
  3785. /* JPIV IS USED AS A FLAG TO INDICATE WHEN 2 BY 2 PIVOTING HAS OCCURRED */
  3786. /* SO THAT IPIV IS INCREMENTED CORRECTLY. */
  3787. jpiv = 1;
  3788. /* NASS IS MAXIMUM POSSIBLE NUMBER OF PIVOTS. */
  3789. /* WE EITHER TAKE THE DIAGONAL ENTRY OR THE 2 BY 2 PIVOT WITH THE */
  3790. /* LARGEST OFF-DIAGONAL AT EACH STAGE. */
  3791. /* EACH PASS THROUGH THIS LOOP TRIES TO CHOOSE ONE PIVOT. */
  3792. i__3 = nass;
  3793. for (ipiv = npivp1; ipiv <= i__3; ++ipiv) {
  3794. --jpiv;
  3795. /* JUMP IF WE HAVE JUST PROCESSED A 2 BY 2 PIVOT. */
  3796. if (jpiv == 1) {
  3797. goto L640;
  3798. }
  3799. i__4 = nfront - npiv;
  3800. i__5 = ipiv - npiv;
  3801. apos = posfac + (i__5 - 1) * (2 * i__4 - i__5 + 2) / 2;
  3802. /* IF THE USER HAS INDICATED THAT THE MATRIX IS DEFINITE, WE */
  3803. /* DO NOT NEED TO TEST FOR STABILITY BUT WE DO CHECK TO SEE IF THE */
  3804. /* PIVOT IS NON-ZERO OR HAS CHANGED SIGN. */
  3805. /* IF IT IS ZERO, WE EXIT WITH AN ERROR. IF IT HAS CHANGED SIGN */
  3806. /* AND U WAS SET NEGATIVE, THEN WE AGAIN EXIT IMMEDIATELY. IF THE */
  3807. /* PIVOT CHANGES SIGN AND U WAS ZERO, WE CONTINUE WITH THE */
  3808. /* FACTORIZATION BUT PRINT A WARNING MESSAGE ON UNIT ICNTL(2). */
  3809. /* ISNPIV HOLDS A FLAG FOR THE SIGN OF THE PIVOTS TO DATE SO THAT */
  3810. /* A SIGN CHANGE WHEN DECOMPOSING AN ALLEGEDLY DEFINITE MATRIX CAN */
  3811. /* BE DETECTED. */
  3812. if (uu > 0.f) {
  3813. goto L320;
  3814. }
  3815. if ((r__1 = a[apos], dabs(r__1)) <= cntl[3]) {
  3816. goto L790;
  3817. }
  3818. /* JUMP IF THIS IS NOT THE FIRST PIVOT TO BE SELECTED. */
  3819. if (ntotpv > 0) {
  3820. goto L300;
  3821. }
  3822. /* SET ISNPIV. */
  3823. if (a[apos] > 0.f) {
  3824. isnpiv = 1;
  3825. }
  3826. if (a[apos] < 0.f) {
  3827. isnpiv = -1;
  3828. }
  3829. L300:
  3830. if (a[apos] > 0.f && isnpiv == 1) {
  3831. goto L560;
  3832. }
  3833. if (a[apos] < 0.f && isnpiv == -1) {
  3834. goto L560;
  3835. }
  3836. if (info[1] != 2) {
  3837. info[2] = 0;
  3838. }
  3839. ++info[2];
  3840. info[1] = 2;
  3841. i__ = ntotpv + 1;
  3842. if (icntl[2] > 0 && info[2] <= 10) {
  3843. io___280.ciunit = icntl[2];
  3844. s_wsfe(&io___280);
  3845. do_fio(&c__1, (char *)&info[1], (ftnlen)sizeof(integer));
  3846. do_fio(&c__1, (char *)&i__, (ftnlen)sizeof(integer));
  3847. e_wsfe();
  3848. }
  3849. isnpiv = -isnpiv;
  3850. if (uu == 0.f) {
  3851. goto L560;
  3852. }
  3853. goto L800;
  3854. L320:
  3855. amax = 0.f;
  3856. tmax = amax;
  3857. /* FIND LARGEST ENTRY TO RIGHT OF DIAGONAL IN ROW OF PROSPECTIVE PIVOT */
  3858. /* IN THE FULLY-SUMMED PART. ALSO RECORD COLUMN OF THIS LARGEST */
  3859. /* ENTRY. */
  3860. j1 = apos + 1;
  3861. j2 = apos + nass - ipiv;
  3862. if (j2 < j1) {
  3863. goto L340;
  3864. }
  3865. i__4 = j2;
  3866. for (jj = j1; jj <= i__4; ++jj) {
  3867. if ((r__1 = a[jj], dabs(r__1)) <= amax) {
  3868. goto L330;
  3869. }
  3870. jmax = ipiv + jj - j1 + 1;
  3871. amax = (r__1 = a[jj], dabs(r__1));
  3872. L330:
  3873. ;
  3874. }
  3875. /* DO SAME AS ABOVE FOR NON-FULLY-SUMMED PART ONLY HERE WE DO NOT NEED */
  3876. /* TO RECORD COLUMN SO LOOP IS SIMPLER. */
  3877. L340:
  3878. j1 = j2 + 1;
  3879. j2 = apos + nfront - ipiv;
  3880. if (j2 < j1) {
  3881. goto L360;
  3882. }
  3883. i__4 = j2;
  3884. for (jj = j1; jj <= i__4; ++jj) {
  3885. /* Computing MAX */
  3886. r__2 = (r__1 = a[jj], dabs(r__1));
  3887. tmax = dmax(r__2,tmax);
  3888. /* L350: */
  3889. }
  3890. /* NOW CALCULATE LARGEST ENTRY IN OTHER PART OF ROW. */
  3891. L360:
  3892. rmax = dmax(tmax,amax);
  3893. apos1 = apos;
  3894. kk = nfront - ipiv;
  3895. lt = ipiv - (npiv + 1);
  3896. if (lt == 0) {
  3897. goto L380;
  3898. }
  3899. i__4 = lt;
  3900. for (k = 1; k <= i__4; ++k) {
  3901. ++kk;
  3902. apos1 -= kk;
  3903. /* Computing MAX */
  3904. r__2 = rmax, r__3 = (r__1 = a[apos1], dabs(r__1));
  3905. rmax = dmax(r__2,r__3);
  3906. /* L370: */
  3907. }
  3908. /* JUMP IF STABILITY TEST SATISFIED. */
  3909. L380:
  3910. /* Computing MAX */
  3911. r__2 = cntl[3], r__3 = uu * rmax;
  3912. if ((r__1 = a[apos], dabs(r__1)) > dmax(r__2,r__3)) {
  3913. goto L450;
  3914. }
  3915. /* CHECK BLOCK PIVOT OF ORDER 2 FOR STABILITY. */
  3916. if (dabs(amax) <= cntl[3]) {
  3917. goto L640;
  3918. }
  3919. i__4 = nfront - npiv;
  3920. i__5 = jmax - npiv;
  3921. apos2 = posfac + (i__5 - 1) * (2 * i__4 - i__5 + 2) / 2;
  3922. detpiv = a[apos] * a[apos2] - amax * amax;
  3923. thresh = dabs(detpiv);
  3924. /* SET THRESH TO U TIMES THE RECIPROCAL OF THE MAX-NORM OF THE INVERSE */
  3925. /* OF THE PROSPECTIVE BLOCK. */
  3926. /* Computing MAX */
  3927. r__3 = (r__1 = a[apos], dabs(r__1)) + amax, r__4 = (r__2 = a[
  3928. apos2], dabs(r__2)) + amax;
  3929. thresh /= uu * dmax(r__3,r__4);
  3930. /* CHECK 2 BY 2 PIVOT FOR STABILITY. */
  3931. /* FIRST CHECK AGAINST ROW IPIV. */
  3932. if (thresh <= rmax) {
  3933. goto L640;
  3934. }
  3935. /* FIND LARGEST ENTRY IN ROW JMAX. */
  3936. /* FIND MAXIMUM TO THE RIGHT OF THE DIAGONAL. */
  3937. rmax = 0.f;
  3938. j1 = apos2 + 1;
  3939. j2 = apos2 + nfront - jmax;
  3940. if (j2 < j1) {
  3941. goto L400;
  3942. }
  3943. i__4 = j2;
  3944. for (jj = j1; jj <= i__4; ++jj) {
  3945. /* Computing MAX */
  3946. r__2 = rmax, r__3 = (r__1 = a[jj], dabs(r__1));
  3947. rmax = dmax(r__2,r__3);
  3948. /* L390: */
  3949. }
  3950. /* NOW CHECK TO THE LEFT OF THE DIAGONAL. */
  3951. /* WE USE TWO LOOPS TO AVOID TESTING FOR ROW IPIV INSIDE THE LOOP. */
  3952. L400:
  3953. kk = nfront - jmax + 1;
  3954. apos3 = apos2;
  3955. jmxmip = jmax - ipiv - 1;
  3956. if (jmxmip == 0) {
  3957. goto L420;
  3958. }
  3959. i__4 = jmxmip;
  3960. for (k = 1; k <= i__4; ++k) {
  3961. apos2 -= kk;
  3962. ++kk;
  3963. /* Computing MAX */
  3964. r__2 = rmax, r__3 = (r__1 = a[apos2], dabs(r__1));
  3965. rmax = dmax(r__2,r__3);
  3966. /* L410: */
  3967. }
  3968. L420:
  3969. ipmnp = ipiv - npiv - 1;
  3970. if (ipmnp == 0) {
  3971. goto L440;
  3972. }
  3973. apos2 -= kk;
  3974. ++kk;
  3975. i__4 = ipmnp;
  3976. for (k = 1; k <= i__4; ++k) {
  3977. apos2 -= kk;
  3978. ++kk;
  3979. /* Computing MAX */
  3980. r__2 = rmax, r__3 = (r__1 = a[apos2], dabs(r__1));
  3981. rmax = dmax(r__2,r__3);
  3982. /* L430: */
  3983. }
  3984. L440:
  3985. if (thresh <= rmax) {
  3986. goto L640;
  3987. }
  3988. pivsiz = 2;
  3989. goto L460;
  3990. L450:
  3991. pivsiz = 1;
  3992. L460:
  3993. irow = ipiv - npiv;
  3994. /* PIVOT HAS BEEN CHOSEN. IF BLOCK PIVOT OF ORDER 2, PIVSIZ IS EQUAL TO */
  3995. /* TWO OTHERWISE PIVSIZ EQUALS ONE.. */
  3996. /* THE FOLLOWING LOOP MOVES THE PIVOT BLOCK TO THE TOP LEFT HAND CORNER */
  3997. /* OF THE FRONTAL MATRIX. */
  3998. i__4 = pivsiz;
  3999. for (krow = 1; krow <= i__4; ++krow) {
  4000. /* WE JUMP IF SWOP IS NOT NECESSARY. */
  4001. if (irow == 1) {
  4002. goto L530;
  4003. }
  4004. j1 = posfac + irow;
  4005. j2 = posfac + nfront - (npiv + 1);
  4006. if (j2 < j1) {
  4007. goto L480;
  4008. }
  4009. apos2 = apos + 1;
  4010. /* SWOP PORTION OF ROWS WHOSE COLUMN INDICES ARE GREATER THAN LATER ROW. */
  4011. i__5 = j2;
  4012. for (jj = j1; jj <= i__5; ++jj) {
  4013. swop = a[apos2];
  4014. a[apos2] = a[jj];
  4015. a[jj] = swop;
  4016. ++apos2;
  4017. /* L470: */
  4018. }
  4019. L480:
  4020. j1 = posfac + 1;
  4021. j2 = posfac + irow - 2;
  4022. apos2 = apos;
  4023. kk = nfront - (irow + npiv);
  4024. if (j2 < j1) {
  4025. goto L500;
  4026. }
  4027. /* SWOP PORTION OF ROWS/COLUMNS WHOSE INDICES LIE BETWEEN THE TWO ROWS. */
  4028. i__5 = j2;
  4029. for (jjj = j1; jjj <= i__5; ++jjj) {
  4030. jj = j2 - jjj + j1;
  4031. ++kk;
  4032. apos2 -= kk;
  4033. swop = a[apos2];
  4034. a[apos2] = a[jj];
  4035. a[jj] = swop;
  4036. /* L490: */
  4037. }
  4038. L500:
  4039. if (npiv == 0) {
  4040. goto L520;
  4041. }
  4042. apos1 = posfac;
  4043. ++kk;
  4044. apos2 -= kk;
  4045. /* SWOP PORTION OF COLUMNS WHOSE INDICES ARE LESS THAN EARLIER ROW. */
  4046. i__5 = npiv;
  4047. for (jj = 1; jj <= i__5; ++jj) {
  4048. ++kk;
  4049. apos1 -= kk;
  4050. apos2 -= kk;
  4051. swop = a[apos2];
  4052. a[apos2] = a[apos1];
  4053. a[apos1] = swop;
  4054. /* L510: */
  4055. }
  4056. /* SWOP DIAGONALS AND INTEGER INDEXING INFORMATION */
  4057. L520:
  4058. swop = a[apos];
  4059. a[apos] = a[posfac];
  4060. a[posfac] = swop;
  4061. ipos = iwpos + npiv + 2;
  4062. iexch = iwpos + irow + npiv + 1;
  4063. iswop = iw[ipos];
  4064. iw[ipos] = iw[iexch];
  4065. iw[iexch] = iswop;
  4066. L530:
  4067. if (pivsiz == 1) {
  4068. goto L550;
  4069. }
  4070. /* SET VARIABLES FOR THE SWOP OF SECOND ROW OF BLOCK PIVOT. */
  4071. if (krow == 2) {
  4072. goto L540;
  4073. }
  4074. irow = jmax - (npiv + 1);
  4075. jpos = posfac;
  4076. posfac = posfac + nfront - npiv;
  4077. ++npiv;
  4078. apos = apos3;
  4079. goto L550;
  4080. /* RESET VARIABLES PREVIOUSLY SET FOR SECOND PASS. */
  4081. L540:
  4082. --npiv;
  4083. posfac = jpos;
  4084. L550:
  4085. ;
  4086. }
  4087. if (pivsiz == 2) {
  4088. goto L600;
  4089. }
  4090. /* PERFORM THE ELIMINATION USING ENTRY (IPIV,IPIV) AS PIVOT. */
  4091. /* WE STORE U AND DINVERSE. */
  4092. L560:
  4093. a[posfac] = 1.f / a[posfac];
  4094. if (a[posfac] < 0.f) {
  4095. ++neig;
  4096. }
  4097. j1 = posfac + 1;
  4098. j2 = posfac + nfront - (npiv + 1);
  4099. if (j2 < j1) {
  4100. goto L590;
  4101. }
  4102. ibeg = j2 + 1;
  4103. i__4 = j2;
  4104. for (jj = j1; jj <= i__4; ++jj) {
  4105. amult = -a[jj] * a[posfac];
  4106. iend = ibeg + nfront - (npiv + jj - j1 + 2);
  4107. /* THE FOLLOWING SPECIAL COMMENT FORCES VECTORIZATION ON THE CRAY-1. */
  4108. /* DIR$ IVDEP */
  4109. i__5 = iend;
  4110. for (irow = ibeg; irow <= i__5; ++irow) {
  4111. jcol = jj + irow - ibeg;
  4112. a[irow] += amult * a[jcol];
  4113. /* L570: */
  4114. }
  4115. ibeg = iend + 1;
  4116. a[jj] = amult;
  4117. /* L580: */
  4118. }
  4119. L590:
  4120. ++npiv;
  4121. ++ntotpv;
  4122. jpiv = 1;
  4123. posfac = posfac + nfront - npiv + 1;
  4124. goto L640;
  4125. /* PERFORM ELIMINATION USING BLOCK PIVOT OF ORDER TWO. */
  4126. /* REPLACE BLOCK PIVOT BY ITS INVERSE. */
  4127. /* SET FLAG TO INDICATE USE OF 2 BY 2 PIVOT IN IW. */
  4128. L600:
  4129. ipos = iwpos + npiv + 2;
  4130. ++ntwo;
  4131. iw[ipos] = -iw[ipos];
  4132. pospv1 = posfac;
  4133. pospv2 = posfac + nfront - npiv;
  4134. swop = a[pospv2];
  4135. if (detpiv < 0.f) {
  4136. ++neig;
  4137. }
  4138. if (detpiv > 0.f && swop < 0.f) {
  4139. neig += 2;
  4140. }
  4141. a[pospv2] = a[pospv1] / detpiv;
  4142. a[pospv1] = swop / detpiv;
  4143. a[pospv1 + 1] = -a[pospv1 + 1] / detpiv;
  4144. j1 = pospv1 + 2;
  4145. j2 = pospv1 + nfront - (npiv + 1);
  4146. if (j2 < j1) {
  4147. goto L630;
  4148. }
  4149. jj1 = pospv2;
  4150. ibeg = pospv2 + nfront - (npiv + 1);
  4151. i__4 = j2;
  4152. for (jj = j1; jj <= i__4; ++jj) {
  4153. ++jj1;
  4154. amult1 = -(a[pospv1] * a[jj] + a[pospv1 + 1] * a[jj1]);
  4155. amult2 = -(a[pospv1 + 1] * a[jj] + a[pospv2] * a[jj1]);
  4156. iend = ibeg + nfront - (npiv + jj - j1 + 3);
  4157. /* THE FOLLOWING SPECIAL COMMENT FORCES VECTORIZATION ON THE CRAY-1. */
  4158. /* DIR$ IVDEP */
  4159. i__5 = iend;
  4160. for (irow = ibeg; irow <= i__5; ++irow) {
  4161. k1 = jj + irow - ibeg;
  4162. k2 = jj1 + irow - ibeg;
  4163. a[irow] = a[irow] + amult1 * a[k1] + amult2 * a[k2];
  4164. /* L610: */
  4165. }
  4166. ibeg = iend + 1;
  4167. a[jj] = amult1;
  4168. a[jj1] = amult2;
  4169. /* L620: */
  4170. }
  4171. L630:
  4172. npiv += 2;
  4173. ntotpv += 2;
  4174. jpiv = 2;
  4175. posfac = pospv2 + nfront - npiv + 1;
  4176. L640:
  4177. ;
  4178. }
  4179. /* L650: */
  4180. }
  4181. /* END OF MAIN ELIMINATION LOOP. */
  4182. L660:
  4183. if (npiv != 0) {
  4184. ++nblk;
  4185. }
  4186. ioldps = iwpos;
  4187. iwpos = iwpos + nfront + 2;
  4188. if (npiv == 0) {
  4189. goto L690;
  4190. }
  4191. if (npiv > 1) {
  4192. goto L680;
  4193. }
  4194. iw[ioldps] = -iw[ioldps];
  4195. i__2 = nfront;
  4196. for (k = 1; k <= i__2; ++k) {
  4197. j1 = ioldps + k;
  4198. iw[j1] = iw[j1 + 1];
  4199. /* L670: */
  4200. }
  4201. --iwpos;
  4202. goto L690;
  4203. L680:
  4204. iw[ioldps + 1] = npiv;
  4205. /* COPY REMAINDER OF ELEMENT TO TOP OF STACK */
  4206. L690:
  4207. liell = nfront - npiv;
  4208. if (liell == 0 || iass == *nsteps) {
  4209. goto L750;
  4210. }
  4211. if (iwpos + liell < istk) {
  4212. goto L700;
  4213. }
  4214. ma27p_(&a[1], &iw[1], &istk, &istk2, &iinput, &c__2, &ncmpbr, &ncmpbi)
  4215. ;
  4216. L700:
  4217. istk = istk - liell - 1;
  4218. iw[istk] = liell;
  4219. j1 = istk;
  4220. kk = iwpos - liell - 1;
  4221. /* THE FOLLOWING SPECIAL COMMENT FORCES VECTORIZATION ON THE CRAY-1. */
  4222. /* DIR$ IVDEP */
  4223. i__2 = liell;
  4224. for (k = 1; k <= i__2; ++k) {
  4225. ++j1;
  4226. ++kk;
  4227. iw[j1] = iw[kk];
  4228. /* L710: */
  4229. }
  4230. /* WE COPY IN REVERSE DIRECTION TO AVOID OVERWRITE PROBLEMS. */
  4231. laell = (liell + 1) * liell / 2;
  4232. kk = posfac + laell;
  4233. if (kk != astk) {
  4234. goto L720;
  4235. }
  4236. astk -= laell;
  4237. goto L740;
  4238. /* THE MOVE AND ZEROING OF ARRAY A IS PERFORMED WITH TWO LOOPS SO */
  4239. /* THAT THE CRAY-1 WILL VECTORIZE THEM SAFELY. */
  4240. L720:
  4241. kmax = kk - 1;
  4242. /* THE FOLLOWING SPECIAL COMMENT FORCES VECTORIZATION ON THE CRAY-1. */
  4243. /* DIR$ IVDEP */
  4244. i__2 = laell;
  4245. for (k = 1; k <= i__2; ++k) {
  4246. --kk;
  4247. --astk;
  4248. a[astk] = a[kk];
  4249. /* L730: */
  4250. }
  4251. /* Computing MIN */
  4252. i__2 = kmax, i__3 = astk - 1;
  4253. kmax = min(i__2,i__3);
  4254. i__2 = kmax;
  4255. for (k = kk; k <= i__2; ++k) {
  4256. a[k] = 0.f;
  4257. /* L735: */
  4258. }
  4259. L740:
  4260. /* Computing MIN */
  4261. i__2 = azero, i__3 = astk - 1;
  4262. azero = min(i__2,i__3);
  4263. L750:
  4264. if (npiv == 0) {
  4265. iwpos = ioldps;
  4266. }
  4267. /* L760: */
  4268. }
  4269. /* END OF LOOP ON TREE NODES. */
  4270. iw[1] = nblk;
  4271. if (ntwo > 0) {
  4272. iw[1] = -nblk;
  4273. }
  4274. nrlbdu = posfac - 1;
  4275. nirbdu = iwpos - 1;
  4276. if (ntotpv == *n) {
  4277. goto L810;
  4278. }
  4279. info[1] = 3;
  4280. info[2] = ntotpv;
  4281. goto L810;
  4282. /* **** ERROR RETURNS **** */
  4283. L770:
  4284. info[1] = -3;
  4285. goto L810;
  4286. L780:
  4287. info[1] = -4;
  4288. /* Computing MAX */
  4289. i__1 = posfac + lnass, i__2 = apos2 - ltopst + 2;
  4290. info[2] = *la + max(i__1,i__2) - astk;
  4291. goto L810;
  4292. L790:
  4293. info[1] = -5;
  4294. info[2] = ntotpv + 1;
  4295. goto L810;
  4296. L800:
  4297. info[1] = -6;
  4298. info[2] = ntotpv + 1;
  4299. L810:
  4300. info[9] = nrlbdu;
  4301. info[10] = nirbdu;
  4302. info[12] = ncmpbr;
  4303. info[13] = ncmpbi;
  4304. info[14] = ntwo;
  4305. info[15] = neig;
  4306. return 0;
  4307. } /* ma27o_ */
  4308. /* Subroutine */ int ma27p_(real *a, integer *iw, integer *j1, integer *j2,
  4309. integer *itop, integer *ireal, integer *ncmpbr, integer *ncmpbi)
  4310. {
  4311. /* System generated locals */
  4312. integer i__1;
  4313. /* Local variables */
  4314. static integer jj, jjj, ipos;
  4315. /* THIS SUBROUTINE PERFORMS A VERY SIMPLE COMPRESS (BLOCK MOVE). */
  4316. /* ENTRIES J1 TO J2 (INCL.) IN A OR IW AS APPROPRIATE ARE MOVED TO */
  4317. /* OCCUPY THE POSITIONS IMMEDIATELY PRIOR TO POSITION ITOP. */
  4318. /* A/IW HOLD THE ARRAY BEING COMPRESSED. */
  4319. /* J1/J2 DEFINE THE ENTRIES BEING MOVED. */
  4320. /* ITOP DEFINES THE POSITION IMMEDIATELY AFTER THE POSITIONS TO WHICH */
  4321. /* J1 TO J2 ARE MOVED. */
  4322. /* IREAL MUST BE SET BY THE USER TO 2 IF THE MOVE IS ON ARRAY IW, */
  4323. /* ANY OTHER VALUE WILL PERFORM THE MOVE ON A. */
  4324. /* NCMPBR and NCMPBI, see INFO(12) and INFO(13) in MA27A/AD (ACCUMULATE */
  4325. /* THE NUMBER OF COMPRESSES OF THE REALS AND INTEGERS PERFORMED BY */
  4326. /* MA27B/BD. */
  4327. /* .. Scalar Arguments .. */
  4328. /* .. */
  4329. /* .. Array Arguments .. */
  4330. /* .. */
  4331. /* .. Local Scalars .. */
  4332. /* .. */
  4333. /* .. Executable Statements .. */
  4334. /* Parameter adjustments */
  4335. --iw;
  4336. --a;
  4337. /* Function Body */
  4338. ipos = *itop - 1;
  4339. if (*j2 == ipos) {
  4340. goto L50;
  4341. }
  4342. if (*ireal == 2) {
  4343. goto L20;
  4344. }
  4345. ++(*ncmpbr);
  4346. if (*j1 > *j2) {
  4347. goto L40;
  4348. }
  4349. i__1 = *j2;
  4350. for (jjj = *j1; jjj <= i__1; ++jjj) {
  4351. jj = *j2 - jjj + *j1;
  4352. a[ipos] = a[jj];
  4353. --ipos;
  4354. /* L10: */
  4355. }
  4356. goto L40;
  4357. L20:
  4358. ++(*ncmpbi);
  4359. if (*j1 > *j2) {
  4360. goto L40;
  4361. }
  4362. i__1 = *j2;
  4363. for (jjj = *j1; jjj <= i__1; ++jjj) {
  4364. jj = *j2 - jjj + *j1;
  4365. iw[ipos] = iw[jj];
  4366. --ipos;
  4367. /* L30: */
  4368. }
  4369. L40:
  4370. *j2 = *itop - 1;
  4371. *j1 = ipos + 1;
  4372. L50:
  4373. return 0;
  4374. } /* ma27p_ */
  4375. /* Subroutine */ int ma27q_(integer *n, real *a, integer *la, integer *iw,
  4376. integer *liw, real *w, integer *maxfnt, real *rhs, integer *iw2,
  4377. integer *nblk, integer *latop, integer *icntl)
  4378. {
  4379. /* System generated locals */
  4380. integer i__1, i__2, i__3;
  4381. /* Local variables */
  4382. static integer j, k, j1, j2, j3, k1, k2, k3;
  4383. static real w1, w2;
  4384. static integer jj, ifr, ist, iblk, apos, irhs, ilvl, ipiv, jpiv, ipos,
  4385. npiv, irow, liell;
  4386. /* THIS SUBROUTINE PERFORMS FORWARD ELIMINATION */
  4387. /* USING THE FACTOR U TRANSPOSE STORED IN A/IA AFTER MA27B/BD. */
  4388. /* N - MUST BE SET TO THE ORDER OF THE MATRIX. NOT ALTERED */
  4389. /* BY MA27Q/QD. */
  4390. /* A - MUST BE SET TO HOLD THE REAL VALUES */
  4391. /* CORRESPONDING TO THE FACTORS OF DINVERSE AND U. THIS MUST BE */
  4392. /* UNCHANGED SINCE THE PRECEDING CALL TO MA27B/BD. NOT ALTERED */
  4393. /* BY MA27Q/QD. */
  4394. /* LA - LENGTH OF ARRAY A. NOT ALTERED BY MA27Q/QD. */
  4395. /* IW - HOLDS THE INTEGER INDEXING */
  4396. /* INFORMATION FOR THE MATRIX FACTORS IN A. THIS MUST BE */
  4397. /* UNCHANGED SINCE THE PRECEDING CALL TO MA27B/BD. NOT ALTERED */
  4398. /* BY MA27Q/QD. */
  4399. /* LIW - LENGTH OF ARRAY IW. NOT ALTERED BY MA27Q/QD. */
  4400. /* W - USED */
  4401. /* AS WORKSPACE BY MA27Q/QD TO HOLD THE COMPONENTS OF THE RIGHT */
  4402. /* HAND SIDES CORRESPONDING TO CURRENT BLOCK PIVOTAL ROWS. */
  4403. /* MAXFNT - MUST BE SET TO THE LARGEST NUMBER OF */
  4404. /* VARIABLES IN ANY BLOCK PIVOT ROW. THIS VALUE WILL HAVE */
  4405. /* BEEN OUTPUT BY MA27B/BD. NOT ALTERED BY MA27Q/QD. */
  4406. /* RHS - ON INPUT, */
  4407. /* MUST BE SET TO HOLD THE RIGHT HAND SIDES FOR THE EQUATIONS */
  4408. /* WHICH THE USER DESIRES TO SOLVE. ON OUTPUT, RHS WILL HOLD */
  4409. /* THE MODIFIED VECTORS CORRESPONDING TO PERFORMING FORWARD */
  4410. /* ELIMINATION ON THE RIGHT HAND SIDES. */
  4411. /* IW2 - NEED NOT BE SET ON ENTRY. ON EXIT IW2(I) (I = 1,NBLK) */
  4412. /* WILL HOLD POINTERS TO THE */
  4413. /* BEGINNING OF EACH BLOCK PIVOT IN ARRAY IW. */
  4414. /* NBLK - NUMBER OF BLOCK PIVOT ROWS. NOT ALTERED BY MA27Q/QD. */
  4415. /* LATOP - NEED NOT BE SET ON ENTRY. ON EXIT, IT IS THE POSITION IN */
  4416. /* A OF THE LAST ENTRY IN THE FACTORS. IT MUST BE PASSED */
  4417. /* UNCHANGED TO MA27R/RD. */
  4418. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  4419. /* ICNTL(IFRLVL+I) I=1,20 IS USED TO CONTROL WHETHER DIRECT OR INDIRECT */
  4420. /* ACCESS IS USED BY MA27C/CD. INDIRECT ACCESS IS EMPLOYED */
  4421. /* IN FORWARD AND BACK SUBSTITUTION RESPECTIVELY IF THE SIZE OF */
  4422. /* A BLOCK IS LESS THAN ICNTL(IFRLVL+MIN(10,NPIV)) AND */
  4423. /* ICNTL(IFRLVL+10+MIN(10,NPIV)) RESPECTIVELY, WHERE NPIV IS THE */
  4424. /* NUMBER OF PIVOTS IN THE BLOCK. */
  4425. /* .. Scalar Arguments .. */
  4426. /* .. */
  4427. /* .. Array Arguments .. */
  4428. /* .. */
  4429. /* .. Local Scalars .. */
  4430. /* .. */
  4431. /* .. Intrinsic Functions .. */
  4432. /* .. */
  4433. /* .. Executable Statements .. */
  4434. /* APOS. RUNNING POINTER TO CURRENT PIVOT POSITION IN ARRAY A. */
  4435. /* IPOS. RUNNING POINTER TO BEGINNING OF BLOCK PIVOT ROW IN IW. */
  4436. /* Parameter adjustments */
  4437. --rhs;
  4438. --a;
  4439. --iw;
  4440. --w;
  4441. --iw2;
  4442. --icntl;
  4443. /* Function Body */
  4444. apos = 1;
  4445. ipos = 1;
  4446. j2 = 0;
  4447. iblk = 0;
  4448. npiv = 0;
  4449. i__1 = *n;
  4450. for (irow = 1; irow <= i__1; ++irow) {
  4451. if (npiv > 0) {
  4452. goto L90;
  4453. }
  4454. ++iblk;
  4455. if (iblk > *nblk) {
  4456. goto L150;
  4457. }
  4458. ipos = j2 + 1;
  4459. /* SET UP POINTER IN PREPARATION FOR BACK SUBSTITUTION. */
  4460. iw2[iblk] = ipos;
  4461. /* ABS(LIELL) IS NUMBER OF VARIABLES (COLUMNS) IN BLOCK PIVOT ROW. */
  4462. liell = -iw[ipos];
  4463. /* NPIV IS NUMBER OF PIVOTS (ROWS) IN BLOCK PIVOT. */
  4464. npiv = 1;
  4465. if (liell > 0) {
  4466. goto L10;
  4467. }
  4468. liell = -liell;
  4469. ++ipos;
  4470. npiv = iw[ipos];
  4471. L10:
  4472. j1 = ipos + 1;
  4473. j2 = ipos + liell;
  4474. ilvl = min(npiv,10);
  4475. if (liell < icntl[ilvl + 5]) {
  4476. goto L90;
  4477. }
  4478. /* PERFORM OPERATIONS USING DIRECT ADDRESSING. */
  4479. /* LOAD APPROPRIATE COMPONENTS OF RIGHT HAND SIDES INTO ARRAY W. */
  4480. ifr = 0;
  4481. i__2 = j2;
  4482. for (jj = j1; jj <= i__2; ++jj) {
  4483. j = (i__3 = iw[jj], abs(i__3));
  4484. ++ifr;
  4485. w[ifr] = rhs[j];
  4486. /* L20: */
  4487. }
  4488. /* JPIV IS USED AS A FLAG SO THAT IPIV IS INCREMENTED CORRECTLY AFTER */
  4489. /* THE USE OF A 2 BY 2 PIVOT. */
  4490. jpiv = 1;
  4491. j3 = j1;
  4492. /* PERFORM OPERATIONS. */
  4493. i__2 = npiv;
  4494. for (ipiv = 1; ipiv <= i__2; ++ipiv) {
  4495. --jpiv;
  4496. if (jpiv == 1) {
  4497. goto L70;
  4498. }
  4499. /* JUMP IF WE HAVE A 2 BY 2 PIVOT. */
  4500. if (iw[j3] < 0) {
  4501. goto L40;
  4502. }
  4503. /* PERFORM FORWARD SUBSTITUTION USING 1 BY 1 PIVOT. */
  4504. jpiv = 1;
  4505. ++j3;
  4506. ++apos;
  4507. ist = ipiv + 1;
  4508. if (liell < ist) {
  4509. goto L70;
  4510. }
  4511. w1 = w[ipiv];
  4512. k = apos;
  4513. i__3 = liell;
  4514. for (j = ist; j <= i__3; ++j) {
  4515. w[j] += a[k] * w1;
  4516. ++k;
  4517. /* L30: */
  4518. }
  4519. apos = apos + liell - ist + 1;
  4520. goto L70;
  4521. /* PERFORM OPERATIONS WITH 2 BY 2 PIVOT. */
  4522. L40:
  4523. jpiv = 2;
  4524. j3 += 2;
  4525. apos += 2;
  4526. ist = ipiv + 2;
  4527. if (liell < ist) {
  4528. goto L60;
  4529. }
  4530. w1 = w[ipiv];
  4531. w2 = w[ipiv + 1];
  4532. k1 = apos;
  4533. k2 = apos + liell - ipiv;
  4534. i__3 = liell;
  4535. for (j = ist; j <= i__3; ++j) {
  4536. w[j] = w[j] + w1 * a[k1] + w2 * a[k2];
  4537. ++k1;
  4538. ++k2;
  4539. /* L50: */
  4540. }
  4541. L60:
  4542. apos = apos + (liell - ist + 1 << 1) + 1;
  4543. L70:
  4544. ;
  4545. }
  4546. /* RELOAD W BACK INTO RHS. */
  4547. ifr = 0;
  4548. i__2 = j2;
  4549. for (jj = j1; jj <= i__2; ++jj) {
  4550. j = (i__3 = iw[jj], abs(i__3));
  4551. ++ifr;
  4552. rhs[j] = w[ifr];
  4553. /* L80: */
  4554. }
  4555. npiv = 0;
  4556. goto L140;
  4557. /* PERFORM OPERATIONS USING INDIRECT ADDRESSING. */
  4558. /* JUMP IF WE HAVE A 2 BY 2 PIVOT. */
  4559. L90:
  4560. if (iw[j1] < 0) {
  4561. goto L110;
  4562. }
  4563. /* PERFORM FORWARD SUBSTITUTION USING 1 BY 1 PIVOT. */
  4564. --npiv;
  4565. ++apos;
  4566. ++j1;
  4567. if (j1 > j2) {
  4568. goto L140;
  4569. }
  4570. irhs = iw[j1 - 1];
  4571. w1 = rhs[irhs];
  4572. k = apos;
  4573. i__2 = j2;
  4574. for (j = j1; j <= i__2; ++j) {
  4575. irhs = (i__3 = iw[j], abs(i__3));
  4576. rhs[irhs] += a[k] * w1;
  4577. ++k;
  4578. /* L100: */
  4579. }
  4580. apos = apos + j2 - j1 + 1;
  4581. goto L140;
  4582. /* PERFORM OPERATIONS WITH 2 BY 2 PIVOT */
  4583. L110:
  4584. npiv += -2;
  4585. j1 += 2;
  4586. apos += 2;
  4587. if (j1 > j2) {
  4588. goto L130;
  4589. }
  4590. irhs = -iw[j1 - 2];
  4591. w1 = rhs[irhs];
  4592. irhs = iw[j1 - 1];
  4593. w2 = rhs[irhs];
  4594. k1 = apos;
  4595. k3 = apos + j2 - j1 + 2;
  4596. i__2 = j2;
  4597. for (j = j1; j <= i__2; ++j) {
  4598. irhs = (i__3 = iw[j], abs(i__3));
  4599. rhs[irhs] = rhs[irhs] + w1 * a[k1] + w2 * a[k3];
  4600. ++k1;
  4601. ++k3;
  4602. /* L120: */
  4603. }
  4604. L130:
  4605. apos = apos + (j2 - j1 + 1 << 1) + 1;
  4606. L140:
  4607. ;
  4608. }
  4609. L150:
  4610. *latop = apos - 1;
  4611. return 0;
  4612. } /* ma27q_ */
  4613. /* Subroutine */ int ma27r_(integer *n, real *a, integer *la, integer *iw,
  4614. integer *liw, real *w, integer *maxfnt, real *rhs, integer *iw2,
  4615. integer *nblk, integer *latop, integer *icntl)
  4616. {
  4617. /* System generated locals */
  4618. integer i__1, i__2, i__3;
  4619. /* Local variables */
  4620. static integer j, k, j1, j2;
  4621. static real w1, w2;
  4622. static integer jj, jj1, jj2, ifr, ist, iblk, apos, irhs, ilvl, ipiv, jpiv,
  4623. loop, ipos, jpos, npiv, apos2, i1rhs, i2rhs, liell, iirhs, iipiv;
  4624. /* THIS SUBROUTINE PERFORMS BACKWARD ELIMINATION OPERATIONS */
  4625. /* USING THE FACTORS DINVERSE AND U */
  4626. /* STORED IN A/IW AFTER MA27B/BD. */
  4627. /* N - MUST BE SET TO THE ORDER OF THE MATRIX. NOT ALTERED */
  4628. /* BY MA27R/RD. */
  4629. /* A - MUST BE SET TO HOLD THE REAL VALUES CORRESPONDING */
  4630. /* TO THE FACTORS OF DINVERSE AND U. THIS MUST BE */
  4631. /* UNCHANGED SINCE THE PRECEDING CALL TO MA27B/BD. NOT ALTERED */
  4632. /* BY MA27R/RD. */
  4633. /* LA - LENGTH OF ARRAY A. NOT ALTERED BY MA27R/RD. */
  4634. /* IW - HOLDS THE INTEGER INDEXING */
  4635. /* INFORMATION FOR THE MATRIX FACTORS IN A. THIS MUST BE */
  4636. /* UNCHANGED SINCE THE PRECEDING CALL TO MA27B/BD. NOT ALTERED */
  4637. /* BY MA27R/RD. */
  4638. /* LIW - LENGTH OF ARRAY IW. NOT ALTERED BY MA27R/RD. */
  4639. /* W - USED */
  4640. /* AS WORKSPACE BY MA27R/RD TO HOLD THE COMPONENTS OF THE RIGHT */
  4641. /* HAND SIDES CORRESPONDING TO CURRENT BLOCK PIVOTAL ROWS. */
  4642. /* MAXFNT - INTEGER VARIABLE. MUST BE SET TO THE LARGEST NUMBER OF */
  4643. /* VARIABLES IN ANY BLOCK PIVOT ROW. THIS VALUE WAS GIVEN */
  4644. /* ON OUTPUT FROM MA27B/BD. NOT ALTERED BY MA27R/RD. */
  4645. /* RHS - ON INPUT, */
  4646. /* MUST BE SET TO HOLD THE RIGHT HAND SIDE MODIFIED BY THE */
  4647. /* FORWARD SUBSTITUTION OPERATIONS. ON OUTPUT, RHS WILL HOLD */
  4648. /* THE SOLUTION VECTOR. */
  4649. /* IW2 - ON ENTRY IW2(I) (I = 1,NBLK) */
  4650. /* MUST HOLD POINTERS TO THE */
  4651. /* BEGINNING OF EACH BLOCK PIVOT IN ARRAY IW, AS SET BY */
  4652. /* MA27Q/QD. */
  4653. /* NBLK - NUMBER OF BLOCK PIVOT ROWS. NOT ALTERED BY MA27R/RD. */
  4654. /* LATOP - IT IS THE POSITION IN */
  4655. /* A OF THE LAST ENTRY IN THE FACTORS. IT MUST BE UNCHANGED */
  4656. /* SINCE THE CALL TO MA27Q/QD. IT IS NOT ALTERED BY MA27R/RD. */
  4657. /* ICNTL is an INTEGER array of length 30, see MA27A/AD. */
  4658. /* ICNTL(IFRLVL+I) I=1,20 IS USED TO CONTROL WHETHER DIRECT OR INDIRECT */
  4659. /* ACCESS IS USED BY MA27C/CD. INDIRECT ACCESS IS EMPLOYED */
  4660. /* IN FORWARD AND BACK SUBSTITUTION RESPECTIVELY IF THE SIZE OF */
  4661. /* A BLOCK IS LESS THAN ICNTL(IFRLVL+MIN(10,NPIV)) AND */
  4662. /* ICNTL(IFRLVL+10+MIN(10,NPIV)) RESPECTIVELY, WHERE NPIV IS THE */
  4663. /* NUMBER OF PIVOTS IN THE BLOCK. */
  4664. /* .. Scalar Arguments .. */
  4665. /* .. */
  4666. /* .. Array Arguments .. */
  4667. /* .. */
  4668. /* .. Local Scalars .. */
  4669. /* .. */
  4670. /* .. Intrinsic Functions .. */
  4671. /* .. */
  4672. /* .. Executable Statements .. */
  4673. /* APOS. RUNNING POINTER TO CURRENT PIVOT POSITION IN ARRAY A. */
  4674. /* IPOS. RUNNING POINTER TO BEGINNING OF CURRENT BLOCK PIVOT ROW. */
  4675. /* Parameter adjustments */
  4676. --rhs;
  4677. --a;
  4678. --iw;
  4679. --w;
  4680. --iw2;
  4681. --icntl;
  4682. /* Function Body */
  4683. apos = *latop + 1;
  4684. npiv = 0;
  4685. iblk = *nblk + 1;
  4686. /* RUN THROUGH BLOCK PIVOT ROWS IN THE REVERSE ORDER. */
  4687. i__1 = *n;
  4688. for (loop = 1; loop <= i__1; ++loop) {
  4689. if (npiv > 0) {
  4690. goto L110;
  4691. }
  4692. --iblk;
  4693. if (iblk < 1) {
  4694. goto L190;
  4695. }
  4696. ipos = iw2[iblk];
  4697. /* ABS(LIELL) IS NUMBER OF VARIABLES (COLUMNS) IN BLOCK PIVOT ROW. */
  4698. liell = -iw[ipos];
  4699. /* NPIV IS NUMBER OF PIVOTS (ROWS) IN BLOCK PIVOT. */
  4700. npiv = 1;
  4701. if (liell > 0) {
  4702. goto L10;
  4703. }
  4704. liell = -liell;
  4705. ++ipos;
  4706. npiv = iw[ipos];
  4707. L10:
  4708. jpos = ipos + npiv;
  4709. j2 = ipos + liell;
  4710. ilvl = min(10,npiv) + 10;
  4711. if (liell < icntl[ilvl + 5]) {
  4712. goto L110;
  4713. }
  4714. /* PERFORM OPERATIONS USING DIRECT ADDRESSING. */
  4715. j1 = ipos + 1;
  4716. /* LOAD APPROPRIATE COMPONENTS OF RHS INTO W. */
  4717. ifr = 0;
  4718. i__2 = j2;
  4719. for (jj = j1; jj <= i__2; ++jj) {
  4720. j = (i__3 = iw[jj], abs(i__3));
  4721. ++ifr;
  4722. w[ifr] = rhs[j];
  4723. /* L20: */
  4724. }
  4725. /* JPIV IS USED AS A FLAG SO THAT IPIV IS INCREMENTED CORRECTLY AFTER */
  4726. /* THE USE OF A 2 BY 2 PIVOT. */
  4727. jpiv = 1;
  4728. /* PERFORM ELIMINATIONS. */
  4729. i__2 = npiv;
  4730. for (iipiv = 1; iipiv <= i__2; ++iipiv) {
  4731. --jpiv;
  4732. if (jpiv == 1) {
  4733. goto L90;
  4734. }
  4735. ipiv = npiv - iipiv + 1;
  4736. if (ipiv == 1) {
  4737. goto L30;
  4738. }
  4739. /* JUMP IF WE HAVE A 2 BY 2 PIVOT. */
  4740. if (iw[jpos - 1] < 0) {
  4741. goto L60;
  4742. }
  4743. /* PERFORM BACK-SUBSTITUTION USING 1 BY 1 PIVOT. */
  4744. L30:
  4745. jpiv = 1;
  4746. apos -= liell + 1 - ipiv;
  4747. ist = ipiv + 1;
  4748. w1 = w[ipiv] * a[apos];
  4749. if (liell < ist) {
  4750. goto L50;
  4751. }
  4752. jj1 = apos + 1;
  4753. i__3 = liell;
  4754. for (j = ist; j <= i__3; ++j) {
  4755. w1 += a[jj1] * w[j];
  4756. ++jj1;
  4757. /* L40: */
  4758. }
  4759. L50:
  4760. w[ipiv] = w1;
  4761. --jpos;
  4762. goto L90;
  4763. /* PERFORM BACK-SUBSTITUTION OPERATIONS WITH 2 BY 2 PIVOT */
  4764. L60:
  4765. jpiv = 2;
  4766. apos2 = apos - (liell + 1 - ipiv);
  4767. apos = apos2 - (liell + 2 - ipiv);
  4768. ist = ipiv + 1;
  4769. w1 = w[ipiv - 1] * a[apos] + w[ipiv] * a[apos + 1];
  4770. w2 = w[ipiv - 1] * a[apos + 1] + w[ipiv] * a[apos2];
  4771. if (liell < ist) {
  4772. goto L80;
  4773. }
  4774. jj1 = apos + 2;
  4775. jj2 = apos2 + 1;
  4776. i__3 = liell;
  4777. for (j = ist; j <= i__3; ++j) {
  4778. w1 += w[j] * a[jj1];
  4779. w2 += w[j] * a[jj2];
  4780. ++jj1;
  4781. ++jj2;
  4782. /* L70: */
  4783. }
  4784. L80:
  4785. w[ipiv - 1] = w1;
  4786. w[ipiv] = w2;
  4787. jpos += -2;
  4788. L90:
  4789. ;
  4790. }
  4791. /* RELOAD WORKING VECTOR INTO SOLUTION VECTOR. */
  4792. ifr = 0;
  4793. i__2 = j2;
  4794. for (jj = j1; jj <= i__2; ++jj) {
  4795. j = (i__3 = iw[jj], abs(i__3));
  4796. ++ifr;
  4797. rhs[j] = w[ifr];
  4798. /* L100: */
  4799. }
  4800. npiv = 0;
  4801. goto L180;
  4802. /* PERFORM OPERATIONS USING INDIRECT ADDRESSING. */
  4803. L110:
  4804. if (npiv == 1) {
  4805. goto L120;
  4806. }
  4807. /* JUMP IF WE HAVE A 2 BY 2 PIVOT. */
  4808. if (iw[jpos - 1] < 0) {
  4809. goto L150;
  4810. }
  4811. /* PERFORM BACK-SUBSTITUTION USING 1 BY 1 PIVOT. */
  4812. L120:
  4813. --npiv;
  4814. apos -= j2 - jpos + 1;
  4815. iirhs = iw[jpos];
  4816. w1 = rhs[iirhs] * a[apos];
  4817. j1 = jpos + 1;
  4818. if (j1 > j2) {
  4819. goto L140;
  4820. }
  4821. k = apos + 1;
  4822. i__2 = j2;
  4823. for (j = j1; j <= i__2; ++j) {
  4824. irhs = (i__3 = iw[j], abs(i__3));
  4825. w1 += a[k] * rhs[irhs];
  4826. ++k;
  4827. /* L130: */
  4828. }
  4829. L140:
  4830. rhs[iirhs] = w1;
  4831. --jpos;
  4832. goto L180;
  4833. /* PERFORM OPERATIONS WITH 2 BY 2 PIVOT */
  4834. L150:
  4835. npiv += -2;
  4836. apos2 = apos - (j2 - jpos + 1);
  4837. apos = apos2 - (j2 - jpos + 2);
  4838. i1rhs = -iw[jpos - 1];
  4839. i2rhs = iw[jpos];
  4840. w1 = rhs[i1rhs] * a[apos] + rhs[i2rhs] * a[apos + 1];
  4841. w2 = rhs[i1rhs] * a[apos + 1] + rhs[i2rhs] * a[apos2];
  4842. j1 = jpos + 1;
  4843. if (j1 > j2) {
  4844. goto L170;
  4845. }
  4846. jj1 = apos + 2;
  4847. jj2 = apos2 + 1;
  4848. i__2 = j2;
  4849. for (j = j1; j <= i__2; ++j) {
  4850. irhs = (i__3 = iw[j], abs(i__3));
  4851. w1 += rhs[irhs] * a[jj1];
  4852. w2 += rhs[irhs] * a[jj2];
  4853. ++jj1;
  4854. ++jj2;
  4855. /* L160: */
  4856. }
  4857. L170:
  4858. rhs[i1rhs] = w1;
  4859. rhs[i2rhs] = w2;
  4860. jpos += -2;
  4861. L180:
  4862. ;
  4863. }
  4864. L190:
  4865. return 0;
  4866. } /* ma27r_ */