c - How to access hidden_attribute functions from the R source? -
i want utilize next function in r.
double attribute_hidden chebyshev_eval(double x, const double *a, const int n) { double b0, b1, b2, twox; int i; if (n < 1 || n > 1000) ml_err_return_nan; if (x < -1.1 || x > 1.1) ml_err_return_nan; twox = x * 2; b2 = b1 = 0; b0 = 0; (i = 1; <= n; i++) { b2 = b1; b1 = b0; b0 = twox * b1 - b2 + a[n - i]; } homecoming (b0 - b2) * 0.5; } for reference, part of r source code chebyshev polynomials.
i can't seem find way reach hidden_attribute functions in r. tried doing calculation manually real utilize case, i'm running errors:
gamcs=c( +.8571195590989331421920062399942e-2, +.4415381324841006757191315771652e-2, +.5685043681599363378632664588789e-1, -.4219835396418560501012500186624e-2, +.1326808181212460220584006796352e-2, -.1893024529798880432523947023886e-3, +.3606925327441245256578082217225e-4, -.6056761904460864218485548290365e-5, +.1055829546302283344731823509093e-5, -.1811967365542384048291855891166e-6, +.3117724964715322277790254593169e-7, -.5354219639019687140874081024347e-8, +.9193275519859588946887786825940e-9, -.1577941280288339761767423273953e-9, +.2707980622934954543266540433089e-10, -.4646818653825730144081661058933e-11, +.7973350192007419656460767175359e-12, -.1368078209830916025799499172309e-12, +.2347319486563800657233471771688e-13, -.4027432614949066932766570534699e-14, +.6910051747372100912138336975257e-15, -.1185584500221992907052387126192e-15, +.2034148542496373955201026051932e-16, -.3490054341717405849274012949108e-17, +.5987993856485305567135051066026e-18, -.1027378057872228074490069778431e-18, +.1762702816060529824942759660748e-19, -.3024320653735306260958772112042e-20, +.5188914660218397839717833550506e-21, -.8902770842456576692449251601066e-22, +.1527474068493342602274596891306e-22, -.2620731256187362900257328332799e-23, +.4496464047830538670331046570666e-24, -.7714712731336877911703901525333e-25, +.1323635453126044036486572714666e-25, -.2270999412942928816702313813333e-26, +.3896418998003991449320816639999e-27, -.6685198115125953327792127999999e-28, +.1146998663140024384347613866666e-28, -.1967938586345134677295103999999e-29, +.3376448816585338090334890666666e-30, -.5793070335782135784625493333333e-31) ngam = 22 y = .8 x = y*2-1 b1 = b2 = 0 b0 = 0 twox = x * 2 n = ngam = gamcs (i in 1:n) { b2 = b1 b1 = b0 b0 = twox * b1 - b2 + a[n - i] } (b0 - b2) * 0.5 (as taken https://github.com/wch/r-source/blob/0b493ddbefbc3cc06f675841c4672b3197dbfbbb/src/nmath/gamma.c#l143 , https://github.com/wch/r-source/blob/0b493ddbefbc3cc06f675841c4672b3197dbfbbb/src/nmath/chebyshev.c#l69. value y dummy value property abs(y * 2 - 1)<=1.1)
calculating manually not tedious, results in zero-value b0, end result (b0 - b2) * 0.5 doesn't homecoming value.
a workaround access function directly. problem because attribute_hidden functions can't accessed r.
i'd know if there's function, workaround, command etc. show these calculations. e.g. showcalculations(chebyshev_eval(.6,gamcs,ngam)).
preferrably function shows / replicates calculation each line, or each iteration of for-loop, , likes.
note: i'm aware not terribly savvy of rprintf option. knowledge of c code limited if 1 decides propose option, guidance appreciated.
c r
No comments:
Post a Comment