How to locate code called by .External2()?

后端 未结 1 2180
北荒
北荒 2021-02-20 03:49

I would like to learn how optim(..., hessian=TRUE) computes a Hessian, so I took a look at the function\'s definition. Near its end, it includes this call to

相关标签:
1条回答
  • 2021-02-20 04:07

    Notice that C_optimhess is an object, not a string.

    > stats:::C_optimhess
    $name
    [1] "optimhess"
    
    $address
    <pointer: 0x266b1a0>
    attr(,"class")
    [1] "RegisteredNativeSymbol"
    
    $dll
    DLL name: stats
    Filename: /usr/lib/R/library/stats/libs/stats.so
    Dynamic lookup: FALSE
    
    $numParameters
    [1] 4
    
    attr(,"class")
    [1] "ExternalRoutine"  "NativeSymbolInfo"
    

    So you need to grep for "optimhess" in $R_SOURCE_DIR/src/library/stats/src/:

    josh@compy: $R_SOURCE_DIR/src/library/stats/src
    > grep optimhess *
    init.c:    EXTDEF(optimhess, 4),
    optim.c:SEXP optimhess(SEXP call, SEXP op, SEXP args, SEXP rho)
    statsR.h:SEXP optimhess(SEXP call, SEXP op, SEXP args, SEXP rho);
    
    0 讨论(0)
提交回复
热议问题