diff --git a/org/qmckl_mykernel.org b/org/qmckl_mykernel.org new file mode 100644 index 0000000..9c807f0 --- /dev/null +++ b/org/qmckl_mykernel.org @@ -0,0 +1,130 @@ +#+TITLE: My Kernel +#+SETUPFILE: ../tools/theme.setup +#+INCLUDE: ../tools/lib.org +#+STARTUP: content + +* Headers + #+begin_src elisp :noexport :results none :exports none +(org-babel-lob-ingest "../tools/lib.org") +#+end_src + + #+begin_src c :comments link :tangle (eval c_test) :noweb yes +#include "qmckl.h" +#include "assert.h" +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include + +int main() { + qmckl_context context; + context = qmckl_context_create(); + qmckl_exit_code rc; + #+end_src + +* My Kernel + +** ~qmckl_mykernel~ + :PROPERTIES: + :Name: qmckl_mykernel + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+NAME: qmckl_mykernel_args + | qmckl_context | context | in | Global state | + | int64_t | myarg1 | in | The only input argument | + +*** Requirements + + * ~context~ is not ~QMCKL_NULL_CONTEXT~ + +*** C header + + #+CALL: generate_c_header(table=qmckl_mykernel_args,rettyp=get_value("CRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src c :tangle (eval h_func) :comments org + qmckl_exit_code qmckl_mykernel(const qmckl_context context, + const int64_t* myarg1); + #+end_src + +*** C source + + #+begin_src c :tangle (eval c) :comments org + #include + #include + #include "qmckl.h" + + qmckl_exit_code qmckl_mykernel_c_(const qmckl_context context, + const int64_t* myarg1) { + + printf("Hello from qmckl_mykernel_c_\n"); + printf("Value of argument 'myarg1' from within 'qmckl_mykernel_c_' is: %i\n", *myarg1); + return QMCKL_SUCCESS; +} + #+end_src + +** C interface :noexport: + :PROPERTIES: + :Name: qmckl_mykernel + :CRetType: qmckl_exit_code + :FRetType: qmckl_exit_code + :END: + + #+CALL: generate_c_interface(table=qmckl_mykernel_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_mykernel(context, myarg1) 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) :: myarg1 + integer(c_int32_t) , external :: qmckl_mykernel_c + + write(*,*) "Hello from Fortran wrapper-function 'qmckl_mykernel'" + write(*,*) "Value of argument 'myarg1' from within 'qmckl_mykernel' before call to C-function 'qmckl_mykernel_c' is: ", myarg1 + info = qmckl_mykernel_c(context, myarg1) + write(*,*) "Value of argument 'myarg1' from within 'qmckl_mykernel' after call to C-function 'qmckl_mykernel_c' is: ", myarg1 + + end function qmckl_mykernel + #+end_src + + #+CALL: generate_f_interface(table=qmckl_mykernel_args,rettyp=get_value("FRetType"),fname=get_value("Name")) + + #+RESULTS: + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none + interface + integer(c_int32_t) function qmckl_mykernel(context, myarg1) bind(C) + use, intrinsic :: iso_c_binding + import + implicit none + integer (c_int64_t) , intent(in) , value :: context + integer (c_int64_t) , intent(in) :: myarg1 + end function qmckl_mykernel + end interface + #+end_src + +*** Test :noexport: + + #+begin_src c :tangle (eval c_test) + const int64_t arg1 = 10; + const int64_t* arg1p = &arg1; + printf("Value of arg1 before passing to 'qmckl_mykernel': %i\n", arg1); + rc = qmckl_mykernel(context, arg1p); + assert(rc == QMCKL_SUCCESS); + #+end_src + +* End of files + + #+begin_src c :comments link :tangle (eval c_test) + assert (qmckl_context_destroy(context) == QMCKL_SUCCESS); + return 0; + } + #+end_src + +# -*- mode: org -*- +# vim: syntax=c diff --git a/org/qmckl_sherman_morrison_woodbury.org b/org/qmckl_sherman_morrison_woodbury.org index 3c8544e..256affd 100644 --- a/org/qmckl_sherman_morrison_woodbury.org +++ b/org/qmckl_sherman_morrison_woodbury.org @@ -86,14 +86,14 @@ int main() { #+RESULTS: #+begin_src c :tangle (eval h_func) :comments org - qmckl_exit_code qmckl_sherman_morrison ( + qmckl_exit_code qmckl_sherman_morrison( const qmckl_context context, - const uint64_t Dim, - const uint64_t N_updates, + const uint64_t* Dim_p, + const uint64_t* N_updates_p, const double* Updates, const uint64_t* Updates_index, - const double breakdown, - double* Slater_inv ); + const double* breakdown_p, + double* Slater_inv); #+end_src *** C source @@ -104,15 +104,15 @@ int main() { #include "qmckl.h" qmckl_exit_code qmckl_sherman_morrison_c_(const qmckl_context context, - const uint64_t Dim, - const uint64_t N_updates, + const uint64_t* Dim_p, + const uint64_t* N_updates_p, const double* Updates, const uint64_t* Updates_index, - const double breakdown, - double * Slater_inv) { -// #ifdef DEBUG -// std::cerr << "Called qmckl_sherman_morrison with " << N_updates << " updates" << std::endl; -// #endif + const double* breakdown_p, + double* Slater_inv) { + const uint64_t Dim = *Dim_p; + const uint64_t N_updates = *N_updates_p; + const double breakdown = *breakdown_p; double C[Dim]; double D[Dim]; @@ -180,11 +180,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) , value :: Dim - integer (c_int64_t) , intent(in) , value :: N_updates + 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) , value :: breakdown + real (c_double ) , intent(in) :: breakdown real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim) integer(c_int32_t), external :: qmckl_sherman_morrison_c @@ -208,11 +208,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) , value :: Dim - integer (c_int64_t) , intent(in) , value :: N_updates + 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) , value :: breakdown + real (c_double ) , intent(in) :: breakdown real (c_double ) , intent(inout) :: Slater_inv(Dim*Dim) end function qmckl_sherman_morrison @@ -225,7 +225,10 @@ 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]; @@ -261,7 +264,8 @@ double Slater_inv5_2[441] = {-0.054189244668834902, -105.426713929607, -88.45849 // WB3,2+spl: 3,2 double Slater_inv5_3[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}; -rc = qmckl_sherman_morrison(context, Dim, N_updates1, Updates1, Updates_index1, breakdown, Slater_inv1); +N_updates_p = &N_updates1; +rc = qmckl_sherman_morrison(context, Dim_p, N_updates_p, Updates1, Updates_index1, breakdown_p, Slater_inv1); for (unsigned int i = 0; i < Dim; i++) { for (unsigned int j = 0; j < Dim; j++) { res[i * Dim + j] = 0; @@ -330,13 +334,13 @@ assert(rc == QMCKL_SUCCESS); #+RESULTS: #+begin_src c :tangle (eval h_func) :comments org - qmckl_exit_code qmckl_woodbury_2_c ( + qmckl_exit_code qmckl_woodbury_2( const qmckl_context context, - const uint64_t Dim, + const uint64_t* Dim_p, const double* Updates, const uint64_t* Updates_index, - const double breakdown, - double* Slater_inv ); + const double* breakdown_p, + double* Slater_inv); #+end_src *** Source @@ -346,20 +350,20 @@ assert(rc == QMCKL_SUCCESS); #include #include "qmckl.h" -qmckl_exit_code qmckl_woodbury_2_c(const qmckl_context context, - const uint64_t Dim, +qmckl_exit_code qmckl_woodbury_2_c_(const qmckl_context context, + const uint64_t* Dim_p, const double* Updates, const uint64_t* Updates_index, - const double breakdown, + const double* breakdown_p, double * Slater_inv) { /* C := S^{-1} * U, dim x 2 B := 1 + V * C, 2 x 2 D := V * S^{-1}, 2 x dim ,*/ -// #ifdef DEBUG // Leave commented out since debugging information is not yet implemented in QMCkl. -// std::cerr << "Called Woodbury 2x2 kernel" << std::endl; -// #endif + + const uint64_t Dim = *Dim_p; + const double breakdown = *breakdown_p; const uint64_t row1 = (Updates_index[0] - 1); const uint64_t row2 = (Updates_index[1] - 1); @@ -430,12 +434,57 @@ qmckl_exit_code qmckl_woodbury_2_c(const qmckl_context context, #+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: + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none + interface + integer(c_int32_t) function qmckl_woodbury_2 & + (context, Dim, Updates, Updates_index, breakdown, Slater_inv) & + bind(C) + use, intrinsic :: iso_c_binding + import + 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) + + end function qmckl_woodbury_2 + end interface + #+end_src + *** Test :noexport: #+begin_src c :tangle (eval c_test) -rc = qmckl_woodbury_2_c(context, Dim, Updates2, Updates_index2, breakdown, Slater_inv2); + +rc = qmckl_woodbury_2(context, Dim_p, Updates2, Updates_index2, breakdown_p, Slater_inv2); for (unsigned int i = 0; i < Dim; i++) { for (unsigned int j = 0; j < Dim; j++) { res[i * Dim + j] = 0; @@ -498,13 +547,13 @@ assert(rc == QMCKL_SUCCESS); #+RESULTS: #+begin_src c :tangle (eval h_func) :comments org - qmckl_exit_code qmckl_woodbury_3_c ( + qmckl_exit_code qmckl_woodbury_3( const qmckl_context context, - const uint64_t Dim, + const uint64_t* Dim_p, const double* Updates, const uint64_t* Updates_index, - const double breakdown, - double* Slater_inv ); + const double* breakdown_p, + double* Slater_inv); #+end_src *** Source @@ -514,20 +563,20 @@ assert(rc == QMCKL_SUCCESS); #include #include "qmckl.h" -qmckl_exit_code qmckl_woodbury_3_c(const qmckl_context context, - const uint64_t Dim, +qmckl_exit_code qmckl_woodbury_3_c_(const qmckl_context context, + const uint64_t* Dim_p, const double* Updates, const uint64_t* Updates_index, - const double breakdown, + const double* breakdown_p, double * Slater_inv) { /* C := S^{-1} * U, dim x 3 B := 1 + V * C, 3 x 3 D := V * S^{-1}, 3 x dim ,*/ -// #ifdef DEBUG // Leave commented out since debugging information is not yet implemented in QMCkl. -// std::cerr << "Called Woodbury 3x3 kernel" << std::endl; -// #endif + + const uint64_t Dim = *Dim_p; + const double breakdown = *breakdown_p; const uint64_t row1 = (Updates_index[0] - 1); const uint64_t row2 = (Updates_index[1] - 1); @@ -597,7 +646,6 @@ qmckl_exit_code qmckl_woodbury_3_c(const qmckl_context context, return QMCKL_SUCCESS; } - #+end_src *** Performance... @@ -614,12 +662,56 @@ qmckl_exit_code qmckl_woodbury_3_c(const qmckl_context context, #+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: + #+begin_src f90 :tangle (eval fh_func) :comments org :exports none + interface + integer(c_int32_t) function qmckl_woodbury_3 & + (context, Dim, Updates, Updates_index, breakdown, Slater_inv) & + bind(C) + use, intrinsic :: iso_c_binding + import + 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) + + end function qmckl_woodbury_3 + end interface + #+end_src + *** Test :noexport: #+begin_src c :tangle (eval c_test) -rc = qmckl_woodbury_3_c(context, Dim, Updates3, Updates_index3, breakdown, Slater_inv3_1); +rc = qmckl_woodbury_3(context, Dim_p, Updates3, Updates_index3, breakdown_p, Slater_inv3_1); for (unsigned int i = 0; i < Dim; i++) { for (unsigned int j = 0; j < Dim; j++) { res[i * Dim + j] = 0; @@ -687,14 +779,14 @@ assert(rc == QMCKL_SUCCESS); #+RESULTS: #+begin_src c :tangle (eval h_func) :comments org - qmckl_exit_code qmckl_sherman_morrison_splitting_c ( + 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 @@ -703,26 +795,23 @@ assert(rc == QMCKL_SUCCESS); #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_c_(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) { -// #ifdef DEBUG // Leave commented out since debugging information is not yet implemented in QMCkl. -// std::cerr << "Called qmckl_sherman_morrison_splitting with " << N_updates << " updates" << std::endl; -// #endif - - double later_updates[Dim * N_updates]; - uint64_t later_index[N_updates]; + + 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_c(*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_c_(context, Dim, later, later_updates, later_index, breakdown, Slater_inv); } @@ -835,10 +924,6 @@ qmckl_exit_code qmckl_sherman_morrison_smw32s_c(const qmckl_context context, const uint64_t* Updates_index, const double breakdown, double * Slater_inv) { -// #ifdef DEBUG // Leave commented out since debugging information is not yet implemented in QMCkl. -// std::cerr << "Called qmckl_sherman_morrison_woodbury_3 with " << N_updates -// << " updates" << std::endl; -// #endif qmckl_exit_code rc; @@ -855,7 +940,7 @@ 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_c_(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, @@ -868,7 +953,7 @@ qmckl_exit_code qmckl_sherman_morrison_smw32s_c(const qmckl_context context, if (remainder == 2) { // Apply last remaining block of 2 updates with Woodbury 2x2 kernel 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_c_(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, diff --git a/org/table_of_contents b/org/table_of_contents index dfc6f52..7aa7dc6 100644 --- a/org/table_of_contents +++ b/org/table_of_contents @@ -7,6 +7,7 @@ qmckl_nucleus.org qmckl_electron.org qmckl_ao.org qmckl_jastrow.org +qmckl_mykernel.org qmckl_sherman_morrison_woodbury.org qmckl_distance.org qmckl_utils.org