]> granicus.if.org Git - jq/commitdiff
Add missing trig functions and barebones test
authorNicolas Williams <nico@cryptonector.com>
Fri, 21 Feb 2014 16:49:21 +0000 (10:49 -0600)
committerNicolas Williams <nico@cryptonector.com>
Fri, 21 Feb 2014 16:49:21 +0000 (10:49 -0600)
libm.h
tests/all.test

diff --git a/libm.h b/libm.h
index cbea4f5068653d69bc6efd77e21f1fdc5b653b36..4dd5f904ab0f4f3de9f51abdb1275fc06e329b23 100644 (file)
--- 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) */
+
index a2c097cf80f6d936c266ea04e974e30df5d0eda2..bcaa4799d8e3bc79784e5ab41ff6e14fd4392462 100644 (file)
@@ -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]]]