From: Nicolas Williams Date: Fri, 21 Feb 2014 16:49:21 +0000 (-0600) Subject: Add missing trig functions and barebones test X-Git-Tag: jq-1.4~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59302fd2086b2bcc7c33e40bede320c2623eafac;p=jq Add missing trig functions and barebones test --- diff --git a/libm.h b/libm.h index cbea4f5..4dd5f90 100644 --- a/libm.h +++ b/libm.h @@ -1,7 +1,10 @@ LIBM_DD(acos) LIBM_DD(acosh) LIBM_DD(asin) +LIBM_DD(asinh) +LIBM_DD(atan) LIBM_DD(atanh) +LIBM_DD(cos) LIBM_DD(cosh) LIBM_DD(exp2) LIBM_DD(exp) @@ -11,8 +14,11 @@ LIBM_DD(j1) LIBM_DD(log10) LIBM_DD(log2) LIBM_DD(log) +LIBM_DD(sin) LIBM_DD(sinh) LIBM_DD(sqrt) +LIBM_DD(tan) +LIBM_DD(tanh) LIBM_DD(tgamma) LIBM_DD(y0) LIBM_DD(y1) @@ -24,3 +30,4 @@ LIBM_DD(y1) /* LIBM_DDD(remainder) */ /* LIBM_DDI(scalbn) */ /* LIBM_DDIP(lgamma_r) */ + diff --git a/tests/all.test b/tests/all.test index a2c097c..bcaa479 100644 --- a/tests/all.test +++ b/tests/all.test @@ -409,6 +409,18 @@ null [2,4,4,4,5,5,7,9] 2 +# Should write a test that calls the -lm function from C to check +# that they match the corresponding jq functions. However, there's so +# little template code standing between that it suffices to test a +# handful of these. The results were checked by eye against bc(1). +[.[]|cos] +[.1,.2,.3,.4,.5,.6] +[0.9950041652780258,0.9800665778412416,0.955336489125606,0.9210609940028851,0.8775825618903728,0.8253356149096783] + +[.[]|sin] +[.1,.2,.3,.4,.5,.6] +[0.09983341664682815,0.19866933079506122,0.29552020666133955,0.3894183423086505,0.479425538604203,0.5646424733950354] + def f(x): x | x; f([.], . + [42]) [1,2,3] [[[1,2,3]]]