NUMclapack.h 237 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614
  1. #ifndef _NUMclapack_h_
  2. #define _NUMclapack_h_
  3. /* NUMclapack.h
  4. *
  5. * Copyright (C) 1994-2011 David Weenink, 2017 Paul Boersma
  6. *
  7. * This code is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * This code is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /*
  21. djmw 20020923 GPL header
  22. djmw 20030310 Latest modification
  23. */
  24. #include "melder.h" /* for integer */
  25. /*
  26. The following routines all use FORTRAN column-major storage of
  27. matrices. A consequence is that all matrices must have been allocated
  28. as a single block of mxn elements.
  29. All matrices are passed as a vector of mxn elements.
  30. matrix[i][j] => vector[(j-1)*m + i] "Fortran"
  31. matrix[i][j] => vector[(i-1)*n + j] "C"
  32. The consequence is that you have to transpose C matrices before you pass them
  33. to a CLAPACK routine.
  34. Sometimes you can avoid transposition by considering the solution
  35. of the transposed problem (e.g. See code in SVD_compute).
  36. */
  37. int NUMlapack_dbdsqr(const char *uplo, integer *n, integer *ncvt, integer *nru, integer *ncc,
  38. double *d, double *e, double *vt, integer *ldvt, double *u, integer *ldu,
  39. double *c, integer *ldc, double *work, integer *info);
  40. /* Purpose
  41. =======
  42. NUMlapack_dbdsqr computes the singular value decomposition (SVD) of a real
  43. N-by-N (upper or lower) bidiagonal matrix B: B = Q * S * P' (P'
  44. denotes the transpose of P), where S is a diagonal matrix with
  45. non-negative diagonal elements (the singular values of B), and Q
  46. and P are orthogonal matrices.
  47. The routine computes S, and optionally computes U * Q, P' * VT,
  48. or Q' * C, for given real input matrices U, VT, and C.
  49. See "Computing Small Singular Values of Bidiagonal Matrices With
  50. Guaranteed High Relative Accuracy," by J. Demmel and W. Kahan,
  51. LAPACK Working Note #3 (or SIAM J. Sci. Statist. Comput. vol. 11,
  52. no. 5, pp. 873-912, Sept 1990) and
  53. "Accurate singular values and differential qd algorithms," by
  54. B. Parlett and V. Fernando, Technical Report CPAM-554, Mathematics
  55. Department, University of California at Berkeley, July 1992
  56. for a detailed description of the algorithm.
  57. Arguments
  58. =========
  59. UPLO (input) char*
  60. = 'U': B is upper bidiagonal;
  61. = 'L': B is lower bidiagonal.
  62. N (input) long
  63. The order of the matrix B. N >= 0.
  64. NCVT (input) long
  65. The number of columns of the matrix VT. NCVT >= 0.
  66. NRU (input) long
  67. The number of rows of the matrix U. NRU >= 0.
  68. NCC (input) long
  69. The number of columns of the matrix C. NCC >= 0.
  70. D (input/output) double array, dimension (N)
  71. On entry, the n diagonal elements of the bidiagonal matrix B.
  72. On exit, if INFO=0, the singular values of B in decreasing
  73. order.
  74. E (input/output) double array, dimension (N)
  75. On entry, the elements of E contain the
  76. offdiagonal elements of the bidiagonal matrix whose SVD
  77. is desired. On normal exit (INFO = 0), E is destroyed.
  78. If the algorithm does not converge (INFO > 0), D and E
  79. will contain the diagonal and superdiagonal elements of a
  80. bidiagonal matrix orthogonally equivalent to the one given
  81. as input. E(N) is used for workspace.
  82. VT (input/output) double array, dimension (LDVT, NCVT)
  83. On entry, an N-by-NCVT matrix VT.
  84. On exit, VT is overwritten by P' * VT.
  85. VT is not referenced if NCVT = 0.
  86. LDVT (input) long
  87. The leading dimension of the array VT.
  88. LDVT >= max(1,N) if NCVT > 0; LDVT >= 1 if NCVT = 0.
  89. U (input/output) double array, dimension (LDU, N)
  90. On entry, an NRU-by-N matrix U.
  91. On exit, U is overwritten by U * Q.
  92. U is not referenced if NRU = 0.
  93. LDU (input) long
  94. The leading dimension of the array U. LDU >= max(1,NRU).
  95. C (input/output) double array, dimension (LDC, NCC)
  96. On entry, an N-by-NCC matrix C.
  97. On exit, C is overwritten by Q' * C.
  98. C is not referenced if NCC = 0.
  99. LDC (input) long
  100. The leading dimension of the array C.
  101. LDC >= max(1,N) if NCC > 0; LDC >=1 if NCC = 0.
  102. WORK (workspace) double array, dimension (4*N)
  103. INFO (output) long
  104. = 0: successful exit
  105. < 0: If INFO = -i, the i-th argument had an illegal value
  106. > 0: the algorithm did not converge; D and E contain the
  107. elements of a bidiagonal matrix which is orthogonally
  108. similar to the input matrix B; if INFO = i, i
  109. elements of E have not converged to zero.
  110. Internal Parameters
  111. ===================
  112. TOLMUL double, default = max(10,min(100,EPS**(-1/8)))
  113. TOLMUL controls the convergence criterion of the QR loop.
  114. If it is positive, TOLMUL*EPS is the desired relative
  115. precision in the computed singular values.
  116. If it is negative, abs(TOLMUL*EPS*sigma_max) is the
  117. desired absolute accuracy in the computed singular
  118. values (corresponds to relative accuracy
  119. abs(TOLMUL*EPS) in the largest singular value.
  120. abs(TOLMUL) should be between 1 and 1/EPS, and preferably
  121. between 10 (for fast convergence) and .1/EPS
  122. (for there to be some accuracy in the results).
  123. Default is to lose at either one eighth or 2 of the
  124. available decimal digits in each computed singular value
  125. (whichever is smaller).
  126. MAXITR long, default = 6
  127. MAXITR controls the maximum number of passes of the
  128. algorithm through its inner loop. The algorithms stops
  129. (and so fails to converge) if the number of passes
  130. through the inner loop exceeds MAXITR*N**2.
  131. =====================================================================
  132. */
  133. int NUMlapack_dgebd2(integer *m, integer *n, double *a, integer *lda, double *d, double *e,
  134. double *tauq, double *taup, double *work, integer *info);
  135. /*
  136. Purpose
  137. =======
  138. NUMlapack_dgebd2 reduces a real general m by n matrix A to upper or lower
  139. bidiagonal form B by an orthogonal transformation: Q' * A * P = B.
  140. If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal.
  141. Arguments
  142. =========
  143. M (input) long
  144. The number of rows in the matrix A. M >= 0.
  145. N (input) long
  146. The number of columns in the matrix A. N >= 0.
  147. A (input/output) double array, dimension (LDA,N)
  148. On entry, the m by n general matrix to be reduced.
  149. On exit,
  150. if m >= n, the diagonal and the first superdiagonal are
  151. overwritten with the upper bidiagonal matrix B; the
  152. elements below the diagonal, with the array TAUQ, represent
  153. the orthogonal matrix Q as a product of elementary
  154. reflectors, and the elements above the first superdiagonal,
  155. with the array TAUP, represent the orthogonal matrix P as
  156. a product of elementary reflectors;
  157. if m < n, the diagonal and the first subdiagonal are
  158. overwritten with the lower bidiagonal matrix B; the
  159. elements below the first subdiagonal, with the array TAUQ,
  160. represent the orthogonal matrix Q as a product of
  161. elementary reflectors, and the elements above the diagonal,
  162. with the array TAUP, represent the orthogonal matrix P as
  163. a product of elementary reflectors.
  164. See Further Details.
  165. LDA (input) long
  166. The leading dimension of the array A. LDA >= max(1,M).
  167. D (output) double array, dimension (min(M,N))
  168. The diagonal elements of the bidiagonal matrix B:
  169. D(i) = A(i,i).
  170. E (output) double array, dimension (min(M,N)-1)
  171. The off-diagonal elements of the bidiagonal matrix B:
  172. if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1;
  173. if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1.
  174. TAUQ (output) double array dimension (min(M,N))
  175. The scalar factors of the elementary reflectors which
  176. represent the orthogonal matrix Q. See Further Details.
  177. TAUP (output) double array, dimension (min(M,N))
  178. The scalar factors of the elementary reflectors which
  179. represent the orthogonal matrix P. See Further Details.
  180. WORK (workspace) double array, dimension (max(M,N))
  181. INFO (output) long
  182. = 0: successful exit.
  183. < 0: if INFO = -i, the i-th argument had an illegal value.
  184. Further Details
  185. ===============
  186. The matrices Q and P are represented as products of elementary
  187. reflectors:
  188. If m >= n,
  189. Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1)
  190. Each H(i) and G(i) has the form:
  191. H(i) = I - tauq * v * v' and G(i) = I - taup * u * u'
  192. where tauq and taup are real scalars, and v and u are real vectors;
  193. v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i);
  194. u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n);
  195. tauq is stored in TAUQ(i) and taup in TAUP(i).
  196. If m < n,
  197. Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m)
  198. Each H(i) and G(i) has the form:
  199. H(i) = I - tauq * v * v' and G(i) = I - taup * u * u'
  200. where tauq and taup are real scalars, and v and u are real vectors;
  201. v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i);
  202. u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n);
  203. tauq is stored in TAUQ(i) and taup in TAUP(i).
  204. The contents of A on exit are illustrated by the following examples:
  205. m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):
  206. ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 )
  207. ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 )
  208. ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 )
  209. ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 )
  210. ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 )
  211. ( v1 v2 v3 v4 v5 )
  212. where d and e denote diagonal and off-diagonal elements of B, vi
  213. denotes an element of the vector defining H(i), and ui an element of
  214. the vector defining G(i).
  215. =====================================================================
  216. */
  217. int NUMlapack_dgebrd(integer *m, integer *n, double *a, integer *lda, double *d, double *e,
  218. double *tauq, double *taup, double *work, integer *lwork, integer *info);
  219. /*
  220. Purpose
  221. =======
  222. NUMlapack_dgebrd reduces a general real M-by-N matrix A to upper or lower
  223. bidiagonal form B by an orthogonal transformation: Q**T * A * P = B.
  224. If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal.
  225. Arguments
  226. =========
  227. M (input) long
  228. The number of rows in the matrix A. M >= 0.
  229. N (input) long
  230. The number of columns in the matrix A. N >= 0.
  231. A (input/output) double array, dimension (LDA,N)
  232. On entry, the M-by-N general matrix to be reduced.
  233. On exit,
  234. if m >= n, the diagonal and the first superdiagonal are
  235. overwritten with the upper bidiagonal matrix B; the
  236. elements below the diagonal, with the array TAUQ, represent
  237. the orthogonal matrix Q as a product of elementary
  238. reflectors, and the elements above the first superdiagonal,
  239. with the array TAUP, represent the orthogonal matrix P as
  240. a product of elementary reflectors;
  241. if m < n, the diagonal and the first subdiagonal are
  242. overwritten with the lower bidiagonal matrix B; the
  243. elements below the first subdiagonal, with the array TAUQ,
  244. represent the orthogonal matrix Q as a product of
  245. elementary reflectors, and the elements above the diagonal,
  246. with the array TAUP, represent the orthogonal matrix P as
  247. a product of elementary reflectors.
  248. See Further Details.
  249. LDA (input) long
  250. The leading dimension of the array A. LDA >= max(1,M).
  251. D (output) double array, dimension (min(M,N))
  252. The diagonal elements of the bidiagonal matrix B:
  253. D(i) = A(i,i).
  254. E (output) double array, dimension (min(M,N)-1)
  255. The off-diagonal elements of the bidiagonal matrix B:
  256. if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1;
  257. if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1.
  258. TAUQ (output) double array dimension (min(M,N))
  259. The scalar factors of the elementary reflectors which
  260. represent the orthogonal matrix Q. See Further Details.
  261. TAUP (output) double array, dimension (min(M,N))
  262. The scalar factors of the elementary reflectors which
  263. represent the orthogonal matrix P. See Further Details.
  264. WORK (workspace/output) double array, dimension (LWORK)
  265. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  266. LWORK (input) long
  267. The length of the array WORK. LWORK >= max(1,M,N).
  268. For optimum performance LWORK >= (M+N)*NB, where NB
  269. is the optimal blocksize.
  270. If LWORK = -1, then a workspace query is assumed; the routine
  271. only calculates the optimal size of the WORK array, returns
  272. this value as the first entry of the WORK array, and no error
  273. message related to LWORK is issued by XERBLA.
  274. INFO (output) long
  275. = 0: successful exit
  276. < 0: if INFO = -i, the i-th argument had an illegal value.
  277. Further Details
  278. ===============
  279. The matrices Q and P are represented as products of elementary
  280. reflectors:
  281. If m >= n,
  282. Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1)
  283. Each H(i) and G(i) has the form:
  284. H(i) = I - tauq * v * v' and G(i) = I - taup * u * u'
  285. where tauq and taup are real scalars, and v and u are real vectors;
  286. v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i);
  287. u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n);
  288. tauq is stored in TAUQ(i) and taup in TAUP(i).
  289. If m < n,
  290. Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m)
  291. Each H(i) and G(i) has the form:
  292. H(i) = I - tauq * v * v' and G(i) = I - taup * u * u'
  293. where tauq and taup are real scalars, and v and u are real vectors;
  294. v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i);
  295. u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n);
  296. tauq is stored in TAUQ(i) and taup in TAUP(i).
  297. The contents of A on exit are illustrated by the following examples:
  298. m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):
  299. ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 )
  300. ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 )
  301. ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 )
  302. ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 )
  303. ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 )
  304. ( v1 v2 v3 v4 v5 )
  305. where d and e denote diagonal and off-diagonal elements of B, vi
  306. denotes an element of the vector defining H(i), and ui an element of
  307. the vector defining G(i).
  308. =====================================================================
  309. */
  310. int NUMlapack_dgebak (const char *job, const char *side, integer *n, integer *ilo, integer *ihi,
  311. double *scale, integer *m, double *v, integer *ldv, integer *info);
  312. /* -- LAPACK routine (version 3.0) --
  313. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  314. Courant Institute, Argonne National Lab, and Rice University
  315. September 30, 1994
  316. Purpose
  317. =======
  318. NUMlapack_dgebak forms the right or left eigenvectors of a real general matrix
  319. by backward transformation on the computed eigenvectors of the
  320. balanced matrix output by NUMlapack_dgebal.
  321. Arguments
  322. =========
  323. JOB (input) char*
  324. Specifies the type of backward transformation required:
  325. = 'N', do nothing, return immediately;
  326. = 'P', do backward transformation for permutation only;
  327. = 'S', do backward transformation for scaling only;
  328. = 'B', do backward transformations for both permutation and
  329. scaling.
  330. JOB must be the same as the argument JOB supplied to NUMlapack_dgebal.
  331. SIDE (input) char*
  332. = 'R': V contains right eigenvectors;
  333. = 'L': V contains left eigenvectors.
  334. N (input) long
  335. The number of rows of the matrix V. N >= 0.
  336. ILO (input) long
  337. IHI (input) long
  338. The integers ILO and IHI determined by NUMlapack_dgebal.
  339. 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
  340. SCALE (input) double array, dimension (N)
  341. Details of the permutation and scaling factors, as returned
  342. by NUMlapack_dgebal.
  343. M (input) long
  344. The number of columns of the matrix V. M >= 0.
  345. V (input/output) double array, dimension (LDV,M)
  346. On entry, the matrix of right or left eigenvectors to be
  347. transformed, as returned by DHSEIN or NUMlapack_dtrevc.
  348. On exit, V is overwritten by the transformed eigenvectors.
  349. LDV (input) long
  350. The leading dimension of the array V. LDV >= max(1,N).
  351. INFO (output) long
  352. = 0: successful exit
  353. < 0: if INFO = -i, the i-th argument had an illegal value.
  354. =====================================================================
  355. */
  356. int NUMlapack_dgebal (const char *job, integer *n, double *a, integer *lda, integer *ilo,
  357. integer *ihi, double *scale, integer *info);
  358. /* -- LAPACK routine (version 3.0) --
  359. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  360. Courant Institute, Argonne National Lab, and Rice University
  361. June 30, 1999
  362. Purpose
  363. =======
  364. NUMlapack_dgebal balances a general real matrix A. This involves, first,
  365. permuting A by a similarity transformation to isolate eigenvalues
  366. in the first 1 to ILO-1 and last IHI+1 to N elements on the
  367. diagonal; and second, applying a diagonal similarity transformation
  368. to rows and columns ILO to IHI to make the rows and columns as
  369. close in norm as possible. Both steps are optional.
  370. Balancing may reduce the 1-norm of the matrix, and improve the
  371. accuracy of the computed eigenvalues and/or eigenvectors.
  372. Arguments
  373. =========
  374. JOB (input) char*
  375. Specifies the operations to be performed on A:
  376. = 'N': none: simply set ILO = 1, IHI = N, SCALE(I) = 1.0
  377. for i = 1,...,N;
  378. = 'P': permute only;
  379. = 'S': scale only;
  380. = 'B': both permute and scale.
  381. N (input) long
  382. The order of the matrix A. N >= 0.
  383. A (input/output) double array, dimension (LDA,N)
  384. On entry, the input matrix A.
  385. On exit, A is overwritten by the balanced matrix.
  386. If JOB = 'N', A is not referenced.
  387. See Further Details.
  388. LDA (input) long
  389. The leading dimension of the array A. LDA >= max(1,N).
  390. ILO (output) long
  391. IHI (output) long
  392. ILO and IHI are set to integers such that on exit
  393. A(i,j) = 0 if i > j and j = 1,...,ILO-1 or I = IHI+1,...,N.
  394. If JOB = 'N' or 'S', ILO = 1 and IHI = N.
  395. SCALE (output) double array, dimension (N)
  396. Details of the permutations and scaling factors applied to
  397. A. If P(j) is the index of the row and column interchanged
  398. with row and column j and D(j) is the scaling factor
  399. applied to row and column j, then
  400. SCALE(j) = P(j) for j = 1,...,ILO-1
  401. = D(j) for j = ILO,...,IHI
  402. = P(j) for j = IHI+1,...,N.
  403. The order in which the interchanges are made is N to IHI+1,
  404. then 1 to ILO-1.
  405. INFO (output) long
  406. = 0: successful exit.
  407. < 0: if INFO = -i, the i-th argument had an illegal value.
  408. Further Details
  409. ===============
  410. The permutations consist of row and column interchanges which put
  411. the matrix in the form
  412. ( T1 X Y )
  413. P A P = ( 0 B Z )
  414. ( 0 0 T2 )
  415. where T1 and T2 are upper triangular matrices whose eigenvalues lie
  416. along the diagonal. The column indices ILO and IHI mark the starting
  417. and ending columns of the submatrix B. Balancing consists of applying
  418. a diagonal similarity transformation inv(D) * B * D to make the
  419. 1-norms of each row of B and its corresponding column nearly equal.
  420. The output matrix is
  421. ( T1 X*D Y )
  422. ( 0 inv(D)*B*D inv(D)*Z ).
  423. ( 0 0 T2 )
  424. Information about the permutations P and the diagonal matrix D is
  425. returned in the vector SCALE.
  426. This subroutine is based on the EISPACK routine BALANC.
  427. Modified by Tzu-Yi Chen, Computer Science Division, University of
  428. California at Berkeley, USA
  429. =====================================================================
  430. */
  431. int NUMlapack_dgeev (const char *jobvl, const char *jobvr, integer *n, double *a, integer *lda,
  432. double *wr, double *wi, double *vl, integer *ldvl, double *vr, integer *ldvr,
  433. double *work, integer *lwork, integer *info);
  434. /* -- LAPACK driver routine (version 3.0) --
  435. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  436. Courant Institute, Argonne National Lab, and Rice University
  437. December 8, 1999
  438. Purpose
  439. =======
  440. NUMlapack_dgeev computes for an N-by-N real nonsymmetric matrix A, the
  441. eigenvalues and, optionally, the left and/or right eigenvectors.
  442. The right eigenvector v(j) of A satisfies
  443. A * v(j) = lambda(j) * v(j)
  444. where lambda(j) is its eigenvalue.
  445. The left eigenvector u(j) of A satisfies
  446. u(j)**H * A = lambda(j) * u(j)**H
  447. where u(j)**H denotes the conjugate transpose of u(j).
  448. The computed eigenvectors are normalized to have Euclidean norm
  449. equal to 1 and largest component real.
  450. Arguments
  451. =========
  452. JOBVL (input) char*
  453. = 'N': left eigenvectors of A are not computed;
  454. = 'V': left eigenvectors of A are computed.
  455. JOBVR (input) char*
  456. = 'N': right eigenvectors of A are not computed;
  457. = 'V': right eigenvectors of A are computed.
  458. N (input) long
  459. The order of the matrix A. N >= 0.
  460. A (input/output) double array, dimension (LDA,N)
  461. On entry, the N-by-N matrix A.
  462. On exit, A has been overwritten.
  463. LDA (input) long
  464. The leading dimension of the array A. LDA >= max(1,N).
  465. WR (output) double array, dimension (N)
  466. WI (output) double array, dimension (N)
  467. WR and WI contain the real and imaginary parts,
  468. respectively, of the computed eigenvalues. Complex
  469. conjugate pairs of eigenvalues appear consecutively
  470. with the eigenvalue having the positive imaginary part
  471. first.
  472. VL (output) double array, dimension (LDVL,N)
  473. If JOBVL = 'V', the left eigenvectors u(j) are stored one
  474. after another in the columns of VL, in the same order
  475. as their eigenvalues.
  476. If JOBVL = 'N', VL is not referenced.
  477. If the j-th eigenvalue is real, then u(j) = VL(:,j),
  478. the j-th column of VL.
  479. If the j-th and (j+1)-st eigenvalues form a complex
  480. conjugate pair, then u(j) = VL(:,j) + i*VL(:,j+1) and
  481. u(j+1) = VL(:,j) - i*VL(:,j+1).
  482. LDVL (input) long
  483. The leading dimension of the array VL. LDVL >= 1; if
  484. JOBVL = 'V', LDVL >= N.
  485. VR (output) double array, dimension (LDVR,N)
  486. If JOBVR = 'V', the right eigenvectors v(j) are stored one
  487. after another in the columns of VR, in the same order
  488. as their eigenvalues.
  489. If JOBVR = 'N', VR is not referenced.
  490. If the j-th eigenvalue is real, then v(j) = VR(:,j),
  491. the j-th column of VR.
  492. If the j-th and (j+1)-st eigenvalues form a complex
  493. conjugate pair, then v(j) = VR(:,j) + i*VR(:,j+1) and
  494. v(j+1) = VR(:,j) - i*VR(:,j+1).
  495. LDVR (input) long
  496. The leading dimension of the array VR. LDVR >= 1; if
  497. JOBVR = 'V', LDVR >= N.
  498. WORK (workspace/output) double array, dimension (LWORK)
  499. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  500. LWORK (input) long
  501. The dimension of the array WORK. LWORK >= max(1,3*N), and
  502. if JOBVL = 'V' or JOBVR = 'V', LWORK >= 4*N. For good
  503. performance, LWORK must generally be larger.
  504. If LWORK = -1, then a workspace query is assumed; the routine
  505. only calculates the optimal size of the WORK array, returns
  506. this value as the first entry of the WORK array, and no error
  507. message related to LWORK is issued by XERBLA.
  508. INFO (output) long
  509. = 0: successful exit
  510. < 0: if INFO = -i, the i-th argument had an illegal value.
  511. > 0: if INFO = i, the QR algorithm failed to compute all the
  512. eigenvalues, and no eigenvectors have been computed;
  513. elements i+1:N of WR and WI contain eigenvalues which
  514. have converged.
  515. =====================================================================
  516. */
  517. int NUMlapack_dgehd2 (integer *n, integer *ilo, integer *ihi, double *a, integer *lda,
  518. double *tau, double *work, integer *info);
  519. /* -- LAPACK routine (version 3.0) --
  520. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  521. Courant Institute, Argonne National Lab, and Rice University
  522. October 31, 1992
  523. Purpose
  524. =======
  525. NUMlapack_dgehd2 reduces a real general matrix A to upper Hessenberg form H by
  526. an orthogonal similarity transformation: Q' * A * Q = H .
  527. Arguments
  528. =========
  529. N (input) long
  530. The order of the matrix A. N >= 0.
  531. ILO (input) long
  532. IHI (input) long
  533. It is assumed that A is already upper triangular in rows
  534. and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally
  535. set by a previous call to NUMlapack_dgebal; otherwise they should be
  536. set to 1 and N respectively. See Further Details.
  537. 1 <= ILO <= IHI <= max(1,N).
  538. A (input/output) double array, dimension (LDA,N)
  539. On entry, the n by n general matrix to be reduced.
  540. On exit, the upper triangle and the first subdiagonal of A
  541. are overwritten with the upper Hessenberg matrix H, and the
  542. elements below the first subdiagonal, with the array TAU,
  543. represent the orthogonal matrix Q as a product of elementary
  544. reflectors. See Further Details.
  545. LDA (input) long
  546. The leading dimension of the array A. LDA >= max(1,N).
  547. TAU (output) double array, dimension (N-1)
  548. The scalar factors of the elementary reflectors (see Further
  549. Details).
  550. WORK (workspace) double array, dimension (N)
  551. INFO (output) long
  552. = 0: successful exit.
  553. < 0: if INFO = -i, the i-th argument had an illegal value.
  554. Further Details
  555. ===============
  556. The matrix Q is represented as a product of (ihi-ilo) elementary
  557. reflectors
  558. Q = H(ilo) H(ilo+1) . . . H(ihi-1).
  559. Each H(i) has the form
  560. H(i) = I - tau * v * v'
  561. where tau is a real scalar, and v is a real vector with
  562. v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on
  563. exit in A(i+2:ihi,i), and tau in TAU(i).
  564. The contents of A are illustrated by the following example, with
  565. n = 7, ilo = 2 and ihi = 6:
  566. on entry, on exit,
  567. ( a a a a a a a ) ( a a h h h h a )
  568. ( a a a a a a ) ( a h h h h a )
  569. ( a a a a a a ) ( h h h h h h )
  570. ( a a a a a a ) ( v2 h h h h h )
  571. ( a a a a a a ) ( v2 v3 h h h h )
  572. ( a a a a a a ) ( v2 v3 v4 h h h )
  573. ( a ) ( a )
  574. where a denotes an element of the original matrix A, h denotes a
  575. modified element of the upper Hessenberg matrix H, and vi denotes an
  576. element of the vector defining H(i).
  577. =====================================================================
  578. */
  579. int NUMlapack_dgehrd (integer *n, integer *ilo, integer *ihi, double *a, integer *lda,
  580. double *tau, double *work, integer *lwork, integer *info);
  581. /* -- LAPACK routine (version 3.0) --
  582. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  583. Courant Institute, Argonne National Lab, and Rice University
  584. June 30, 1999
  585. Purpose
  586. =======
  587. NUMlapack_dgehrd reduces a real general matrix A to upper Hessenberg form H by
  588. an orthogonal similarity transformation: Q' * A * Q = H .
  589. Arguments
  590. =========
  591. N (input) long
  592. The order of the matrix A. N >= 0.
  593. ILO (input) long
  594. IHI (input) long
  595. It is assumed that A is already upper triangular in rows
  596. and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally
  597. set by a previous call to NUMlapack_dgebal; otherwise they should be
  598. set to 1 and N respectively. See Further Details.
  599. 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
  600. A (input/output) double array, dimension (LDA,N)
  601. On entry, the N-by-N general matrix to be reduced.
  602. On exit, the upper triangle and the first subdiagonal of A
  603. are overwritten with the upper Hessenberg matrix H, and the
  604. elements below the first subdiagonal, with the array TAU,
  605. represent the orthogonal matrix Q as a product of elementary
  606. reflectors. See Further Details.
  607. LDA (input) long
  608. The leading dimension of the array A. LDA >= max(1,N).
  609. TAU (output) double array, dimension (N-1)
  610. The scalar factors of the elementary reflectors (see Further
  611. Details). Elements 1:ILO-1 and IHI:N-1 of TAU are set to
  612. zero.
  613. WORK (workspace/output) double array, dimension (LWORK)
  614. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  615. LWORK (input) long
  616. The length of the array WORK. LWORK >= max(1,N).
  617. For optimum performance LWORK >= N*NB, where NB is the
  618. optimal blocksize.
  619. If LWORK = -1, then a workspace query is assumed; the routine
  620. only calculates the optimal size of the WORK array, returns
  621. this value as the first entry of the WORK array, and no error
  622. message related to LWORK is issued by XERBLA.
  623. INFO (output) long
  624. = 0: successful exit
  625. < 0: if INFO = -i, the i-th argument had an illegal value.
  626. Further Details
  627. ===============
  628. The matrix Q is represented as a product of (ihi-ilo) elementary
  629. reflectors
  630. Q = H(ilo) H(ilo+1) . . . H(ihi-1).
  631. Each H(i) has the form
  632. H(i) = I - tau * v * v'
  633. where tau is a real scalar, and v is a real vector with
  634. v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on
  635. exit in A(i+2:ihi,i), and tau in TAU(i).
  636. The contents of A are illustrated by the following example, with
  637. n = 7, ilo = 2 and ihi = 6:
  638. on entry, on exit,
  639. ( a a a a a a a ) ( a a h h h h a )
  640. ( a a a a a a ) ( a h h h h a )
  641. ( a a a a a a ) ( h h h h h h )
  642. ( a a a a a a ) ( v2 h h h h h )
  643. ( a a a a a a ) ( v2 v3 h h h h )
  644. ( a a a a a a ) ( v2 v3 v4 h h h )
  645. ( a ) ( a )
  646. where a denotes an element of the original matrix A, h denotes a
  647. modified element of the upper Hessenberg matrix H, and vi denotes an
  648. element of the vector defining H(i).
  649. =====================================================================
  650. */
  651. int NUMlapack_dgelq2 (integer *m, integer *n, double *a, integer *lda, double *tau, double *work, integer *info);
  652. /* Purpose
  653. =======
  654. NUMlapack_dgelq2 computes an LQ factorization of a real m by n matrix A:
  655. A = L * Q.
  656. Arguments
  657. =========
  658. M (input) long
  659. The number of rows of the matrix A. M >= 0.
  660. N (input) long
  661. The number of columns of the matrix A. N >= 0.
  662. A (input/output) double array, dimension (LDA,N)
  663. On entry, the m by n matrix A.
  664. On exit, the elements on and below the diagonal of the array
  665. contain the m by min(m,n) lower trapezoidal matrix L (L is
  666. lower triangular if m <= n); the elements above the diagonal,
  667. with the array TAU, represent the orthogonal matrix Q as a
  668. product of elementary reflectors (see Further Details).
  669. LDA (input) long
  670. The leading dimension of the array A. LDA >= max(1,M).
  671. TAU (output) double array, dimension (min(M,N))
  672. The scalar factors of the elementary reflectors (see Further
  673. Details).
  674. WORK (workspace) double array, dimension (M)
  675. INFO (output) long
  676. = 0: successful exit
  677. < 0: if INFO = -i, the i-th argument had an illegal value
  678. Further Details
  679. ===============
  680. The matrix Q is represented as a product of elementary reflectors
  681. Q = H(k) . . . H(2) H(1), where k = min(m,n).
  682. Each H(i) has the form
  683. H(i) = I - tau * v * v'
  684. where tau is a real scalar, and v is a real vector with
  685. v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n),
  686. and tau in TAU(i).
  687. =====================================================================
  688. */
  689. int NUMlapack_dgelqf (integer *m, integer *n, double *a, integer *lda, double *tau,
  690. double *work, integer *lwork, integer *info);
  691. /* Purpose
  692. =======
  693. NUMlapack_dgelqf computes an LQ factorization of a real M-by-N matrix A:
  694. A = L * Q.
  695. Arguments
  696. =========
  697. M (input) long
  698. The number of rows of the matrix A. M >= 0.
  699. N (input) long
  700. The number of columns of the matrix A. N >= 0.
  701. A (input/output) double array, dimension (LDA,N)
  702. On entry, the M-by-N matrix A.
  703. On exit, the elements on and below the diagonal of the array
  704. contain the m-by-min(m,n) lower trapezoidal matrix L (L is
  705. lower triangular if m <= n); the elements above the diagonal,
  706. with the array TAU, represent the orthogonal matrix Q as a
  707. product of elementary reflectors (see Further Details).
  708. LDA (input) long
  709. The leading dimension of the array A. LDA >= max(1,M).
  710. TAU (output) double array, dimension (min(M,N))
  711. The scalar factors of the elementary reflectors (see Further
  712. Details).
  713. WORK (workspace/output) double array, dimension (LWORK)
  714. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  715. LWORK (input) long
  716. The dimension of the array WORK. LWORK >= max(1,M).
  717. For optimum performance LWORK >= M*NB, where NB is the
  718. optimal blocksize.
  719. If LWORK = -1, then a workspace query is assumed; the routine
  720. only calculates the optimal size of the WORK array, returns
  721. this value as the first entry of the WORK array, and no error
  722. message related to LWORK is issued by XERBLA.
  723. INFO (output) long
  724. = 0: successful exit
  725. < 0: if INFO = -i, the i-th argument had an illegal value
  726. Further Details
  727. ===============
  728. The matrix Q is represented as a product of elementary reflectors
  729. Q = H(k) . . . H(2) H(1), where k = min(m,n).
  730. Each H(i) has the form
  731. H(i) = I - tau * v * v'
  732. where tau is a real scalar, and v is a real vector with
  733. v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n),
  734. and tau in TAU(i).
  735. =====================================================================
  736. */
  737. int NUMlapack_dgelss (integer *m, integer *n, integer *nrhs, double *a, integer *lda,
  738. double *b, integer *ldb, double *s, double *rcond, integer *rank, double *work,
  739. integer *lwork, integer *info);
  740. /* Purpose
  741. =======
  742. NUMlapack_dgelss computes the minimum norm solution to a real linear least
  743. squares problem:
  744. Minimize 2-norm(| b - A*x |).
  745. using the singular value decomposition (SVD) of A. A is an M-by-N
  746. matrix which may be rank-deficient.
  747. Several right hand side vectors b and solution vectors x can be
  748. handled in a single call; they are stored as the columns of the
  749. M-by-NRHS right hand side matrix B and the N-by-NRHS solution matrix
  750. X.
  751. The effective rank of A is determined by treating as zero those
  752. singular values which are less than RCOND times the largest singular
  753. value.
  754. Arguments
  755. =========
  756. M (input) long
  757. The number of rows of the matrix A. M >= 0.
  758. N (input) long
  759. The number of columns of the matrix A. N >= 0.
  760. NRHS (input) long
  761. The number of right hand sides, i.e., the number of columns
  762. of the matrices B and X. NRHS >= 0.
  763. A (input/output) double array, dimension (LDA,N)
  764. On entry, the M-by-N matrix A.
  765. On exit, the first min(m,n) rows of A are overwritten with
  766. its right singular vectors, stored rowwise.
  767. LDA (input) long
  768. The leading dimension of the array A. LDA >= max(1,M).
  769. B (input/output) double array, dimension (LDB,NRHS)
  770. On entry, the M-by-NRHS right hand side matrix B.
  771. On exit, B is overwritten by the N-by-NRHS solution
  772. matrix X. If m >= n and RANK = n, the residual
  773. sum-of-squares for the solution in the i-th column is given
  774. by the sum of squares of elements n+1:m in that column.
  775. LDB (input) long
  776. The leading dimension of the array B. LDB >= max(1,max(M,N)).
  777. S (output) double array, dimension (min(M,N))
  778. The singular values of A in decreasing order.
  779. The condition number of A in the 2-norm = S(1)/S(min(m,n)).
  780. RCOND (input) double
  781. RCOND is used to determine the effective rank of A.
  782. Singular values S(i) <= RCOND*S(1) are treated as zero.
  783. If RCOND < 0, machine precision is used instead.
  784. RANK (output) long
  785. The effective rank of A, i.e., the number of singular values
  786. which are greater than RCOND*S(1).
  787. WORK (workspace/output) double array, dimension (LWORK)
  788. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  789. LWORK (input) long
  790. The dimension of the array WORK. LWORK >= 1, and also:
  791. LWORK >= 3*min(M,N) + max( 2*min(M,N), max(M,N), NRHS )
  792. For good performance, LWORK should generally be larger.
  793. If LWORK = -1, then a workspace query is assumed; the routine
  794. only calculates the optimal size of the WORK array, returns
  795. this value as the first entry of the WORK array, and no error
  796. message related to LWORK is issued by XERBLA.
  797. INFO (output) long
  798. = 0: successful exit
  799. < 0: if INFO = -i, the i-th argument had an illegal value.
  800. > 0: the algorithm for computing the SVD failed to converge;
  801. if INFO = i, i off-diagonal elements of an intermediate
  802. bidiagonal form did not converge to zero.
  803. =====================================================================
  804. */
  805. int NUMlapack_dgeqpf (integer *m, integer *n, double *a, integer *lda, integer *jpvt,
  806. double *tau, double *work, integer *info);
  807. /* Purpose
  808. =======
  809. This routine is deprecated and has been replaced by routine DGEQP3.
  810. NUMlapack_dgeqpf computes a QR factorization with column pivoting of a
  811. real M-by-N matrix A: A*P = Q*R.
  812. Arguments
  813. =========
  814. M (input) long
  815. The number of rows of the matrix A. M >= 0.
  816. N (input) long
  817. The number of columns of the matrix A. N >= 0
  818. A (input/output) double array, dimension (LDA,N)
  819. On entry, the M-by-N matrix A.
  820. On exit, the upper triangle of the array contains the
  821. min(M,N)-by-N upper triangular matrix R; the elements
  822. below the diagonal, together with the array TAU,
  823. represent the orthogonal matrix Q as a product of
  824. min(m,n) elementary reflectors.
  825. LDA (input) long
  826. The leading dimension of the array A. LDA >= max(1,M).
  827. JPVT (input/output) long array, dimension (N)
  828. On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted
  829. to the front of A*P (a leading column); if JPVT(i) = 0,
  830. the i-th column of A is a free column.
  831. On exit, if JPVT(i) = k, then the i-th column of A*P
  832. was the k-th column of A.
  833. TAU (output) double array, dimension (min(M,N))
  834. The scalar factors of the elementary reflectors.
  835. WORK (workspace) double array, dimension (3*N)
  836. INFO (output) long
  837. = 0: successful exit
  838. < 0: if INFO = -i, the i-th argument had an illegal value
  839. Further Details
  840. ===============
  841. The matrix Q is represented as a product of elementary reflectors
  842. Q = H(1) H(2) . . . H(n)
  843. Each H(i) has the form
  844. H = I - tau * v * v'
  845. where tau is a real scalar, and v is a real vector with
  846. v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i).
  847. The matrix P is represented in jpvt as follows: If
  848. jpvt(j) = i
  849. then the jth column of P is the ith canonical unit vector.
  850. =====================================================================
  851. */
  852. int NUMlapack_dgeqr2 (integer *m, integer *n, double *a, integer *lda, double *tau,
  853. double *work, integer *info);
  854. /* Purpose
  855. =======
  856. NUMlapack_dgeqr2 computes a QR factorization of a real m by n matrix A:
  857. A = Q * R.
  858. Arguments
  859. =========
  860. M (input) long
  861. The number of rows of the matrix A. M >= 0.
  862. N (input) long
  863. The number of columns of the matrix A. N >= 0.
  864. A (input/output) double array, dimension (LDA,N)
  865. On entry, the m by n matrix A.
  866. On exit, the elements on and above the diagonal of the array
  867. contain the min(m,n) by n upper trapezoidal matrix R (R is
  868. upper triangular if m >= n); the elements below the diagonal,
  869. with the array TAU, represent the orthogonal matrix Q as a
  870. product of elementary reflectors (see Further Details).
  871. LDA (input) long
  872. The leading dimension of the array A. LDA >= max(1,M).
  873. TAU (output) double array, dimension (min(M,N))
  874. The scalar factors of the elementary reflectors (see Further
  875. Details).
  876. WORK (workspace) double array, dimension (N)
  877. INFO (output) long
  878. = 0: successful exit
  879. < 0: if INFO = -i, the i-th argument had an illegal value
  880. Further Details
  881. ===============
  882. The matrix Q is represented as a product of elementary reflectors
  883. Q = H(1) H(2) . . . H(k), where k = min(m,n).
  884. Each H(i) has the form
  885. H(i) = I - tau * v * v'
  886. where tau is a real scalar, and v is a real vector with
  887. v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i),
  888. and tau in TAU(i).
  889. =====================================================================
  890. */
  891. int NUMlapack_dgeqrf(integer *m, integer *n, double *a, integer *lda, double *tau,
  892. double *work, integer *lwork, integer *info);
  893. /* Purpose
  894. =======
  895. NUMlapack_dgeqrf computes a QR factorization of a real M-by-N matrix A:
  896. A = Q * R.
  897. Arguments
  898. =========
  899. M (input) long
  900. The number of rows of the matrix A. M >= 0.
  901. N (input) long
  902. The number of columns of the matrix A. N >= 0.
  903. A (input/output) double array, dimension (LDA,N)
  904. On entry, the M-by-N matrix A.
  905. On exit, the elements on and above the diagonal of the array
  906. contain the min(M,N)-by-N upper trapezoidal matrix R (R is
  907. upper triangular if m >= n); the elements below the diagonal,
  908. with the array TAU, represent the orthogonal matrix Q as a
  909. product of min(m,n) elementary reflectors (see Further
  910. Details).
  911. LDA (input) long
  912. The leading dimension of the array A. LDA >= max(1,M).
  913. TAU (output) double array, dimension (min(M,N))
  914. The scalar factors of the elementary reflectors (see Further
  915. Details).
  916. WORK (workspace/output) double array, dimension (LWORK)
  917. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  918. LWORK (input) long
  919. The dimension of the array WORK. LWORK >= max(1,N).
  920. For optimum performance LWORK >= N*NB, where NB is
  921. the optimal blocksize.
  922. If LWORK = -1, then a workspace query is assumed; the routine
  923. only calculates the optimal size of the WORK array, returns
  924. this value as the first entry of the WORK array, and no error
  925. message related to LWORK is issued by XERBLA.
  926. INFO (output) long
  927. = 0: successful exit
  928. < 0: if INFO = -i, the i-th argument had an illegal value
  929. Further Details
  930. ===============
  931. The matrix Q is represented as a product of elementary reflectors
  932. Q = H(1) H(2) . . . H(k), where k = min(m,n).
  933. Each H(i) has the form
  934. H(i) = I - tau * v * v'
  935. where tau is a real scalar, and v is a real vector with
  936. v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i),
  937. and tau in TAU(i).
  938. =====================================================================
  939. */
  940. int NUMlapack_dgerq2(integer *m, integer *n, double *a, integer *lda, double *tau,
  941. double *work, integer *info);
  942. /* Purpose
  943. =======
  944. NUMlapack_dgerq2 computes an RQ factorization of a real m by n matrix A:
  945. A = R * Q.
  946. Arguments
  947. =========
  948. M (input) long
  949. The number of rows of the matrix A. M >= 0.
  950. N (input) long
  951. The number of columns of the matrix A. N >= 0.
  952. A (input/output) double array, dimension (LDA,N)
  953. On entry, the m by n matrix A.
  954. On exit, if m <= n, the upper triangle of the subarray
  955. A(1:m,n-m+1:n) contains the m by m upper triangular matrix R;
  956. if m >= n, the elements on and above the (m-n)-th subdiagonal
  957. contain the m by n upper trapezoidal matrix R; the remaining
  958. elements, with the array TAU, represent the orthogonal matrix
  959. Q as a product of elementary reflectors (see Further
  960. Details).
  961. LDA (input) long
  962. The leading dimension of the array A. LDA >= max(1,M).
  963. TAU (output) double array, dimension (min(M,N))
  964. The scalar factors of the elementary reflectors (see Further
  965. Details).
  966. WORK (workspace) double array, dimension (M)
  967. INFO (output) long
  968. = 0: successful exit
  969. < 0: if INFO = -i, the i-th argument had an illegal value
  970. Further Details
  971. ===============
  972. The matrix Q is represented as a product of elementary reflectors
  973. Q = H(1) H(2) . . . H(k), where k = min(m,n).
  974. Each H(i) has the form
  975. H(i) = I - tau * v * v'
  976. where tau is a real scalar, and v is a real vector with
  977. v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in
  978. A(m-k+i,1:n-k+i-1), and tau in TAU(i).
  979. =====================================================================
  980. */
  981. int NUMlapack_dgesv (integer *n, integer *nrhs, double *a, integer *lda, integer *ipiv,
  982. double *b, integer *ldb, integer *info);
  983. /* Purpose
  984. =======
  985. NUMlapack_dgesv computes the solution to a real system of linear equations
  986. A * X = B,
  987. where A is an N-by-N matrix and X and B are N-by-NRHS matrices.
  988. The LU decomposition with partial pivoting and row interchanges is
  989. used to factor A as
  990. A = P * L * U,
  991. where P is a permutation matrix, L is unit lower triangular, and U is
  992. upper triangular. The factored form of A is then used to solve the
  993. system of equations A * X = B.
  994. Arguments
  995. =========
  996. N (input) long
  997. The number of linear equations, i.e., the order of the
  998. matrix A. N >= 0.
  999. NRHS (input) long
  1000. The number of right hand sides, i.e., the number of columns
  1001. of the matrix B. NRHS >= 0.
  1002. A (input/output) double array, dimension (LDA,N)
  1003. On entry, the N-by-N coefficient matrix A.
  1004. On exit, the factors L and U from the factorization
  1005. A = P*L*U; the unit diagonal elements of L are not stored.
  1006. LDA (input) long
  1007. The leading dimension of the array A. LDA >= max(1,N).
  1008. IPIV (output) long array, dimension (N)
  1009. The pivot indices that define the permutation matrix P;
  1010. row i of the matrix was interchanged with row IPIV(i).
  1011. B (input/output) double array, dimension (LDB,NRHS)
  1012. On entry, the N-by-NRHS matrix of right hand side matrix B.
  1013. On exit, if INFO = 0, the N-by-NRHS solution matrix X.
  1014. LDB (input) long
  1015. The leading dimension of the array B. LDB >= max(1,N).
  1016. INFO (output) long
  1017. = 0: successful exit
  1018. < 0: if INFO = -i, the i-th argument had an illegal value
  1019. > 0: if INFO = i, U(i,i) is exactly zero. The factorization
  1020. has been completed, but the factor U is exactly
  1021. singular, so the solution could not be computed.
  1022. =====================================================================
  1023. */
  1024. int NUMlapack_dgesvd (const char *jobu, const char *jobvt, integer *m, integer *n, double *a, integer *lda,
  1025. double *s, double *u, integer *ldu, double *vt, integer *ldvt, double *work,
  1026. integer *lwork, integer *info);
  1027. /*
  1028. Purpose
  1029. =======
  1030. NUMlapack_dgesvd computes the singular value decomposition (SVD) of a real
  1031. M-by-N matrix A, optionally computing the left and/or right singular
  1032. vectors. The SVD is written
  1033. A = U * SIGMA * transpose(V)
  1034. where SIGMA is an M-by-N matrix which is zero except for its
  1035. min(m,n) diagonal elements, U is an M-by-M orthogonal matrix, and
  1036. V is an N-by-N orthogonal matrix. The diagonal elements of SIGMA
  1037. are the singular values of A; they are real and non-negative, and
  1038. are returned in descending order. The first min(m,n) columns of
  1039. U and V are the left and right singular vectors of A.
  1040. Note that the routine returns V**T, not V.
  1041. Arguments
  1042. =========
  1043. JOBU (input) char*
  1044. Specifies options for computing all or part of the matrix U:
  1045. = 'A': all M columns of U are returned in array U:
  1046. = 'S': the first min(m,n) columns of U (the left singular
  1047. vectors) are returned in the array U;
  1048. = 'O': the first min(m,n) columns of U (the left singular
  1049. vectors) are overwritten on the array A;
  1050. = 'N': no columns of U (no left singular vectors) are
  1051. computed.
  1052. JOBVT (input) char*
  1053. Specifies options for computing all or part of the matrix
  1054. V**T:
  1055. = 'A': all N rows of V**T are returned in the array VT;
  1056. = 'S': the first min(m,n) rows of V**T (the right singular
  1057. vectors) are returned in the array VT;
  1058. = 'O': the first min(m,n) rows of V**T (the right singular
  1059. vectors) are overwritten on the array A;
  1060. = 'N': no rows of V**T (no right singular vectors) are
  1061. computed.
  1062. JOBVT and JOBU cannot both be 'O'.
  1063. M (input) long
  1064. The number of rows of the input matrix A. M >= 0.
  1065. N (input) long
  1066. The number of columns of the input matrix A. N >= 0.
  1067. A (input/output) double array, dimension (LDA,N)
  1068. On entry, the M-by-N matrix A.
  1069. On exit,
  1070. if JOBU = 'O', A is overwritten with the first min(m,n)
  1071. columns of U (the left singular vectors,
  1072. stored columnwise);
  1073. if JOBVT = 'O', A is overwritten with the first min(m,n)
  1074. rows of V**T (the right singular vectors,
  1075. stored rowwise);
  1076. if JOBU .ne. 'O' and JOBVT .ne. 'O', the contents of A
  1077. are destroyed.
  1078. LDA (input) long
  1079. The leading dimension of the array A. LDA >= max(1,M).
  1080. S (output) double array, dimension (min(M,N))
  1081. The singular values of A, sorted so that S(i) >= S(i+1).
  1082. U (output) double array, dimension (LDU,UCOL)
  1083. (LDU,M) if JOBU = 'A' or (LDU,min(M,N)) if JOBU = 'S'.
  1084. If JOBU = 'A', U contains the M-by-M orthogonal matrix U;
  1085. if JOBU = 'S', U contains the first min(m,n) columns of U
  1086. (the left singular vectors, stored columnwise);
  1087. if JOBU = 'N' or 'O', U is not referenced.
  1088. LDU (input) long
  1089. The leading dimension of the array U. LDU >= 1; if
  1090. JOBU = 'S' or 'A', LDU >= M.
  1091. VT (output) double array, dimension (LDVT,N)
  1092. If JOBVT = 'A', VT contains the N-by-N orthogonal matrix
  1093. V**T;
  1094. if JOBVT = 'S', VT contains the first min(m,n) rows of
  1095. V**T (the right singular vectors, stored rowwise);
  1096. if JOBVT = 'N' or 'O', VT is not referenced.
  1097. LDVT (input) long
  1098. The leading dimension of the array VT. LDVT >= 1; if
  1099. JOBVT = 'A', LDVT >= N; if JOBVT = 'S', LDVT >= min(M,N).
  1100. WORK (workspace/output) double array, dimension (LWORK)
  1101. On exit, if INFO = 0, WORK(1) returns the optimal LWORK;
  1102. if INFO > 0, WORK(2:MIN(M,N)) contains the unconverged
  1103. superdiagonal elements of an upper bidiagonal matrix B
  1104. whose diagonal is in S (not necessarily sorted). B
  1105. satisfies A = U * B * VT, so it has the same singular values
  1106. as A, and singular vectors related by U and VT.
  1107. LWORK (input) long
  1108. The dimension of the array WORK. LWORK >= 1.
  1109. LWORK >= MAX(3*MIN(M,N)+MAX(M,N),5*MIN(M,N)).
  1110. For good performance, LWORK should generally be larger.
  1111. If LWORK = -1, then a workspace query is assumed; the routine
  1112. only calculates the optimal size of the WORK array, returns
  1113. this value as the first entry of the WORK array, and no error
  1114. message related to LWORK is issued by XERBLA.
  1115. INFO (output) long
  1116. = 0: successful exit.
  1117. < 0: if INFO = -i, the i-th argument had an illegal value.
  1118. > 0: if DBDSQR did not converge, INFO specifies how many
  1119. superdiagonals of an intermediate bidiagonal form B
  1120. did not converge to zero. See the description of WORK
  1121. above for details.
  1122. =====================================================================
  1123. */
  1124. int NUMlapack_dgetf2 (integer *m, integer *n, double *a, integer *lda, integer *ipiv, integer *info);
  1125. /* Purpose
  1126. =======
  1127. NUMlapack_dgetf2 computes an LU factorization of a general m-by-n matrix A
  1128. using partial pivoting with row interchanges.
  1129. The factorization has the form
  1130. A = P * L * U
  1131. where P is a permutation matrix, L is lower triangular with unit
  1132. diagonal elements (lower trapezoidal if m > n), and U is upper
  1133. triangular (upper trapezoidal if m < n).
  1134. This is the right-looking Level 2 BLAS version of the algorithm.
  1135. Arguments
  1136. =========
  1137. M (input) long
  1138. The number of rows of the matrix A. M >= 0.
  1139. N (input) long
  1140. The number of columns of the matrix A. N >= 0.
  1141. A (input/output) double array, dimension (LDA,N)
  1142. On entry, the m by n matrix to be factored.
  1143. On exit, the factors L and U from the factorization
  1144. A = P*L*U; the unit diagonal elements of L are not stored.
  1145. LDA (input) long
  1146. The leading dimension of the array A. LDA >= max(1,M).
  1147. IPIV (output) long array, dimension (min(M,N))
  1148. The pivot indices; for 1 <= i <= min(M,N), row i of the
  1149. matrix was interchanged with row IPIV(i).
  1150. INFO (output) long
  1151. = 0: successful exit
  1152. < 0: if INFO = -k, the k-th argument had an illegal value
  1153. > 0: if INFO = k, U(k,k) is exactly zero. The factorization
  1154. has been completed, but the factor U is exactly
  1155. singular, and division by zero will occur if it is used
  1156. to solve a system of equations.
  1157. =====================================================================
  1158. */
  1159. int NUMlapack_dgetri (integer *n, double *a, integer *lda, integer *ipiv, double *work,
  1160. integer *lwork, integer *info);
  1161. /* Purpose
  1162. =======
  1163. NUMlapack_dgetri computes the inverse of a matrix using the LU factorization
  1164. computed by NUMlapack_dgetrf.
  1165. This method inverts U and then computes inv(A) by solving the system
  1166. inv(A)*L = inv(U) for inv(A).
  1167. Arguments
  1168. =========
  1169. N (input) long
  1170. The order of the matrix A. N >= 0.
  1171. A (input/output) double array, dimension (LDA,N)
  1172. On entry, the factors L and U from the factorization
  1173. A = P*L*U as computed by DGETRF.
  1174. On exit, if INFO = 0, the inverse of the original matrix A.
  1175. LDA (input) long
  1176. The leading dimension of the array A. LDA >= max(1,N).
  1177. IPIV (input) long array, dimension (N)
  1178. The pivot indices from DGETRF; for 1<=i<=N, row i of the
  1179. matrix was interchanged with row IPIV(i).
  1180. WORK (workspace/output) double array, dimension (LWORK)
  1181. On exit, if INFO=0, then WORK(1) returns the optimal LWORK.
  1182. LWORK (input) long
  1183. The dimension of the array WORK. LWORK >= max(1,N).
  1184. For optimal performance LWORK >= N*NB, where NB is
  1185. the optimal blocksize returned by NUMlapack_ilaenv.
  1186. If LWORK = -1, then a workspace query is assumed; the routine
  1187. only calculates the optimal size of the WORK array, returns
  1188. this value as the first entry of the WORK array, and no error
  1189. message related to LWORK is issued by XERBLA.
  1190. INFO (output) long
  1191. = 0: successful exit
  1192. < 0: if INFO = -i, the i-th argument had an illegal value
  1193. > 0: if INFO = i, U(i,i) is exactly zero; the matrix is
  1194. singular and its inverse could not be computed.
  1195. =====================================================================
  1196. */
  1197. int NUMlapack_dgetrf (integer *m, integer *n, double *a, integer *lda, integer *ipiv, integer *info);
  1198. /* Purpose
  1199. =======
  1200. NUMlapack_dgetrf computes an LU factorization of a general M-by-N matrix A
  1201. using partial pivoting with row interchanges.
  1202. The factorization has the form
  1203. A = P * L * U
  1204. where P is a permutation matrix, L is lower triangular with unit
  1205. diagonal elements (lower trapezoidal if m > n), and U is upper
  1206. triangular (upper trapezoidal if m < n).
  1207. This is the right-looking Level 3 BLAS version of the algorithm.
  1208. Arguments
  1209. =========
  1210. M (input) long
  1211. The number of rows of the matrix A. M >= 0.
  1212. N (input) long
  1213. The number of columns of the matrix A. N >= 0.
  1214. A (input/output) double array, dimension (LDA,N)
  1215. On entry, the M-by-N matrix to be factored.
  1216. On exit, the factors L and U from the factorization
  1217. A = P*L*U; the unit diagonal elements of L are not stored.
  1218. LDA (input) long
  1219. The leading dimension of the array A. LDA >= max(1,M).
  1220. IPIV (output) long array, dimension (min(M,N))
  1221. The pivot indices; for 1 <= i <= min(M,N), row i of the
  1222. matrix was interchanged with row IPIV(i).
  1223. INFO (output) long
  1224. = 0: successful exit
  1225. < 0: if INFO = -i, the i-th argument had an illegal value
  1226. > 0: if INFO = i, U(i,i) is exactly zero. The factorization
  1227. has been completed, but the factor U is exactly
  1228. singular, and division by zero will occur if it is used
  1229. to solve a system of equations.
  1230. =====================================================================
  1231. */
  1232. int NUMlapack_dgetrs (const char *trans, integer *n, integer *nrhs, double *a, integer *lda,
  1233. integer *ipiv, double *b, integer *ldb, integer *info);
  1234. /* Purpose
  1235. =======
  1236. NUMlapack_dgetrs solves a system of linear equations
  1237. A * X = B or A' * X = B
  1238. with a general N-by-N matrix A using the LU factorization computed
  1239. by DGETRF.
  1240. Arguments
  1241. =========
  1242. TRANS (input) char*
  1243. Specifies the form of the system of equations:
  1244. = 'N': A * X = B (No transpose)
  1245. = 'T': A'* X = B (Transpose)
  1246. = 'C': A'* X = B (Conjugate transpose = Transpose)
  1247. N (input) long
  1248. The order of the matrix A. N >= 0.
  1249. NRHS (input) long
  1250. The number of right hand sides, i.e., the number of columns
  1251. of the matrix B. NRHS >= 0.
  1252. A (input) double array, dimension (LDA,N)
  1253. The factors L and U from the factorization A = P*L*U
  1254. as computed by DGETRF.
  1255. LDA (input) long
  1256. The leading dimension of the array A. LDA >= max(1,N).
  1257. IPIV (input) long array, dimension (N)
  1258. The pivot indices from DGETRF; for 1<=i<=N, row i of the
  1259. matrix was interchanged with row IPIV(i).
  1260. B (input/output) double array, dimension (LDB,NRHS)
  1261. On entry, the right hand side matrix B.
  1262. On exit, the solution matrix X.
  1263. LDB (input) long
  1264. The leading dimension of the array B. LDB >= max(1,N).
  1265. INFO (output) long
  1266. = 0: successful exit
  1267. < 0: if INFO = -i, the i-th argument had an illegal value
  1268. =====================================================================
  1269. */
  1270. int NUMlapack_dggsvd (const char *jobu, const char *jobv, const char *jobq, integer *m, integer *n,
  1271. integer *p, integer *k, integer *l, double *a, integer *lda, double *b, integer *ldb,
  1272. double *alpha, double *beta, double *u, integer *ldu, double *v, integer *ldv,
  1273. double *q, integer *ldq, double *work, integer *iwork, integer *info);
  1274. /* Purpose
  1275. =======
  1276. NUMlapack_dggsvd computes the generalized singular value decomposition (GSVD)
  1277. of an M-by-N real matrix A and P-by-N real matrix B:
  1278. U'*A*Q = D1*( 0 R ), V'*B*Q = D2*( 0 R )
  1279. where U, V and Q are orthogonal matrices, and Z' is the transpose
  1280. of Z. Let K+L = the effective numerical rank of the matrix (A',B')',
  1281. then R is a K+L-by-K+L nonsingular upper triangular matrix, D1 and
  1282. D2 are M-by-(K+L) and P-by-(K+L) "diagonal" matrices and of the
  1283. following structures, respectively:
  1284. If M-K-L >= 0,
  1285. K L
  1286. D1 = K ( I 0 )
  1287. L ( 0 C )
  1288. M-K-L ( 0 0 )
  1289. K L
  1290. D2 = L ( 0 S )
  1291. P-L ( 0 0 )
  1292. N-K-L K L
  1293. ( 0 R ) = K ( 0 R11 R12 )
  1294. L ( 0 0 R22 )
  1295. where
  1296. C = diag( ALPHA(K+1), ... , ALPHA(K+L) ),
  1297. S = diag( BETA(K+1), ... , BETA(K+L) ),
  1298. C**2 + S**2 = I.
  1299. R is stored in A(1:K+L,N-K-L+1:N) on exit.
  1300. If M-K-L < 0,
  1301. K M-K K+L-M
  1302. D1 = K ( I 0 0 )
  1303. M-K ( 0 C 0 )
  1304. K M-K K+L-M
  1305. D2 = M-K ( 0 S 0 )
  1306. K+L-M ( 0 0 I )
  1307. P-L ( 0 0 0 )
  1308. N-K-L K M-K K+L-M
  1309. ( 0 R ) = K ( 0 R11 R12 R13 )
  1310. M-K ( 0 0 R22 R23 )
  1311. K+L-M ( 0 0 0 R33 )
  1312. where
  1313. C = diag( ALPHA(K+1), ... , ALPHA(M) ),
  1314. S = diag( BETA(K+1), ... , BETA(M) ),
  1315. C**2 + S**2 = I.
  1316. (R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N), and R33 is stored
  1317. ( 0 R22 R23 )
  1318. in B(M-K+1:L,N+M-K-L+1:N) on exit.
  1319. The routine computes C, S, R, and optionally the orthogonal
  1320. transformation matrices U, V and Q.
  1321. In particular, if B is an N-by-N nonsingular matrix, then the GSVD of
  1322. A and B implicitly gives the SVD of A*inv(B):
  1323. A*inv(B) = U*(D1*inv(D2))*V'.
  1324. If ( A',B')' has orthonormal columns, then the GSVD of A and B is
  1325. also equal to the CS decomposition of A and B. Furthermore, the GSVD
  1326. can be used to derive the solution of the eigenvalue problem:
  1327. A'*A x = lambda* B'*B x.
  1328. In some literature, the GSVD of A and B is presented in the form
  1329. U'*A*X = ( 0 D1 ), V'*B*X = ( 0 D2 )
  1330. where U and V are orthogonal and X is nonsingular, D1 and D2 are
  1331. ``diagonal''. The former GSVD form can be converted to the latter
  1332. form by taking the nonsingular matrix X as
  1333. X = Q*( I 0 )
  1334. ( 0 inv(R) ).
  1335. Arguments
  1336. =========
  1337. JOBU (input) char*
  1338. = 'U': Orthogonal matrix U is computed;
  1339. = 'N': U is not computed.
  1340. JOBV (input) char*
  1341. = 'V': Orthogonal matrix V is computed;
  1342. = 'N': V is not computed.
  1343. JOBQ (input) char*
  1344. = 'Q': Orthogonal matrix Q is computed;
  1345. = 'N': Q is not computed.
  1346. M (input) long
  1347. The number of rows of the matrix A. M >= 0.
  1348. N (input) long
  1349. The number of columns of the matrices A and B. N >= 0.
  1350. P (input) long
  1351. The number of rows of the matrix B. P >= 0.
  1352. K (output) long
  1353. L (output) long
  1354. On exit, K and L specify the dimension of the subblocks
  1355. described in the Purpose section.
  1356. K + L = effective numerical rank of (A',B')'.
  1357. A (input/output) double array, dimension (LDA,N)
  1358. On entry, the M-by-N matrix A.
  1359. On exit, A contains the triangular matrix R, or part of R.
  1360. See Purpose for details.
  1361. LDA (input) long
  1362. The leading dimension of the array A. LDA >= max(1,M).
  1363. B (input/output) double array, dimension (LDB,N)
  1364. On entry, the P-by-N matrix B.
  1365. On exit, B contains the triangular matrix R if M-K-L < 0.
  1366. See Purpose for details.
  1367. LDB (input) long
  1368. The leading dimension of the array B. LDA >= max(1,P).
  1369. ALPHA (output) double array, dimension (N)
  1370. BETA (output) double array, dimension (N)
  1371. On exit, ALPHA and BETA contain the generalized singular
  1372. value pairs of A and B;
  1373. ALPHA(1:K) = 1,
  1374. BETA(1:K) = 0,
  1375. and if M-K-L >= 0,
  1376. ALPHA(K+1:K+L) = C,
  1377. BETA(K+1:K+L) = S,
  1378. or if M-K-L < 0,
  1379. ALPHA(K+1:M)=C, ALPHA(M+1:K+L)=0
  1380. BETA(K+1:M) =S, BETA(M+1:K+L) =1
  1381. and
  1382. ALPHA(K+L+1:N) = 0
  1383. BETA(K+L+1:N) = 0
  1384. U (output) double array, dimension (LDU,M)
  1385. If JOBU = 'U', U contains the M-by-M orthogonal matrix U.
  1386. If JOBU = 'N', U is not referenced.
  1387. LDU (input) long
  1388. The leading dimension of the array U. LDU >= max(1,M) if
  1389. JOBU = 'U'; LDU >= 1 otherwise.
  1390. V (output) double array, dimension (LDV,P)
  1391. If JOBV = 'V', V contains the P-by-P orthogonal matrix V.
  1392. If JOBV = 'N', V is not referenced.
  1393. LDV (input) long
  1394. The leading dimension of the array V. LDV >= max(1,P) if
  1395. JOBV = 'V'; LDV >= 1 otherwise.
  1396. Q (output) double array, dimension (LDQ,N)
  1397. If JOBQ = 'Q', Q contains the N-by-N orthogonal matrix Q.
  1398. If JOBQ = 'N', Q is not referenced.
  1399. LDQ (input) long
  1400. The leading dimension of the array Q. LDQ >= max(1,N) if
  1401. JOBQ = 'Q'; LDQ >= 1 otherwise.
  1402. WORK (workspace) double array,
  1403. dimension (max(3*N,M,P)+N)
  1404. IWORK (workspace/output) long array, dimension (N)
  1405. On exit, IWORK stores the sorting information. More
  1406. precisely, the following loop will sort ALPHA
  1407. for I = K+1, min(M,K+L)
  1408. swap ALPHA(I) and ALPHA(IWORK(I))
  1409. endfor
  1410. such that ALPHA(1) >= ALPHA(2) >= ... >= ALPHA(N).
  1411. INFO (output)long
  1412. = 0: successful exit
  1413. < 0: if INFO = -i, the i-th argument had an illegal value.
  1414. > 0: if INFO = 1, the Jacobi-type procedure failed to
  1415. converge. For further details, see subroutine NUMlapack_dtgsja.
  1416. Internal Parameters
  1417. ===================
  1418. TOLA double
  1419. TOLB double
  1420. TOLA and TOLB are the thresholds to determine the effective
  1421. rank of (A',B')'. Generally, they are set to
  1422. TOLA = MAX(M,N)*norm(A)*MAZHEPS,
  1423. TOLB = MAX(P,N)*norm(B)*MAZHEPS.
  1424. The size of TOLA and TOLB may affect the size of backward
  1425. errors of the decomposition.
  1426. =====================================================================
  1427. */
  1428. int NUMlapack_dggsvp (const char *jobu, const char *jobv, const char *jobq, integer *m, integer *p,
  1429. integer *n, double *a, integer *lda, double *b, integer *ldb, double *tola,
  1430. double *tolb, integer *k, integer *l, double *u, integer *ldu, double *v, integer *ldv,
  1431. double *q, integer *ldq, integer *iwork, double *tau, double *work, integer *info);
  1432. /* Purpose
  1433. =======
  1434. NUMlapack_dggsvp computes orthogonal matrices U, V and Q such that
  1435. N-K-L K L
  1436. U'*A*Q = K ( 0 A12 A13 ) if M-K-L >= 0;
  1437. L ( 0 0 A23 )
  1438. M-K-L ( 0 0 0 )
  1439. N-K-L K L
  1440. = K ( 0 A12 A13 ) if M-K-L < 0;
  1441. M-K ( 0 0 A23 )
  1442. N-K-L K L
  1443. V'*B*Q = L ( 0 0 B13 )
  1444. P-L ( 0 0 0 )
  1445. where the K-by-K matrix A12 and L-by-L matrix B13 are nonsingular
  1446. upper triangular; A23 is L-by-L upper triangular if M-K-L >= 0,
  1447. otherwise A23 is (M-K)-by-L upper trapezoidal. K+L = the effective
  1448. numerical rank of the (M+P)-by-N matrix (A',B')'. Z' denotes the
  1449. transpose of Z.
  1450. This decomposition is the preprocessing step for computing the
  1451. Generalized Singular Value Decomposition (GSVD), see subroutine
  1452. NUMlapack_dggsvd.
  1453. Arguments
  1454. =========
  1455. JOBU (input) char*
  1456. = 'U': Orthogonal matrix U is computed;
  1457. = 'N': U is not computed.
  1458. JOBV (input) char*
  1459. = 'V': Orthogonal matrix V is computed;
  1460. = 'N': V is not computed.
  1461. JOBQ (input) char*
  1462. = 'Q': Orthogonal matrix Q is computed;
  1463. = 'N': Q is not computed.
  1464. M (input) long
  1465. The number of rows of the matrix A. M >= 0.
  1466. P (input) long
  1467. The number of rows of the matrix B. P >= 0.
  1468. N (input) long
  1469. The number of columns of the matrices A and B. N >= 0.
  1470. A (input/output) double array, dimension (LDA,N)
  1471. On entry, the M-by-N matrix A.
  1472. On exit, A contains the triangular (or trapezoidal) matrix
  1473. described in the Purpose section.
  1474. LDA (input) long
  1475. The leading dimension of the array A. LDA >= max(1,M).
  1476. B (input/output) double array, dimension (LDB,N)
  1477. On entry, the P-by-N matrix B.
  1478. On exit, B contains the triangular matrix described in
  1479. the Purpose section.
  1480. LDB (input) long
  1481. The leading dimension of the array B. LDB >= max(1,P).
  1482. TOLA (input) double
  1483. TOLB (input) double
  1484. TOLA and TOLB are the thresholds to determine the effective
  1485. numerical rank of matrix B and a subblock of A. Generally,
  1486. they are set to
  1487. TOLA = MAX(M,N)*norm(A)*MAZHEPS,
  1488. TOLB = MAX(P,N)*norm(B)*MAZHEPS.
  1489. The size of TOLA and TOLB may affect the size of backward
  1490. errors of the decomposition.
  1491. K (output) long
  1492. L (output) long
  1493. On exit, K and L specify the dimension of the subblocks
  1494. described in Purpose.
  1495. K + L = effective numerical rank of (A',B')'.
  1496. U (output) double array, dimension (LDU,M)
  1497. If JOBU = 'U', U contains the orthogonal matrix U.
  1498. If JOBU = 'N', U is not referenced.
  1499. LDU (input) long
  1500. The leading dimension of the array U. LDU >= max(1,M) if
  1501. JOBU = 'U'; LDU >= 1 otherwise.
  1502. V (output) double array, dimension (LDV,M)
  1503. If JOBV = 'V', V contains the orthogonal matrix V.
  1504. If JOBV = 'N', V is not referenced.
  1505. LDV (input) long
  1506. The leading dimension of the array V. LDV >= max(1,P) if
  1507. JOBV = 'V'; LDV >= 1 otherwise.
  1508. Q (output) double array, dimension (LDQ,N)
  1509. If JOBQ = 'Q', Q contains the orthogonal matrix Q.
  1510. If JOBQ = 'N', Q is not referenced.
  1511. LDQ (input) long
  1512. The leading dimension of the array Q. LDQ >= max(1,N) if
  1513. JOBQ = 'Q'; LDQ >= 1 otherwise.
  1514. IWORK (workspace) long array, dimension (N)
  1515. TAU (workspace) double array, dimension (N)
  1516. WORK (workspace) double array, dimension (max(3*N,M,P))
  1517. INFO (output) long
  1518. = 0: successful exit
  1519. < 0: if INFO = -i, the i-th argument had an illegal value.
  1520. Further Details
  1521. ===============
  1522. The subroutine uses LAPACK subroutine DGEQPF for the QR factorization
  1523. with column pivoting to detect the effective numerical rank of the
  1524. a matrix. It may be replaced by a better rank determination strategy.
  1525. =====================================================================
  1526. */
  1527. int NUMlapack_dhseqr (const char *job, const char *compz, integer *n, integer *ilo, integer *ihi,
  1528. double *h, integer *ldh, double *wr, double *wi, double *z, integer *ldz,
  1529. double *work, integer *lwork, integer *info);
  1530. /* -- LAPACK routine (version 3.0) --
  1531. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  1532. Courant Institute, Argonne National Lab, and Rice University
  1533. June 30, 1999
  1534. Purpose
  1535. =======
  1536. NUMlapack_dhseqr computes the eigenvalues of a real upper Hessenberg matrix H
  1537. and, optionally, the matrices T and Z from the Schur decomposition
  1538. H = Z T Z**T, where T is an upper quasi-triangular matrix (the Schur
  1539. form), and Z is the orthogonal matrix of Schur vectors.
  1540. Optionally Z may be postmultiplied into an input orthogonal matrix Q,
  1541. so that this routine can give the Schur factorization of a matrix A
  1542. which has been reduced to the Hessenberg form H by the orthogonal
  1543. matrix Q: A = Q*H*Q**T = (QZ)*T*(QZ)**T.
  1544. Arguments
  1545. =========
  1546. JOB (input) char*
  1547. = 'E': compute eigenvalues only;
  1548. = 'S': compute eigenvalues and the Schur form T.
  1549. COMPZ (input) char*
  1550. = 'N': no Schur vectors are computed;
  1551. = 'I': Z is initialized to the unit matrix and the matrix Z
  1552. of Schur vectors of H is returned;
  1553. = 'V': Z must contain an orthogonal matrix Q on entry, and
  1554. the product Q*Z is returned.
  1555. N (input) long
  1556. The order of the matrix H. N >= 0.
  1557. ILO (input) long
  1558. IHI (input) long
  1559. It is assumed that H is already upper triangular in rows
  1560. and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally
  1561. set by a previous call to NUMlapack_dgebal, and then passed to SGEHRD
  1562. when the matrix output by NUMlapack_dgebal is reduced to Hessenberg
  1563. form. Otherwise ILO and IHI should be set to 1 and N
  1564. respectively.
  1565. 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
  1566. H (input/output) double array, dimension (LDH,N)
  1567. On entry, the upper Hessenberg matrix H.
  1568. On exit, if JOB = 'S', H contains the upper quasi-triangular
  1569. matrix T from the Schur decomposition (the Schur form);
  1570. 2-by-2 diagonal blocks (corresponding to complex conjugate
  1571. pairs of eigenvalues) are returned in standard form, with
  1572. H(i,i) = H(i+1,i+1) and H(i+1,i)*H(i,i+1) < 0. If JOB = 'E',
  1573. the contents of H are unspecified on exit.
  1574. LDH (input) long
  1575. The leading dimension of the array H. LDH >= max(1,N).
  1576. WR (output) double array, dimension (N)
  1577. WI (output) double array, dimension (N)
  1578. The real and imaginary parts, respectively, of the computed
  1579. eigenvalues. If two eigenvalues are computed as a complex
  1580. conjugate pair, they are stored in consecutive elements of
  1581. WR and WI, say the i-th and (i+1)th, with WI(i) > 0 and
  1582. WI(i+1) < 0. If JOB = 'S', the eigenvalues are stored in the
  1583. same order as on the diagonal of the Schur form returned in
  1584. H, with WR(i) = H(i,i) and, if H(i:i+1,i:i+1) is a 2-by-2
  1585. diagonal block, WI(i) = sqrt(H(i+1,i)*H(i,i+1)) and
  1586. WI(i+1) = -WI(i).
  1587. Z (input/output) double array, dimension (LDZ,N)
  1588. If COMPZ = 'N': Z is not referenced.
  1589. If COMPZ = 'I': on entry, Z need not be set, and on exit, Z
  1590. contains the orthogonal matrix Z of the Schur vectors of H.
  1591. If COMPZ = 'V': on entry Z must contain an N-by-N matrix Q,
  1592. which is assumed to be equal to the unit matrix except for
  1593. the submatrix Z(ILO:IHI,ILO:IHI); on exit Z contains Q*Z.
  1594. Normally Q is the orthogonal matrix generated by NUMlapack_dorghr after
  1595. the call to NUMlapack_dgehrd which formed the Hessenberg matrix H.
  1596. LDZ (input) long
  1597. The leading dimension of the array Z.
  1598. LDZ >= max(1,N) if COMPZ = 'I' or 'V'; LDZ >= 1 otherwise.
  1599. WORK (workspace/output) double array, dimension (LWORK)
  1600. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  1601. LWORK (input) long
  1602. The dimension of the array WORK. LWORK >= max(1,N).
  1603. If LWORK = -1, then a workspace query is assumed; the routine
  1604. only calculates the optimal size of the WORK array, returns
  1605. this value as the first entry of the WORK array, and no error
  1606. message related to LWORK is issued by XERBLA.
  1607. INFO (output) long
  1608. = 0: successful exit
  1609. < 0: if INFO = -i, the i-th argument had an illegal value
  1610. > 0: if INFO = i, NUMlapack_dhseqr failed to compute all of the
  1611. eigenvalues in a total of 30*(IHI-ILO+1) iterations;
  1612. elements 1:ilo-1 and i+1:n of WR and WI contain those
  1613. eigenvalues which have been successfully computed.
  1614. =====================================================================
  1615. */
  1616. int NUMlapack_dlabad (double *smal, double *large);
  1617. /* Purpose
  1618. =======
  1619. NUMlapack_dlabad takes as input the values computed by DLAMCH for underflow and
  1620. overflow, and returns the square root of each of these values if the
  1621. log of LARGE is sufficiently large. This subroutine is intended to
  1622. identify machines with a large exponent range, such as the Crays, and
  1623. redefine the underflow and overflow limits to be the square roots of
  1624. the values computed by DLAMCH. This subroutine is needed because
  1625. DLAMCH does not compensate for poor arithmetic in the upper half of
  1626. the exponent range, as is found on a Cray.
  1627. Arguments
  1628. =========
  1629. smal (input/output) double
  1630. On entry, the underflow threshold as computed by DLAMCH.
  1631. On exit, if LOG10(LARGE) is sufficiently large, the square
  1632. root of smal, otherwise unchanged.
  1633. LARGE (input/output) double
  1634. On entry, the overflow threshold as computed by DLAMCH.
  1635. On exit, if LOG10(LARGE) is sufficiently large, the square
  1636. root of LARGE, otherwise unchanged.
  1637. =====================================================================
  1638. If it looks like we're on a Cray, take the square root of
  1639. smal and LARGE to avoid overflow and underflow problems.
  1640. */
  1641. int NUMlapack_dlabrd (integer *m, integer *n, integer *nb, double *a, integer *lda, double *d,
  1642. double *e, double *tauq, double *taup, double *x, integer *ldx, double *y,
  1643. integer *ldy);
  1644. /* Purpose
  1645. =======
  1646. NUMlapack_dlabrd reduces the first NB rows and columns of a real general
  1647. m by n matrix A to upper or lower bidiagonal form by an orthogonal
  1648. transformation Q' * A * P, and returns the matrices X and Y which
  1649. are needed to apply the transformation to the unreduced part of A.
  1650. If m >= n, A is reduced to upper bidiagonal form; if m < n, to lower
  1651. bidiagonal form.
  1652. This is an auxiliary routine called by DGEBRD
  1653. Arguments
  1654. =========
  1655. M (input) long
  1656. The number of rows in the matrix A.
  1657. N (input) long
  1658. The number of columns in the matrix A.
  1659. NB (input) long
  1660. The number of leading rows and columns of A to be reduced.
  1661. A (input/output) double array, dimension (LDA,N)
  1662. On entry, the m by n general matrix to be reduced.
  1663. On exit, the first NB rows and columns of the matrix are
  1664. overwritten; the rest of the array is unchanged.
  1665. If m >= n, elements on and below the diagonal in the first NB
  1666. columns, with the array TAUQ, represent the orthogonal
  1667. matrix Q as a product of elementary reflectors; and
  1668. elements above the diagonal in the first NB rows, with the
  1669. array TAUP, represent the orthogonal matrix P as a product
  1670. of elementary reflectors.
  1671. If m < n, elements below the diagonal in the first NB
  1672. columns, with the array TAUQ, represent the orthogonal
  1673. matrix Q as a product of elementary reflectors, and
  1674. elements on and above the diagonal in the first NB rows,
  1675. with the array TAUP, represent the orthogonal matrix P as
  1676. a product of elementary reflectors.
  1677. See Further Details.
  1678. LDA (input) long
  1679. The leading dimension of the array A. LDA >= max(1,M).
  1680. D (output) double array, dimension (NB)
  1681. The diagonal elements of the first NB rows and columns of
  1682. the reduced matrix. D(i) = A(i,i).
  1683. E (output) double array, dimension (NB)
  1684. The off-diagonal elements of the first NB rows and columns of
  1685. the reduced matrix.
  1686. TAUQ (output) double array dimension (NB)
  1687. The scalar factors of the elementary reflectors which
  1688. represent the orthogonal matrix Q. See Further Details.
  1689. TAUP (output) double array, dimension (NB)
  1690. The scalar factors of the elementary reflectors which
  1691. represent the orthogonal matrix P. See Further Details.
  1692. X (output) double array, dimension (LDX,NB)
  1693. The m-by-nb matrix X required to update the unreduced part
  1694. of A.
  1695. LDX (input) long
  1696. The leading dimension of the array X. LDX >= M.
  1697. Y (output) double array, dimension (LDY,NB)
  1698. The n-by-nb matrix Y required to update the unreduced part
  1699. of A.
  1700. LDY (output) long
  1701. The leading dimension of the array Y. LDY >= N.
  1702. Further Details
  1703. ===============
  1704. The matrices Q and P are represented as products of elementary
  1705. reflectors:
  1706. Q = H(1) H(2) . . . H(nb) and P = G(1) G(2) . . . G(nb)
  1707. Each H(i) and G(i) has the form:
  1708. H(i) = I - tauq * v * v' and G(i) = I - taup * u * u'
  1709. where tauq and taup are real scalars, and v and u are real vectors.
  1710. If m >= n, v(1:i-1) = 0, v(i) = 1, and v(i:m) is stored on exit in
  1711. A(i:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+1:n) is stored on exit in
  1712. A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
  1713. If m < n, v(1:i) = 0, v(i+1) = 1, and v(i+1:m) is stored on exit in
  1714. A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i:n) is stored on exit in
  1715. A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i).
  1716. The elements of the vectors v and u together form the m-by-nb matrix
  1717. V and the nb-by-n matrix U' which are needed, with X and Y, to apply
  1718. the transformation to the unreduced part of the matrix, using a block
  1719. update of the form: A := A - V*Y' - X*U'.
  1720. The contents of A on exit are illustrated by the following examples
  1721. with nb = 2:
  1722. m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):
  1723. ( 1 1 u1 u1 u1 ) ( 1 u1 u1 u1 u1 u1 )
  1724. ( v1 1 1 u2 u2 ) ( 1 1 u2 u2 u2 u2 )
  1725. ( v1 v2 a a a ) ( v1 1 a a a a )
  1726. ( v1 v2 a a a ) ( v1 v2 a a a a )
  1727. ( v1 v2 a a a ) ( v1 v2 a a a a )
  1728. ( v1 v2 a a a )
  1729. where a denotes an element of the original matrix which is unchanged,
  1730. vi denotes an element of the vector defining H(i), and ui an element
  1731. of the vector defining G(i).
  1732. =====================================================================
  1733. */
  1734. int NUMlapack_dlacpy (const char *uplo, integer *m, integer *n, double *a, integer *lda, double *b, integer *ldb);
  1735. /* Purpose
  1736. =======
  1737. NUMlapack_dlacpy copies all or part of a two-dimensional matrix A to another
  1738. matrix B.
  1739. Arguments
  1740. =========
  1741. UPLO (input) char*
  1742. Specifies the part of the matrix A to be copied to B.
  1743. = 'U': Upper triangular part
  1744. = 'L': Lower triangular part
  1745. Otherwise: All of the matrix A
  1746. M (input) long
  1747. The number of rows of the matrix A. M >= 0.
  1748. N (input) long
  1749. The number of columns of the matrix A. N >= 0.
  1750. A (input) double array, dimension (LDA,N)
  1751. The m by n matrix A. If UPLO = 'U', only the upper triangle
  1752. or trapezoid is accessed; if UPLO = 'L', only the lower
  1753. triangle or trapezoid is accessed.
  1754. LDA (input) long
  1755. The leading dimension of the array A. LDA >= max(1,M).
  1756. B (output) double array, dimension (LDB,N)
  1757. On exit, B = A in the locations specified by UPLO.
  1758. LDB (input) long
  1759. The leading dimension of the array B. LDB >= max(1,M).
  1760. =====================================================================
  1761. */
  1762. int NUMlapack_dladiv (double *a, double *b, double *c, double *d, double *p, double *q);
  1763. /* -- LAPACK auxiliary routine (version 3.0) --
  1764. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  1765. Courant Institute, Argonne National Lab, and Rice University
  1766. October 31, 1992
  1767. Purpose
  1768. =======
  1769. NUMlapack_dladiv performs complex division in real arithmetic
  1770. a + i*b
  1771. p + i*q = ---------
  1772. c + i*d
  1773. The algorithm is due to Robert L. Smith and can be found
  1774. in D. Knuth, The art of Computer Programming, Vol.2, p.195
  1775. Arguments
  1776. =========
  1777. A (input) double
  1778. B (input) double
  1779. C (input) double
  1780. D (input) double
  1781. The scalars a, b, c, and d in the above expression.
  1782. P (output) double
  1783. Q (output) double
  1784. The scalars p and q in the above expression.
  1785. =====================================================================
  1786. */
  1787. int NUMlapack_dlae2 (double *a, double *b, double *c, double *rt1, double *rt2);
  1788. /* Purpose
  1789. =======
  1790. NUMlapack_dlae2 computes the eigenvalues of a 2-by-2 symmetric matrix
  1791. [ A B ]
  1792. [ B C ].
  1793. On return, RT1 is the eigenvalue of larger absolute value, and RT2
  1794. is the eigenvalue of smaller absolute value.
  1795. Arguments
  1796. =========
  1797. A (input) double
  1798. The (1,1) element of the 2-by-2 matrix.
  1799. B (input) double
  1800. The (1,2) and (2,1) elements of the 2-by-2 matrix.
  1801. C (input) double
  1802. The (2,2) element of the 2-by-2 matrix.
  1803. RT1 (output) double
  1804. The eigenvalue of larger absolute value.
  1805. RT2 (output) double
  1806. The eigenvalue of smaller absolute value.
  1807. Further Details
  1808. ===============
  1809. RT1 is accurate to a few ulps barring over/underflow.
  1810. RT2 may be inaccurate if there is massive cancellation in the
  1811. determinant A*C-B*B; higher precision or correctly rounded or
  1812. correctly truncated arithmetic would be needed to compute RT2
  1813. accurately in all cases.
  1814. Overflow is possible only if RT1 is within a factor of 5 of overflow.
  1815. Underflow is harmless if the input data is 0 or exceeds
  1816. underflow_threshold / macheps.
  1817. =====================================================================
  1818. */
  1819. int NUMlapack_dlaev2 (double *a, double *b, double *c, double *rt1, double *rt2,
  1820. double *cs1, double *sn1);
  1821. /* Purpose
  1822. =======
  1823. NUMlapack_dlaev2 computes the eigendecomposition of a 2-by-2 symmetric matrix
  1824. [ A B ]
  1825. [ B C ].
  1826. On return, RT1 is the eigenvalue of larger absolute value, RT2 is the
  1827. eigenvalue of smaller absolute value, and (CS1,SN1) is the unit right
  1828. eigenvector for RT1, giving the decomposition
  1829. [ CS1 SN1 ] [ A B ] [ CS1 -SN1 ] = [ RT1 0 ]
  1830. [-SN1 CS1 ] [ B C ] [ SN1 CS1 ] [ 0 RT2 ].
  1831. Arguments
  1832. =========
  1833. A (input) double
  1834. The (1,1) element of the 2-by-2 matrix.
  1835. B (input) double
  1836. The (1,2) element and the conjugate of the (2,1) element of
  1837. the 2-by-2 matrix.
  1838. C (input) double
  1839. The (2,2) element of the 2-by-2 matrix.
  1840. RT1 (output) double
  1841. The eigenvalue of larger absolute value.
  1842. RT2 (output) double
  1843. The eigenvalue of smaller absolute value.
  1844. CS1 (output) double
  1845. SN1 (output) double
  1846. The vector (CS1, SN1) is a unit right eigenvector for RT1.
  1847. Further Details
  1848. ===============
  1849. RT1 is accurate to a few ulps barring over/underflow.
  1850. RT2 may be inaccurate if there is massive cancellation in the
  1851. determinant A*C-B*B; higher precision or correctly rounded or
  1852. correctly truncated arithmetic would be needed to compute RT2
  1853. accurately in all cases.
  1854. CS1 and SN1 are accurate to a few ulps barring over/underflow.
  1855. Overflow is possible only if RT1 is within a factor of 5 of overflow.
  1856. Underflow is harmless if the input data is 0 or exceeds
  1857. underflow_threshold / macheps.
  1858. =====================================================================
  1859. */
  1860. int NUMlapack_dlags2 (integer *upper, double *a1, double *a2, double *a3, double *b1,
  1861. double *b2, double *b3, double *csu, double *snu, double *csv, double *snv,
  1862. double *csq, double *snq);
  1863. /* Purpose
  1864. =======
  1865. NUMlapack_dlags2 computes 2-by-2 orthogonal matrices U, V and Q, such
  1866. that if ( UPPER ) then
  1867. U'*A*Q = U'*( A1 A2 )*Q = ( x 0 )
  1868. ( 0 A3 ) ( x x )
  1869. and
  1870. V'*B*Q = V'*( B1 B2 )*Q = ( x 0 )
  1871. ( 0 B3 ) ( x x )
  1872. or if ( .NOT.UPPER ) then
  1873. U'*A*Q = U'*( A1 0 )*Q = ( x x )
  1874. ( A2 A3 ) ( 0 x )
  1875. and
  1876. V'*B*Q = V'*( B1 0 )*Q = ( x x )
  1877. ( B2 B3 ) ( 0 x )
  1878. The rows of the transformed A and B are parallel, where
  1879. U = ( CSU SNU ), V = ( CSV SNV ), Q = ( CSQ SNQ )
  1880. ( -SNU CSU ) ( -SNV CSV ) ( -SNQ CSQ )
  1881. Z' denotes the transpose of Z.
  1882. Arguments
  1883. =========
  1884. UPPER (input) long* (boolean)
  1885. = TRUE: the input matrices A and B are upper triangular.
  1886. = FALSE: the input matrices A and B are lower triangular.
  1887. A1 (input) double
  1888. A2 (input) double
  1889. A3 (input) double
  1890. On entry, A1, A2 and A3 are elements of the input 2-by-2
  1891. upper (lower) triangular matrix A.
  1892. B1 (input) double
  1893. B2 (input) double
  1894. B3 (input) double
  1895. On entry, B1, B2 and B3 are elements of the input 2-by-2
  1896. upper (lower) triangular matrix B.
  1897. CSU (output) double
  1898. SNU (output) double
  1899. The desired orthogonal matrix U.
  1900. CSV (output) double
  1901. SNV (output) double
  1902. The desired orthogonal matrix V.
  1903. CSQ (output) double
  1904. SNQ (output) double
  1905. The desired orthogonal matrix Q.
  1906. =====================================================================
  1907. */
  1908. int NUMlapack_dlahqr (int * wantt, int * wantz, integer *n, integer *ilo,
  1909. integer *ihi, double *h, integer *ldh, double *wr, double *wi, integer *iloz,
  1910. integer *ihiz, double *z, integer *ldz, integer *info);
  1911. /* -- LAPACK auxiliary routine (version 3.0) --
  1912. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  1913. Courant Institute, Argonne National Lab, and Rice University
  1914. June 30, 1999
  1915. Purpose
  1916. =======
  1917. NUMlapack_dlahqr is an auxiliary routine called by NUMlapack_dhseqr to update the
  1918. eigenvalues and Schur decomposition already computed by NUMlapack_dhseqr, by
  1919. dealing with the Hessenberg submatrix in rows and columns ILO to IHI.
  1920. Arguments
  1921. =========
  1922. WANTT (input) int
  1923. = .TRUE. : the full Schur form T is required;
  1924. = .FALSE.: only eigenvalues are required.
  1925. WANTZ (input) int
  1926. = .TRUE. : the matrix of Schur vectors Z is required;
  1927. = .FALSE.: Schur vectors are not required.
  1928. N (input) long
  1929. The order of the matrix H. N >= 0.
  1930. ILO (input) long
  1931. IHI (input) long
  1932. It is assumed that H is already upper quasi-triangular in
  1933. rows and columns IHI+1:N, and that H(ILO,ILO-1) = 0 (unless
  1934. ILO = 1). NUMlapack_dlahqr works primarily with the Hessenberg
  1935. submatrix in rows and columns ILO to IHI, but applies
  1936. transformations to all of H if WANTT is .TRUE..
  1937. 1 <= ILO <= max(1,IHI); IHI <= N.
  1938. H (input/output) double array, dimension (LDH,N)
  1939. On entry, the upper Hessenberg matrix H.
  1940. On exit, if WANTT is .TRUE., H is upper quasi-triangular in
  1941. rows and columns ILO:IHI, with any 2-by-2 diagonal blocks in
  1942. standard form. If WANTT is .FALSE., the contents of H are
  1943. unspecified on exit.
  1944. LDH (input) long
  1945. The leading dimension of the array H. LDH >= max(1,N).
  1946. WR (output) double array, dimension (N)
  1947. WI (output) double array, dimension (N)
  1948. The real and imaginary parts, respectively, of the computed
  1949. eigenvalues ILO to IHI are stored in the corresponding
  1950. elements of WR and WI. If two eigenvalues are computed as a
  1951. complex conjugate pair, they are stored in consecutive
  1952. elements of WR and WI, say the i-th and (i+1)th, with
  1953. WI(i) > 0 and WI(i+1) < 0. If WANTT is .TRUE., the
  1954. eigenvalues are stored in the same order as on the diagonal
  1955. of the Schur form returned in H, with WR(i) = H(i,i), and, if
  1956. H(i:i+1,i:i+1) is a 2-by-2 diagonal block,
  1957. WI(i) = sqrt(H(i+1,i)*H(i,i+1)) and WI(i+1) = -WI(i).
  1958. ILOZ (input) long
  1959. IHIZ (input) long
  1960. Specify the rows of Z to which transformations must be
  1961. applied if WANTZ is .TRUE..
  1962. 1 <= ILOZ <= ILO; IHI <= IHIZ <= N.
  1963. Z (input/output) double array, dimension (LDZ,N)
  1964. If WANTZ is .TRUE., on entry Z must contain the current
  1965. matrix Z of transformations accumulated by NUMlapack_dhseqr, and on
  1966. exit Z has been updated; transformations are applied only to
  1967. the submatrix Z(ILOZ:IHIZ,ILO:IHI).
  1968. If WANTZ is .FALSE., Z is not referenced.
  1969. LDZ (input) long
  1970. The leading dimension of the array Z. LDZ >= max(1,N).
  1971. INFO (output) long
  1972. = 0: successful exit
  1973. > 0: NUMlapack_dlahqr failed to compute all the eigenvalues ILO to IHI
  1974. in a total of 30*(IHI-ILO+1) iterations; if INFO = i,
  1975. elements i+1:ihi of WR and WI contain those eigenvalues
  1976. which have been successfully computed.
  1977. Further Details
  1978. ===============
  1979. 2-96 Based on modifications by
  1980. David Day, Sandia National Laboratory, USA
  1981. =====================================================================
  1982. */
  1983. int NUMlapack_dlahrd (integer *n, integer *k, integer *nb, double *a, integer *lda,
  1984. double *tau, double *t, integer *ldt, double *y, integer *ldy);
  1985. /* -- LAPACK auxiliary routine (version 3.0) --
  1986. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  1987. Courant Institute, Argonne National Lab, and Rice University
  1988. June 30, 1999
  1989. Purpose
  1990. =======
  1991. NUMlapack_dlahrd reduces the first NB columns of a real general n-by-(n-k+1)
  1992. matrix A so that elements below the k-th subdiagonal are zero. The
  1993. reduction is performed by an orthogonal similarity transformation
  1994. Q' * A * Q. The routine returns the matrices V and T which determine
  1995. Q as a block reflector I - V*T*V', and also the matrix Y = A * V * T.
  1996. This is an auxiliary routine called by NUMlapack_dgehrd.
  1997. Arguments
  1998. =========
  1999. N (input) long
  2000. The order of the matrix A.
  2001. K (input) long
  2002. The offset for the reduction. Elements below the k-th
  2003. subdiagonal in the first NB columns are reduced to zero.
  2004. NB (input) long
  2005. The number of columns to be reduced.
  2006. A (input/output) double array, dimension (LDA,N-K+1)
  2007. On entry, the n-by-(n-k+1) general matrix A.
  2008. On exit, the elements on and above the k-th subdiagonal in
  2009. the first NB columns are overwritten with the corresponding
  2010. elements of the reduced matrix; the elements below the k-th
  2011. subdiagonal, with the array TAU, represent the matrix Q as a
  2012. product of elementary reflectors. The other columns of A are
  2013. unchanged. See Further Details.
  2014. LDA (input) long
  2015. The leading dimension of the array A. LDA >= max(1,N).
  2016. TAU (output) double array, dimension (NB)
  2017. The scalar factors of the elementary reflectors. See Further
  2018. Details.
  2019. T (output) double array, dimension (LDT,NB)
  2020. The upper triangular matrix T.
  2021. LDT (input) long
  2022. The leading dimension of the array T. LDT >= NB.
  2023. Y (output) double array, dimension (LDY,NB)
  2024. The n-by-nb matrix Y.
  2025. LDY (input) long
  2026. The leading dimension of the array Y. LDY >= N.
  2027. Further Details
  2028. ===============
  2029. The matrix Q is represented as a product of nb elementary reflectors
  2030. Q = H(1) H(2) . . . H(nb).
  2031. Each H(i) has the form
  2032. H(i) = I - tau * v * v'
  2033. where tau is a real scalar, and v is a real vector with
  2034. v(1:i+k-1) = 0, v(i+k) = 1; v(i+k+1:n) is stored on exit in
  2035. A(i+k+1:n,i), and tau in TAU(i).
  2036. The elements of the vectors v together form the (n-k+1)-by-nb matrix
  2037. V which is needed, with T and Y, to apply the transformation to the
  2038. unreduced part of the matrix, using an update of the form:
  2039. A := (I - V*T*V') * (A - Y*V').
  2040. The contents of A on exit are illustrated by the following example
  2041. with n = 7, k = 3 and nb = 2:
  2042. ( a h a a a )
  2043. ( a h a a a )
  2044. ( a h a a a )
  2045. ( h h a a a )
  2046. ( v1 h a a a )
  2047. ( v1 v2 a a a )
  2048. ( v1 v2 a a a )
  2049. where a denotes an element of the original matrix A, h denotes a
  2050. modified element of the upper Hessenberg matrix H, and vi denotes an
  2051. element of the vector defining H(i).
  2052. =====================================================================
  2053. */
  2054. int NUMlapack_dlaln2 (int * ltrans, integer *na, integer *nw, double *smin,
  2055. double *ca, double *a, integer *lda, double *d1, double *d2, double *b,
  2056. integer *ldb, double *wr, double *wi, double *x, integer *ldx, double *scale,
  2057. double *xnorm, integer *info);
  2058. /* -- LAPACK auxiliary routine (version 3.0) --
  2059. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  2060. Courant Institute, Argonne National Lab, and Rice University
  2061. October 31, 1992
  2062. Purpose
  2063. =======
  2064. NUMlapack_dlaln2 solves a system of the form (ca A - w D ) X = s B
  2065. or (ca A' - w D) X = s B with possible scaling ("s") and
  2066. perturbation of A. (A' means A-transpose.)
  2067. A is an NA x NA real matrix, ca is a real scalar, D is an NA x NA
  2068. real diagonal matrix, w is a real or complex value, and X and B are
  2069. NA x 1 matrices -- real if w is real, complex if w is complex. NA
  2070. may be 1 or 2.
  2071. If w is complex, X and B are represented as NA x 2 matrices,
  2072. the first column of each being the real part and the second
  2073. being the imaginary part.
  2074. "s" is a scaling factor (.LE. 1), computed by NUMlapack_dlaln2, which is
  2075. so chosen that X can be computed without overflow. X is further
  2076. scaled if necessary to assure that norm(ca A - w D)*norm(X) is less
  2077. than overflow.
  2078. If both singular values of (ca A - w D) are less than SMIN,
  2079. SMIN*identity will be used instead of (ca A - w D). If only one
  2080. singular value is less than SMIN, one element of (ca A - w D) will be
  2081. perturbed enough to make the smallest singular value roughly SMIN.
  2082. If both singular values are at least SMIN, (ca A - w D) will not be
  2083. perturbed. In any case, the perturbation will be at most some small
  2084. multiple of max( SMIN, ulp*norm(ca A - w D) ). The singular values
  2085. are computed by infinity-norm approximations, and thus will only be
  2086. correct to a factor of 2 or so.
  2087. Note: all input quantities are assumed to be smaller than overflow
  2088. by a reasonable factor. (See BIGNUM.)
  2089. Arguments
  2090. ==========
  2091. LTRANS (input) int
  2092. =.TRUE.: A-transpose will be used.
  2093. =.FALSE.: A will be used (not transposed.)
  2094. NA (input) long
  2095. The size of the matrix A. It may (only) be 1 or 2.
  2096. NW (input) long
  2097. 1 if "w" is real, 2 if "w" is complex. It may only be 1
  2098. or 2.
  2099. SMIN (input) double
  2100. The desired lower bound on the singular values of A. This
  2101. should be a safe distance away from underflow or overflow,
  2102. say, between (underflow/machine precision) and (machine
  2103. precision * overflow ). (See BIGNUM and ULP.)
  2104. CA (input) double
  2105. The coefficient c, which A is multiplied by.
  2106. A (input) double array, dimension (LDA,NA)
  2107. The NA x NA matrix A.
  2108. LDA (input) long
  2109. The leading dimension of A. It must be at least NA.
  2110. D1 (input) double
  2111. The 1,1 element in the diagonal matrix D.
  2112. D2 (input) double
  2113. The 2,2 element in the diagonal matrix D. Not used if NW=1.
  2114. B (input) double array, dimension (LDB,NW)
  2115. The NA x NW matrix B (right-hand side). If NW=2 ("w" is
  2116. complex), column 1 contains the real part of B and column 2
  2117. contains the imaginary part.
  2118. LDB (input) long
  2119. The leading dimension of B. It must be at least NA.
  2120. WR (input) double
  2121. The real part of the scalar "w".
  2122. WI (input) double
  2123. The imaginary part of the scalar "w". Not used if NW=1.
  2124. X (output) double array, dimension (LDX,NW)
  2125. The NA x NW matrix X (unknowns), as computed by NUMlapack_dlaln2.
  2126. If NW=2 ("w" is complex), on exit, column 1 will contain
  2127. the real part of X and column 2 will contain the imaginary
  2128. part.
  2129. LDX (input) long
  2130. The leading dimension of X. It must be at least NA.
  2131. SCALE (output) double
  2132. The scale factor that B must be multiplied by to insure
  2133. that overflow does not occur when computing X. Thus,
  2134. (ca A - w D) X will be SCALE*B, not B (ignoring
  2135. perturbations of A.) It will be at most 1.
  2136. XNORM (output) double
  2137. The infinity-norm of X, when X is regarded as an NA x NW
  2138. real matrix.
  2139. INFO (output) long
  2140. An error flag. It will be set to zero if no error occurs,
  2141. a negative number if an argument is in error, or a positive
  2142. number if ca A - w D had to be perturbed.
  2143. The possible values are:
  2144. = 0: No error occurred, and (ca A - w D) did not have to be
  2145. perturbed.
  2146. = 1: (ca A - w D) had to be perturbed to make its smallest
  2147. (or only) singular value greater than SMIN.
  2148. NOTE: In the interests of speed, this routine does not
  2149. check the inputs for errors.
  2150. =====================================================================
  2151. */
  2152. double NUMlapack_dlange (const char *norm, integer *m, integer *n, double *a, integer *lda, double *work);
  2153. /* Purpose
  2154. =======
  2155. NUMlapack_dlange returns the value of the one norm, or the Frobenius norm, or
  2156. the infinity norm, or the element of largest absolute value of a
  2157. real matrix A.
  2158. Description
  2159. ===========
  2160. DLANGE returns the value
  2161. DLANGE = ( max(abs(A(i,j))), NORM = 'M' or 'm'
  2162. (
  2163. ( norm1(A), NORM = '1', 'O' or 'o'
  2164. (
  2165. ( normI(A), NORM = 'I' or 'i'
  2166. (
  2167. ( normF(A), NORM = 'F', 'f', 'E' or 'e'
  2168. where norm1 denotes the one norm of a matrix (maximum column sum),
  2169. normI denotes the infinity norm of a matrix (maximum row sum) and
  2170. normF denotes the Frobenius norm of a matrix (square root of sum of
  2171. squares). Note that max(abs(A(i,j))) is not a matrix norm.
  2172. Arguments
  2173. =========
  2174. NORM (input) char*
  2175. Specifies the value to be returned in DLANGE as described
  2176. above.
  2177. M (input) long
  2178. The number of rows of the matrix A. M >= 0. When M = 0,
  2179. DLANGE is set to zero.
  2180. N (input) long
  2181. The number of columns of the matrix A. N >= 0. When N = 0,
  2182. DLANGE is set to zero.
  2183. A (input) double array, dimension (LDA,N)
  2184. The m by n matrix A.
  2185. LDA (input) long
  2186. The leading dimension of the array A. LDA >= max(M,1).
  2187. WORK (workspace) double array, dimension (LWORK),
  2188. where LWORK >= M when NORM = 'I'; otherwise, WORK is not
  2189. referenced.
  2190. =====================================================================
  2191. */
  2192. double NUMlapack_dlanhs (const char *norm, integer *n, double *a, integer *lda, double *work);
  2193. /* -- LAPACK auxiliary routine (version 3.0) --
  2194. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  2195. Courant Institute, Argonne National Lab, and Rice University
  2196. October 31, 1992
  2197. Purpose
  2198. =======
  2199. NUMlapack_dlanhs returns the value of the one norm, or the Frobenius norm, or
  2200. the infinity norm, or the element of largest absolute value of a
  2201. Hessenberg matrix A.
  2202. Description
  2203. ===========
  2204. NUMlapack_dlanhs returns the value
  2205. NUMlapack_dlanhs =
  2206. ( max(abs(A(i,j))), NORM = 'M' or 'm'
  2207. (
  2208. ( norm1(A), NORM = '1', 'O' or 'o'
  2209. (
  2210. ( normI(A), NORM = 'I' or 'i'
  2211. (
  2212. ( normF(A), NORM = 'F', 'f', 'E' or 'e'
  2213. where norm1 denotes the one norm of a matrix (maximum column sum),
  2214. normI denotes the infinity norm of a matrix (maximum row sum) and
  2215. normF denotes the Frobenius norm of a matrix (square root of sum of
  2216. squares). Note that max(abs(A(i,j))) is not a matrix norm.
  2217. Arguments
  2218. =========
  2219. NORM (input) char*
  2220. Specifies the value to be returned in NUMlapack_dlanhs as described
  2221. above.
  2222. N (input) long
  2223. The order of the matrix A. N >= 0. When N = 0, NUMlapack_dlanhs is
  2224. set to zero.
  2225. A (input) double array, dimension (LDA,N)
  2226. The n by n upper Hessenberg matrix A; the part of A below the
  2227. first sub-diagonal is not referenced.
  2228. LDA (input) long
  2229. The leading dimension of the array A. LDA >= max(N,1).
  2230. WORK (workspace) double array, dimension (LWORK),
  2231. where LWORK >= N when NORM = 'I'; otherwise, WORK is not
  2232. referenced.
  2233. =====================================================================
  2234. */
  2235. double NUMlapack_dlanst (const char *norm, integer *n, double *d, double *e);
  2236. /* Purpose
  2237. =======
  2238. NUMlapack_dlanst returns the value of the one norm, or the Frobenius norm, or
  2239. the infinity norm, or the element of largest absolute value of a
  2240. real symmetric tridiagonal matrix A.
  2241. Description
  2242. ===========
  2243. NUMlapack_dlanst returns the value
  2244. NUMlapack_dlanst =
  2245. ( max(abs(A(i,j))), NORM = 'M' or 'm'
  2246. (
  2247. ( norm1(A), NORM = '1', 'O' or 'o'
  2248. (
  2249. ( normI(A), NORM = 'I' or 'i'
  2250. (
  2251. ( normF(A), NORM = 'F', 'f', 'E' or 'e'
  2252. where norm1 denotes the one norm of a matrix (maximum column sum),
  2253. normI denotes the infinity norm of a matrix (maximum row sum) and
  2254. normF denotes the Frobenius norm of a matrix (square root of sum of
  2255. squares). Note that max(abs(A(i,j))) is not a matrix norm.
  2256. Arguments
  2257. =========
  2258. NORM (input) char*
  2259. Specifies the value to be returned in DLANST as described
  2260. above.
  2261. N (input) long
  2262. The order of the matrix A. N >= 0. When N = 0, DLANST is
  2263. set to zero.
  2264. D (input) double array, dimension (N)
  2265. The diagonal elements of A.
  2266. E (input) double array, dimension (N-1)
  2267. The (n-1) sub-diagonal or super-diagonal elements of A.
  2268. =====================================================================
  2269. */
  2270. double NUMlapack_dlansy (const char *norm, const char *uplo, integer *n, double *a,
  2271. integer *lda, double *work);
  2272. /* Purpose
  2273. =======
  2274. NUMlapack_dlansy returns the value of the one norm, or the Frobenius norm, or
  2275. the infinity norm, or the element of largest absolute value of a
  2276. real symmetric matrix A.
  2277. Description
  2278. ===========
  2279. NUMlapack_dlansy returns the value
  2280. ( max(abs(A(i,j))), NORM = 'M' or 'm'
  2281. (
  2282. ( norm1(A), NORM = '1', 'O' or 'o'
  2283. (
  2284. ( normI(A), NORM = 'I' or 'i'
  2285. (
  2286. ( normF(A), NORM = 'F', 'f', 'E' or 'e'
  2287. where norm1 denotes the one norm of a matrix (maximum column sum),
  2288. normI denotes the infinity norm of a matrix (maximum row sum) and
  2289. normF denotes the Frobenius norm of a matrix (square root of sum of
  2290. squares). Note that max(abs(A(i,j))) is not a matrix norm.
  2291. Arguments
  2292. =========
  2293. NORM (input) char*
  2294. Specifies the value to be returned in DLANSY as described
  2295. above.
  2296. UPLO (input) char*
  2297. Specifies whether the upper or lower triangular part of the
  2298. symmetric matrix A is to be referenced.
  2299. = 'U': Upper triangular part of A is referenced
  2300. = 'L': Lower triangular part of A is referenced
  2301. N (input) long
  2302. The order of the matrix A. N >= 0. When N = 0, DLANSY is
  2303. set to zero.
  2304. A (input) double array, dimension (LDA,N)
  2305. The symmetric matrix A. If UPLO = 'U', the leading n by n
  2306. upper triangular part of A contains the upper triangular part
  2307. of the matrix A, and the strictly lower triangular part of A
  2308. is not referenced. If UPLO = 'L', the leading n by n lower
  2309. triangular part of A contains the lower triangular part of
  2310. the matrix A, and the strictly upper triangular part of A is
  2311. not referenced.
  2312. LDA (input) long
  2313. The leading dimension of the array A. LDA >= max(N,1).
  2314. WORK (workspace) double array, dimension (LWORK),
  2315. where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
  2316. WORK is not referenced.
  2317. =====================================================================
  2318. */
  2319. int NUMlapack_dlanv2 (double *a, double *b, double *c, double *d, double *rt1r,
  2320. double *rt1i, double *rt2r, double *rt2i, double *cs, double *sn);
  2321. /* -- LAPACK driver routine (version 3.0) --
  2322. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  2323. Courant Institute, Argonne National Lab, and Rice University
  2324. June 30, 1999
  2325. Purpose
  2326. =======
  2327. NUMlapack_dlanv2 computes the Schur factorization of a real 2-by-2 nonsymmetric
  2328. matrix in standard form:
  2329. [ A B ] = [ CS -SN ] [ AA BB ] [ CS SN ]
  2330. [ C D ] [ SN CS ] [ CC DD ] [-SN CS ]
  2331. where either
  2332. 1) CC = 0 so that AA and DD are real eigenvalues of the matrix, or
  2333. 2) AA = DD and BB*CC < 0, so that AA + or - sqrt(BB*CC) are complex
  2334. conjugate eigenvalues.
  2335. Arguments
  2336. =========
  2337. A (input/output) double
  2338. B (input/output) double
  2339. C (input/output) double
  2340. D (input/output) double
  2341. On entry, the elements of the input matrix.
  2342. On exit, they are overwritten by the elements of the
  2343. standardised Schur form.
  2344. RT1R (output) double
  2345. RT1I (output) double
  2346. RT2R (output) double
  2347. RT2I (output) double
  2348. The real and imaginary parts of the eigenvalues. If the
  2349. eigenvalues are a complex conjugate pair, RT1I > 0.
  2350. CS (output) double
  2351. SN (output) double
  2352. Parameters of the rotation matrix.
  2353. Further Details
  2354. ===============
  2355. Modified by V. Sima, Research Institute for Informatics, Bucharest,
  2356. Romania, to reduce the risk of cancellation errors,
  2357. when computing real eigenvalues, and to ensure, if possible, that
  2358. abs(RT1R) >= abs(RT2R).
  2359. =====================================================================
  2360. */
  2361. int NUMlapack_dlapll(integer *n, double *x, integer *incx, double *y, integer *incy, double *ssmin);
  2362. /* Purpose
  2363. =======
  2364. Given two column vectors X and Y, let
  2365. A = ( X Y ).
  2366. The subroutine first computes the QR factorization of A = Q*R,
  2367. and then computes the SVD of the 2-by-2 upper triangular matrix R.
  2368. The smaller singular value of R is returned in SSMIN, which is used
  2369. as the measurement of the linear dependency of the vectors X and Y.
  2370. Arguments
  2371. =========
  2372. N (input) long
  2373. The length of the vectors X and Y.
  2374. X (input/output) double array,
  2375. dimension (1+(N-1)*INCX)
  2376. On entry, X contains the N-vector X.
  2377. On exit, X is overwritten.
  2378. INCX (input) long
  2379. The increment between successive elements of X. INCX > 0.
  2380. Y (input/output) double array,
  2381. dimension (1+(N-1)*INCY)
  2382. On entry, Y contains the N-vector Y.
  2383. On exit, Y is overwritten.
  2384. INCY (input) long
  2385. The increment between successive elements of Y. INCY > 0.
  2386. SSMIN (output) double
  2387. The smallest singular value of the N-by-2 matrix A = ( X Y ).
  2388. =====================================================================
  2389. */
  2390. double NUMlapack_dlapy2 (double *x, double *y);
  2391. /* Purpose
  2392. =======
  2393. NUMlapack_dlapy2 returns sqrt(x**2+y**2), taking care not to cause unnecessary
  2394. overflow.
  2395. Arguments
  2396. =========
  2397. X (input) double
  2398. Y (input) double
  2399. X and Y specify the values x and y.
  2400. =====================================================================
  2401. */
  2402. int NUMlapack_dlapmt (integer *forwrd, integer *m, integer *n, double *x, integer *ldx, integer *k);
  2403. /* Purpose
  2404. =======
  2405. NUMlapack_dlapmt rearranges the columns of the M by N matrix X as specified
  2406. by the permutation K(1),K(2),...,K(N) of the integers 1,...,N.
  2407. If FORWRD = TRUE, forward permutation:
  2408. X(*,K(J)) is moved X(*,J) for J = 1,2,...,N.
  2409. If FORWRD = FALSE, backward permutation:
  2410. X(*,J) is moved to X(*,K(J)) for J = 1,2,...,N.
  2411. Arguments
  2412. =========
  2413. FORWRD (input) long* (boolean)
  2414. = TRUE, forward permutation
  2415. = FALSE, backward permutation
  2416. M (input) long
  2417. The number of rows of the matrix X. M >= 0.
  2418. N (input) long
  2419. The number of columns of the matrix X. N >= 0.
  2420. X (input/output) double array, dimension (LDX,N)
  2421. On entry, the M by N matrix X.
  2422. On exit, X contains the permuted matrix X.
  2423. LDX (input) long
  2424. The leading dimension of the array X, LDX >= MAX(1,M).
  2425. K (input) long array, dimension (N)
  2426. On entry, K contains the permutation vector.
  2427. =====================================================================
  2428. */
  2429. int NUMlapack_dlarf (const char *side, integer *m, integer *n, double *v, integer *incv, double *tau,
  2430. double *c, integer *ldc, double *work);
  2431. /*
  2432. Purpose
  2433. =======
  2434. NUMlapack_dlarf applies a real elementary reflector H to a real m by n matrix
  2435. C, from either the left or the right. H is represented in the form
  2436. H = I - tau * v * v'
  2437. where tau is a real scalar and v is a real vector.
  2438. If tau = 0, then H is taken to be the unit matrix.
  2439. Arguments
  2440. =========
  2441. SIDE (input) char*
  2442. = 'L': form H * C
  2443. = 'R': form C * H
  2444. M (input) long
  2445. The number of rows of the matrix C.
  2446. N (input) long
  2447. The number of columns of the matrix C.
  2448. V (input) double array, dimension
  2449. (1 + (M-1)*abs(INCV)) if SIDE = 'L'
  2450. or (1 + (N-1)*abs(INCV)) if SIDE = 'R'
  2451. The vector v in the representation of H. V is not used if
  2452. TAU = 0.
  2453. INCV (input) long
  2454. The increment between elements of v. INCV <> 0.
  2455. TAU (input) double
  2456. The value tau in the representation of H.
  2457. C (input/output) double array, dimension (LDC,N)
  2458. On entry, the m by n matrix C.
  2459. On exit, C is overwritten by the matrix H * C if SIDE = 'L',
  2460. or C * H if SIDE = 'R'.
  2461. LDC (input) long
  2462. The leading dimension of the array C. LDC >= max(1,M).
  2463. WORK (workspace) double array, dimension
  2464. (N) if SIDE = 'L'
  2465. or (M) if SIDE = 'R'
  2466. =====================================================================
  2467. */
  2468. int NUMlapack_dlarfb (const char *side, const char *trans, const char *direct, const char *storev,
  2469. integer *m, integer *n, integer *k, double *v, integer *ldv, double *t, integer *ldt,
  2470. double *c, integer *ldc, double *work, integer *ldwork);
  2471. /* Purpose
  2472. =======
  2473. NUMlapack_dlarfb applies a real block reflector H or its transpose H' to a
  2474. real m by n matrix C, from either the left or the right.
  2475. Arguments
  2476. =========
  2477. SIDE (input) char*
  2478. = 'L': apply H or H' from the Left
  2479. = 'R': apply H or H' from the Right
  2480. TRANS (input) char*
  2481. = 'N': apply H (No transpose)
  2482. = 'T': apply H' (Transpose)
  2483. DIRECT (input) char*
  2484. Indicates how H is formed from a product of elementary
  2485. reflectors
  2486. = 'F': H = H(1) H(2) . . . H(k) (Forward)
  2487. = 'B': H = H(k) . . . H(2) H(1) (Backward)
  2488. STOREV (input) char*
  2489. Indicates how the vectors which define the elementary
  2490. reflectors are stored:
  2491. = 'C': Columnwise
  2492. = 'R': Rowwise
  2493. M (input) long
  2494. The number of rows of the matrix C.
  2495. N (input) long
  2496. The number of columns of the matrix C.
  2497. K (input) long
  2498. The order of the matrix T (= the number of elementary
  2499. reflectors whose product defines the block reflector).
  2500. V (input) double array, dimension
  2501. (LDV,K) if STOREV = 'C'
  2502. (LDV,M) if STOREV = 'R' and SIDE = 'L'
  2503. (LDV,N) if STOREV = 'R' and SIDE = 'R'
  2504. The matrix V. See further details.
  2505. LDV (input) long
  2506. The leading dimension of the array V.
  2507. If STOREV = 'C' and SIDE = 'L', LDV >= max(1,M);
  2508. if STOREV = 'C' and SIDE = 'R', LDV >= max(1,N);
  2509. if STOREV = 'R', LDV >= K.
  2510. T (input) double array, dimension (LDT,K)
  2511. The triangular k by k matrix T in the representation of the
  2512. block reflector.
  2513. LDT (input) long
  2514. The leading dimension of the array T. LDT >= K.
  2515. C (input/output) double array, dimension (LDC,N)
  2516. On entry, the m by n matrix C.
  2517. On exit, C is overwritten by H*C or H'*C or C*H or C*H'.
  2518. LDC (input) long
  2519. The leading dimension of the array C. LDA >= max(1,M).
  2520. WORK (workspace) double array, dimension (LDWORK,K)
  2521. LDWORK (input) long
  2522. The leading dimension of the array WORK.
  2523. If SIDE = 'L', LDWORK >= max(1,N);
  2524. if SIDE = 'R', LDWORK >= max(1,M).
  2525. =====================================================================
  2526. */
  2527. int NUMlapack_dlarfg (integer *n, double *alpha, double *x, integer *incx, double *tau);
  2528. /* Purpose
  2529. =======
  2530. NUMlapack_dlarfg generates a real elementary reflector H of order n, such
  2531. that
  2532. H * ( alpha ) = ( beta ), H' * H = I.
  2533. ( x ) ( 0 )
  2534. where alpha and beta are scalars, and x is an (n-1)-element real
  2535. vector. H is represented in the form
  2536. H = I - tau * ( 1 ) * ( 1 v' ) ,
  2537. ( v )
  2538. where tau is a real scalar and v is a real (n-1)-element
  2539. vector.
  2540. If the elements of x are all zero, then tau = 0 and H is taken to be
  2541. the unit matrix.
  2542. Otherwise 1 <= tau <= 2.
  2543. Arguments
  2544. =========
  2545. N (input) long
  2546. The order of the elementary reflector.
  2547. ALPHA (input/output) double
  2548. On entry, the value alpha.
  2549. On exit, it is overwritten with the value beta.
  2550. X (input/output) double array, dimension
  2551. (1+(N-2)*abs(INCX))
  2552. On entry, the vector x.
  2553. On exit, it is overwritten with the vector v.
  2554. INCX (input) long
  2555. The increment between elements of X. INCX > 0.
  2556. TAU (output) double
  2557. The value tau.
  2558. =====================================================================
  2559. */
  2560. int NUMlapack_dlarft (const char *direct, const char *storev, integer *n, integer *k,
  2561. double *v, integer *ldv, double *tau, double *t, integer *ldt);
  2562. /* Purpose
  2563. =======
  2564. NUMlapack_dlarft forms the triangular factor T of a real block reflector H
  2565. of order n, which is defined as a product of k elementary reflectors.
  2566. If DIRECT = 'F', H = H(1) H(2) . . . H(k) and T is upper triangular;
  2567. If DIRECT = 'B', H = H(k) . . . H(2) H(1) and T is lower triangular.
  2568. If STOREV = 'C', the vector which defines the elementary reflector
  2569. H(i) is stored in the i-th column of the array V, and
  2570. H = I - V * T * V'
  2571. If STOREV = 'R', the vector which defines the elementary reflector
  2572. H(i) is stored in the i-th row of the array V, and
  2573. H = I - V' * T * V
  2574. Arguments
  2575. =========
  2576. DIRECT (input) char*
  2577. Specifies the order in which the elementary reflectors are
  2578. multiplied to form the block reflector:
  2579. = 'F': H = H(1) H(2) . . . H(k) (Forward)
  2580. = 'B': H = H(k) . . . H(2) H(1) (Backward)
  2581. STOREV (input) char*
  2582. Specifies how the vectors which define the elementary
  2583. reflectors are stored (see also Further Details):
  2584. = 'C': columnwise
  2585. = 'R': rowwise
  2586. N (input) long
  2587. The order of the block reflector H. N >= 0.
  2588. K (input) long
  2589. The order of the triangular factor T (= the number of
  2590. elementary reflectors). K >= 1.
  2591. V (input/output) double array, dimension
  2592. (LDV,K) if STOREV = 'C'
  2593. (LDV,N) if STOREV = 'R'
  2594. The matrix V. See further details.
  2595. LDV (input) long
  2596. The leading dimension of the array V.
  2597. If STOREV = 'C', LDV >= max(1,N); if STOREV = 'R', LDV >= K.
  2598. TAU (input) double array, dimension (K)
  2599. TAU(i) must contain the scalar factor of the elementary
  2600. reflector H(i).
  2601. T (output) double array, dimension (LDT,K)
  2602. The k by k triangular factor T of the block reflector.
  2603. If DIRECT = 'F', T is upper triangular; if DIRECT = 'B', T is
  2604. lower triangular. The rest of the array is not used.
  2605. LDT (input) long
  2606. The leading dimension of the array T. LDT >= K.
  2607. Further Details
  2608. ===============
  2609. The shape of the matrix V and the storage of the vectors which define
  2610. the H(i) is best illustrated by the following example with n = 5 and
  2611. k = 3. The elements equal to 1 are not stored; the corresponding
  2612. array elements are modified but restored on exit. The rest of the
  2613. array is not used.
  2614. DIRECT = 'F' and STOREV = 'C': DIRECT = 'F' and STOREV = 'R':
  2615. V = ( 1 ) V = ( 1 v1 v1 v1 v1 )
  2616. ( v1 1 ) ( 1 v2 v2 v2 )
  2617. ( v1 v2 1 ) ( 1 v3 v3 )
  2618. ( v1 v2 v3 )
  2619. ( v1 v2 v3 )
  2620. DIRECT = 'B' and STOREV = 'C': DIRECT = 'B' and STOREV = 'R':
  2621. V = ( v1 v2 v3 ) V = ( v1 v1 1 )
  2622. ( v1 v2 v3 ) ( v2 v2 v2 1 )
  2623. ( 1 v2 v3 ) ( v3 v3 v3 v3 1 )
  2624. ( 1 v3 )
  2625. ( 1 )
  2626. =====================================================================
  2627. */
  2628. int NUMlapack_dlarfx (const char *side, integer *m, integer *n, double *v, double *tau,
  2629. double *c, integer *ldc, double *work);
  2630. /* -- LAPACK auxiliary routine (version 3.0) --
  2631. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  2632. Courant Institute, Argonne National Lab, and Rice University
  2633. February 29, 1992
  2634. Purpose
  2635. =======
  2636. NUMlapack_dlarfx applies a real elementary reflector H to a real m by n
  2637. matrix C, from either the left or the right. H is represented in the
  2638. form
  2639. H = I - tau * v * v'
  2640. where tau is a real scalar and v is a real vector.
  2641. If tau = 0, then H is taken to be the unit matrix
  2642. This version uses inline code if H has order < 11.
  2643. Arguments
  2644. =========
  2645. SIDE (input) char*
  2646. = 'L': form H * C
  2647. = 'R': form C * H
  2648. M (input) long
  2649. The number of rows of the matrix C.
  2650. N (input) long
  2651. The number of columns of the matrix C.
  2652. V (input) double array, dimension (M) if SIDE = 'L'
  2653. or (N) if SIDE = 'R'
  2654. The vector v in the representation of H.
  2655. TAU (input) double
  2656. The value tau in the representation of H.
  2657. C (input/output) double array, dimension (LDC,N)
  2658. On entry, the m by n matrix C.
  2659. On exit, C is overwritten by the matrix H * C if SIDE = 'L',
  2660. or C * H if SIDE = 'R'.
  2661. LDC (input) long
  2662. The leading dimension of the array C. LDA >= (1,M).
  2663. WORK (workspace) double array, dimension
  2664. (N) if SIDE = 'L'
  2665. or (M) if SIDE = 'R'
  2666. WORK is not referenced if H has order < 11.
  2667. =====================================================================
  2668. */
  2669. int NUMlapack_dlartg (double *f, double *g, double *cs, double *sn, double *r);
  2670. /* Purpose
  2671. =======
  2672. NUMlapack_dlartg generate a plane rotation so that
  2673. [ CS SN ] . [ F ] = [ R ] where CS**2 + SN**2 = 1.
  2674. [ -SN CS ] [ G ] [ 0 ]
  2675. This is a slower, more accurate version of the BLAS1 routine DROTG,
  2676. with the following other differences:
  2677. F and G are unchanged on return.
  2678. If G=0, then CS=1 and SN=0.
  2679. If F=0 and (G .ne. 0), then CS=0 and SN=1 without doing any
  2680. floating point operations (saves work in DBDSQR when
  2681. there are zeros on the diagonal).
  2682. If F exceeds G in magnitude, CS will be positive.
  2683. Arguments
  2684. =========
  2685. F (input) double
  2686. The first component of vector to be rotated.
  2687. G (input) double
  2688. The second component of vector to be rotated.
  2689. CS (output) double
  2690. The cosine of the rotation.
  2691. SN (output) double
  2692. The sine of the rotation.
  2693. R (output) double
  2694. The nonzero component of the rotated vector.
  2695. =====================================================================
  2696. */
  2697. int NUMlapack_dlas2 (double *f, double *g, double *h, double *ssmin, double *ssmax);
  2698. /* Purpose
  2699. =======
  2700. NUMlapack_dlas2 computes the singular values of the 2-by-2 matrix
  2701. [ F G ]
  2702. [ 0 H ].
  2703. On return, SSMIN is the smaller singular value and SSMAX is the
  2704. larger singular value.
  2705. Arguments
  2706. =========
  2707. F (input) double
  2708. The (1,1) element of the 2-by-2 matrix.
  2709. G (input) double
  2710. The (1,2) element of the 2-by-2 matrix.
  2711. H (input) double
  2712. The (2,2) element of the 2-by-2 matrix.
  2713. SSMIN (output) double
  2714. The smaller singular value.
  2715. SSMAX (output) double
  2716. The larger singular value.
  2717. Further Details
  2718. ===============
  2719. Barring over/underflow, all output quantities are correct to within
  2720. a few units in the last place (ulps), even in the absence of a guard
  2721. digit in addition/subtraction.
  2722. In IEEE arithmetic, the code works correctly if one matrix element is
  2723. infinite.
  2724. Overflow will not occur unless the largest singular value itself
  2725. overflows, or is within a few ulps of overflow. (On machines with
  2726. partial overflow, like the Cray, overflow may occur if the largest
  2727. singular value is within a factor of 2 of overflow.)
  2728. Underflow is harmless if underflow is gradual. Otherwise, results
  2729. may correspond to a matrix modified by perturbations of size near
  2730. the underflow threshold.
  2731. ====================================================================
  2732. */
  2733. int NUMlapack_dlascl (const char *type, integer *kl, integer *ku, double *cfrom, double *cto,
  2734. integer *m, integer *n, double *a, integer *lda, integer *info);
  2735. /* Purpose
  2736. =======
  2737. NUMlapack_dlascl multiplies the M by N real matrix A by the real scalar
  2738. CTO/CFROM. This is done without over/underflow as long as the final
  2739. result CTO*A(I,J)/CFROM does not over/underflow. TYPE specifies that
  2740. A may be full, upper triangular, lower triangular, upper Hessenberg,
  2741. or banded.
  2742. Arguments
  2743. =========
  2744. TYPE (input) char*
  2745. TYPE indices the storage type of the input matrix.
  2746. = 'G': A is a full matrix.
  2747. = 'L': A is a lower triangular matrix.
  2748. = 'U': A is an upper triangular matrix.
  2749. = 'H': A is an upper Hessenberg matrix.
  2750. = 'B': A is a symmetric band matrix with lower bandwidth KL
  2751. and upper bandwidth KU and with the only the lower
  2752. half stored.
  2753. = 'Q': A is a symmetric band matrix with lower bandwidth KL
  2754. and upper bandwidth KU and with the only the upper
  2755. half stored.
  2756. = 'Z': A is a band matrix with lower bandwidth KL and upper
  2757. bandwidth KU.
  2758. KL (input) long
  2759. The lower bandwidth of A. Referenced only if TYPE = 'B',
  2760. 'Q' or 'Z'.
  2761. KU (input) long
  2762. The upper bandwidth of A. Referenced only if TYPE = 'B',
  2763. 'Q' or 'Z'.
  2764. CFROM (input) double
  2765. CTO (input) double
  2766. The matrix A is multiplied by CTO/CFROM. A(I,J) is computed
  2767. without over/underflow if the final result CTO*A(I,J)/CFROM
  2768. can be represented without over/underflow. CFROM must be
  2769. nonzero.
  2770. M (input) long
  2771. The number of rows of the matrix A. M >= 0.
  2772. N (input) long
  2773. The number of columns of the matrix A. N >= 0.
  2774. A (input/output) double array, dimension (LDA,M)
  2775. The matrix to be multiplied by CTO/CFROM. See TYPE for the
  2776. storage type.
  2777. LDA (input) long
  2778. The leading dimension of the array A. LDA >= max(1,M).
  2779. INFO (output) long
  2780. 0 - successful exit
  2781. <0 - if INFO = -i, the i-th argument had an illegal value.
  2782. =====================================================================
  2783. */
  2784. int NUMlapack_dlaset (const char *uplo, integer *m, integer *n, double *alpha, double *beta,
  2785. double *a, integer *lda);
  2786. /* Purpose
  2787. =======
  2788. NUMlapack_dlaset initializes an m-by-n matrix A to BETA on the diagonal and
  2789. ALPHA on the offdiagonals.
  2790. Arguments
  2791. =========
  2792. UPLO (input) char*
  2793. Specifies the part of the matrix A to be set.
  2794. = 'U': Upper triangular part is set; the strictly lower
  2795. triangular part of A is not changed.
  2796. = 'L': Lower triangular part is set; the strictly upper
  2797. triangular part of A is not changed.
  2798. Otherwise: All of the matrix A is set.
  2799. M (input) long
  2800. The number of rows of the matrix A. M >= 0.
  2801. N (input) long
  2802. The number of columns of the matrix A. N >= 0.
  2803. ALPHA (input) double
  2804. The constant to which the offdiagonal elements are to be set.
  2805. BETA (input) double
  2806. The constant to which the diagonal elements are to be set.
  2807. A (input/output) double array, dimension (LDA,N)
  2808. On exit, the leading m-by-n submatrix of A is set as follows:
  2809. if UPLO = 'U', A(i,j) = ALPHA, 1<=i<=j-1, 1<=j<=n,
  2810. if UPLO = 'L', A(i,j) = ALPHA, j+1<=i<=m, 1<=j<=n,
  2811. otherwise, A(i,j) = ALPHA, 1<=i<=m, 1<=j<=n, i.ne.j,
  2812. and, for all UPLO, A(i,i) = BETA, 1<=i<=min(m,n).
  2813. LDA (input) long
  2814. The leading dimension of the array A. LDA >= max(1,M).
  2815. =====================================================================
  2816. */
  2817. int NUMlapack_dlasq1 (integer *n, double *d, double *e, double *work, integer *info);
  2818. /* Purpose
  2819. =======
  2820. NUMlapack_dlasq1 computes the singular values of a real N-by-N bidiagonal
  2821. matrix with diagonal D and off-diagonal E. The singular values
  2822. are computed to high relative accuracy, in the absence of
  2823. denormalization, underflow and overflow. The algorithm was first
  2824. presented in
  2825. "Accurate singular values and differential qd algorithms" by K. V.
  2826. Fernando and B. N. Parlett, Numer. Math., Vol-67, No. 2, pp. 191-230,
  2827. 1994,
  2828. and the present implementation is described in "An implementation of
  2829. the dqds Algorithm (Positive Case)", LAPACK Working Note.
  2830. Arguments
  2831. =========
  2832. N (input) long
  2833. The number of rows and columns in the matrix. N >= 0.
  2834. D (input/output) double array, dimension (N)
  2835. On entry, D contains the diagonal elements of the
  2836. bidiagonal matrix whose SVD is desired. On normal exit,
  2837. D contains the singular values in decreasing order.
  2838. E (input/output) double array, dimension (N)
  2839. On entry, elements E(1:N-1) contain the off-diagonal elements
  2840. of the bidiagonal matrix whose SVD is desired.
  2841. On exit, E is overwritten.
  2842. WORK (workspace) double array, dimension (4*N)
  2843. INFO (output) long
  2844. = 0: successful exit
  2845. < 0: if INFO = -i, the i-th argument had an illegal value
  2846. > 0: the algorithm failed
  2847. = 1, a split was marked by a positive value in E
  2848. = 2, current block of Z not diagonalized after 30*N
  2849. iterations (in inner while loop)
  2850. = 3, termination criterion of outer while loop not met
  2851. (program created more than N unreduced blocks)
  2852. =====================================================================
  2853. */
  2854. int NUMlapack_dlasq2 (integer *n, double *z, integer *info);
  2855. /* Purpose
  2856. =======
  2857. NUMlapack_dlasq2 computes all the eigenvalues of the symmetric positive
  2858. definite tridiagonal matrix associated with the qd array Z to high
  2859. relative accuracy are computed to high relative accuracy, in the
  2860. absence of denormalization, underflow and overflow.
  2861. To see the relation of Z to the tridiagonal matrix, let L be a
  2862. unit lower bidiagonal matrix with subdiagonals Z(2,4,6,,..) and
  2863. let U be an upper bidiagonal matrix with 1's above and diagonal
  2864. Z(1,3,5,,..). The tridiagonal is L*U or, if you prefer, the
  2865. symmetric tridiagonal to which it is similar.
  2866. Note : NUMlapack_dlasq2 defines a long* (boolean) variable, IEEE, which is true
  2867. on machines which follow ieee-754 floating-point standard in their
  2868. handling of infinities and NaNs, and false otherwise. This variable
  2869. is passed to NUMlapack_dlasq3.
  2870. Arguments
  2871. =========
  2872. N (input) long
  2873. The number of rows and columns in the matrix. N >= 0.
  2874. Z (workspace) double array, dimension ( 4*N )
  2875. On entry Z holds the qd array. On exit, entries 1 to N hold
  2876. the eigenvalues in decreasing order, Z( 2*N+1 ) holds the
  2877. trace, and Z( 2*N+2 ) holds the sum of the eigenvalues. If
  2878. N > 2, then Z( 2*N+3 ) holds the iteration count, Z( 2*N+4 )
  2879. holds NDIVS/NIN^2, and Z( 2*N+5 ) holds the percentage of
  2880. shifts that failed.
  2881. INFO (output) long
  2882. = 0: successful exit
  2883. < 0: if the i-th argument is a scalar and had an illegal
  2884. value, then INFO = -i, if the i-th argument is an
  2885. array and the j-entry had an illegal value, then
  2886. INFO = -(i*100+j)
  2887. > 0: the algorithm failed
  2888. = 1, a split was marked by a positive value in E
  2889. = 2, current block of Z not diagonalized after 30*N
  2890. iterations (in inner while loop)
  2891. = 3, termination criterion of outer while loop not met
  2892. (program created more than N unreduced blocks)
  2893. Further Details
  2894. ===============
  2895. Local Variables: I0:N0 defines a current unreduced segment of Z.
  2896. The shifts are accumulated in SIGMA. Iteration count is in ITER.
  2897. Ping-pong is controlled by PP (alternates between 0 and 1).
  2898. =====================================================================
  2899. */
  2900. int NUMlapack_dlasq3 (integer *i0, integer *n0, double *z, integer *pp, double *dmin,
  2901. double *sigma, double *desig, double *qmax, integer *nfail, integer *iter,
  2902. integer *ndiv, integer *ieee);
  2903. /* Purpose
  2904. =======
  2905. NUMlapack_dlasq3 checks for deflation, computes a shift (TAU) and calls dqds.
  2906. In case of failure it changes shifts, and tries again until output
  2907. is positive.
  2908. Arguments
  2909. =========
  2910. I0 (input) long
  2911. First index.
  2912. N0 (input) long
  2913. Last index.
  2914. Z (input) double array, dimension ( 4*N )
  2915. Z holds the qd array.
  2916. PP (input) long
  2917. PP=0 for ping, PP=1 for pong.
  2918. DMIN (output) double
  2919. Minimum value of d.
  2920. SIGMA (output) double
  2921. Sum of shifts used in current segment.
  2922. DESIG (input/output) double
  2923. Lower order part of SIGMA
  2924. QMAX (input) double
  2925. Maximum value of q.
  2926. NFAIL (output) long
  2927. Number of times shift was too big.
  2928. ITER (output) long
  2929. Number of iterations.
  2930. NDIV (output) long
  2931. Number of divisions.
  2932. TTYPE (output) long
  2933. Shift type.
  2934. IEEE (input) long* (boolean)
  2935. Flag for IEEE or non IEEE arithmetic (passed to DLASQ5).
  2936. =====================================================================
  2937. */
  2938. int NUMlapack_dlasq4 (integer *i0, integer *n0, double *z, integer *pp, integer *n0in, double *dmin,
  2939. double *dmin1, double *dmin2, double *dn, double *dn1, double *dn2,
  2940. double *tau, integer *ttype);
  2941. /* Purpose
  2942. =======
  2943. NUMlapack_dlasq4 computes an approximation TAU to the smallest eigenvalue
  2944. using values of d from the previous transform.
  2945. I0 (input) long
  2946. First index.
  2947. N0 (input) long
  2948. Last index.
  2949. Z (input) double array, dimension ( 4*N )
  2950. Z holds the qd array.
  2951. PP (input) long
  2952. PP=0 for ping, PP=1 for pong.
  2953. NOIN (input) long
  2954. The value of N0 at start of EIGTEST.
  2955. DMIN (input) double
  2956. Minimum value of d.
  2957. DMIN1 (input) double
  2958. Minimum value of d, excluding D( N0 ).
  2959. DMIN2 (input) double
  2960. Minimum value of d, excluding D( N0 ) and D( N0-1 ).
  2961. DN (input) double
  2962. d(N)
  2963. DN1 (input) double
  2964. d(N-1)
  2965. DN2 (input) double
  2966. d(N-2)
  2967. TAU (output) double
  2968. This is the shift.
  2969. TTYPE (output) long
  2970. Shift type.
  2971. Further Details
  2972. ===============
  2973. CNST1 = 9/16
  2974. =====================================================================
  2975. */
  2976. int NUMlapack_dlasq5 (integer *i0, integer *n0, double *z, integer *pp, double *tau, double *dmin,
  2977. double *dmin1, double *dmin2, double *dn, double *dnm1, double *dnm2, integer *ieee);
  2978. /* Purpose
  2979. =======
  2980. NUMlapack_dlasq5 computes one dqds transform in ping-pong form, one
  2981. version for IEEE machines another for non IEEE machines.
  2982. Arguments
  2983. =========
  2984. I0 (input) long
  2985. First index.
  2986. N0 (input) long
  2987. Last index.
  2988. Z (input) double array, dimension ( 4*N )
  2989. Z holds the qd array. EMIN is stored in Z(4*N0) to avoid
  2990. an extra argument.
  2991. PP (input) long
  2992. PP=0 for ping, PP=1 for pong.
  2993. TAU (input) double
  2994. This is the shift.
  2995. DMIN (output) double
  2996. Minimum value of d.
  2997. DMIN1 (output) double
  2998. Minimum value of d, excluding D( N0 ).
  2999. DMIN2 (output) double
  3000. Minimum value of d, excluding D( N0 ) and D( N0-1 ).
  3001. DN (output) double
  3002. d(N0), the last value of d.
  3003. DNM1 (output) double
  3004. d(N0-1).
  3005. DNM2 (output) double
  3006. d(N0-2).
  3007. IEEE (input) long* (boolean)
  3008. Flag for IEEE or non IEEE arithmetic.
  3009. =====================================================================
  3010. */
  3011. int NUMlapack_dlasq6 (integer *i0, integer *n0, double *z, integer *pp, double *dmin,
  3012. double *dmin1, double *dmin2, double *dn, double *dnm1, double *dnm2);
  3013. /* Purpose
  3014. =======
  3015. NUMlapack_dlasq6 computes one dqd (shift equal to zero) transform in
  3016. ping-pong form, with protection against underflow and overflow.
  3017. Arguments
  3018. =========
  3019. I0 (input) long
  3020. First index.
  3021. N0 (input) long
  3022. Last index.
  3023. Z (input) double array, dimension ( 4*N )
  3024. Z holds the qd array. EMIN is stored in Z(4*N0) to avoid
  3025. an extra argument.
  3026. PP (input) long
  3027. PP=0 for ping, PP=1 for pong.
  3028. DMIN (output) double
  3029. Minimum value of d.
  3030. DMIN1 (output) double
  3031. Minimum value of d, excluding D( N0 ).
  3032. DMIN2 (output) double
  3033. Minimum value of d, excluding D( N0 ) and D( N0-1 ).
  3034. DN (output) double
  3035. d(N0), the last value of d.
  3036. DNM1 (output) double
  3037. d(N0-1).
  3038. DNM2 (output) double
  3039. d(N0-2).
  3040. =====================================================================
  3041. */
  3042. int NUMlapack_dlasr (const char *side, const char *pivot, const char *direct, integer *m,
  3043. integer *n, double *c, double *s, double *a, integer *lda);
  3044. /* Purpose
  3045. =======
  3046. NUMlapack_dlasr performs the transformation
  3047. A := P*A, when SIDE = 'L' or 'l' ( Left-hand side )
  3048. A := A*P', when SIDE = 'R' or 'r' ( Right-hand side )
  3049. where A is an m by n real matrix and P is an orthogonal matrix,
  3050. consisting of a sequence of plane rotations determined by the
  3051. parameters PIVOT and DIRECT as follows ( z = m when SIDE = 'L' or 'l'
  3052. and z = n when SIDE = 'R' or 'r' ):
  3053. When DIRECT = 'F' or 'f' ( Forward sequence ) then
  3054. P = P( z - 1 )*...*P( 2 )*P( 1 ),
  3055. and when DIRECT = 'B' or 'b' ( Backward sequence ) then
  3056. P = P( 1 )*P( 2 )*...*P( z - 1 ),
  3057. where P( k ) is a plane rotation matrix for the following planes:
  3058. when PIVOT = 'V' or 'v' ( Variable pivot ),
  3059. the plane ( k, k + 1 )
  3060. when PIVOT = 'T' or 't' ( Top pivot ),
  3061. the plane ( 1, k + 1 )
  3062. when PIVOT = 'B' or 'b' ( Bottom pivot ),
  3063. the plane ( k, z )
  3064. c( k ) and s( k ) must contain the cosine and sine that define the
  3065. matrix P( k ). The two by two plane rotation part of the matrix
  3066. P( k ), R( k ), is assumed to be of the form
  3067. R( k ) = ( c( k ) s( k ) ).
  3068. ( -s( k ) c( k ) )
  3069. This version vectorises across rows of the array A when SIDE = 'L'.
  3070. Arguments
  3071. =========
  3072. SIDE (input) char*
  3073. Specifies whether the plane rotation matrix P is applied to
  3074. A on the left or the right.
  3075. = 'L': Left, compute A := P*A
  3076. = 'R': Right, compute A:= A*P'
  3077. DIRECT (input) char*
  3078. Specifies whether P is a forward or backward sequence of
  3079. plane rotations.
  3080. = 'F': Forward, P = P( z - 1 )*...*P( 2 )*P( 1 )
  3081. = 'B': Backward, P = P( 1 )*P( 2 )*...*P( z - 1 )
  3082. PIVOT (input) char*
  3083. Specifies the plane for which P(k) is a plane rotation
  3084. matrix.
  3085. = 'V': Variable pivot, the plane (k,k+1)
  3086. = 'T': Top pivot, the plane (1,k+1)
  3087. = 'B': Bottom pivot, the plane (k,z)
  3088. M (input) long
  3089. The number of rows of the matrix A. If m <= 1, an immediate
  3090. return is effected.
  3091. N (input) long
  3092. The number of columns of the matrix A. If n <= 1, an
  3093. immediate return is effected.
  3094. C, S (input) double arrays, dimension
  3095. (M-1) if SIDE = 'L'
  3096. (N-1) if SIDE = 'R'
  3097. c(k) and s(k) contain the cosine and sine that define the
  3098. matrix P(k). The two by two plane rotation part of the
  3099. matrix P(k), R(k), is assumed to be of the form
  3100. R( k ) = ( c( k ) s( k ) ).
  3101. ( -s( k ) c( k ) )
  3102. A (input/output) double array, dimension (LDA,N)
  3103. The m by n matrix A. On exit, A is overwritten by P*A if
  3104. SIDE = 'R' or by A*P' if SIDE = 'L'.
  3105. LDA (input) long
  3106. The leading dimension of the array A. LDA >= max(1,M).
  3107. =====================================================================
  3108. */
  3109. int NUMlapack_dlasrt (const char *id, integer *n, double *d, integer *info);
  3110. /* Purpose
  3111. =======
  3112. Sort the numbers in D in increasing order (if ID = 'I') or
  3113. in decreasing order (if ID = 'D' ).
  3114. Use Quick Sort, reverting to Insertion sort on arrays of
  3115. size <= 20. Dimension of STACK limits N to about 2**32.
  3116. Arguments
  3117. =========
  3118. ID (input) char*
  3119. = 'I': sort D in increasing order;
  3120. = 'D': sort D in decreasing order.
  3121. N (input) long
  3122. The length of the array D.
  3123. D (input/output) double array, dimension (N)
  3124. On entry, the array to be sorted.
  3125. On exit, D has been sorted into increasing order
  3126. (D(1) <= ... <= D(N) ) or into decreasing order
  3127. (D(1) >= ... >= D(N) ), depending on ID.
  3128. INFO (output) long
  3129. = 0: successful exit
  3130. < 0: if INFO = -i, the i-th argument had an illegal value
  3131. =====================================================================
  3132. */
  3133. int NUMlapack_dlassq (integer *n, double *x, integer *incx, double *scale, double *sumsq);
  3134. /* Purpose
  3135. =======
  3136. NUMlapack_dlassq returns the values scl and smsq such that
  3137. ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,
  3138. where x( i ) = X( 1 + ( i - 1 )*INCX ). The value of sumsq is
  3139. assumed to be non-negative and scl returns the value
  3140. scl = max( scale, abs( x( i ) ) ).
  3141. scale and sumsq must be supplied in SCALE and SUMSQ and
  3142. scl and smsq are overwritten on SCALE and SUMSQ respectively.
  3143. The routine makes only one pass through the vector x.
  3144. Arguments
  3145. =========
  3146. N (input) long
  3147. The number of elements to be used from the vector X.
  3148. X (input) double array, dimension (N)
  3149. The vector for which a scaled sum of squares is computed.
  3150. x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n.
  3151. INCX (input) long
  3152. The increment between successive values of the vector X.
  3153. INCX > 0.
  3154. SCALE (input/output) double
  3155. On entry, the value scale in the equation above.
  3156. On exit, SCALE is overwritten with scl , the scaling factor
  3157. for the sum of squares.
  3158. SUMSQ (input/output) double
  3159. On entry, the value sumsq in the equation above.
  3160. On exit, SUMSQ is overwritten with smsq , the basic sum of
  3161. squares from which scl has been factored out.
  3162. =====================================================================
  3163. */
  3164. int NUMlapack_dlasv2 (double *f, double *g, double *h, double *ssmin,
  3165. double *ssmax, double *snr, double *csr, double *snl, double *csl);
  3166. /* Purpose
  3167. =======
  3168. NUMlapack_dlasv2 computes the singular value decomposition of a 2-by-2
  3169. triangular matrix
  3170. [ F G ]
  3171. [ 0 H ].
  3172. On return, abs(SSMAX) is the larger singular value, abs(SSMIN) is the
  3173. smaller singular value, and (CSL,SNL) and (CSR,SNR) are the left and
  3174. right singular vectors for abs(SSMAX), giving the decomposition
  3175. [ CSL SNL ] [ F G ] [ CSR -SNR ] = [ SSMAX 0 ]
  3176. [-SNL CSL ] [ 0 H ] [ SNR CSR ] [ 0 SSMIN ].
  3177. Arguments
  3178. =========
  3179. F (input) double
  3180. The (1,1) element of the 2-by-2 matrix.
  3181. G (input) double
  3182. The (1,2) element of the 2-by-2 matrix.
  3183. H (input) double
  3184. The (2,2) element of the 2-by-2 matrix.
  3185. SSMIN (output) double
  3186. abs(SSMIN) is the smaller singular value.
  3187. SSMAX (output) double
  3188. abs(SSMAX) is the larger singular value.
  3189. SNL (output) double
  3190. CSL (output) double
  3191. The vector (CSL, SNL) is a unit left singular vector for the
  3192. singular value abs(SSMAX).
  3193. SNR (output) double
  3194. CSR (output) double
  3195. The vector (CSR, SNR) is a unit right singular vector for the
  3196. singular value abs(SSMAX).
  3197. Further Details
  3198. ===============
  3199. Any input parameter may be aliased with any output parameter.
  3200. Barring over/underflow and assuming a guard digit in subtraction, all
  3201. output quantities are correct to within a few units in the last
  3202. place (ulps).
  3203. In IEEE arithmetic, the code works correctly if one matrix element is
  3204. infinite.
  3205. Overflow will not occur unless the largest singular value itself
  3206. overflows or is within a few ulps of overflow. (On machines with
  3207. partial overflow, like the Cray, overflow may occur if the largest
  3208. singular value is within a factor of 2 of overflow.)
  3209. Underflow is harmless if underflow is gradual. Otherwise, results
  3210. may correspond to a matrix modified by perturbations of size near
  3211. the underflow threshold.
  3212. =====================================================================
  3213. */
  3214. int NUMlapack_dlaswp (integer *n, double *a, integer *lda, integer *k1, integer *k2,
  3215. integer *ipiv, integer *incx);
  3216. /* Purpose
  3217. =======
  3218. NUMlapack_dlaswp performs a series of row interchanges on the matrix A.
  3219. One row interchange is initiated for each of rows K1 through K2 of A.
  3220. Arguments
  3221. =========
  3222. N (input) long
  3223. The number of columns of the matrix A.
  3224. A (input/output) double array, dimension (LDA,N)
  3225. On entry, the matrix of column dimension N to which the row
  3226. interchanges will be applied.
  3227. On exit, the permuted matrix.
  3228. LDA (input) long
  3229. The leading dimension of the array A.
  3230. K1 (input) long
  3231. The first element of IPIV for which a row interchange will
  3232. be done.
  3233. K2 (input) long
  3234. The last element of IPIV for which a row interchange will
  3235. be done.
  3236. IPIV (input) long array, dimension (M*abs(INCX))
  3237. The vector of pivot indices. Only the elements in positions
  3238. K1 through K2 of IPIV are accessed.
  3239. IPIV(K) = L implies rows K and L are to be interchanged.
  3240. INCX (input) long
  3241. The increment between successive values of IPIV. If IPIV
  3242. is negative, the pivots are applied in reverse order.
  3243. =====================================================================
  3244. */
  3245. int NUMlapack_dlatrd (const char *uplo, integer *n, integer *nb, double *a, integer *lda,
  3246. double *e, double *tau, double *w, integer *ldw);
  3247. /* Purpose =======
  3248. NUMlapack_dlatrd reduces NB rows and columns of a real symmetric matrix A to
  3249. symmetric tridiagonal form by an orthogonal similarity transformation
  3250. Q' * A * Q, and returns the matrices V and W which are needed to apply
  3251. the transformation to the unreduced part of A.
  3252. If UPLO = 'U', DLATRD reduces the last NB rows and columns of a matrix,
  3253. of which the upper triangle is supplied; if UPLO = 'L', DLATRD reduces
  3254. the first NB rows and columns of a matrix, of which the lower triangle
  3255. is supplied.
  3256. This is an auxiliary routine called by NUMlapack_dsytrd.
  3257. Arguments =========
  3258. UPLO (input) CHARACTER Specifies whether the upper or lower triangular
  3259. part of the symmetric matrix A is stored: = 'U': Upper triangular =
  3260. 'L': Lower triangular
  3261. N (input) long The order of the matrix A.
  3262. NB (input) long The number of rows and columns to be reduced.
  3263. A (input/output) double array, dimension (LDA,N) On entry,
  3264. the symmetric matrix A. If UPLO = 'U', the leading n-by-n upper
  3265. triangular part of A contains the upper triangular part of the matrix
  3266. A, and the strictly lower triangular part of A is not referenced. If
  3267. UPLO = 'L', the leading n-by-n lower triangular part of A contains the
  3268. lower triangular part of the matrix A, and the strictly upper
  3269. triangular part of A is not referenced. On exit: if UPLO = 'U', the
  3270. last NB columns have been reduced to tridiagonal form, with the
  3271. diagonal elements overwriting the diagonal elements of A; the elements
  3272. above the diagonal with the array TAU, represent the orthogonal matrix
  3273. Q as a product of elementary reflectors; if UPLO = 'L', the first NB
  3274. columns have been reduced to tridiagonal form, with the diagonal
  3275. elements overwriting the diagonal elements of A; the elements below the
  3276. diagonal with the array TAU, represent the orthogonal matrix Q as a
  3277. product of elementary reflectors. See Further Details.
  3278. LDA (input) long The leading dimension of the array A. LDA >=
  3279. (1,N).
  3280. E (output) double array, dimension (N-1) If UPLO = 'U',
  3281. E(n-nb:n-1) contains the superdiagonal elements of the last NB columns
  3282. of the reduced matrix; if UPLO = 'L', E(1:nb) contains the subdiagonal
  3283. elements of the first NB columns of the reduced matrix.
  3284. TAU (output) double array, dimension (N-1) The scalar factors
  3285. of the elementary reflectors, stored in TAU(n-nb:n-1) if UPLO = 'U',
  3286. and in TAU(1:nb) if UPLO = 'L'. See Further Details.
  3287. W (output) double array, dimension (LDW,NB) The n-by-nb
  3288. matrix W required to update the unreduced part of A.
  3289. LDW (input) long The leading dimension of the array W. LDW >=
  3290. max(1,N).
  3291. Further Details ===============
  3292. If UPLO = 'U', the matrix Q is represented as a product of elementary
  3293. reflectors
  3294. Q = H(n) H(n-1) . . . H(n-nb+1).
  3295. Each H(i) has the form
  3296. H(i) = I - tau * v * v'
  3297. where tau is a real scalar, and v is a real vector with v(i:n) = 0 and
  3298. v(i-1) = 1; v(1:i-1) is stored on exit in A(1:i-1,i), and tau in
  3299. TAU(i-1).
  3300. If UPLO = 'L', the matrix Q is represented as a product of elementary
  3301. reflectors
  3302. Q = H(1) H(2) . . . H(nb).
  3303. Each H(i) has the form
  3304. H(i) = I - tau * v * v'
  3305. where tau is a real scalar, and v is a real vector with v(1:i) = 0 and
  3306. v(i+1) = 1; v(i+1:n) is stored on exit in A(i+1:n,i), and tau in
  3307. TAU(i).
  3308. The elements of the vectors v together form the n-by-nb matrix V which
  3309. is needed, with W, to apply the transformation to the unreduced part of
  3310. the matrix, using a symmetric rank-2k update of the form: A := A - V*W'
  3311. - W*V'.
  3312. The contents of A on exit are illustrated by the following examples with
  3313. n = 5 and nb = 2:
  3314. if UPLO = 'U': if UPLO = 'L':
  3315. ( a a a v4 v5 ) ( d ) ( a a v4 v5 ) ( 1 d ) ( a 1 v5 ) ( v1 1 a ) ( d 1
  3316. ) ( v1 v2 a a ) ( d ) ( v1 v2 a a a )
  3317. where d denotes a diagonal element of the reduced matrix, a denotes an
  3318. element of the original matrix that is unchanged, and vi denotes an
  3319. element of the vector defining H(i).
  3320. =====================================================================
  3321. */
  3322. int NUMlapack_dorg2l (integer *m, integer *n, integer *k, double * a, integer *lda, double *tau,
  3323. double *work, integer *info);
  3324. /* Purpose
  3325. =======
  3326. NUMlapack_dorg2l generates an m by n real matrix Q with orthonormal columns,
  3327. which is defined as the last n columns of a product of k elementary
  3328. reflectors of order m
  3329. Q = H(k) . . . H(2) H(1)
  3330. as returned by NUMlapack_dgeqlf.
  3331. Arguments
  3332. =========
  3333. M (input) long
  3334. The number of rows of the matrix Q. M >= 0.
  3335. N (input) long
  3336. The number of columns of the matrix Q. M >= N >= 0.
  3337. K (input) long
  3338. The number of elementary reflectors whose product defines the
  3339. matrix Q. N >= K >= 0.
  3340. A (input/output) double array, dimension (LDA,N)
  3341. On entry, the (n-k+i)-th column must contain the vector which
  3342. defines the elementary reflector H(i), for i = 1,2,...,k, as
  3343. returned by DGEQLF in the last k columns of its array
  3344. argument A.
  3345. On exit, the m by n matrix Q.
  3346. LDA (input) long
  3347. The first dimension of the array A. LDA >= max(1,M).
  3348. TAU (input) double array, dimension (K)
  3349. TAU(i) must contain the scalar factor of the elementary
  3350. reflector H(i), as returned by DGEQLF.
  3351. WORK (workspace) double array, dimension (N)
  3352. INFO (output) long
  3353. = 0: successful exit
  3354. < 0: if INFO = -i, the i-th argument has an illegal value
  3355. =====================================================================
  3356. */
  3357. int NUMlapack_dorg2r (integer *m, integer *n, integer *k, double *a, integer *lda,
  3358. double *tau, double *work, integer *info);
  3359. /* Purpose
  3360. =======
  3361. NUMlapack_dorg2r generates an m by n real matrix Q with orthonormal columns,
  3362. which is defined as the first n columns of a product of k elementary
  3363. reflectors of order m
  3364. Q = H(1) H(2) . . . H(k)
  3365. as returned by NUMlapack_dgeqrf.
  3366. Arguments
  3367. =========
  3368. M (input) long
  3369. The number of rows of the matrix Q. M >= 0.
  3370. N (input) long
  3371. The number of columns of the matrix Q. M >= N >= 0.
  3372. K (input) long
  3373. The number of elementary reflectors whose product defines the
  3374. matrix Q. N >= K >= 0.
  3375. A (input/output) double array, dimension (LDA,N)
  3376. On entry, the i-th column must contain the vector which
  3377. defines the elementary reflector H(i), for i = 1,2,...,k, as
  3378. returned by DGEQRF in the first k columns of its array
  3379. argument A.
  3380. On exit, the m-by-n matrix Q.
  3381. LDA (input) long
  3382. The first dimension of the array A. LDA >= max(1,M).
  3383. TAU (input) double array, dimension (K)
  3384. TAU(i) must contain the scalar factor of the elementary
  3385. reflector H(i), as returned by DGEQRF.
  3386. WORK (workspace) double array, dimension (N)
  3387. INFO (output) long
  3388. = 0: successful exit
  3389. < 0: if INFO = -i, the i-th argument has an illegal value
  3390. =====================================================================
  3391. */
  3392. int NUMlapack_dorgbr (const char *vect, integer *m, integer *n, integer *k, double *a, integer *lda,
  3393. double *tau, double *work, integer *lwork, integer *info);
  3394. /* Purpose
  3395. =======
  3396. NUMlapack_dorgbr generates one of the real orthogonal matrices Q or P**T
  3397. determined by DGEBRD when reducing a real matrix A to bidiagonal
  3398. form: A = Q * B * P**T. Q and P**T are defined as products of
  3399. elementary reflectors H(i) or G(i) respectively.
  3400. If VECT = 'Q', A is assumed to have been an M-by-K matrix, and Q
  3401. is of order M:
  3402. if m >= k, Q = H(1) H(2) . . . H(k) and NUMlapack_dorgbr returns the first n
  3403. columns of Q, where m >= n >= k;
  3404. if m < k, Q = H(1) H(2) . . . H(m-1) and NUMlapack_dorgbr returns Q as an
  3405. M-by-M matrix.
  3406. If VECT = 'P', A is assumed to have been a K-by-N matrix, and P**T
  3407. is of order N:
  3408. if k < n, P**T = G(k) . . . G(2) G(1) and NUMlapack_dorgbr returns the first m
  3409. rows of P**T, where n >= m >= k;
  3410. if k >= n, P**T = G(n-1) . . . G(2) G(1) and NUMlapack_dorgbr returns P**T as
  3411. an N-by-N matrix.
  3412. Arguments
  3413. =========
  3414. VECT (input) char*
  3415. Specifies whether the matrix Q or the matrix P**T is
  3416. required, as defined in the transformation applied by DGEBRD:
  3417. = 'Q': generate Q;
  3418. = 'P': generate P**T.
  3419. M (input) long
  3420. The number of rows of the matrix Q or P**T to be returned.
  3421. M >= 0.
  3422. N (input) long
  3423. The number of columns of the matrix Q or P**T to be returned.
  3424. N >= 0.
  3425. If VECT = 'Q', M >= N >= min(M,K);
  3426. if VECT = 'P', N >= M >= min(N,K).
  3427. K (input) long
  3428. If VECT = 'Q', the number of columns in the original M-by-K
  3429. matrix reduced by DGEBRD.
  3430. If VECT = 'P', the number of rows in the original K-by-N
  3431. matrix reduced by DGEBRD.
  3432. K >= 0.
  3433. A (input/output) double array, dimension (LDA,N)
  3434. On entry, the vectors which define the elementary reflectors,
  3435. as returned by DGEBRD.
  3436. On exit, the M-by-N matrix Q or P**T.
  3437. LDA (input) long
  3438. The leading dimension of the array A. LDA >= max(1,M).
  3439. TAU (input) double array, dimension
  3440. (min(M,K)) if VECT = 'Q'
  3441. (min(N,K)) if VECT = 'P'
  3442. TAU(i) must contain the scalar factor of the elementary
  3443. reflector H(i) or G(i), which determines Q or P**T, as
  3444. returned by DGEBRD in its array argument TAUQ or TAUP.
  3445. WORK (workspace/output) double array, dimension (LWORK)
  3446. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3447. LWORK (input) long
  3448. The dimension of the array WORK. LWORK >= max(1,min(M,N)).
  3449. For optimum performance LWORK >= min(M,N)*NB, where NB
  3450. is the optimal blocksize.
  3451. If LWORK = -1, then a workspace query is assumed; the routine
  3452. only calculates the optimal size of the WORK array, returns
  3453. this value as the first entry of the WORK array, and no error
  3454. message related to LWORK is issued by XERBLA.
  3455. INFO (output) long
  3456. = 0: successful exit
  3457. < 0: if INFO = -i, the i-th argument had an illegal value
  3458. =====================================================================
  3459. */
  3460. int NUMlapack_dorghr (integer *n, integer *ilo, integer *ihi, double *a, integer *lda,
  3461. double *tau, double *work, integer *lwork, integer *info);
  3462. /* -- LAPACK routine (version 3.0) --
  3463. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  3464. Courant Institute, Argonne National Lab, and Rice University
  3465. June 30, 1999
  3466. Purpose
  3467. =======
  3468. NUMlapack_dorghr generates a real orthogonal matrix Q which is defined as the
  3469. product of IHI-ILO elementary reflectors of order N, as returned by
  3470. NUMlapack_dgehrd:
  3471. Q = H(ilo) H(ilo+1) . . . H(ihi-1).
  3472. Arguments
  3473. =========
  3474. N (input) long
  3475. The order of the matrix Q. N >= 0.
  3476. ILO (input) long
  3477. IHI (input) long
  3478. ILO and IHI must have the same values as in the previous call
  3479. of NUMlapack_dgehrd. Q is equal to the unit matrix except in the
  3480. submatrix Q(ilo+1:ihi,ilo+1:ihi).
  3481. 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
  3482. A (input/output) double array, dimension (LDA,N)
  3483. On entry, the vectors which define the elementary reflectors,
  3484. as returned by NUMlapack_dgehrd.
  3485. On exit, the N-by-N orthogonal matrix Q.
  3486. LDA (input) long
  3487. The leading dimension of the array A. LDA >= max(1,N).
  3488. TAU (input) double array, dimension (N-1)
  3489. TAU(i) must contain the scalar factor of the elementary
  3490. reflector H(i), as returned by NUMlapack_dgehrd.
  3491. WORK (workspace/output) double array, dimension (LWORK)
  3492. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3493. LWORK (input) long
  3494. The dimension of the array WORK. LWORK >= IHI-ILO.
  3495. For optimum performance LWORK >= (IHI-ILO)*NB, where NB is
  3496. the optimal blocksize.
  3497. If LWORK = -1, then a workspace query is assumed; the routine
  3498. only calculates the optimal size of the WORK array, returns
  3499. this value as the first entry of the WORK array, and no error
  3500. message related to LWORK is issued by XERBLA.
  3501. INFO (output) long
  3502. = 0: successful exit
  3503. < 0: if INFO = -i, the i-th argument had an illegal value
  3504. =====================================================================
  3505. */
  3506. int NUMlapack_dorgl2 (integer *m, integer *n, integer *k, double *a, integer *lda, double *tau,
  3507. double *work, integer *info);
  3508. /* Purpose
  3509. =======
  3510. NUMlapack_dorgl2 generates an m by n real matrix Q with orthonormal rows,
  3511. which is defined as the first m rows of a product of k elementary
  3512. reflectors of order n
  3513. Q = H(k) . . . H(2) H(1)
  3514. as returned by NUMlapack_dgelqf.
  3515. Arguments
  3516. =========
  3517. M (input) long
  3518. The number of rows of the matrix Q. M >= 0.
  3519. N (input) long
  3520. The number of columns of the matrix Q. N >= M.
  3521. K (input) long
  3522. The number of elementary reflectors whose product defines the
  3523. matrix Q. M >= K >= 0.
  3524. A (input/output) double array, dimension (LDA,N)
  3525. On entry, the i-th row must contain the vector which defines
  3526. the elementary reflector H(i), for i = 1,2,...,k, as returned
  3527. by NUMlapack_dgelqf in the first k rows of its array argument A.
  3528. On exit, the m-by-n matrix Q.
  3529. LDA (input) long
  3530. The first dimension of the array A. LDA >= max(1,M).
  3531. TAU (input) double array, dimension (K)
  3532. TAU(i) must contain the scalar factor of the elementary
  3533. reflector H(i), as returned by NUMlapack_dgelqf.
  3534. WORK (workspace) double array, dimension (M)
  3535. INFO (output) long
  3536. = 0: successful exit
  3537. < 0: if INFO = -i, the i-th argument has an illegal value
  3538. =====================================================================
  3539. */
  3540. int NUMlapack_dorglq (integer *m, integer *n, integer *k, double *a, integer *lda, double *tau,
  3541. double *work, integer *lwork, integer *info);
  3542. /* Purpose
  3543. =======
  3544. NUMlapack_dorglq generates an M-by-N real matrix Q with orthonormal rows,
  3545. which is defined as the first M rows of a product of K elementary
  3546. reflectors of order N
  3547. Q = H(k) . . . H(2) H(1)
  3548. as returned by DGELQf.
  3549. Arguments
  3550. =========
  3551. M (input) long
  3552. The number of rows of the matrix Q. M >= 0.
  3553. N (input) long
  3554. The number of columns of the matrix Q. N >= M.
  3555. K (input) long
  3556. The number of elementary reflectors whose product defines the
  3557. matrix Q. M >= K >= 0.
  3558. A (input/output) double array, dimension (LDA,N)
  3559. On entry, the i-th row must contain the vector which defines
  3560. the elementary reflector H(i), for i = 1,2,...,k, as returned
  3561. by NUMlapack_dgelqf in the first k rows of its array argument A.
  3562. On exit, the M-by-N matrix Q.
  3563. LDA (input) long
  3564. The first dimension of the array A. LDA >= max(1,M).
  3565. TAU (input) double array, dimension (K)
  3566. TAU(i) must contain the scalar factor of the elementary
  3567. reflector H(i), as returned by NUMlapack_dgelqf.
  3568. WORK (workspace/output) double array, dimension (LWORK)
  3569. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3570. LWORK (input) long
  3571. The dimension of the array WORK. LWORK >= max(1,M).
  3572. For optimum performance LWORK >= M*NB, where NB is
  3573. the optimal blocksize.
  3574. If LWORK = -1, then a workspace query is assumed; the routine
  3575. only calculates the optimal size of the WORK array, returns
  3576. this value as the first entry of the WORK array, and no error
  3577. message related to LWORK is issued by XERBLA.
  3578. INFO (output) long
  3579. = 0: successful exit
  3580. < 0: if INFO = -i, the i-th argument has an illegal value
  3581. =====================================================================
  3582. */
  3583. int NUMlapack_dorgql (integer *m, integer *n, integer *k, double *a, integer *lda, double *tau,
  3584. double *work, integer *lwork, integer *info);
  3585. /* Purpose
  3586. =======
  3587. NUMlapack_dorgql generates an M-by-N real matrix Q with orthonormal columns,
  3588. which is defined as the last N columns of a product of K elementary
  3589. reflectors of order M
  3590. Q = H(k) . . . H(2) H(1)
  3591. as returned by DGEQLF.
  3592. Arguments
  3593. =========
  3594. M (input) long
  3595. The number of rows of the matrix Q. M >= 0.
  3596. N (input) long
  3597. The number of columns of the matrix Q. M >= N >= 0.
  3598. K (input) long
  3599. The number of elementary reflectors whose product defines the
  3600. matrix Q. N >= K >= 0.
  3601. A (input/output) double array, dimension (LDA,N)
  3602. On entry, the (n-k+i)-th column must contain the vector which
  3603. defines the elementary reflector H(i), for i = 1,2,...,k, as
  3604. returned by DGEQLF in the last k columns of its array
  3605. argument A.
  3606. On exit, the M-by-N matrix Q.
  3607. LDA (input) long
  3608. The first dimension of the array A. LDA >= max(1,M).
  3609. TAU (input) double array, dimension (K)
  3610. TAU(i) must contain the scalar factor of the elementary
  3611. reflector H(i), as returned by DGEQLF.
  3612. WORK (workspace/output) double array, dimension (LWORK)
  3613. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3614. LWORK (input) long
  3615. The dimension of the array WORK. LWORK >= max(1,N).
  3616. For optimum performance LWORK >= N*NB, where NB is the
  3617. optimal blocksize.
  3618. If LWORK = -1, then a workspace query is assumed; the routine
  3619. only calculates the optimal size of the WORK array, returns
  3620. this value as the first entry of the WORK array, and no error
  3621. message related to LWORK is issued by XERBLA.
  3622. INFO (output) long
  3623. = 0: successful exit
  3624. < 0: if INFO = -i, the i-th argument has an illegal value
  3625. =====================================================================
  3626. */
  3627. int NUMlapack_dorgqr (integer *m, integer *n, integer *k, double *a, integer *lda, double *tau,
  3628. double *work, integer *lwork, integer *info);
  3629. /* Purpose
  3630. =======
  3631. NUMlapack_dorgqr generates an M-by-N real matrix Q with orthonormal columns,
  3632. which is defined as the first N columns of a product of K elementary
  3633. reflectors of order M
  3634. Q = H(1) H(2) . . . H(k)
  3635. as returned by DGEQRF.
  3636. Arguments
  3637. =========
  3638. M (input) long
  3639. The number of rows of the matrix Q. M >= 0.
  3640. N (input) long
  3641. The number of columns of the matrix Q. M >= N >= 0.
  3642. K (input) long
  3643. The number of elementary reflectors whose product defines the
  3644. matrix Q. N >= K >= 0.
  3645. A (input/output) double array, dimension (LDA,N)
  3646. On entry, the i-th column must contain the vector which
  3647. defines the elementary reflector H(i), for i = 1,2,...,k, as
  3648. returned by DGEQRF in the first k columns of its array
  3649. argument A.
  3650. On exit, the M-by-N matrix Q.
  3651. LDA (input) long
  3652. The first dimension of the array A. LDA >= max(1,M).
  3653. TAU (input) double array, dimension (K)
  3654. TAU(i) must contain the scalar factor of the elementary
  3655. reflector H(i), as returned by DGEQRF.
  3656. WORK (workspace/output) double array, dimension (LWORK)
  3657. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3658. LWORK (input) long
  3659. The dimension of the array WORK. LWORK >= max(1,N).
  3660. For optimum performance LWORK >= N*NB, where NB is the
  3661. optimal blocksize.
  3662. If LWORK = -1, then a workspace query is assumed; the routine
  3663. only calculates the optimal size of the WORK array, returns
  3664. this value as the first entry of the WORK array, and no error
  3665. message related to LWORK is issued by XERBLA.
  3666. INFO (output) long
  3667. = 0: successful exit
  3668. < 0: if INFO = -i, the i-th argument has an illegal value
  3669. =====================================================================
  3670. */
  3671. int NUMlapack_dorgtr (const char *uplo, integer *n, double *a, integer *lda, double *tau,
  3672. double *work, integer *lwork, integer *info);
  3673. /* Purpose
  3674. =======
  3675. NUMlapack_dorgtr generates a real orthogonal matrix Q which is defined as the
  3676. product of n-1 elementary reflectors of order N, as returned by
  3677. NUMlapack_dsytrd:
  3678. if UPLO = 'U', Q = H(n-1) . . . H(2) H(1),
  3679. if UPLO = 'L', Q = H(1) H(2) . . . H(n-1).
  3680. Arguments
  3681. =========
  3682. UPLO (input) char*
  3683. = 'U': Upper triangle of A contains elementary reflectors
  3684. from NUMlapack_dsytrd;
  3685. = 'L': Lower triangle of A contains elementary reflectors
  3686. from NUMlapack_dsytrd.
  3687. N (input) long
  3688. The order of the matrix Q. N >= 0.
  3689. A (input/output) double array, dimension (LDA,N)
  3690. On entry, the vectors which define the elementary reflectors,
  3691. as returned by NUMlapack_dsytrd.
  3692. On exit, the N-by-N orthogonal matrix Q.
  3693. LDA (input) long
  3694. The leading dimension of the array A. LDA >= max(1,N).
  3695. TAU (input) double array, dimension (N-1)
  3696. TAU(i) must contain the scalar factor of the elementary
  3697. reflector H(i), as returned by NUMlapack_dsytrd.
  3698. WORK (workspace/output) double array, dimension (LWORK)
  3699. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3700. LWORK (input) long
  3701. The dimension of the array WORK. LWORK >= max(1,N-1).
  3702. For optimum performance LWORK >= (N-1)*NB, where NB is
  3703. the optimal blocksize.
  3704. If LWORK = -1, then a workspace query is assumed; the routine
  3705. only calculates the optimal size of the WORK array, returns
  3706. this value as the first entry of the WORK array, and no error
  3707. message related to LWORK is issued by XERBLA.
  3708. INFO (output) long
  3709. = 0: successful exit
  3710. < 0: if INFO = -i, the i-th argument had an illegal value
  3711. =====================================================================
  3712. */
  3713. int NUMlapack_dorm2r (const char *side, const char *trans, integer *m, integer *n, integer *k,
  3714. double *a, integer *lda, double *tau, double *c, integer *ldc, double *work,
  3715. integer *info);
  3716. /* Purpose
  3717. =======
  3718. NUMlapack_dorm2r overwrites the general real m by n matrix C with
  3719. Q * C if SIDE = 'L' and TRANS = 'N', or
  3720. Q'* C if SIDE = 'L' and TRANS = 'T', or
  3721. C * Q if SIDE = 'R' and TRANS = 'N', or
  3722. C * Q' if SIDE = 'R' and TRANS = 'T',
  3723. where Q is a real orthogonal matrix defined as the product of k
  3724. elementary reflectors
  3725. Q = H(1) H(2) . . . H(k)
  3726. as returned by DGEQRF. Q is of order m if SIDE = 'L' and of order n
  3727. if SIDE = 'R'.
  3728. Arguments
  3729. =========
  3730. SIDE (input) char*
  3731. = 'L': apply Q or Q' from the Left
  3732. = 'R': apply Q or Q' from the Right
  3733. TRANS (input) char*
  3734. = 'N': apply Q (No transpose)
  3735. = 'T': apply Q' (Transpose)
  3736. M (input) long
  3737. The number of rows of the matrix C. M >= 0.
  3738. N (input) long
  3739. The number of columns of the matrix C. N >= 0.
  3740. K (input) long
  3741. The number of elementary reflectors whose product defines
  3742. the matrix Q.
  3743. If SIDE = 'L', M >= K >= 0;
  3744. if SIDE = 'R', N >= K >= 0.
  3745. A (input) double array, dimension (LDA,K)
  3746. The i-th column must contain the vector which defines the
  3747. elementary reflector H(i), for i = 1,2,...,k, as returned by
  3748. DGEQRF in the first k columns of its array argument A.
  3749. A is modified by the routine but restored on exit.
  3750. LDA (input) long
  3751. The leading dimension of the array A.
  3752. If SIDE = 'L', LDA >= max(1,M);
  3753. if SIDE = 'R', LDA >= max(1,N).
  3754. TAU (input) double array, dimension (K)
  3755. TAU(i) must contain the scalar factor of the elementary
  3756. reflector H(i), as returned by DGEQRF.
  3757. C (input/output) double array, dimension (LDC,N)
  3758. On entry, the m by n matrix C.
  3759. On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q.
  3760. LDC (input) long
  3761. The leading dimension of the array C. LDC >= max(1,M).
  3762. WORK (workspace) double array, dimension
  3763. (N) if SIDE = 'L',
  3764. (M) if SIDE = 'R'
  3765. INFO (output) long
  3766. = 0: successful exit
  3767. < 0: if INFO = -i, the i-th argument had an illegal value
  3768. =====================================================================
  3769. */
  3770. int NUMlapack_dormbr (const char *vect, const char *side, const char *trans, integer *m, integer *n,
  3771. integer *k, double *a, integer *lda, double *tau, double *c, integer *ldc,
  3772. double *work, integer *lwork, integer *info);
  3773. /* Purpose
  3774. =======
  3775. If VECT = 'Q', NUMlapack_dormbr overwrites the general real M-by-N matrix C
  3776. with
  3777. SIDE = 'L' SIDE = 'R'
  3778. TRANS = 'N': Q * C C * Q
  3779. TRANS = 'T': Q**T * C C * Q**T
  3780. If VECT = 'P', NUMlapack_dormbr overwrites the general real M-by-N matrix C
  3781. with
  3782. SIDE = 'L' SIDE = 'R'
  3783. TRANS = 'N': P * C C * P
  3784. TRANS = 'T': P**T * C C * P**T
  3785. Here Q and P**T are the orthogonal matrices determined by DGEBRD when
  3786. reducing a real matrix A to bidiagonal form: A = Q * B * P**T. Q and
  3787. P**T are defined as products of elementary reflectors H(i) and G(i)
  3788. respectively.
  3789. Let nq = m if SIDE = 'L' and nq = n if SIDE = 'R'. Thus nq is the
  3790. order of the orthogonal matrix Q or P**T that is applied.
  3791. If VECT = 'Q', A is assumed to have been an NQ-by-K matrix:
  3792. if nq >= k, Q = H(1) H(2) . . . H(k);
  3793. if nq < k, Q = H(1) H(2) . . . H(nq-1).
  3794. If VECT = 'P', A is assumed to have been a K-by-NQ matrix:
  3795. if k < nq, P = G(1) G(2) . . . G(k);
  3796. if k >= nq, P = G(1) G(2) . . . G(nq-1).
  3797. Arguments
  3798. =========
  3799. VECT (input) char*
  3800. = 'Q': apply Q or Q**T;
  3801. = 'P': apply P or P**T.
  3802. SIDE (input) char*
  3803. = 'L': apply Q, Q**T, P or P**T from the Left;
  3804. = 'R': apply Q, Q**T, P or P**T from the Right.
  3805. TRANS (input) char*
  3806. = 'N': No transpose, apply Q or P;
  3807. = 'T': Transpose, apply Q**T or P**T.
  3808. M (input) long
  3809. The number of rows of the matrix C. M >= 0.
  3810. N (input) long
  3811. The number of columns of the matrix C. N >= 0.
  3812. K (input) long
  3813. If VECT = 'Q', the number of columns in the original
  3814. matrix reduced by DGEBRD.
  3815. If VECT = 'P', the number of rows in the original
  3816. matrix reduced by DGEBRD.
  3817. K >= 0.
  3818. A (input) double array, dimension
  3819. (LDA,min(nq,K)) if VECT = 'Q'
  3820. (LDA,nq) if VECT = 'P'
  3821. The vectors which define the elementary reflectors H(i) and
  3822. G(i), whose products determine the matrices Q and P, as
  3823. returned by DGEBRD.
  3824. LDA (input) long
  3825. The leading dimension of the array A.
  3826. If VECT = 'Q', LDA >= max(1,nq);
  3827. if VECT = 'P', LDA >= max(1,min(nq,K)).
  3828. TAU (input) double array, dimension (min(nq,K))
  3829. TAU(i) must contain the scalar factor of the elementary
  3830. reflector H(i) or G(i) which determines Q or P, as returned
  3831. by DGEBRD in the array argument TAUQ or TAUP.
  3832. C (input/output) double array, dimension (LDC,N)
  3833. On entry, the M-by-N matrix C.
  3834. On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q
  3835. or P*C or P**T*C or C*P or C*P**T.
  3836. LDC (input) long
  3837. The leading dimension of the array C. LDC >= max(1,M).
  3838. WORK (workspace/output) double array, dimension (LWORK)
  3839. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3840. LWORK (input) long
  3841. The dimension of the array WORK.
  3842. If SIDE = 'L', LWORK >= max(1,N);
  3843. if SIDE = 'R', LWORK >= max(1,M).
  3844. For optimum performance LWORK >= N*NB if SIDE = 'L', and
  3845. LWORK >= M*NB if SIDE = 'R', where NB is the optimal
  3846. blocksize.
  3847. If LWORK = -1, then a workspace query is assumed; the routine
  3848. only calculates the optimal size of the WORK array, returns
  3849. this value as the first entry of the WORK array, and no error
  3850. message related to LWORK is issued by XERBLA.
  3851. INFO (output) long
  3852. = 0: successful exit
  3853. < 0: if INFO = -i, the i-th argument had an illegal value
  3854. =====================================================================
  3855. */
  3856. int NUMlapack_dorml2 (const char *side, const char *trans, integer *m, integer *n, integer *k, double *a,
  3857. integer *lda, double *tau, double *c, integer *ldc, double *work, integer *info);
  3858. /* Purpose
  3859. =======
  3860. NUMlapack_dorml2 overwrites the general real m by n matrix C with
  3861. Q * C if SIDE = 'L' and TRANS = 'N', or
  3862. Q'* C if SIDE = 'L' and TRANS = 'T', or
  3863. C * Q if SIDE = 'R' and TRANS = 'N', or
  3864. C * Q' if SIDE = 'R' and TRANS = 'T',
  3865. where Q is a real orthogonal matrix defined as the product of k
  3866. elementary reflectors
  3867. Q = H(k) . . . H(2) H(1)
  3868. as returned by NUMlapack_dgelqf. Q is of order m if SIDE = 'L' and of order n
  3869. if SIDE = 'R'.
  3870. Arguments
  3871. =========
  3872. SIDE (input) char*
  3873. = 'L': apply Q or Q' from the Left
  3874. = 'R': apply Q or Q' from the Right
  3875. TRANS (input) char*
  3876. = 'N': apply Q (No transpose)
  3877. = 'T': apply Q' (Transpose)
  3878. M (input) long
  3879. The number of rows of the matrix C. M >= 0.
  3880. N (input) long
  3881. The number of columns of the matrix C. N >= 0.
  3882. K (input) long
  3883. The number of elementary reflectors whose product defines
  3884. the matrix Q.
  3885. If SIDE = 'L', M >= K >= 0;
  3886. if SIDE = 'R', N >= K >= 0.
  3887. A (input) double array, dimension
  3888. (LDA,M) if SIDE = 'L',
  3889. (LDA,N) if SIDE = 'R'
  3890. The i-th row must contain the vector which defines the
  3891. elementary reflector H(i), for i = 1,2,...,k, as returned by
  3892. NUMlapack_dgelqf in the first k rows of its array argument A.
  3893. A is modified by the routine but restored on exit.
  3894. LDA (input) long
  3895. The leading dimension of the array A. LDA >= max(1,K).
  3896. TAU (input) double array, dimension (K)
  3897. TAU(i) must contain the scalar factor of the elementary
  3898. reflector H(i), as returned by NUMlapack_dgelqf.
  3899. C (input/output) double array, dimension (LDC,N)
  3900. On entry, the m by n matrix C.
  3901. On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q.
  3902. LDC (input) long
  3903. The leading dimension of the array C. LDC >= max(1,M).
  3904. WORK (workspace) double array, dimension
  3905. (N) if SIDE = 'L',
  3906. (M) if SIDE = 'R'
  3907. INFO (output) long
  3908. = 0: successful exit
  3909. < 0: if INFO = -i, the i-th argument had an illegal value
  3910. =====================================================================
  3911. */
  3912. int NUMlapack_dormlq (const char *side, const char *trans, integer *m, integer *n,
  3913. integer *k, double *a, integer *lda, double *tau, double *c,
  3914. integer *ldc, double *work, integer *lwork, integer *info);
  3915. /* Purpose
  3916. =======
  3917. NUMlapack_dormlq overwrites the general real M-by-N matrix C with
  3918. SIDE = 'L' SIDE = 'R'
  3919. TRANS = 'N': Q * C C * Q
  3920. TRANS = 'T': Q**T * C C * Q**T
  3921. where Q is a real orthogonal matrix defined as the product of k
  3922. elementary reflectors
  3923. Q = H(k) . . . H(2) H(1)
  3924. as returned by NUMlapack_dgelqf. Q is of order M if SIDE = 'L' and of order N
  3925. if SIDE = 'R'.
  3926. Arguments
  3927. =========
  3928. SIDE (input) char*
  3929. = 'L': apply Q or Q**T from the Left;
  3930. = 'R': apply Q or Q**T from the Right.
  3931. TRANS (input) char*
  3932. = 'N': No transpose, apply Q;
  3933. = 'T': Transpose, apply Q**T.
  3934. M (input) long
  3935. The number of rows of the matrix C. M >= 0.
  3936. N (input) long
  3937. The number of columns of the matrix C. N >= 0.
  3938. K (input) long
  3939. The number of elementary reflectors whose product defines
  3940. the matrix Q.
  3941. If SIDE = 'L', M >= K >= 0;
  3942. if SIDE = 'R', N >= K >= 0.
  3943. A (input) double array, dimension
  3944. (LDA,M) if SIDE = 'L',
  3945. (LDA,N) if SIDE = 'R'
  3946. The i-th row must contain the vector which defines the
  3947. elementary reflector H(i), for i = 1,2,...,k, as returned by
  3948. NUMlapack_dgelqf in the first k rows of its array argument A.
  3949. A is modified by the routine but restored on exit.
  3950. LDA (input) long
  3951. The leading dimension of the array A. LDA >= max(1,K).
  3952. TAU (input) double array, dimension (K)
  3953. TAU(i) must contain the scalar factor of the elementary
  3954. reflector H(i), as returned by NUMlapack_dgelqf.
  3955. C (input/output) double array, dimension (LDC,N)
  3956. On entry, the M-by-N matrix C.
  3957. On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
  3958. LDC (input) long
  3959. The leading dimension of the array C. LDC >= max(1,M).
  3960. WORK (workspace/output) double array, dimension (LWORK)
  3961. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3962. LWORK (input) long
  3963. The dimension of the array WORK.
  3964. If SIDE = 'L', LWORK >= max(1,N);
  3965. if SIDE = 'R', LWORK >= max(1,M).
  3966. For optimum performance LWORK >= N*NB if SIDE = 'L', and
  3967. LWORK >= M*NB if SIDE = 'R', where NB is the optimal
  3968. blocksize.
  3969. If LWORK = -1, then a workspace query is assumed; the routine
  3970. only calculates the optimal size of the WORK array, returns
  3971. this value as the first entry of the WORK array, and no error
  3972. message related to LWORK is issued by XERBLA.
  3973. INFO (output) long
  3974. = 0: successful exit
  3975. < 0: if INFO = -i, the i-th argument had an illegal value
  3976. =====================================================================
  3977. */
  3978. int NUMlapack_dormqr (const char *side, const char *trans, integer *m, integer *n, integer *k,
  3979. double *a, integer *lda, double *tau, double *c, integer *ldc, double *work,
  3980. integer *lwork, integer *info);
  3981. /* Purpose
  3982. =======
  3983. NUMlapack_dormqr overwrites the general real M-by-N matrix C with
  3984. SIDE = 'L' SIDE = 'R'
  3985. TRANS = 'N': Q * C C * Q
  3986. TRANS = 'T': Q**T * C C * Q**T
  3987. where Q is a real orthogonal matrix defined as the product of k
  3988. elementary reflectors
  3989. Q = H(1) H(2) . . . H(k)
  3990. as returned by DGEQRF. Q is of order M if SIDE = 'L' and of order N
  3991. if SIDE = 'R'.
  3992. Arguments
  3993. =========
  3994. SIDE (input) char*
  3995. = 'L': apply Q or Q**T from the Left;
  3996. = 'R': apply Q or Q**T from the Right.
  3997. TRANS (input) char*
  3998. = 'N': No transpose, apply Q;
  3999. = 'T': Transpose, apply Q**T.
  4000. M (input) long
  4001. The number of rows of the matrix C. M >= 0.
  4002. N (input) long
  4003. The number of columns of the matrix C. N >= 0.
  4004. K (input) long
  4005. The number of elementary reflectors whose product defines
  4006. the matrix Q.
  4007. If SIDE = 'L', M >= K >= 0;
  4008. if SIDE = 'R', N >= K >= 0.
  4009. A (input) double array, dimension (LDA,K)
  4010. The i-th column must contain the vector which defines the
  4011. elementary reflector H(i), for i = 1,2,...,k, as returned by
  4012. DGEQRF in the first k columns of its array argument A.
  4013. A is modified by the routine but restored on exit.
  4014. LDA (input) long
  4015. The leading dimension of the array A.
  4016. If SIDE = 'L', LDA >= max(1,M);
  4017. if SIDE = 'R', LDA >= max(1,N).
  4018. TAU (input) double array, dimension (K)
  4019. TAU(i) must contain the scalar factor of the elementary
  4020. reflector H(i), as returned by DGEQRF.
  4021. C (input/output) double array, dimension (LDC,N)
  4022. On entry, the M-by-N matrix C.
  4023. On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
  4024. LDC (input) long
  4025. The leading dimension of the array C. LDC >= max(1,M).
  4026. WORK (workspace/output) double array, dimension (LWORK)
  4027. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  4028. LWORK (input) long
  4029. The dimension of the array WORK.
  4030. If SIDE = 'L', LWORK >= max(1,N);
  4031. if SIDE = 'R', LWORK >= max(1,M).
  4032. For optimum performance LWORK >= N*NB if SIDE = 'L', and
  4033. LWORK >= M*NB if SIDE = 'R', where NB is the optimal
  4034. blocksize.
  4035. If LWORK = -1, then a workspace query is assumed; the routine
  4036. only calculates the optimal size of the WORK array, returns
  4037. this value as the first entry of the WORK array, and no error
  4038. message related to LWORK is issued by XERBLA.
  4039. INFO (output) long
  4040. = 0: successful exit
  4041. < 0: if INFO = -i, the i-th argument had an illegal value
  4042. =====================================================================
  4043. */
  4044. int NUMlapack_dormr2 (const char *side, const char *trans, integer *m, integer *n, integer *k,
  4045. double *a, integer *lda, double *tau, double *c, integer *ldc, double *work,
  4046. integer *info);
  4047. /* Purpose
  4048. =======
  4049. NUMlapack_dormr2 overwrites the general real m by n matrix C with
  4050. Q * C if SIDE = 'L' and TRANS = 'N', or
  4051. Q'* C if SIDE = 'L' and TRANS = 'T', or
  4052. C * Q if SIDE = 'R' and TRANS = 'N', or
  4053. C * Q' if SIDE = 'R' and TRANS = 'T',
  4054. where Q is a real orthogonal matrix defined as the product of k
  4055. elementary reflectors
  4056. Q = H(1) H(2) . . . H(k)
  4057. as returned by DGERQF. Q is of order m if SIDE = 'L' and of order n
  4058. if SIDE = 'R'.
  4059. Arguments
  4060. =========
  4061. SIDE (input) char*
  4062. = 'L': apply Q or Q' from the Left
  4063. = 'R': apply Q or Q' from the Right
  4064. TRANS (input) char*
  4065. = 'N': apply Q (No transpose)
  4066. = 'T': apply Q' (Transpose)
  4067. M (input) long
  4068. The number of rows of the matrix C. M >= 0.
  4069. N (input) long
  4070. The number of columns of the matrix C. N >= 0.
  4071. K (input) long
  4072. The number of elementary reflectors whose product defines
  4073. the matrix Q.
  4074. If SIDE = 'L', M >= K >= 0;
  4075. if SIDE = 'R', N >= K >= 0.
  4076. A (input) double array, dimension
  4077. (LDA,M) if SIDE = 'L',
  4078. (LDA,N) if SIDE = 'R'
  4079. The i-th row must contain the vector which defines the
  4080. elementary reflector H(i), for i = 1,2,...,k, as returned by
  4081. DGERQF in the last k rows of its array argument A.
  4082. A is modified by the routine but restored on exit.
  4083. LDA (input) long
  4084. The leading dimension of the array A. LDA >= max(1,K).
  4085. TAU (input) double array, dimension (K)
  4086. TAU(i) must contain the scalar factor of the elementary
  4087. reflector H(i), as returned by DGERQF.
  4088. C (input/output) double array, dimension (LDC,N)
  4089. On entry, the m by n matrix C.
  4090. On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q.
  4091. LDC (input) long
  4092. The leading dimension of the array C. LDC >= max(1,M).
  4093. WORK (workspace) double array, dimension
  4094. (N) if SIDE = 'L',
  4095. (M) if SIDE = 'R'
  4096. INFO (output) long
  4097. = 0: successful exit
  4098. < 0: if INFO = -i, the i-th argument had an illegal value
  4099. =====================================================================
  4100. */
  4101. int NUMlapack_dpotf2 (const char *uplo, integer *n, double *a, integer *lda, integer *info);
  4102. /* -- LAPACK routine (version 3.0) --
  4103. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  4104. Courant Institute, Argonne National Lab, and Rice University
  4105. February 29, 1992
  4106. Purpose
  4107. =======
  4108. NUMlapack_dpotf2 computes the Cholesky factorization of a real symmetric
  4109. positive definite matrix A.
  4110. The factorization has the form
  4111. A = U' * U , if UPLO = 'U', or
  4112. A = L * L', if UPLO = 'L',
  4113. where U is an upper triangular matrix and L is lower triangular.
  4114. This is the unblocked version of the algorithm, calling Level 2 BLAS.
  4115. Arguments
  4116. =========
  4117. UPLO (input) char *
  4118. Specifies whether the upper or lower triangular part of the
  4119. symmetric matrix A is stored.
  4120. = 'U': Upper triangular
  4121. = 'L': Lower triangular
  4122. N (input) long
  4123. The order of the matrix A. N >= 0.
  4124. A (input/output) double array, dimension (LDA,N)
  4125. On entry, the symmetric matrix A. If UPLO = 'U', the leading
  4126. n by n upper triangular part of A contains the upper
  4127. triangular part of the matrix A, and the strictly lower
  4128. triangular part of A is not referenced. If UPLO = 'L', the
  4129. leading n by n lower triangular part of A contains the lower
  4130. triangular part of the matrix A, and the strictly upper
  4131. triangular part of A is not referenced.
  4132. On exit, if INFO = 0, the factor U or L from the Cholesky
  4133. factorization A = U'*U or A = L*L'.
  4134. LDA (input) long
  4135. The leading dimension of the array A. LDA >= max(1,N).
  4136. INFO (output) long
  4137. = 0: successful exit
  4138. < 0: if INFO = -k, the k-th argument had an illegal value
  4139. > 0: if INFO = k, the leading minor of order k is not
  4140. positive definite, and the factorization could not be
  4141. completed.
  4142. */
  4143. int NUMlapack_drscl (integer *n, double *sa, double *sx, integer *incx);
  4144. /* Purpose
  4145. =======
  4146. NUMlapack_drscl multiplies an n-element real vector x by the real scalar 1/a.
  4147. This is done without overflow or underflow as long as
  4148. the final result x/a does not overflow or underflow.
  4149. Arguments
  4150. =========
  4151. N (input) long
  4152. The number of components of the vector x.
  4153. SA (input) double
  4154. The scalar a which is used to divide each component of x.
  4155. SA must be >= 0, or the subroutine will divide by zero.
  4156. SX (input/output) double array, dimension
  4157. (1+(N-1)*abs(INCX))
  4158. The n-element vector x.
  4159. INCX (input) long
  4160. The increment between successive values of the vector SX.
  4161. > 0: SX(1) = X(1) and SX(1+(i-1)*INCX) = x(i), 1< i<= n
  4162. =====================================================================
  4163. */
  4164. int NUMlapack_dsteqr (const char *compz, integer *n, double *d, double *e, double *z, integer *ldz,
  4165. double *work, integer *info);
  4166. /* Purpose
  4167. =======
  4168. NUMlapack_dsteqr computes all eigenvalues and, optionally, eigenvectors of a
  4169. symmetric tridiagonal matrix using the implicit QL or QR method.
  4170. The eigenvectors of a full or band symmetric matrix can also be found
  4171. if NUMlapack_dsytrd or DSPTRD or DSBTRD has been used to reduce this matrix to
  4172. tridiagonal form.
  4173. Arguments
  4174. =========
  4175. COMPZ (input) char*
  4176. = 'N': Compute eigenvalues only.
  4177. = 'V': Compute eigenvalues and eigenvectors of the original
  4178. symmetric matrix. On entry, Z must contain the
  4179. orthogonal matrix used to reduce the original matrix
  4180. to tridiagonal form.
  4181. = 'I': Compute eigenvalues and eigenvectors of the
  4182. tridiagonal matrix. Z is initialized to the identity
  4183. matrix.
  4184. N (input) long
  4185. The order of the matrix. N >= 0.
  4186. D (input/output) double array, dimension (N)
  4187. On entry, the diagonal elements of the tridiagonal matrix.
  4188. On exit, if INFO = 0, the eigenvalues in ascending order.
  4189. E (input/output) double array, dimension (N-1)
  4190. On entry, the (n-1) subdiagonal elements of the tridiagonal
  4191. matrix.
  4192. On exit, E has been destroyed.
  4193. Z (input/output) double array, dimension (LDZ, N)
  4194. On entry, if COMPZ = 'V', then Z contains the orthogonal
  4195. matrix used in the reduction to tridiagonal form.
  4196. On exit, if INFO = 0, then if COMPZ = 'V', Z contains the
  4197. orthonormal eigenvectors of the original symmetric matrix,
  4198. and if COMPZ = 'I', Z contains the orthonormal eigenvectors
  4199. of the symmetric tridiagonal matrix.
  4200. If COMPZ = 'N', then Z is not referenced.
  4201. LDZ (input) long
  4202. The leading dimension of the array Z. LDZ >= 1, and if
  4203. eigenvectors are desired, then LDZ >= max(1,N).
  4204. WORK (workspace) double array, dimension (max(1,2*N-2))
  4205. If COMPZ = 'N', then WORK is not referenced.
  4206. INFO (output) long
  4207. = 0: successful exit
  4208. < 0: if INFO = -i, the i-th argument had an illegal value
  4209. > 0: the algorithm has failed to find all the eigenvalues in
  4210. a total of 30*N iterations; if INFO = i, then i
  4211. elements of E have not converged to zero; on exit, D
  4212. and E contain the elements of a symmetric tridiagonal
  4213. matrix which is orthogonally similar to the original
  4214. matrix.
  4215. =====================================================================
  4216. */
  4217. int NUMlapack_dsterf (integer *n, double *d, double *e, integer *info);
  4218. /* Purpose
  4219. =======
  4220. NUMlapack_dsterf computes all eigenvalues of a symmetric tridiagonal matrix
  4221. using the Pal-Walker-Kahan variant of the QL or QR algorithm.
  4222. Arguments
  4223. =========
  4224. N (input) long
  4225. The order of the matrix. N >= 0.
  4226. D (input/output) double array, dimension (N)
  4227. On entry, the n diagonal elements of the tridiagonal matrix.
  4228. On exit, if INFO = 0, the eigenvalues in ascending order.
  4229. E (input/output) double array, dimension (N-1)
  4230. On entry, the (n-1) subdiagonal elements of the tridiagonal
  4231. matrix.
  4232. On exit, E has been destroyed.
  4233. INFO (output) long
  4234. = 0: successful exit
  4235. < 0: if INFO = -i, the i-th argument had an illegal value
  4236. > 0: the algorithm failed to find all of the eigenvalues in
  4237. a total of 30*N iterations; if INFO = i, then i
  4238. elements of E have not converged to zero.
  4239. =====================================================================
  4240. */
  4241. int NUMlapack_dsyev (const char *jobz, const char *uplo, integer *n, double *a, integer *lda,
  4242. double *w, double *work, integer *lwork, integer *info);
  4243. /* Purpose =======
  4244. NUMlapack_dsyev computes all eigenvalues and, optionally, eigenvectors of a
  4245. real symmetric matrix A.
  4246. Arguments
  4247. =========
  4248. JOBZ (input) char*
  4249. = 'N': Compute eigenvalues only;
  4250. = 'V': Compute eigenvalues and eigenvectors.
  4251. UPLO (input) char*
  4252. = 'U': Upper triangle of A is stored;
  4253. = 'L': Lower triangle of A is stored.
  4254. N (input) long
  4255. The order of the matrix A. N >= 0.
  4256. A (input/output) double array, dimension (LDA, N)
  4257. On entry, the symmetric matrix A. If UPLO = 'U', the
  4258. leading N-by-N upper triangular part of A contains the
  4259. upper triangular part of the matrix A. If UPLO = 'L',
  4260. the leading N-by-N lower triangular part of A contains
  4261. the lower triangular part of the matrix A.
  4262. On exit, if JOBZ = 'V', then if INFO = 0, A contains the
  4263. orthonormal eigenvectors of the matrix A.
  4264. If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
  4265. or the upper triangle (if UPLO='U') of A, including the
  4266. diagonal, is destroyed.
  4267. LDA (input) long
  4268. The leading dimension of the array A. LDA >= max(1,N).
  4269. W (output) double array, dimension (N)
  4270. If INFO = 0, the eigenvalues in ascending order.
  4271. WORK (workspace/output) double array, dimension (LWORK)
  4272. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  4273. LWORK (input) long
  4274. The length of the array WORK. LWORK >= max(1,3*N-1).
  4275. For optimal efficiency, LWORK >= (NB+2)*N,
  4276. where NB is the blocksize for NUMlapack_dsytrd returned by NUMlapack_ilaenv.
  4277. If LWORK = -1, then a workspace query is assumed; the routine
  4278. only calculates the optimal size of the WORK array, returns
  4279. this value as the first entry of the WORK array, and no error
  4280. message related to LWORK is issued by XERBLA.
  4281. INFO (output) long
  4282. = 0: successful exit
  4283. < 0: if INFO = -i, the i-th argument had an illegal value
  4284. > 0: if INFO = i, the algorithm failed to converge; i
  4285. off-diagonal elements of an intermediate tridiagonal
  4286. form did not converge to zero.
  4287. =====================================================================
  4288. */
  4289. int NUMlapack_dsytd2 (const char *uplo, integer *n, double *a, integer *lda, double *d,
  4290. double *e, double *tau, integer *info);
  4291. /* Purpose
  4292. =======
  4293. NUMlapack_dsytd2 reduces a real symmetric matrix A to symmetric tridiagonal
  4294. form T by an orthogonal similarity transformation: Q' * A * Q = T.
  4295. Arguments
  4296. =========
  4297. UPLO (input) char*
  4298. Specifies whether the upper or lower triangular part of the
  4299. symmetric matrix A is stored:
  4300. = 'U': Upper triangular
  4301. = 'L': Lower triangular
  4302. N (input) long
  4303. The order of the matrix A. N >= 0.
  4304. A (input/output) double array, dimension (LDA,N)
  4305. On entry, the symmetric matrix A. If UPLO = 'U', the leading
  4306. n-by-n upper triangular part of A contains the upper
  4307. triangular part of the matrix A, and the strictly lower
  4308. triangular part of A is not referenced. If UPLO = 'L', the
  4309. leading n-by-n lower triangular part of A contains the lower
  4310. triangular part of the matrix A, and the strictly upper
  4311. triangular part of A is not referenced.
  4312. On exit, if UPLO = 'U', the diagonal and first superdiagonal
  4313. of A are overwritten by the corresponding elements of the
  4314. tridiagonal matrix T, and the elements above the first
  4315. superdiagonal, with the array TAU, represent the orthogonal
  4316. matrix Q as a product of elementary reflectors; if UPLO
  4317. = 'L', the diagonal and first subdiagonal of A are over-
  4318. written by the corresponding elements of the tridiagonal
  4319. matrix T, and the elements below the first subdiagonal, with
  4320. the array TAU, represent the orthogonal matrix Q as a product
  4321. of elementary reflectors. See Further Details.
  4322. LDA (input) long
  4323. The leading dimension of the array A. LDA >= max(1,N).
  4324. D (output) double array, dimension (N)
  4325. The diagonal elements of the tridiagonal matrix T:
  4326. D(i) = A(i,i).
  4327. E (output) double array, dimension (N-1)
  4328. The off-diagonal elements of the tridiagonal matrix T:
  4329. E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'.
  4330. TAU (output) double array, dimension (N-1)
  4331. The scalar factors of the elementary reflectors (see Further
  4332. Details).
  4333. INFO (output) long
  4334. = 0: successful exit
  4335. < 0: if INFO = -i, the i-th argument had an illegal value.
  4336. Further Details
  4337. ===============
  4338. If UPLO = 'U', the matrix Q is represented as a product of elementary
  4339. reflectors
  4340. Q = H(n-1) . . . H(2) H(1).
  4341. Each H(i) has the form
  4342. H(i) = I - tau * v * v'
  4343. where tau is a real scalar, and v is a real vector with
  4344. v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in
  4345. A(1:i-1,i+1), and tau in TAU(i).
  4346. If UPLO = 'L', the matrix Q is represented as a product of elementary
  4347. reflectors
  4348. Q = H(1) H(2) . . . H(n-1).
  4349. Each H(i) has the form
  4350. H(i) = I - tau * v * v'
  4351. where tau is a real scalar, and v is a real vector with
  4352. v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i),
  4353. and tau in TAU(i).
  4354. The contents of A on exit are illustrated by the following examples
  4355. with n = 5:
  4356. if UPLO = 'U': if UPLO = 'L':
  4357. ( d e v2 v3 v4 ) ( d )
  4358. ( d e v3 v4 ) ( e d )
  4359. ( d e v4 ) ( v1 e d )
  4360. ( d e ) ( v1 v2 e d )
  4361. ( d ) ( v1 v2 v3 e d )
  4362. where d and e denote diagonal and off-diagonal elements of T, and vi
  4363. denotes an element of the vector defining H(i).
  4364. =====================================================================
  4365. */
  4366. int NUMlapack_dsytrd (const char *uplo, integer *n, double *a, integer *lda, double *d,
  4367. double *e, double *tau, double *work, integer *lwork, integer *info);
  4368. /* Purpose
  4369. =======
  4370. NUMlapack_dsytrd reduces a real symmetric matrix A to real symmetric
  4371. tridiagonal form T by an orthogonal similarity transformation:
  4372. Q**T * A * Q = T.
  4373. Arguments
  4374. =========
  4375. UPLO (input) char*
  4376. = 'U': Upper triangle of A is stored;
  4377. = 'L': Lower triangle of A is stored.
  4378. N (input) long
  4379. The order of the matrix A. N >= 0.
  4380. A (input/output) double array, dimension (LDA,N)
  4381. On entry, the symmetric matrix A. If UPLO = 'U', the leading
  4382. N-by-N upper triangular part of A contains the upper
  4383. triangular part of the matrix A, and the strictly lower
  4384. triangular part of A is not referenced. If UPLO = 'L', the
  4385. leading N-by-N lower triangular part of A contains the lower
  4386. triangular part of the matrix A, and the strictly upper
  4387. triangular part of A is not referenced.
  4388. On exit, if UPLO = 'U', the diagonal and first superdiagonal
  4389. of A are overwritten by the corresponding elements of the
  4390. tridiagonal matrix T, and the elements above the first
  4391. superdiagonal, with the array TAU, represent the orthogonal
  4392. matrix Q as a product of elementary reflectors; if UPLO
  4393. = 'L', the diagonal and first subdiagonal of A are over-
  4394. written by the corresponding elements of the tridiagonal
  4395. matrix T, and the elements below the first subdiagonal, with
  4396. the array TAU, represent the orthogonal matrix Q as a product
  4397. of elementary reflectors. See Further Details.
  4398. LDA (input) long
  4399. The leading dimension of the array A. LDA >= max(1,N).
  4400. D (output) double array, dimension (N)
  4401. The diagonal elements of the tridiagonal matrix T:
  4402. D(i) = A(i,i).
  4403. E (output) double array, dimension (N-1)
  4404. The off-diagonal elements of the tridiagonal matrix T:
  4405. E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'.
  4406. TAU (output) double array, dimension (N-1)
  4407. The scalar factors of the elementary reflectors (see Further
  4408. Details).
  4409. WORK (workspace/output) double array, dimension (LWORK)
  4410. On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  4411. LWORK (input) long
  4412. The dimension of the array WORK. LWORK >= 1.
  4413. For optimum performance LWORK >= N*NB, where NB is the
  4414. optimal blocksize.
  4415. If LWORK = -1, then a workspace query is assumed; the routine
  4416. only calculates the optimal size of the WORK array, returns
  4417. this value as the first entry of the WORK array, and no error
  4418. message related to LWORK is issued by XERBLA.
  4419. INFO (output) long
  4420. = 0: successful exit
  4421. < 0: if INFO = -i, the i-th argument had an illegal value
  4422. Further Details
  4423. ===============
  4424. If UPLO = 'U', the matrix Q is represented as a product of elementary
  4425. reflectors
  4426. Q = H(n-1) . . . H(2) H(1).
  4427. Each H(i) has the form
  4428. H(i) = I - tau * v * v'
  4429. where tau is a real scalar, and v is a real vector with
  4430. v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in
  4431. A(1:i-1,i+1), and tau in TAU(i).
  4432. If UPLO = 'L', the matrix Q is represented as a product of elementary
  4433. reflectors
  4434. Q = H(1) H(2) . . . H(n-1).
  4435. Each H(i) has the form
  4436. H(i) = I - tau * v * v'
  4437. where tau is a real scalar, and v is a real vector with
  4438. v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i),
  4439. and tau in TAU(i).
  4440. The contents of A on exit are illustrated by the following examples
  4441. with n = 5:
  4442. if UPLO = 'U': if UPLO = 'L':
  4443. ( d e v2 v3 v4 ) ( d )
  4444. ( d e v3 v4 ) ( e d )
  4445. ( d e v4 ) ( v1 e d )
  4446. ( d e ) ( v1 v2 e d )
  4447. ( d ) ( v1 v2 v3 e d )
  4448. where d and e denote diagonal and off-diagonal elements of T, and vi
  4449. denotes an element of the vector defining H(i).
  4450. =====================================================================
  4451. */
  4452. int NUMlapack_dtgsja(const char *jobu, const char *jobv, const char *jobq, integer *m, integer *p,
  4453. integer *n, integer *k, integer *l, double *a, integer *lda, double *b, integer *ldb,
  4454. double *tola, double *tolb, double *alpha, double *beta, double *u,
  4455. integer *ldu, double *v, integer *ldv, double *q, integer *ldq, double *work,
  4456. integer *ncycle, integer *info);
  4457. /* Purpose
  4458. =======
  4459. NUMlapack_dtgsja computes the generalized singular value decomposition (GSVD)
  4460. of two real upper triangular (or trapezoidal) matrices A and B.
  4461. On entry, it is assumed that matrices A and B have the following
  4462. forms, which may be obtained by the preprocessing subroutine NUMlapack_dggsvp
  4463. from a general M-by-N matrix A and P-by-N matrix B:
  4464. N-K-L K L
  4465. A = K ( 0 A12 A13 ) if M-K-L >= 0;
  4466. L ( 0 0 A23 )
  4467. M-K-L ( 0 0 0 )
  4468. N-K-L K L
  4469. A = K ( 0 A12 A13 ) if M-K-L < 0;
  4470. M-K ( 0 0 A23 )
  4471. N-K-L K L
  4472. B = L ( 0 0 B13 )
  4473. P-L ( 0 0 0 )
  4474. where the K-by-K matrix A12 and L-by-L matrix B13 are nonsingular
  4475. upper triangular; A23 is L-by-L upper triangular if M-K-L >= 0,
  4476. otherwise A23 is (M-K)-by-L upper trapezoidal.
  4477. On exit,
  4478. U'*A*Q = D1*( 0 R ), V'*B*Q = D2*( 0 R ),
  4479. where U, V and Q are orthogonal matrices, Z' denotes the transpose
  4480. of Z, R is a nonsingular upper triangular matrix, and D1 and D2 are
  4481. ``diagonal'' matrices, which are of the following structures:
  4482. If M-K-L >= 0,
  4483. K L
  4484. D1 = K ( I 0 )
  4485. L ( 0 C )
  4486. M-K-L ( 0 0 )
  4487. K L
  4488. D2 = L ( 0 S )
  4489. P-L ( 0 0 )
  4490. N-K-L K L
  4491. ( 0 R ) = K ( 0 R11 R12 ) K
  4492. L ( 0 0 R22 ) L
  4493. where
  4494. C = diag( ALPHA(K+1), ... , ALPHA(K+L) ),
  4495. S = diag( BETA(K+1), ... , BETA(K+L) ),
  4496. C**2 + S**2 = I.
  4497. R is stored in A(1:K+L,N-K-L+1:N) on exit.
  4498. If M-K-L < 0,
  4499. K M-K K+L-M
  4500. D1 = K ( I 0 0 )
  4501. M-K ( 0 C 0 )
  4502. K M-K K+L-M
  4503. D2 = M-K ( 0 S 0 )
  4504. K+L-M ( 0 0 I )
  4505. P-L ( 0 0 0 )
  4506. N-K-L K M-K K+L-M
  4507. ( 0 R ) = K ( 0 R11 R12 R13 )
  4508. M-K ( 0 0 R22 R23 )
  4509. K+L-M ( 0 0 0 R33 )
  4510. where
  4511. C = diag( ALPHA(K+1), ... , ALPHA(M) ),
  4512. S = diag( BETA(K+1), ... , BETA(M) ),
  4513. C**2 + S**2 = I.
  4514. R = ( R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N) and R33 is stored
  4515. ( 0 R22 R23 )
  4516. in B(M-K+1:L,N+M-K-L+1:N) on exit.
  4517. The computation of the orthogonal transformation matrices U, V or Q
  4518. is optional. These matrices may either be formed explicitly, or they
  4519. may be postmultiplied into input matrices U1, V1, or Q1.
  4520. Arguments
  4521. =========
  4522. JOBU (input) char*
  4523. = 'U': U must contain an orthogonal matrix U1 on entry, and
  4524. the product U1*U is returned;
  4525. = 'I': U is initialized to the unit matrix, and the
  4526. orthogonal matrix U is returned;
  4527. = 'N': U is not computed.
  4528. JOBV (input) char*
  4529. = 'V': V must contain an orthogonal matrix V1 on entry, and
  4530. the product V1*V is returned;
  4531. = 'I': V is initialized to the unit matrix, and the
  4532. orthogonal matrix V is returned;
  4533. = 'N': V is not computed.
  4534. JOBQ (input) char*
  4535. = 'Q': Q must contain an orthogonal matrix Q1 on entry, and
  4536. the product Q1*Q is returned;
  4537. = 'I': Q is initialized to the unit matrix, and the
  4538. orthogonal matrix Q is returned;
  4539. = 'N': Q is not computed.
  4540. M (input) long
  4541. The number of rows of the matrix A. M >= 0.
  4542. P (input) long
  4543. The number of rows of the matrix B. P >= 0.
  4544. N (input) long
  4545. The number of columns of the matrices A and B. N >= 0.
  4546. K (input) long
  4547. L (input) long
  4548. K and L specify the subblocks in the input matrices A and B:
  4549. A23 = A(K+1:MIN(K+L,M),N-L+1:N) and B13 = B(1:L,N-L+1:N)
  4550. of A and B, whose GSVD is going to be computed by NUMlapack_dtgsja.
  4551. See Further details.
  4552. A (input/output) double array, dimension (LDA,N)
  4553. On entry, the M-by-N matrix A.
  4554. On exit, A(N-K+1:N,1:MIN(K+L,M) ) contains the triangular
  4555. matrix R or part of R. See Purpose for details.
  4556. LDA (input) long
  4557. The leading dimension of the array A. LDA >= max(1,M).
  4558. B (input/output) double array, dimension (LDB,N)
  4559. On entry, the P-by-N matrix B.
  4560. On exit, if necessary, B(M-K+1:L,N+M-K-L+1:N) contains
  4561. a part of R. See Purpose for details.
  4562. LDB (input) long
  4563. The leading dimension of the array B. LDB >= max(1,P).
  4564. TOLA (input) double
  4565. TOLB (input) double
  4566. TOLA and TOLB are the convergence criteria for the Jacobi-
  4567. Kogbetliantz iteration procedure. Generally, they are the
  4568. same as used in the preprocessing step, say
  4569. TOLA = max(M,N)*norm(A)*MAZHEPS,
  4570. TOLB = max(P,N)*norm(B)*MAZHEPS.
  4571. ALPHA (output) double array, dimension (N)
  4572. BETA (output) double array, dimension (N)
  4573. On exit, ALPHA and BETA contain the generalized singular
  4574. value pairs of A and B;
  4575. ALPHA(1:K) = 1,
  4576. BETA(1:K) = 0,
  4577. and if M-K-L >= 0,
  4578. ALPHA(K+1:K+L) = diag(C),
  4579. BETA(K+1:K+L) = diag(S),
  4580. or if M-K-L < 0,
  4581. ALPHA(K+1:M)= C, ALPHA(M+1:K+L)= 0
  4582. BETA(K+1:M) = S, BETA(M+1:K+L) = 1.
  4583. Furthermore, if K+L < N,
  4584. ALPHA(K+L+1:N) = 0 and
  4585. BETA(K+L+1:N) = 0.
  4586. U (input/output) double array, dimension (LDU,M)
  4587. On entry, if JOBU = 'U', U must contain a matrix U1 (usually
  4588. the orthogonal matrix returned by NUMlapack_dggsvp).
  4589. On exit,
  4590. if JOBU = 'I', U contains the orthogonal matrix U;
  4591. if JOBU = 'U', U contains the product U1*U.
  4592. If JOBU = 'N', U is not referenced.
  4593. LDU (input) long
  4594. The leading dimension of the array U. LDU >= max(1,M) if
  4595. JOBU = 'U'; LDU >= 1 otherwise.
  4596. V (input/output) double array, dimension (LDV,P)
  4597. On entry, if JOBV = 'V', V must contain a matrix V1 (usually
  4598. the orthogonal matrix returned by NUMlapack_dggsvp).
  4599. On exit,
  4600. if JOBV = 'I', V contains the orthogonal matrix V;
  4601. if JOBV = 'V', V contains the product V1*V.
  4602. If JOBV = 'N', V is not referenced.
  4603. LDV (input) long
  4604. The leading dimension of the array V. LDV >= max(1,P) if
  4605. JOBV = 'V'; LDV >= 1 otherwise.
  4606. Q (input/output) double array, dimension (LDQ,N)
  4607. On entry, if JOBQ = 'Q', Q must contain a matrix Q1 (usually
  4608. the orthogonal matrix returned by NUMlapack_dggsvp).
  4609. On exit,
  4610. if JOBQ = 'I', Q contains the orthogonal matrix Q;
  4611. if JOBQ = 'Q', Q contains the product Q1*Q.
  4612. If JOBQ = 'N', Q is not referenced.
  4613. LDQ (input) long
  4614. The leading dimension of the array Q. LDQ >= max(1,N) if
  4615. JOBQ = 'Q'; LDQ >= 1 otherwise.
  4616. WORK (workspace) double array, dimension (2*N)
  4617. NCYCLE (output) long
  4618. The number of cycles required for convergence.
  4619. INFO (output) long
  4620. = 0: successful exit
  4621. < 0: if INFO = -i, the i-th argument had an illegal value.
  4622. = 1: the procedure does not converge after MAXIT cycles.
  4623. Internal Parameters
  4624. ===================
  4625. MAXIT long
  4626. MAXIT specifies the total loops that the iterative procedure
  4627. may take. If after MAXIT cycles, the routine fails to
  4628. converge, we return INFO = 1.
  4629. Further Details
  4630. ===============
  4631. NUMlapack_dtgsja essentially uses a variant of Kogbetliantz algorithm to reduce
  4632. min(L,M-K)-by-L triangular (or trapezoidal) matrix A23 and L-by-L
  4633. matrix B13 to the form:
  4634. U1'*A13*Q1 = C1*R1; V1'*B13*Q1 = S1*R1,
  4635. where U1, V1 and Q1 are orthogonal matrix, and Z' is the transpose
  4636. of Z. C1 and S1 are diagonal matrices satisfying
  4637. C1**2 + S1**2 = I,
  4638. and R1 is an L-by-L nonsingular upper triangular matrix.
  4639. =====================================================================
  4640. */
  4641. int NUMlapack_dtrevc (const char *side, const char *howmny, int * select, integer *n,
  4642. double *t, integer *ldt, double *vl, integer *ldvl, double *vr, integer *ldvr,
  4643. integer *mm, integer *m, double *work, integer *info);
  4644. /* -- LAPACK routine (version 3.0) --
  4645. Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  4646. Courant Institute, Argonne National Lab, and Rice University
  4647. June 30, 1999
  4648. Purpose
  4649. =======
  4650. NUMlapack_dtrevc computes some or all of the right and/or left eigenvectors of
  4651. a real upper quasi-triangular matrix T.
  4652. The right eigenvector x and the left eigenvector y of T corresponding
  4653. to an eigenvalue w are defined by:
  4654. T*x = w*x, y'*T = w*y'
  4655. where y' denotes the conjugate transpose of the vector y.
  4656. If all eigenvectors are requested, the routine may either return the
  4657. matrices X and/or Y of right or left eigenvectors of T, or the
  4658. products Q*X and/or Q*Y, where Q is an input orthogonal
  4659. matrix. If T was obtained from the real-Schur factorization of an
  4660. original matrix A = Q*T*Q', then Q*X and Q*Y are the matrices of
  4661. right or left eigenvectors of A.
  4662. T must be in Schur canonical form (as returned by NUMlapack_dhseqr), that is,
  4663. block upper triangular with 1-by-1 and 2-by-2 diagonal blocks; each
  4664. 2-by-2 diagonal block has its diagonal elements equal and its
  4665. off-diagonal elements of opposite sign. Corresponding to each 2-by-2
  4666. diagonal block is a complex conjugate pair of eigenvalues and
  4667. eigenvectors; only one eigenvector of the pair is computed, namely
  4668. the one corresponding to the eigenvalue with positive imaginary part.
  4669. Arguments
  4670. =========
  4671. SIDE (input) char*
  4672. = 'R': compute right eigenvectors only;
  4673. = 'L': compute left eigenvectors only;
  4674. = 'B': compute both right and left eigenvectors.
  4675. HOWMNY (input) char*
  4676. = 'A': compute all right and/or left eigenvectors;
  4677. = 'B': compute all right and/or left eigenvectors,
  4678. and backtransform them using the input matrices
  4679. supplied in VR and/or VL;
  4680. = 'S': compute selected right and/or left eigenvectors,
  4681. specified by the int array SELECT.
  4682. SELECT (input/output) int array, dimension (N)
  4683. If HOWMNY = 'S', SELECT specifies the eigenvectors to be
  4684. computed.
  4685. If HOWMNY = 'A' or 'B', SELECT is not referenced.
  4686. To select the real eigenvector corresponding to a real
  4687. eigenvalue w(j), SELECT(j) must be set to .TRUE.. To select
  4688. the complex eigenvector corresponding to a complex conjugate
  4689. pair w(j) and w(j+1), either SELECT(j) or SELECT(j+1) must be
  4690. set to .TRUE.; then on exit SELECT(j) is .TRUE. and
  4691. SELECT(j+1) is .FALSE..
  4692. N (input) long
  4693. The order of the matrix T. N >= 0.
  4694. T (input) double array, dimension (LDT,N)
  4695. The upper quasi-triangular matrix T in Schur canonical form.
  4696. LDT (input) long
  4697. The leading dimension of the array T. LDT >= max(1,N).
  4698. VL (input/output) double array, dimension (LDVL,MM)
  4699. On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must
  4700. contain an N-by-N matrix Q (usually the orthogonal matrix Q
  4701. of Schur vectors returned by NUMlapack_dhseqr).
  4702. On exit, if SIDE = 'L' or 'B', VL contains:
  4703. if HOWMNY = 'A', the matrix Y of left eigenvectors of T;
  4704. VL has the same quasi-lower triangular form
  4705. as T'. If T(i,i) is a real eigenvalue, then
  4706. the i-th column VL(i) of VL is its
  4707. corresponding eigenvector. If T(i:i+1,i:i+1)
  4708. is a 2-by-2 block whose eigenvalues are
  4709. complex-conjugate eigenvalues of T, then
  4710. VL(i)+sqrt(-1)*VL(i+1) is the complex
  4711. eigenvector corresponding to the eigenvalue
  4712. with positive real part.
  4713. if HOWMNY = 'B', the matrix Q*Y;
  4714. if HOWMNY = 'S', the left eigenvectors of T specified by
  4715. SELECT, stored consecutively in the columns
  4716. of VL, in the same order as their
  4717. eigenvalues.
  4718. A complex eigenvector corresponding to a complex eigenvalue
  4719. is stored in two consecutive columns, the first holding the
  4720. real part, and the second the imaginary part.
  4721. If SIDE = 'R', VL is not referenced.
  4722. LDVL (input) long
  4723. The leading dimension of the array VL. LDVL >= max(1,N) if
  4724. SIDE = 'L' or 'B'; LDVL >= 1 otherwise.
  4725. VR (input/output) double array, dimension (LDVR,MM)
  4726. On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
  4727. contain an N-by-N matrix Q (usually the orthogonal matrix Q
  4728. of Schur vectors returned by NUMlapack_dhseqr).
  4729. On exit, if SIDE = 'R' or 'B', VR contains:
  4730. if HOWMNY = 'A', the matrix X of right eigenvectors of T;
  4731. VR has the same quasi-upper triangular form
  4732. as T. If T(i,i) is a real eigenvalue, then
  4733. the i-th column VR(i) of VR is its
  4734. corresponding eigenvector. If T(i:i+1,i:i+1)
  4735. is a 2-by-2 block whose eigenvalues are
  4736. complex-conjugate eigenvalues of T, then
  4737. VR(i)+sqrt(-1)*VR(i+1) is the complex
  4738. eigenvector corresponding to the eigenvalue
  4739. with positive real part.
  4740. if HOWMNY = 'B', the matrix Q*X;
  4741. if HOWMNY = 'S', the right eigenvectors of T specified by
  4742. SELECT, stored consecutively in the columns
  4743. of VR, in the same order as their
  4744. eigenvalues.
  4745. A complex eigenvector corresponding to a complex eigenvalue
  4746. is stored in two consecutive columns, the first holding the
  4747. real part and the second the imaginary part.
  4748. If SIDE = 'L', VR is not referenced.
  4749. LDVR (input) long
  4750. The leading dimension of the array VR. LDVR >= max(1,N) if
  4751. SIDE = 'R' or 'B'; LDVR >= 1 otherwise.
  4752. MM (input) long
  4753. The number of columns in the arrays VL and/or VR. MM >= M.
  4754. M (output) long
  4755. The number of columns in the arrays VL and/or VR actually
  4756. used to store the eigenvectors.
  4757. If HOWMNY = 'A' or 'B', M is set to N.
  4758. Each selected real eigenvector occupies one column and each
  4759. selected complex eigenvector occupies two columns.
  4760. WORK (workspace) double array, dimension (3*N)
  4761. INFO (output) INTEGER
  4762. = 0: successful exit
  4763. < 0: if INFO = -i, the i-th argument had an illegal value
  4764. Further Details
  4765. ===============
  4766. The algorithm used in this program is basically backward (forward)
  4767. substitution, with scaling to make the the code robust against
  4768. possible overflow.
  4769. Each eigenvector is normalized so that the element of largest
  4770. magnitude has magnitude 1; here the magnitude of a complex number
  4771. (x,y) is taken to be |x| + |y|.
  4772. =====================================================================
  4773. */
  4774. int NUMlapack_dtrti2 (const char *uplo, const char *diag, integer *n, double *a, integer *lda, integer *info);
  4775. /* Purpose
  4776. =======
  4777. NUMlapack_dtrti2 computes the inverse of a real upper or lower triangular
  4778. matrix.
  4779. This is the Level 2 BLAS version of the algorithm.
  4780. Arguments
  4781. =========
  4782. UPLO (input) char*
  4783. Specifies whether the matrix A is upper or lower triangular.
  4784. = 'U': Upper triangular
  4785. = 'L': Lower triangular
  4786. DIAG (input) char*
  4787. Specifies whether or not the matrix A is unit triangular.
  4788. = 'N': Non-unit triangular
  4789. = 'U': Unit triangular
  4790. N (input) long
  4791. The order of the matrix A. N >= 0.
  4792. A (input/output) double array, dimension (LDA,N)
  4793. On entry, the triangular matrix A. If UPLO = 'U', the
  4794. leading n by n upper triangular part of the array A contains
  4795. the upper triangular matrix, and the strictly lower
  4796. triangular part of A is not referenced. If UPLO = 'L', the
  4797. leading n by n lower triangular part of the array A contains
  4798. the lower triangular matrix, and the strictly upper
  4799. triangular part of A is not referenced. If DIAG = 'U', the
  4800. diagonal elements of A are also not referenced and are
  4801. assumed to be 1.
  4802. On exit, the (triangular) inverse of the original matrix, in
  4803. the same storage format.
  4804. LDA (input) long
  4805. The leading dimension of the array A. LDA >= max(1,N).
  4806. INFO (output) long
  4807. = 0: successful exit
  4808. < 0: if INFO = -k, the k-th argument had an illegal value
  4809. =====================================================================
  4810. */
  4811. int NUMlapack_dtrtri (const char *uplo, const char *diag, integer *n, double *
  4812. a, integer *lda, integer *info);
  4813. /* Purpose
  4814. =======
  4815. NUMlapack_dtrtri computes the inverse of a real upper or lower triangular
  4816. matrix A.
  4817. This is the Level 3 BLAS version of the algorithm.
  4818. Arguments
  4819. =========
  4820. UPLO (input) char*
  4821. = 'U': A is upper triangular;
  4822. = 'L': A is lower triangular.
  4823. DIAG (input) char*
  4824. = 'N': A is non-unit triangular;
  4825. = 'U': A is unit triangular.
  4826. N (input) long
  4827. The order of the matrix A. N >= 0.
  4828. A (input/output) double array, dimension (LDA,N)
  4829. On entry, the triangular matrix A. If UPLO = 'U', the
  4830. leading N-by-N upper triangular part of the array A contains
  4831. the upper triangular matrix, and the strictly lower
  4832. triangular part of A is not referenced. If UPLO = 'L', the
  4833. leading N-by-N lower triangular part of the array A contains
  4834. the lower triangular matrix, and the strictly upper
  4835. triangular part of A is not referenced. If DIAG = 'U', the
  4836. diagonal elements of A are also not referenced and are
  4837. assumed to be 1.
  4838. On exit, the (triangular) inverse of the original matrix, in
  4839. the same storage format.
  4840. LDA (input) long
  4841. The leading dimension of the array A. LDA >= max(1,N).
  4842. INFO (output) long
  4843. = 0: successful exit
  4844. < 0: if INFO = -i, the i-th argument had an illegal value
  4845. > 0: if INFO = i, A(i,i) is exactly zero. The triangular
  4846. matrix is singular and its inverse can not be computed.
  4847. =====================================================================
  4848. */
  4849. integer NUMlapack_ieeeck (integer *ispec, float *zero, float *one);
  4850. /* Purpose
  4851. =======
  4852. NUMlapack_ieeeck is called from the NUMlapack_ilaenv to verify that Infinity and
  4853. possibly NaN arithmetic is safe (i.e. will not trap).
  4854. Arguments
  4855. =========
  4856. ISPEC (input) long
  4857. Specifies whether to test just for inifinity arithmetic
  4858. or whether to test for infinity and NaN arithmetic.
  4859. = 0: Verify infinity arithmetic only.
  4860. = 1: Verify infinity and NaN arithmetic.
  4861. ZERO (input) REAL
  4862. Must contain the value 0.0
  4863. This is passed to prevent the compiler from optimizing
  4864. away this code.
  4865. ONE (input) REAL
  4866. Must contain the value 1.0
  4867. This is passed to prevent the compiler from optimizing
  4868. away this code.
  4869. RETURN VALUE: long
  4870. = 0: Arithmetic failed to produce the correct answers
  4871. = 1: Arithmetic produced the correct answers
  4872. */
  4873. integer NUMlapack_ilaenv (integer *ispec, const char *name, const char *opts, integer *n1,
  4874. integer *n2, integer *n3, integer *n4, integer name_len, integer opts_len);
  4875. /* Purpose
  4876. =======
  4877. NUMlapack_ilaenv is called from the LAPACK routines to choose problem-dependent
  4878. parameters for the local environment. See ISPEC for a description of
  4879. the parameters.
  4880. This version provides a set of parameters which should give good,
  4881. but not optimal, performance on many of the currently available
  4882. computers. Users are encouraged to modify this subroutine to set
  4883. the tuning parameters for their particular machine using the option
  4884. and problem size information in the arguments.
  4885. This routine will not function correctly if it is converted to all
  4886. lower case. Converting it to all upper case is allowed.
  4887. Arguments
  4888. =========
  4889. ISPEC (input) long
  4890. Specifies the parameter to be returned as the value of
  4891. NUMlapack_ilaenv.
  4892. = 1: the optimal blocksize; if this value is 1, an unblocked
  4893. algorithm will give the best performance.
  4894. = 2: the minimum block size for which the block routine
  4895. should be used; if the usable block size is less than
  4896. this value, an unblocked routine should be used.
  4897. = 3: the crossover point (in a block routine, for N less
  4898. than this value, an unblocked routine should be used)
  4899. = 4: the number of shifts, used in the nonsymmetric
  4900. eigenvalue routines
  4901. = 5: the minimum column dimension for blocking to be used;
  4902. rectangular blocks must have dimension at least k by m,
  4903. where k is given by NUMlapack_ilaenv(2,...) and m by NUMlapack_ilaenv(5,...)
  4904. = 6: the crossover point for the SVD (when reducing an m by n
  4905. matrix to bidiagonal form, if max(m,n)/min(m,n) exceeds
  4906. this value, a QR factorization is used first to reduce
  4907. the matrix to a triangular form.)
  4908. = 7: the number of processors
  4909. = 8: the crossover point for the multishift QR and QZ methods
  4910. for nonsymmetric eigenvalue problems.
  4911. = 9: maximum size of the subproblems at the bottom of the
  4912. computation tree in the divide-and-conquer algorithm
  4913. (used by xGELSD and xGESDD)
  4914. =10: ieee NaN arithmetic can be trusted not to trap
  4915. =11: infinity arithmetic can be trusted not to trap
  4916. NAME (input) CHARACTER*(*)
  4917. The name of the calling subroutine, in either upper case or
  4918. lower case.
  4919. OPTS (input) CHARACTER*(*)
  4920. The character options to the subroutine NAME, concatenated
  4921. into a single character string. For example, UPLO = 'U',
  4922. TRANS = 'T', and DIAG = 'N' for a triangular routine would
  4923. be specified as OPTS = 'UTN'.
  4924. N1 (input) long
  4925. N2 (input) long
  4926. N3 (input) long
  4927. N4 (input) long
  4928. Problem dimensions for the subroutine NAME; these may not all
  4929. be required.
  4930. (NUMlapack_ilaenv) (output) long
  4931. >= 0: the value of the parameter specified by ISPEC
  4932. < 0: if NUMlapack_ilaenv = -k, the k-th argument had an illegal value.
  4933. Further Details
  4934. ===============
  4935. The following conventions have been used when calling NUMlapack_ilaenv from the
  4936. LAPACK routines:
  4937. 1) OPTS is a concatenation of all of the character options to
  4938. subroutine NAME, in the same order that they appear in the
  4939. argument list for NAME, even if they are not used in determining
  4940. the value of the parameter specified by ISPEC.
  4941. 2) The problem dimensions N1, N2, N3, N4 are specified in the order
  4942. that they appear in the argument list for NAME. N1 is used
  4943. first, N2 second, and so on, and unused problem dimensions are
  4944. passed a value of -1.
  4945. 3) The parameter value returned by NUMlapack_ilaenv is checked for validity in
  4946. the calling subroutine. For example, NUMlapack_ilaenv is used to retrieve
  4947. the optimal blocksize for STRTRI as follows:
  4948. NB = NUMlapack_ilaenv( 1, 'STRTRI', UPLO // DIAG, N, -1, -1, -1 )
  4949. IF( NB.LE.1 ) NB = MAX( 1, N )
  4950. =====================================================================
  4951. */
  4952. #endif /* _NUMclapack_h_ */