diff --git a/org/qmckl_numprec.org b/org/qmckl_numprec.org index 9ca8104..3b73dc3 100644 --- a/org/qmckl_numprec.org +++ b/org/qmckl_numprec.org @@ -262,7 +262,7 @@ qmckl_exit_code qmckl_set_numprec_range(const qmckl_context context, const int r ~qmckl_get_numprec_range~ returns the value of the numerical range in the context. #+begin_src c :comments org :tangle (eval h_func) :exports none -int32_t qmckl_context_get_range(const qmckl_context context); +int32_t qmckl_get_numprec_get_range(const qmckl_context context); #+end_src # Source diff --git a/org/qmckl_sherman_morrison_woodbury.org b/org/qmckl_sherman_morrison_woodbury.org index cf8f15f..efb75dc 100644 --- a/org/qmckl_sherman_morrison_woodbury.org +++ b/org/qmckl_sherman_morrison_woodbury.org @@ -23,10 +23,9 @@ int main() { qmckl_context context; context = qmckl_context_create(); - qmckl_exit_code rc; #+end_src - + * Naïve Sherman-Morrison ** ~qmckl_sherman_morrison~ @@ -71,7 +70,7 @@ int main() { | double | Slater_inv[Dim*Dim] | inout | Array containing the inverse of a Slater-matrix | *** Requirements - + * ~context~ is not ~QMCKL_NULL_CONTEXT~ * ~Dim >= 2~ * ~N_updates >= 1~ @@ -79,7 +78,7 @@ int main() { * ~Updates_index~ is allocated with $N_updates$ elements * ~breakdown~ is a small number such that $0 < breakdown << 1$ * ~Slater_inv~ is allocated with $Dim \times Dim$ elements - + *** C header #+CALL: generate_c_header(table=qmckl_sherman_morrison_args,rettyp=get_value("CRetType"),fname=get_value("Name")) @@ -88,32 +87,32 @@ int main() { #+begin_src c :tangle (eval h_func) :comments org qmckl_exit_code qmckl_sherman_morrison( const qmckl_context context, - const uint64_t* Dim_p, - const uint64_t* N_updates_p, + const uint64_t Dim, + const uint64_t N_updates, const double* Updates, const uint64_t* Updates_index, - const double* breakdown_p, - double* Slater_inv); + const double breakdown, + double* Slater_inv); #+end_src -*** Source +*** C source #+begin_src c :tangle (eval c) :comments org #include #include #include "qmckl.h" -qmckl_exit_code qmckl_sherman_morrison_c_(const qmckl_context context, - const uint64_t* Dim_p, - const uint64_t* N_updates_p, +qmckl_exit_code qmckl_sherman_morrison(const qmckl_context context, + const uint64_t Dim, + const uint64_t N_updates, const double* Updates, const uint64_t* Updates_index, - const double* breakdown_p, + const double breakdown, double* Slater_inv) { - - const uint64_t Dim = *Dim_p; - const uint64_t N_updates = *N_updates_p; - const double breakdown = *breakdown_p; + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } double C[Dim]; double D[Dim]; @@ -162,39 +161,13 @@ qmckl_exit_code qmckl_sherman_morrison_c_(const qmckl_context context, use Sherman-Morrison with update splitting for these cycles since splitting can never resolve a situation where applying the update causes singular behaviour. -** C interface :noexport: +** Fortran interface :noexport: :PROPERTIES: :Name: qmckl_sherman_morrison :CRetType: qmckl_exit_code :FRetType: qmckl_exit_code :END: - - #+CALL: generate_c_interface(table=qmckl_sherman_morrison_args,rettyp=get_value("FRetType"),fname=get_value("Name")) - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_sherman_morrison & - (context, Dim, N_updates, Updates, Updates_index, breakdown, Slater_inv) & - bind(C) result(info) - - use, intrinsic :: iso_c_binding - implicit none - - integer (c_int64_t) , intent(in) , value :: context - integer (c_int64_t) , intent(in) :: Dim - integer (c_int64_t) , intent(in) :: N_updates - real (c_double ) , intent(in) :: Updates(N_updates*Dim) - integer (c_int64_t) , intent(in) :: Updates_index(N_updates) - real (c_double ) , intent(in) :: breakdown - real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim) - - integer(c_int32_t), external :: qmckl_sherman_morrison_c - info = qmckl_sherman_morrison_c & - (context, Dim, N_updates, Updates, Updates_index, breakdown, Slater_inv) - - end function qmckl_sherman_morrison - #+end_src - #+CALL: generate_f_interface(table=qmckl_sherman_morrison_args,rettyp=get_value("FRetType"),fname=get_value("Name")) #+RESULTS: @@ -209,11 +182,11 @@ qmckl_exit_code qmckl_sherman_morrison_c_(const qmckl_context context, implicit none integer (c_int64_t) , intent(in) , value :: context - integer (c_int64_t) , intent(in) :: Dim - integer (c_int64_t) , intent(in) :: N_updates + integer (c_int64_t) , intent(in) , value :: Dim + integer (c_int64_t) , intent(in) , value :: N_updates real (c_double ) , intent(in) :: Updates(N_updates*Dim) integer (c_int64_t) , intent(in) :: Updates_index(N_updates) - real (c_double ) , intent(in) :: breakdown + real (c_double ) , intent(in) , value :: breakdown real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim) end function qmckl_sherman_morrison @@ -226,10 +199,8 @@ The tests for the kernels are executed on datasets that are extracted from a run #+begin_src c :tangle (eval c_test) const uint64_t Dim = 21; -const uint64_t* Dim_p = &Dim; const uint64_t* N_updates_p = NULL; const double breakdown = 1e-3; -const double* breakdown_p = &breakdown; const double tolerance = 1e-3; double res[441]; @@ -260,14 +231,10 @@ const double Updates5[105] = {-0.026680206879973502, 0.27298007905483301, -0.099 const double Slater5[441] = {-2.8945870399475102, 3.5455725193023699, 2.0470812320709202, -3.5464441776275599, -2.0474903583526598, -2.89596366882324, -0.61329728364944502, 0.70991641283035301, 0.45664468407630898, 0.59523195028305098, 0.26079276204109197, -0.027727147564291999, -0.35093706846237199, -0.095610238611698206, -0.130077064037323, 0.10946778208017301, 0.021800471469759899, 0.048480678349733401, -0.092234551906585693, -0.0160505045205355, -0.42026260495185902, -0.78021097183227495, -0.95558542013168302, -0.55174458026885997, -0.95579683780670199, -0.55179446935653698, 0.78044348955154397, -0.115299895405769, -0.11754634231329, -0.0318448171019554, -0.00082233443390577999, 0.064001239836216001, 0.12740932404995001, -0.049412809312343597, -0.074464745819568606, 0.19851659238338501, -0.088878795504569993, 0.135610401630402, -0.13736967742443101, -0.101879440248013, 0.102390937507153, -0.12476679682731601, -0.00527230883017182, 0.00029381641070358499, 0.0072919740341603799, -0.00026352208806201799, 0.0068838247098028703, 0.0047294595278799499, 0.11728889495134399, -0.062190085649490398, -0.15969239175319699, -0.10645916312933, 0.112943567335606, -0.0015487050404772199, -0.045737843960523598, 0.13196058571338701, 0.038660705089569099, -0.050266433507204097, -0.13745591044426, -0.037740666419267703, 0.11781705915927899, 0.19417031109332999, -0.0079971449449658394, -0.30874741077423101, -0.37815779447555498, 0.218254208564758, 0.378139227628708, -0.21839827299118, -0.30879178643226601, 0.025539221242070202, 0.112043909728527, 0.037676706910133403, 0.025347150862216901, -0.19991625845432301, 0.14163509011268599, 0.13326919078826899, 0.213842943310738, 0.131471157073975, 0.14626120030879999, -0.0118067460134625, 0.093547157943248693, 0.22439678013324699, 0.0082425400614738499, 0.0250354297459126, -1.52881526947021, -1.9163775505148799e-05, -2.1623263359069802, -1.5540548702119799e-05, 2.16284847259521, -1.52953028678894, -0.26402890682220498, 0.024944067001342801, -0.37140902876853898, -0.044071510434150703, -0.29843890666961698, -0.043834518641233403, -0.177285701036453, -0.058585006743669503, -0.0183692276477814, -0.026075478643178902, -0.15623773634433699, -0.011319605633616401, 0.054057534784078598, -0.23151709139347099, -0.0016308756312355399, -0.067333526909351293, 0.00043256155913695698, 0.095035225152969402, -0.00043632232700474598, 0.094624765217304202, 0.066768139600753798, 0.14448715746402699, -0.12090456485748299, -0.203432962298393, -0.21472349762916601, 0.154288679361343, 0.017385326325893399, -0.071518480777740506, 0.27918133139610302, 0.080454014241695404, -0.0361245274543762, 0.0566458702087402, -0.030157707631588, 0.25150132179260298, -0.082445412874221802, -0.017600754275918, -2.2779068946838401, -2.3393469746224599e-05, -3.2218937873840301, -1.7939200915861899e-05, 3.22278833389282, -2.2791447639465301, -0.47945570945739702, 0.045197278261184699, -0.64478874206543002, -0.080234304070472703, -0.47389149665832497, 0.024908870458602898, -0.23455648124218001, -0.10695217549800901, -0.033054649829864502, -0.195749551057816, -0.040076982229948002, 0.094596333801746396, 0.098401188850402804, -0.059563819319009802, -0.0045592403039336196, -0.0025739683769643298, -0.0020174346864223502, -0.0024467820767313199, -0.00204527890309691, 0.00013988610589876801, 0.00073755031917244196, 0.17339251935482, 0.099962860345840496, 0.14622049033641801, -0.088966980576515198, 0.040044382214546197, -0.14437201619148299, -1.5416861060657501e-05, -0.081159926950931494, -0.11909016221761699, 0.170753449201584, 0.031124599277973199, -0.052109345793724102, 0.121445283293724, 0.0289684906601906, 0.120766848325729, -0.0043673445470631097, -0.00014539182302542001, 0.0061219600029289696, 0.000189467871678062, 0.0060523007996380303, 0.00425094133242965, 0.0905451029539108, 0.058540407568216303, -0.15191346406936601, 0.11511342227459, 0.15016922354698201, 0.10024280846118901, -0.11066282540559801, -0.15089659392833699, -0.021995550021529201, 0.10021472722291901, 0.019932290539145501, 0.070281185209751101, -0.120184391736984, -0.030551897361874601, 0.10763206332922, -0.0097634727135300602, 0.0119331693276763, -0.0068263513967394803, 0.011701960116624799, -0.0068089049309492103, 0.0095072658732533507, 0.133816182613373, -0.15090283751487699, 0.070243604481220204, 0.077758952975273105, -0.071993313729763003, -0.0526336021721363, -0.033549431711435297, -0.029018172994255999, 0.10475520789623299, 0.047332767397165298, 0.17077720165252699, 0.057527918368577999, -0.043988067656755399, 0.11077278107404701, -0.11803108453750601, -0.71565270423889205, 2.80283820757177e-05, 1.0121610164642301, -2.41986454057042e-05, 1.0123220682144201, 0.71586799621581998, -0.045286595821380601, -0.0269623268395662, 0.0683262273669243, -0.047560662031173699, -0.062597043812274905, -0.0278066452592611, 0.045772761106491103, 0.063010454177856404, 0.0197743345052004, -0.025724532082676901, -0.20542661845684099, -0.0248414911329746, 0.058127623051405002, 0.30385830998420699, -0.0018243347294628601, -0.00073456991231069001, 0.000104061764432117, -0.0010063005611300501, 0.00014142321015242501, 0.00095045292982831597, -0.00064003589795902404, 0.056538689881563201, -0.038196403533220298, 0.095246985554695102, 0.077704243361949907, 0.089713566005229894, 0.071932643651962294, 0.058404259383678402, 0.097089007496833801, -1.8242251826450202e-05, -0.070699930191039997, 0.0231548044830561, 0.036239527165889698, -0.064700096845626803, 0.035663921386003501, 0.140344902873039, -0.0285779368132353, 2.2119384368579599e-07, -0.0404084548354149, 4.62594880445977e-06, 0.040473498404025997, -0.028664523735642398, 0.0818745791912079, -0.0072916029021143896, 0.171691119670868, 0.0142411412671208, 0.227563425898552, 0.20764905214309701, 0.23875248432159399, 0.019401129335165, 0.0041248365305364097, -0.273390233516693, 0.031942136585712398, 0.24207504093647, -0.016599044203758202, 0.0499182641506195, 0.011294623836875, -0.083720728754997295, -0.102523192763329, -0.059237916022539097, -0.10253403335809699, -0.0591498985886574, 0.083691440522670704, 0.093738317489623996, 0.118414394557476, 0.119053602218628, -0.19025875627994501, -0.017257452011108398, 0.111288614571095, -0.14737996459007299, -0.106449924409389, 0.119639433920383, -0.0358475148677826, 0.16083629429340399, -0.135845571756363, -0.045223556458950001, 0.129632458090782, 0.0101170120760798, -0.0016409500967711199, 0.0020083498675376199, 0.0011536112288013101, -0.0019761291332542901, -0.0011378186754882301, -0.0015965295024216199, 0.062009602785110501, -0.085591755807399694, -0.073869466781616197, -0.129948750138283, -0.025633471086621298, 0.092304252088069902, 0.11476875841617599, 0.0570255033671856, -0.098354063928127303, 0.048130486160516697, -0.075562968850135803, -0.087558984756469699, -0.061446368694305399, 0.073952160775661496, -0.030968701466917999, -0.086937576532363905, -5.2227896958356703e-05, -0.12295132130384399, -5.67086790397298e-05, 0.122932203114033, -0.086922481656074496, 0.092386581003665896, 0.0563923679292202, 0.16267444193363201, -0.103307262063026, 0.177027583122253, 0.119934171438217, 0.15235325694084201, -0.13730293512344399, -0.036718469113111503, -0.13380806148052199, -0.14056211709976199, 0.11525499820709199, 0.122316166758537, -0.211628392338753, -0.030221903696656199, -0.71328485012054399, -0.87364697456359897, -0.50431287288665805, -0.87368428707122803, -0.50450080633163497, 0.71341556310653698, -0.0728774294257164, -0.0137394573539495, -0.131415024399757, 0.120499663054943, -0.15048809349536901, 0.067258194088935894, -0.016238121315836899, 0.25341770052909901, 0.061544414609670597, -0.124150305986404, -0.023104058578610399, 0.161576017737389, -0.18417926132678999, -0.016373874619603199, -0.061180751770734801, -0.00358590018004179, -3.1569013572152501e-06, 0.00505110481753945, -1.33700987134944e-05, 0.0050756097771227403, 0.0036168387159705201, 0.076649472117423997, -0.0148532707244158, -0.15424914658069599, -0.031277053058147403, 0.20174449682235701, 0.17827098071575201, -0.21435502171516399, 0.043405968695879003, 0.0060502337291836704, 0.23922684788703899, 0.022777535021305102, 0.22072769701480899, 0.035028267651796299, -0.037091828882694203, -0.054775215685367598, -0.0137155568227172, -0.00072690693195909305, 0.019026592373848, 0.00073597067967057196, 0.018235495314001999, 0.012611641548574, 0.14907942712307001, 0.10721461474895499, -0.205590710043907, 0.18899101018905601, 0.14405034482479101, 0.0080890702083706908, -0.049517802894115399, -0.23817741870880099, -0.062822751700878102, -0.056222390383482, 0.079762905836105305, -0.057780988514423398, -0.208331778645515, -0.11229432374239, 0.0132825700566173, -0.13207408785819999, -0.00012266315752640399, -0.18668732047080999, -0.000116608949610963, 0.18647037446498901, -0.13181127607822399, 0.17992316186428101, 0.0310163982212543, 0.194987177848816, -0.051282022148370701, 0.079243704676628099, -0.16229276359081299, -0.029616238549351699, -0.065854735672473894, -0.025143278762698201, 0.277732163667679, -0.117880158126354, -0.184251189231873, 0.0632317289710045, -0.16761179268360099, 0.0096404440701007808, -0.0068073021247982996, -0.0083365431055426598, 0.0048150913789868398, 0.0083073899149894697, -0.0047997133806347804, -0.0067770029418170504, 0.077614806592464405, 0.12953585386276201, -0.063416801393032102, 0.138088583946228, -0.10224375873804099, 0.130568191409111, 0.164952263236046, 0.026345754042267799, 0.13718618452549, 0.084768116474151597, 0.096043966710567502, -0.054612904787063599, 0.138456135988235, -0.071488708257675199, -0.0153317032381892}; double Slater_inv5[441] = {-0.054189244668834902, -105.426713929607, -88.458496476283003, 1.5333775291907901, -306.17152423250297, 211.834723659242, 189.348181800731, -164.85602878397, 1001.02895803198, -19.086531171244101, -14.1862411100869, 93.929906236367501, -177.880045125896, -6.7382862272631598, -14.511503830974201, 198.86948709278099, 116.24375034946701, -509.187787693936, -474.82187536023201, 185.49468275501101, -68.704359475869197, 0.066396729468773799, 128.61396390514599, 107.279152808508, -3.2214077352586501, 377.39638500462598, -258.32727230254102, -233.50899542599601, 202.73053181330999, -1222.6711957145401, 23.374193247961198, 17.0231928902612, -115.31992914359, 218.34781344598201, 8.5868800406738099, 17.706454078785399, -244.13052330624399, -142.42769283244499, 622.15335091370196, 579.15535219316803, -228.72024346964599, 85.262861528059901, 0.042977214694503003, -75.818887039648899, -63.4429496117761, 1.89037149893251, -221.440571714557, 152.54192851849001, 136.92110635753301, -119.073716594494, 720.98982202338402, -13.516656591400601, -9.7291496308540406, 67.372278162472895, -128.19425354399101, -4.9638472213270699, -10.200417492010599, 143.31769471617801, 83.615852083439094, -366.86654819753397, -341.426964056759, 133.98241248588599, -50.230799667840699, -0.074440153582489205, 131.003888225851, 110.340015781723, -1.92534262087524, 381.482058581253, -264.51148724341499, -236.035513173862, 204.43864191351099, -1249.3967405711001, 23.404380739562701, 17.427737318703301, -116.737852869633, 221.189913802663, 8.4677080090305399, 17.684126766935599, -247.44394443997601, -145.031902348194, 635.53348480709997, 592.58164589603302, -230.87850923206801, 85.694308069456397, -0.038299262589364599, -74.702005824131604, -63.171412849899497, 1.0859859506457199, -217.148397050222, 150.25957665606299, 134.431598757773, -117.013550651343, 708.34335491195498, -13.4940069422526, -9.5788103819957797, 66.593490547156307, -125.80391712960601, -4.7671091217963504, -10.2632044954116, 140.809682960885, 82.366527572926103, -360.28206877713399, -335.74815599116999, 131.925760239261, -48.660685665615503, -0.060749768867194, 106.92546569584999, 88.790343162838894, -2.6692288353747702, 312.16097467403699, -214.903931604847, -193.215823966269, 167.781122174079, -1018.10641886182, 19.107519450141002, 14.388719322765001, -95.267373183568594, 180.40857560667001, 6.9728512293157801, 14.4102075774752, -201.83015329787199, -117.917199027973, 518.09179195913805, 482.46342773412402, -189.25708821193001, 70.869624357767506, -0.000187411047696029, -11.9846117540694, -9.5726690972884096, 0.23970985157893901, -31.525734707294099, 26.424001662617101, 19.629541977294, -12.8111861333484, 126.186955595279, -0.21994779537689901, -1.75278408990554, 12.699562562401301, -19.050321348645301, 0.28466729039388, -1.07057307471916, 20.675591706275501, 13.1048598424623, -64.121267975873096, -59.394985304548896, 16.918592992744401, -7.70362909966763, 0.00036065684724530402, 12.9068309168011, 12.002712393435401, -0.33194601220397202, 40.326484701927001, -31.878253347415502, -25.170560077575001, 17.9905011861023, -156.05779622500401, 0.28522581276215098, 2.06069522309385, -17.151275363286, 25.397351917205899, 2.08581286823873, 0.91118057859336898, -26.515090998756101, -14.4035822159035, 78.890023885294596, 75.240667711773398, -20.769502289340899, 10.973365712218101, 0.00054214253230406803, -2.29504518628212, -2.1312244512866698, 0.047562978801466302, -10.6318457557031, 3.0591772010668401, 6.6375862982055702, -4.4363733110097296, 16.291945106274301, -0.062929125223047597, -0.16835581689436099, 6.0820271877694996, -5.8351950377758204, 0.35401259185447298, -0.90070453596893996, 6.0382685793059503, 2.4785619931575602, -8.4908203096171402, -8.6197966065449307, 5.8804527059182696, -1.67757738078734, 0.00096800508899916803, -2.4934502646428101, -4.5195305250493698, 0.052900907147883501, -6.5403147654399101, 8.5375829900159896, 4.1350660479474399, -1.63386715634978, 39.5635438458416, -0.11054656518749099, -0.56905231469759199, 10.2311793759502, -8.8014973731182806, -1.42214511908425, -1.9356586876592501, 7.4277556761303396, 2.8985267278915199, -19.981167223464801, -18.310196540769098, 1.3631485584979499, -1.4104996470922699, 0.000167515045034934, 10.6237721447983, 9.6125946891096099, -0.20829092726741699, 28.481388931713699, -22.584157610136199, -17.8392407006579, 11.6781776869203, -110.705963174229, 0.192721307745398, 1.4471736958685699, -11.629464509211299, 19.0388155304672, -0.23390314175395899, 0.62505732559282601, -19.284349111137399, -11.6199046959709, 56.562315732201498, 53.440734762614099, -13.464260193464, 6.5494922727750904, -0.00064712664753083498, 0.51012013976619996, -0.40601608060218902, -0.010304898323864499, -1.9162384482042301, 0.67040773560745603, 1.4195140953666501, 1.89175006728124, 8.4997123797302105, -0.053837688493721801, -0.0081694468687663092, 7.5841687069424202, -3.9864241641726901, 0.82441242748559596, 1.28841942280286, 2.4602644684099202, -0.65833650503714802, -2.93422340475106, -4.7994849299481297, -3.1153746742144999, 0.76509679552570997, -0.00094253467883977896, 4.5884404541075803, 2.5577714145483599, -0.100362327319965, 18.711173319888399, -7.5191542625802104, -11.814804467633101, 7.51205003788884, -36.605280961279099, 0.11460812693040601, 0.498461399643222, -10.903564320961401, 13.2948947844546, -0.64349351510306596, 1.9974412451213299, -11.727821769419799, -4.9603602940684901, 17.916362650168399, 17.291804112001799, -7.9761250950845, 3.6407278735208699, -0.000183321670183587, 6.4691421816769399, 6.0512576241625498, -0.15162968127745899, 23.395366108183801, -14.5381852262701, -14.606223833564799, 10.199271998597199, -73.975176230999594, 0.109352036334604, 0.939662287060122, -5.0493506777824901, 12.432450504307001, 0.66340082972807302, 0.89171490853171798, -14.301193838340501, -7.1767924210601599, 37.417730343433, 34.621199008384998, -12.2257905481279, 5.0337643040644098, 0.00077853683475417402, -4.0437466042030499, -3.2232682351578399, 0.038202731665628202, -12.153196028398099, 6.5027616010011799, 7.2973627140258399, -12.054113026894999, 23.6623418919025, 0.0029087480524890102, -0.465988240269751, -5.8215678299339997, -0.92982871489462304, 0.72875377435640498, -1.76856112702097, 3.9100682853776498, 4.3638012685037904, -12.532035664209801, -10.8596693966264, 12.5729914998231, -1.17795314966104, -0.00047116201805309901, 2.7712702890005598, 1.4259517039641101, -0.060855532638316702, 9.8783846948200704, -5.3156162802238898, -6.24217543532784, 4.0955113938692902, -22.6133771249789, 0.0576846298115802, 0.37261538596098298, -5.69311024324454, 6.6165547759347501, -0.31572322723037299, 1.2076815066994999, -7.13883450856141, -3.0036796657518701, 12.888731168100399, 10.144844547714699, -3.4202567509716602, 2.2424073656324301, 0.00046719815518450402, -6.1786048720593501, -4.9366254575058903, 0.121293000821164, -13.5354546658637, 11.122151465656, 8.2996176249675795, -7.8492497139147304, 53.792699096533298, -0.056207389907105297, -0.72284563910330601, -0.034988476570927102, -5.8914910450597402, -0.57259031868870103, -1.3110690999933601, 8.9888650972260002, 6.8430482968640902, -26.406527264610599, -25.8419474444987, 8.95444342115516, -4.1168180484580699, 0.00068908057573134802, -2.0076563509740999, -3.65231424825159, 0.042894239647239998, -9.7520285174303201, 7.9819862061298199, 6.2214414143151, -1.1841920217922099, 31.911005041941699, -0.080053013664620296, -0.54185675163812796, 8.0781654837979193, -9.3493294125201594, -1.24083642122091, -1.6208022544009499, 8.8607449463367196, 2.3445831189331501, -16.218420387174199, -15.8119148955707, 1.7389982134136399, -1.0509978817476, -3.48584361237575e-05, 0.61330220442703598, 2.33052219623813, -0.0057796507046079101, 5.3801162861110896, -1.7460100802854299, -3.4260231079769401, 1.85323155008146, -1.34565392401789, 0.0020702237459098, 0.147768044797361, -0.43649104760725999, 0.997972495465969, 0.056933085588242997, 0.0077486424610570597, -0.89070134502194598, -0.68148789029708001, 0.89518325797891696, 0.16523545732706499, -2.8298454160600501, 0.26096748561569599, -3.9951230141139501e-05, 2.6625953366596802, 0.159171360187916, -0.0080654609832386693, 14.485659114429501, 0.26188806209423798, -8.9564367313419204, 9.5170929366304993, 3.6594343436186199, 0.017879567938259198, 0.0042052494877241001, -1.4377710841437801, 5.8763150360799203, 0.47441391996743998, -0.014783250610591801, -7.06163381200634, -2.9885184999935599, -1.42889911045556, -2.4433038426403901, -9.8958894810457991, 0.55194555716779503, -5.7250805560848302e-05, 0.98372766353792995, 3.2392588139392098, -0.0119630481344816, 0.14153713576169, -2.73924503033615, 0.060309030316031902, 2.34167965625057, -3.8604817562043001, 0.012593073725828199, 0.22349082635471901, -0.35749918018293803, 2.0835157939561699, 0.13368765195851301, 0.0515445449292352, -2.95655438325227, -1.09680637412728, 2.2418386652533302, 1.2169977713442901, -1.20005576483735, 0.48385142427875799}; -N_updates_p = &N_updates1; -assert(Dim_p != NULL); -assert(N_updates_p != NULL); assert(Updates1 != NULL); assert(Updates_index1 != NULL); -assert(breakdown_p != NULL); assert(Slater_inv1 != NULL); -rc = qmckl_sherman_morrison(context, Dim_p, N_updates_p, Updates1, Updates_index1, breakdown_p, Slater_inv1); +rc = qmckl_sherman_morrison(context, Dim, N_updates1, Updates1, Updates_index1, breakdown, Slater_inv1); for (unsigned int i = 0; i < Dim; i++) { for (unsigned int j = 0; j < Dim; j++) { res[i * Dim + j] = 0; @@ -311,7 +278,7 @@ assert(rc == QMCKL_SUCCESS); $C:= S^{-1}U$, a Dim $\times 2$ matrix $B := 1 + VC$, the $2 \times 2$ matrix that is going to be inverted $D := VS^{-1}$, a $2 \times Dim$ matrix - + #+NAME: qmckl_woodbury_2_args | qmckl_context | context | in | Global state | @@ -338,25 +305,25 @@ assert(rc == QMCKL_SUCCESS); #+begin_src c :tangle (eval h_func) :comments org qmckl_exit_code qmckl_woodbury_2( const qmckl_context context, - const uint64_t* Dim_p, + const uint64_t Dim, const double* Updates, const uint64_t* Updates_index, - const double* breakdown_p, - double* Slater_inv); + const double breakdown, + double* Slater_inv); #+end_src -*** Source +*** C source #+begin_src c :tangle (eval c) :comments org #include #include #include "qmckl.h" -qmckl_exit_code qmckl_woodbury_2_c_(const qmckl_context context, - const uint64_t* Dim_p, +qmckl_exit_code qmckl_woodbury_2(const qmckl_context context, + const uint64_t Dim, const double* Updates, const uint64_t* Updates_index, - const double* breakdown_p, + const double breakdown, double* Slater_inv) { /* C := S^{-1} * U, dim x 2 @@ -364,8 +331,9 @@ qmckl_exit_code qmckl_woodbury_2_c_(const qmckl_context context, D := V * S^{-1}, 2 x dim ,*/ - const uint64_t Dim = *Dim_p; - const double breakdown = *breakdown_p; + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } const uint64_t row1 = (Updates_index[0] - 1); const uint64_t row2 = (Updates_index[1] - 1); @@ -427,38 +395,13 @@ qmckl_exit_code qmckl_woodbury_2_c_(const qmckl_context context, This function is most efficient when used in cases where there are only 2 rank-1 updates and it is sure they will not result in a singular matrix. -** C interface :noexport: +** Fortran interface :noexport: :PROPERTIES: :Name: qmckl_woodbury_2 :CRetType: qmckl_exit_code :FRetType: qmckl_exit_code :END: - #+CALL: generate_c_interface(table=qmckl_woodbury_2_args,rettyp=get_value("FRetType"),fname=get_value("Name")) - - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_woodbury_2 & - (context, Dim, Updates, Updates_index, breakdown, Slater_inv) & - bind(C) result(info) - - use, intrinsic :: iso_c_binding - implicit none - - integer (c_int64_t) , intent(in) , value :: context - integer (c_int64_t) , intent(in) :: Dim - real (c_double ) , intent(in) :: Updates(2*Dim) - integer (c_int64_t) , intent(in) :: Updates_index(2) - real (c_double ) , intent(in) :: breakdown - real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim) - - integer(c_int32_t), external :: qmckl_woodbury_2_c - info = qmckl_woodbury_2_c & - (context, Dim, Updates, Updates_index, breakdown, Slater_inv) - - end function qmckl_woodbury_2 - #+end_src - #+CALL: generate_f_interface(table=qmckl_woodbury_2_args,rettyp=get_value("FRetType"),fname=get_value("Name")) #+RESULTS: @@ -472,10 +415,10 @@ qmckl_exit_code qmckl_woodbury_2_c_(const qmckl_context context, implicit none integer (c_int64_t) , intent(in) , value :: context - integer (c_int64_t) , intent(in) :: Dim + integer (c_int64_t) , intent(in) , value :: Dim real (c_double ) , intent(in) :: Updates(2*Dim) integer (c_int64_t) , intent(in) :: Updates_index(2) - real (c_double ) , intent(in) :: breakdown + real (c_double ) , intent(in) , value :: breakdown real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim) end function qmckl_woodbury_2 @@ -485,12 +428,10 @@ qmckl_exit_code qmckl_woodbury_2_c_(const qmckl_context context, *** Test :noexport: #+begin_src c :tangle (eval c_test) -assert(Dim_p != NULL); assert(Updates2 != NULL); assert(Updates_index2 != NULL); -assert(breakdown_p != NULL); assert(Slater_inv2 != NULL); -rc = qmckl_woodbury_2(context, Dim_p, Updates2, Updates_index2, breakdown_p, Slater_inv2); +rc = qmckl_woodbury_2(context, Dim, Updates2, Updates_index2, breakdown, Slater_inv2); for (unsigned int i = 0; i < Dim; i++) { for (unsigned int j = 0; j < Dim; j++) { res[i * Dim + j] = 0; @@ -514,7 +455,7 @@ assert(rc == QMCKL_SUCCESS); #+end_src * Woodbury 3x3 - + ** ~qmckl_woodbury_3~ :PROPERTIES: :Name: qmckl_woodbury_3 @@ -555,25 +496,25 @@ assert(rc == QMCKL_SUCCESS); #+begin_src c :tangle (eval h_func) :comments org qmckl_exit_code qmckl_woodbury_3( const qmckl_context context, - const uint64_t* Dim_p, + const uint64_t Dim, const double* Updates, const uint64_t* Updates_index, - const double* breakdown_p, - double* Slater_inv); + const double breakdown, + double* Slater_inv); #+end_src -*** Source +*** C source #+begin_src c :tangle (eval c) :comments org #include #include #include "qmckl.h" -qmckl_exit_code qmckl_woodbury_3_c_(const qmckl_context context, - const uint64_t* Dim_p, +qmckl_exit_code qmckl_woodbury_3(const qmckl_context context, + const uint64_t Dim, const double* Updates, const uint64_t* Updates_index, - const double* breakdown_p, + const double breakdown, double* Slater_inv) { /* C := S^{-1} * U, dim x 3 @@ -581,8 +522,9 @@ qmckl_exit_code qmckl_woodbury_3_c_(const qmckl_context context, D := V * S^{-1}, 3 x dim ,*/ - const uint64_t Dim = *Dim_p; - const double breakdown = *breakdown_p; + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } const uint64_t row1 = (Updates_index[0] - 1); const uint64_t row2 = (Updates_index[1] - 1); @@ -655,42 +597,17 @@ qmckl_exit_code qmckl_woodbury_3_c_(const qmckl_context context, #+end_src *** Performance... - + This function is most efficient when used in cases where there are only 3 rank-1 updates and it is sure they will not result in a singular matrix. -** C interface :noexport: +** Fortran interface :noexport: :PROPERTIES: :Name: qmckl_woodbury_3 :CRetType: qmckl_exit_code :FRetType: qmckl_exit_code :END: - #+CALL: generate_c_interface(table=qmckl_woodbury_3_args,rettyp=get_value("FRetType"),fname=get_value("Name")) - - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_woodbury_3 & - (context, Dim, Updates, Updates_index, breakdown, Slater_inv) & - bind(C) result(info) - - use, intrinsic :: iso_c_binding - implicit none - - integer (c_int64_t) , intent(in) , value :: context - integer (c_int64_t) , intent(in) :: Dim - real (c_double ) , intent(in) :: Updates(3*Dim) - integer (c_int64_t) , intent(in) :: Updates_index(3) - real (c_double ) , intent(in) :: breakdown - real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim) - - integer(c_int32_t), external :: qmckl_woodbury_3_c - info = qmckl_woodbury_3_c & - (context, Dim, Updates, Updates_index, breakdown, Slater_inv) - - end function qmckl_woodbury_3 - #+end_src - #+CALL: generate_f_interface(table=qmckl_woodbury_3_args,rettyp=get_value("FRetType"),fname=get_value("Name")) #+RESULTS: @@ -704,10 +621,10 @@ qmckl_exit_code qmckl_woodbury_3_c_(const qmckl_context context, implicit none integer (c_int64_t) , intent(in) , value :: context - integer (c_int64_t) , intent(in) :: Dim + integer (c_int64_t) , intent(in) , value :: Dim real (c_double ) , intent(in) :: Updates(3*Dim) integer (c_int64_t) , intent(in) :: Updates_index(3) - real (c_double ) , intent(in) :: breakdown + real (c_double ) , intent(in) , value :: breakdown real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim) end function qmckl_woodbury_3 @@ -717,12 +634,10 @@ qmckl_exit_code qmckl_woodbury_3_c_(const qmckl_context context, *** Test :noexport: #+begin_src c :tangle (eval c_test) -assert(Dim_p != NULL); assert(Updates3 != NULL); assert(Updates_index3 != NULL); -assert(breakdown_p != NULL); assert(Slater_inv3_1 != NULL); -rc = qmckl_woodbury_3(context, Dim_p, Updates3, Updates_index3, breakdown_p, Slater_inv3_1); +rc = qmckl_woodbury_3(context, Dim, Updates3, Updates_index3, breakdown, Slater_inv3_1); for (unsigned int i = 0; i < Dim; i++) { for (unsigned int j = 0; j < Dim; j++) { res[i * Dim + j] = 0; @@ -746,7 +661,7 @@ assert(rc == QMCKL_SUCCESS); #+end_src * Sherman-Morrison with update splitting - + ** ~qmckl_sherman_morrison_splitting~ :PROPERTIES: :Name: qmckl_sherman_morrison_splitting @@ -783,7 +698,7 @@ assert(rc == QMCKL_SUCCESS); * ~Updates_index~ is allocated with $N_updates$ elements * ~breakdown~ is a small number such that $0 < breakdown << 1$ * ~Slater_inv~ is allocated with $Dim \times Dim$ elements - + *** C header #+CALL: generate_c_header(table=qmckl_sherman_morrison_splitting_args,rettyp=get_value("CRetType"),fname=get_value("Name")) @@ -792,37 +707,41 @@ assert(rc == QMCKL_SUCCESS); #+begin_src c :tangle (eval h_func) :comments org qmckl_exit_code qmckl_sherman_morrison_splitting( const qmckl_context context, - const uint64_t* Dim, - const uint64_t* N_updates, + const uint64_t Dim, + const uint64_t N_updates, const double* Updates, const uint64_t* Updates_index, - const double* breakdown, - double* Slater_inv); + const double breakdown, + double* Slater_inv); #+end_src -*** Source +*** C source #+begin_src c :tangle (eval c) :comments org #include #include "qmckl.h" -qmckl_exit_code qmckl_sherman_morrison_splitting_c_(const qmckl_context context, - const uint64_t* Dim, - const uint64_t* N_updates, +qmckl_exit_code qmckl_sherman_morrison_splitting(const qmckl_context context, + const uint64_t Dim, + const uint64_t N_updates, const double* Updates, const uint64_t* Updates_index, - const double* breakdown, + const double breakdown, double* Slater_inv) { - - double later_updates[*Dim * *N_updates]; - uint64_t later_index[*N_updates]; + + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } + + double later_updates[Dim * N_updates]; + uint64_t later_index[N_updates]; uint64_t later = 0; - (void) qmckl_slagel_splitting_c(*Dim, *N_updates, Updates, Updates_index, - *breakdown, Slater_inv, later_updates, later_index, &later); - + (void) qmckl_slagel_splitting(Dim, N_updates, Updates, Updates_index, + breakdown, Slater_inv, later_updates, later_index, &later); + if (later > 0) { - (void) qmckl_sherman_morrison_splitting_c_(context, Dim, &later, + (void) qmckl_sherman_morrison_splitting(context, Dim, later, later_updates, later_index, breakdown, Slater_inv); } @@ -834,40 +753,14 @@ qmckl_exit_code qmckl_sherman_morrison_splitting_c_(const qmckl_context context, *** Performance... This kernel performs best when there are 2 or more rank-1 update cycles and fail-rate is high. - -** C interface :noexport: + +** Fortran interface :noexport: :PROPERTIES: :Name: qmckl_sherman_morrison_splitting :CRetType: qmckl_exit_code :FRetType: qmckl_exit_code :END: - #+CALL: generate_c_interface(table=qmckl_sherman_morrison_splitting_args,rettyp=get_value("FRetType"),fname=get_value("Name")) - - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_sherman_morrison_splitting & - (context, Dim, N_updates, Updates, Updates_index, breakdown, Slater_inv) & - bind(C) result(info) - - use, intrinsic :: iso_c_binding - implicit none - - integer (c_int64_t) , intent(in) , value :: context - integer (c_int64_t) , intent(in) :: Dim - integer (c_int64_t) , intent(in) :: N_updates - real (c_double ) , intent(in) :: Updates(N_updates*Dim) - integer (c_int64_t) , intent(in) :: Updates_index(N_updates) - real (c_double ) , intent(in) :: breakdown - real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim) - - integer(c_int32_t), external :: qmckl_sherman_morrison_splitting_c - info = qmckl_sherman_morrison_splitting_c & - (context, Dim, N_updates, Updates, Updates_index, breakdown, Slater_inv) - - end function qmckl_sherman_morrison_splitting - #+end_src - #+CALL: generate_f_interface(table=qmckl_sherman_morrison_splitting_args,rettyp=get_value("FRetType"),fname=get_value("Name")) #+RESULTS: @@ -881,11 +774,11 @@ qmckl_exit_code qmckl_sherman_morrison_splitting_c_(const qmckl_context context, implicit none integer (c_int64_t) , intent(in) , value :: context - integer (c_int64_t) , intent(in) :: Dim - integer (c_int64_t) , intent(in) :: N_updates + integer (c_int64_t) , intent(in) , value :: Dim + integer (c_int64_t) , intent(in) , value :: N_updates real (c_double ) , intent(in) :: Updates(N_updates*Dim) integer (c_int64_t) , intent(in) :: Updates_index(N_updates) - real (c_double ) , intent(in) :: breakdown + real (c_double ) , intent(in) , value :: breakdown real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim) end function qmckl_sherman_morrison_splitting @@ -895,14 +788,10 @@ qmckl_exit_code qmckl_sherman_morrison_splitting_c_(const qmckl_context context, *** Test :noexport: #+begin_src c :tangle (eval c_test) -N_updates_p = &N_updates3; -assert(Dim_p != NULL); -assert(N_updates_p != NULL); assert(Updates3 != NULL); assert(Updates_index3 != NULL); -assert(breakdown_p != NULL); assert(Slater_inv3_2 != NULL); -rc = qmckl_sherman_morrison_splitting(context, Dim_p, N_updates_p, Updates3, Updates_index3, breakdown_p, Slater_inv3_2); +rc = qmckl_sherman_morrison_splitting(context, Dim, N_updates3, Updates3, Updates_index3, breakdown, Slater_inv3_2); for (unsigned int i = 0; i < Dim; i++) { for (unsigned int j = 0; j < Dim; j++) { res[i * Dim + j] = 0; @@ -926,7 +815,7 @@ assert(rc == QMCKL_SUCCESS); #+end_src * Woodbury 3x3 and 2x2 with Sherman-Morrison and update splitting - + ** ~qmckl_sherman_morrison_smw32s~ :PROPERTIES: :Name: qmckl_sherman_morrison_smw32s @@ -967,31 +856,31 @@ assert(rc == QMCKL_SUCCESS); #+begin_src c :tangle (eval h_func) :comments org qmckl_exit_code qmckl_sherman_morrison_smw32s( const qmckl_context context, - const uint64_t* Dim_p, - const uint64_t* N_updates_p, + const uint64_t Dim, + const uint64_t N_updates, const double* Updates, const uint64_t* Updates_index, - const double* breakdown_p, - double* Slater_inv); + const double breakdown, + double* Slater_inv); #+end_src -*** Source +*** C source #+begin_src c :tangle (eval c) :comments org #include #include "qmckl.h" -qmckl_exit_code qmckl_sherman_morrison_smw32s_c_(const qmckl_context context, - const uint64_t* Dim_p, - const uint64_t* N_updates_p, +qmckl_exit_code qmckl_sherman_morrison_smw32s(const qmckl_context context, + const uint64_t Dim, + const uint64_t N_updates, const double* Updates, const uint64_t* Updates_index, - const double* breakdown_p, + const double breakdown, double* Slater_inv) { - const uint64_t Dim = *Dim_p; - const uint64_t N_updates = *N_updates_p; - const double breakdown = *breakdown_p; + if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) { + return QMCKL_NULL_CONTEXT; + } qmckl_exit_code rc; @@ -1008,10 +897,10 @@ qmckl_exit_code qmckl_sherman_morrison_smw32s_c_(const qmckl_context context, for (uint64_t i = 0; i < n_of_3blocks; i++) { const double *Updates_3block = &Updates[i * length_3block]; const uint64_t *Updates_index_3block = &Updates_index[i * 3]; - rc = qmckl_woodbury_3_c_(context, &Dim, Updates_3block, Updates_index_3block, &breakdown, Slater_inv); + rc = qmckl_woodbury_3(context, Dim, Updates_3block, Updates_index_3block, breakdown, Slater_inv); if (rc != 0) { // Send the entire block to slagel_splitting uint64_t l = 0; - rc = qmckl_slagel_splitting_c(Dim, 3, Updates_3block, Updates_index_3block, + rc = qmckl_slagel_splitting(Dim, 3, Updates_3block, Updates_index_3block, breakdown, Slater_inv, later_updates + (Dim * later), later_index + later, &l); later = later + l; } @@ -1022,10 +911,10 @@ qmckl_exit_code qmckl_sherman_morrison_smw32s_c_(const qmckl_context context, if (remainder == 2) { const double *Updates_2block = &Updates[n_of_3blocks * length_3block]; const uint64_t *Updates_index_2block = &Updates_index[3 * n_of_3blocks]; - rc = qmckl_woodbury_2_c_(context, &Dim, Updates_2block, Updates_index_2block, &breakdown, Slater_inv); + rc = qmckl_woodbury_2(context, Dim, Updates_2block, Updates_index_2block, breakdown, Slater_inv); if (rc != 0) { // Send the entire block to slagel_splitting uint64_t l = 0; - (void) qmckl_slagel_splitting_c(Dim, 2, Updates_2block, Updates_index_2block, + (void) qmckl_slagel_splitting(Dim, 2, Updates_2block, Updates_index_2block, breakdown, Slater_inv, later_updates + (Dim * later), later_index + later, &l); later = later + l; } @@ -1035,13 +924,13 @@ qmckl_exit_code qmckl_sherman_morrison_smw32s_c_(const qmckl_context context, const double *Updates_1block = &Updates[n_of_3blocks * length_3block]; const uint64_t *Updates_index_1block = &Updates_index[3 * n_of_3blocks]; uint64_t l = 0; - (void) qmckl_slagel_splitting_c(Dim, 1, Updates_1block, Updates_index_1block, + (void) qmckl_slagel_splitting(Dim, 1, Updates_1block, Updates_index_1block, breakdown, Slater_inv, later_updates + (Dim * later), later_index + later, &l); later = later + l; } if (later > 0) { - (void) qmckl_sherman_morrison_splitting_c_(context, &Dim, &later, later_updates, later_index, &breakdown, Slater_inv); + (void) qmckl_sherman_morrison_splitting(context, Dim, later, later_updates, later_index, breakdown, Slater_inv); } return QMCKL_SUCCESS; } @@ -1052,39 +941,13 @@ qmckl_exit_code qmckl_sherman_morrison_smw32s_c_(const qmckl_context context, This kernel performs best for update cycles with 2 or more rank-1 updates and the fail-rate is low. -** C interface :noexport: +** Fortran interface :noexport: :PROPERTIES: :Name: qmckl_sherman_morrison_smw32s :CRetType: qmckl_exit_code :FRetType: qmckl_exit_code :END: - #+CALL: generate_c_interface(table=qmckl_sherman_morrison_smw32s_args,rettyp=get_value("FRetType"),fname=get_value("Name")) - - #+RESULTS: - #+begin_src f90 :tangle (eval f) :comments org :exports none - integer(c_int32_t) function qmckl_sherman_morrison_smw32s & - (context, Dim, N_updates, Updates, Updates_index, breakdown, Slater_inv) & - bind(C) result(info) - - use, intrinsic :: iso_c_binding - implicit none - - integer (c_int64_t) , intent(in) , value :: context - integer (c_int64_t) , intent(in) :: Dim - integer (c_int64_t) , intent(in) :: N_updates - real (c_double ) , intent(in) :: Updates(N_updates*Dim) - integer (c_int64_t) , intent(in) :: Updates_index(N_updates) - real (c_double ) , intent(in) :: breakdown - real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim) - - integer(c_int32_t), external :: qmckl_sherman_morrison_smw32s_c - info = qmckl_sherman_morrison_smw32s_c & - (context, Dim, N_updates, Updates, Updates_index, breakdown, Slater_inv) - - end function qmckl_sherman_morrison_smw32s - #+end_src - #+CALL: generate_f_interface(table=qmckl_sherman_morrison_smw32s_args,rettyp=get_value("FRetType"),fname=get_value("Name")) #+RESULTS: @@ -1098,11 +961,11 @@ qmckl_exit_code qmckl_sherman_morrison_smw32s_c_(const qmckl_context context, implicit none integer (c_int64_t) , intent(in) , value :: context - integer (c_int64_t) , intent(in) :: Dim - integer (c_int64_t) , intent(in) :: N_updates + integer (c_int64_t) , intent(in) , value :: Dim + integer (c_int64_t) , intent(in) , value :: N_updates real (c_double ) , intent(in) :: Updates(N_updates*Dim) integer (c_int64_t) , intent(in) :: Updates_index(N_updates) - real (c_double ) , intent(in) :: breakdown + real (c_double ) , intent(in) , value :: breakdown real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim) end function qmckl_sherman_morrison_smw32s @@ -1112,14 +975,10 @@ qmckl_exit_code qmckl_sherman_morrison_smw32s_c_(const qmckl_context context, *** Test :noexport: #+begin_src c :tangle (eval c_test) -N_updates_p = &N_updates5; -assert(Dim_p != NULL); -assert(N_updates_p != NULL); assert(Updates5 != NULL); assert(Updates_index5 != NULL); -assert(breakdown_p != NULL); assert(Slater_inv5 != NULL); -rc = qmckl_sherman_morrison_smw32s(context, Dim_p, N_updates_p, Updates5, Updates_index5, breakdown_p, Slater_inv5); +rc = qmckl_sherman_morrison_smw32s(context, Dim, N_updates5, Updates5, Updates_index5, breakdown, Slater_inv5); for (unsigned int i = 0; i < Dim; i++) { for (unsigned int j = 0; j < Dim; j++) { res[i * Dim + j] = 0; @@ -1141,10 +1000,10 @@ for (unsigned int i = 0; i < Dim; i++) { } assert(rc == QMCKL_SUCCESS); #+end_src - + * Helper Functions - -Private helper-functions that are used by the Sherman-Morrison-Woodbury kernels. + +Private helper-functions that are used by the Sherman-Morrison-Woodbury kernels. These functions can only be used internally by the kernels in this module. ** ~qmckl_slagel_splitting~ @@ -1158,11 +1017,11 @@ These functions can only be used internally by the kernels in this module. It is used internally to apply a collection of $N$ rank-1 updates to the inverse Slater-matrix $S^{-1}$ and splitting an update in two equal pieces if necessary. In case of a split, it applies the first half of the update, while putting the second half in a waiting queue to be applied at the end. - + Therefore, when $1+v_j^TS^{-1}u_j \geq \epsilon$, the update is applied as usual. Otherwise, $u_j$ will be redefined as $\frac{1}{2}u_j$. One half is applied immediately, the other half will be applied at the end of the algorithm, using vectors $u_{j'}=\frac{1}{2}u_j$ and $v_{j'}^T=v_{j}^T$, which are stored in the array \texttt{later_updates}. - + #+NAME: qmckl_slagel_splitting_args | uint64_t | Dim | in | Leading dimension of Slater_inv | | uint64_t | N_updates | in | Number of rank-1 updates to be applied to Slater_inv | @@ -1173,7 +1032,7 @@ These functions can only be used internally by the kernels in this module. | double | later_updates[Dim * N_updates] | inout | Array containing the split updates for later | | uint64_t | later_index[N_updates] | inout | Array containing the positions of the split updates for later | | uint64_t | later | inout | Number of split updates for later | - + *** Requirements @@ -1185,15 +1044,15 @@ These functions can only be used internally by the kernels in this module. - ~Slater_inv~ is allocated with $Dim \times Dim$ elements - ~later_updates~ is allocated with $later \times Dim$ elements - ~later_index~ is allocated with $N_updates$ elements - - ~later >= 0~ - + - ~later >= 0~ + *** C header #+CALL: generate_c_header(table=qmckl_slagel_splitting_args,rettyp=get_value("CRetType"),fname=get_value("Name")) #+RESULTS: #+begin_src c :tangle (eval h_func) :comments org - qmckl_exit_code qmckl_slagel_splitting_c ( + qmckl_exit_code qmckl_slagel_splitting ( const uint64_t Dim, const uint64_t N_updates, const double* Updates, @@ -1202,23 +1061,23 @@ These functions can only be used internally by the kernels in this module. double* Slater_inv, double* later_updates, uint64_t* later_index, - uint64_t* later ); + uint64_t* later ); #+end_src -*** Source +*** C source #+begin_src c :tangle (eval c) :comments org #include #include #include "qmckl.h" -qmckl_exit_code qmckl_slagel_splitting_c(uint64_t Dim, +qmckl_exit_code qmckl_slagel_splitting(uint64_t Dim, uint64_t N_updates, - const double *Updates, + const double *Updates, const uint64_t *Updates_index, const double breakdown, double *Slater_inv, - double *later_updates, + double *later_updates, uint64_t *later_index, uint64_t *later) { // #ifdef DEBUG // Leave commented out since debugging information is not yet implemented in QMCkl. @@ -1274,31 +1133,18 @@ qmckl_exit_code qmckl_slagel_splitting_c(uint64_t Dim, } #+end_src - + *** Performance This function cannot be used by itself and is used in Sherman-Morrison with update splitting and Woodbury 3x3 and 2x2 with Sherman-Morrison and update splitting. Please look at the performance reccomendations for those two kernels. -** C interface :noexport: - :PROPERTIES: - :Name: qmckl_slagel_splitting - :CRetType: double - :FRetType: double precision - :END: - - #+CALL: generate_c_interface(table=qmckl_slagel_splitting_args,rettyp=get_value("FRetType"),fname=get_value("Name")) - -*** Test :noexport: - - This kernel does not have an explicit test because it is only used internally by higher-level Sherman-Morrison-Woodbury kernels. - * End of files #+begin_src c :comments link :tangle (eval c_test) assert (qmckl_context_destroy(context) == QMCKL_SUCCESS); return 0; - + } #+end_src diff --git a/tools/config_doc.el b/tools/config_doc.el index 9501d64..da425cc 100755 --- a/tools/config_doc.el +++ b/tools/config_doc.el @@ -9,6 +9,7 @@ (setq org-confirm-babel-evaluate nil) (global-font-lock-mode t) (setq org-src-fontify-natively t) +(setq python-indent-guess-indent-offset-verbose nil) ;; Remove warning : Can’t guess python-indent-offset ;(require 'ox-latex) ;(setq org-latex-listings t) diff --git a/tools/init.el b/tools/init.el index ed3af2b..bf2b48f 100644 --- a/tools/init.el +++ b/tools/init.el @@ -39,6 +39,7 @@ (setq org-hide-emphasis-markers nil) (setq org-pretty-entities nil) (setq org-confirm-babel-evaluate nil) ;; Do not ask for confirmation all the time!! +(setq python-indent-guess-indent-offset-verbose nil) ;; Remove warning : Can’t guess python-indent-offset (org-babel-do-load-languages 'org-babel-load-languages