spline.1 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. .TH SPLINE 1 "Dec 1998" "FSF" "GNU Plotting Utilities"
  2. .SH NAME
  3. spline \- interpolate datasets using splines under tension
  4. .SH SYNOPSIS
  5. .B spline
  6. [
  7. .I options
  8. ] [
  9. .I files
  10. ]
  11. .SH DESCRIPTION
  12. .LP
  13. .B spline
  14. reads datasets from standard input or from one or more files, and
  15. fits a smooth curve (a "spline") through each dataset.
  16. An interpolated version of each dataset, consisting of points from the
  17. smooth curve, is written to standard output.
  18. .LP
  19. Unless the
  20. .B \-a
  21. or
  22. .B \-A
  23. options are used (see below), each dataset should be a sequence of values
  24. for a vector-valued function of a single scalar variable.
  25. That is, each dataset should be a sequence of data points,
  26. given as alternating \fIt\fP\^
  27. and \fIy\fP\^ values.
  28. \fIt\fP\^ is a scalar independent variable, and
  29. \fIy\fP\^ is a vector-valued dependent variable.
  30. The dimensionality of
  31. \fIy\fP\^ is specified with the
  32. .B \-d
  33. option (the default dimensionality is 1).
  34. Between each data point
  35. and the next, \fIt\fP\^ should increase.
  36. .LP
  37. An input file may contain more than a single dataset.
  38. If an input file is in
  39. .SM ASCII
  40. format (the default), its datasets should be separated by blank lines.
  41. The \fIt\fP\^ and \fIy\fP\^ values of the data points in each dataset
  42. may be arranged arbitrarily, so long as they are separated by white space.
  43. Besides datasets, an input file may contain any number of
  44. comment lines, which should begin with the comment character `#'.
  45. Comment lines are ignored.
  46. They are not treated as blank, i.e.,
  47. they do not interrupt a dataset in progress.
  48. .LP
  49. Options and file names may be interspersed on the command line, but
  50. the options are processed before the file names are read.
  51. If
  52. .B \-\-
  53. is seen, it is interpreted as the end of the options.
  54. If no file names are specified, or the file name
  55. .B \-
  56. is encountered, the standard input is read.
  57. .LP
  58. The type of interpolation, and the format of the input and output files,
  59. may be selected by command-line options.
  60. .SH OPTIONS
  61. .SS "Interpolation-Related Options"
  62. .TP
  63. .B \-f
  64. .br
  65. .ns
  66. .TP
  67. .B \-\-filter
  68. Use a local interpolation algorithm (the cubic Bessel algorithm), so that
  69. .B spline
  70. can be used as a real-time filter.
  71. The slope of the interpolating curve at each point in a dataset will be
  72. chosen by fitting a quadratic function through that point and the two
  73. adjacent points in the dataset.
  74. If
  75. .B \-f
  76. is specified then the
  77. .B \-t
  78. option, otherwise optional, must be used as well.
  79. Also, if
  80. .B \-f
  81. is specified then the \fB\-k\fP, \fB\-p\fP, and \fB\-T\fP options
  82. may not be used.
  83. .IP ""
  84. If
  85. .BR \-f
  86. is \fInot\fP\^ specified, then the default (global) interpolation algorithm
  87. will be used.
  88. .TP
  89. .BI \-k " k"
  90. .br
  91. .ns
  92. .TP
  93. .BI \-\-boundary\-condition " k"
  94. Set the boundary condition parameter for each constructed spline to be
  95. .IR k .
  96. (The default value is 1.0.)
  97. In each of its components, the spline will
  98. satisfy the two boundary conditions y"[0]=ky"[1] and y"[n]=ky"[n-1].
  99. Here y[0] and y[1] signify the values of a specified component of the
  100. vector-valued dependent variable \fIy\fP\^ at the first two points of a
  101. dataset, and y[n-1] and y[n] the values at the last two points.
  102. Setting \fIk\fP\^ to zero will yield a "natural" spline, i.e., one that has
  103. zero curvature at the two ends of the dataset.
  104. The \fB\-k\fP option may not be used if \fB\-f\fP or \fB\-p\fP is specified.
  105. .TP
  106. .BI \-n " n"
  107. .br
  108. .ns
  109. .TP
  110. .BI \-\-number\-of\-intervals " n"
  111. Subdivide the interval over which interpolation occurs into \fIn\fP\^
  112. subintervals.
  113. The number of data points computed, and written to the
  114. output, will be
  115. .IR n+1 .
  116. The default value for \fIn\fP\^ is 100.
  117. .TP
  118. .B \-p
  119. .br
  120. .ns
  121. .TP
  122. .B \-\-periodic
  123. Construct a periodic spline.
  124. If this option is specified, the \fIy\fP\^
  125. values for the first and last points in each dataset must be equal.
  126. The
  127. \fB\-f\fP and \fB\-k\fP options may not be used if \fB\-p\fP is specified.
  128. .TP
  129. .BI \-T " tension"
  130. .br
  131. .ns
  132. .TP
  133. .BI \-\-tension " tension"
  134. Each interpolating curve will be a spline under tension.
  135. This option sets the tension value (the default is 0.0).
  136. .IP ""
  137. If \fItension\fP\^ equals zero, the curve will be a piecewise cubic spline.
  138. Increasing the tension above zero makes the curve "tighter", and
  139. reduces the likelihood of spurious inflection points.
  140. That is because between each pair of successive points in a dataset,
  141. the curve will satisfy the fourth-order differential equation
  142. y""=sgn(\fItension\fP\^)*(\fItension\fP\^^2)y" in each of its components.
  143. As \fItension\fP\^ increases to positive infinity,
  144. it will converge to a polygonal line.
  145. The \fB\-T\fP option may not be used if \fB\-f\fP is specified.
  146. .TP
  147. .B \-t \fItmin tmax [tspacing]\fP
  148. .br
  149. .ns
  150. .TP
  151. .B \-\-t\-spacing \fItmin tmax [tspacing]\fP
  152. For each dataset, set the interval over which interpolation occurs
  153. to be the interval between
  154. \fItmin\fP\^ and
  155. .IR tmax .
  156. If \fItspacing\fP\^ is not specified, the interval will be divided into the
  157. number of subintervals specified by the \fB\-n\fP option.
  158. .IP ""
  159. If the \fB\-t\fP
  160. option is not used, the interval over which interpolation occurs will be
  161. the entire range of the independent variable in the dataset.
  162. The \fB\-t\fP
  163. option must always be used if the \fB\-f\fP option is used to request
  164. filter-like behavior (see above).
  165. .SS "Format-Related Options"
  166. .TP
  167. .BI \-d " dimension"
  168. .br
  169. .ns
  170. .TP
  171. .BI \-\-y\-dimension " dimension"
  172. Set the dimensionality of the dependent variable
  173. .IR y " in"
  174. the input and output files to be
  175. .IR dimension .
  176. The default dimension is 1.
  177. .TP
  178. .BI \-I " data-format"
  179. .br
  180. .ns
  181. .TP
  182. .BI \-\-input\-format " data-format"
  183. Set the data format for the input file(s) to be
  184. .IR data-format ,
  185. which may be one of the following.
  186. .RS
  187. .TP
  188. .B a
  189. .SM ASCII
  190. format (the default).
  191. Each file is a sequence of floating point numbers, interpreted as the
  192. \fIt\fP\^ and \fIy\fP\^ coordinates of the successive data points in a dataset.
  193. If \fIy\fP\^ is \fId\fP\^-dimensional,
  194. there will be \fId+1\fP\^ numbers for each point.
  195. The \fIt\fP\^ and
  196. \fIy\fP\^ coordinates of a point need not appear on the same line, and
  197. points need not appear on different lines.
  198. But if a blank line occurs (i.e., two newlines in succession are seen), it
  199. is interpreted as the end of a dataset, and the beginning of the next.
  200. .TP
  201. .B f
  202. Single precision binary format.
  203. Each file is a sequence of floating point
  204. numbers, interpreted as the \fIt\fP\^
  205. and \fIy\fP\^ coordinates of the successive data
  206. points in a dataset.
  207. If \fIy\fP\^ is \fId\fP\^-dimensional,
  208. there will be \fId+1\fP\^ numbers for each point.
  209. Successive datasets are separated by a single occurrence of the quantity
  210. .SM FLT_MAX,
  211. which is the largest possible single precision floating point number.
  212. On most machines this is approximately 3.4x10^38.
  213. .TP
  214. .B d
  215. Double precision binary format.
  216. Each file is a sequence of double
  217. precision floating point numbers, interpreted as the \fIt\fP\^
  218. and \fIy\fP\^ coordinates of the successive data points in a dataset.
  219. If \fIy\fP\^ is \fId\fP\^-dimensional, there will
  220. be \fId+1\fP\^ numbers for each point.
  221. Successive datasets are separated by a single occurrence of the quantity
  222. .SM DBL_MAX,
  223. which is the largest possible double precision floating point number.
  224. On most machines this is approximately 1.8x10^308.
  225. .TP
  226. .B i
  227. Integer binary format.
  228. Each file is a sequence of integers, interpreted as
  229. the \fIt\fP\^ and \fIy\fP\^ coordinates of the successive data points
  230. in a dataset.
  231. If \fIy\fP\^ is \fId\fP\^-dimensional,
  232. there will be \fId+1\fP\^ numbers for each point.
  233. Successive datasets are separated by a single occurrence of the quantity
  234. .SM INT_MAX,
  235. which is the largest possible integer.
  236. On most machines this is 2^31\-1.
  237. .RE
  238. .TP
  239. .B \-a \fI[step_size [lower_limit]]\fP
  240. .br
  241. .ns
  242. .TP
  243. .B \-\-auto\-abscissa \fI[step_size [lower_limit]]\fP
  244. Automatically generate values for
  245. .IR t ,
  246. the independent variable (the default values of \fIstep_size\fP\^ and
  247. \fIlower_limit\fP\^ are 1.0 and 0.0, respectively).
  248. .IP ""
  249. Irrespective of data format (`a', `f', `d', or `i'), this option specifies
  250. that the values of \fIt\fP\^ are missing from the input file: the
  251. dataset(s) to be read contain only values of
  252. .IR y ,
  253. the dependent variable.
  254. So if \fIy\fP\^ is \fId\fP\^-dimensional, there will be
  255. only \fId\fP\^ numbers for each point.
  256. The increment from each \fIt\fP\^ value to the next will be
  257. .IR step_size ,
  258. and the first
  259. \fIt\fP\^ value
  260. will be
  261. .IR lower_limit .
  262. This option is useful, e.g., when interpolating curves rather than functions.
  263. .TP
  264. .B \-A
  265. .br
  266. .ns
  267. .TP
  268. .B \-\-auto\-dist\-abscissa
  269. Automatically generate values for
  270. .IR t ,
  271. the independent variable.
  272. This is a variant form of the \fB\-a\fP option.
  273. The increment from each \fIt\fP\^ value to the next will be the distance in
  274. \fId\fP\^-dimensional space between the corresponding \fIy\fP\^ values, and
  275. the first \fIt\fP\^ value will be 0.0.
  276. That is, \fIt\fP\^ will be "polygonal arclength".
  277. This option is useful when interpolating curves rather than functions.
  278. .TP
  279. .BI \-O " data-format"
  280. .br
  281. .ns
  282. .TP
  283. .BI \-\-output\-format " data-format"
  284. Set the data format for the output file to be
  285. .IR data-format .
  286. The interpretation of \fIdata-format\fP\^ is the same as for the
  287. \fB\-I\fP option.
  288. The default is `a', i.e.,
  289. .SM ASCII
  290. format.
  291. .TP
  292. .BI \-P " significant-digits"
  293. .br
  294. .ns
  295. .TP
  296. .BI \-\-precision " significant-digits"
  297. Set the numerical precision for the \fIt\fP\^ and \fIy\fP\^ values in the
  298. output file to be
  299. .IR significant-digits .
  300. This takes effect only if the output file is written in `a' format,
  301. i.e., in
  302. .SM ASCII.
  303. \fIsignificant-digits\fP\^ must be a positive integer (the default is 6).
  304. .TP
  305. .B \-s
  306. .br
  307. .ns
  308. .TP
  309. .B \-\-suppress\-abscissa
  310. Omit the independent variable \fIt\fP\^ from the output file; for each
  311. point, supply only the dependent variable
  312. .IR y .
  313. If \fIy\fP\^ is \fId\fP\^-dimensional, there will be only \fId\fP\^ numbers for
  314. each point, not
  315. .IR d+1 .
  316. This option is useful when interpolating curves rather than functions.
  317. .SS Informational Options
  318. .TP
  319. .B \-\-help
  320. Print a list of command-line options, and exit.
  321. .TP
  322. .B \-\-version
  323. Print the version number of
  324. .B spline
  325. and the plotting utilities package, and exit.
  326. .SH EXAMPLES
  327. .LP
  328. Typing
  329. .LP
  330. .RS
  331. .B echo 0 0 1 1 2 0 \||\| spline
  332. .RE
  333. .LP
  334. will produce on standard output an interpolated dataset consisting of
  335. 101 data points.
  336. If graphed, this interpolated dataset will yield a parabola.
  337. .LP
  338. It is sometimes useful to interpolate between a sequence of
  339. arbitrarily placed points in \fId\fP\^-dimensional space,
  340. i.e., to "spline a curve" rather than a function.
  341. The
  342. .B \-a
  343. and
  344. .B \-s
  345. options are used for this.
  346. For example,
  347. .LP
  348. .RS
  349. .B echo 0 0 1 0 1 1 0 1 \||\| spline \-d 2 \-a \-s
  350. .RE
  351. .LP
  352. will produce on standard output a 101-point dataset that interpolates
  353. between the four points (0,0), (1,0), (1,1), and (0,1).
  354. The
  355. .B \-d 2
  356. option specifies that the dependent variable \fIy\fP\^ is two-dimensional.
  357. The
  358. .B \-a
  359. option specifies that the \fIt\fP\^ values are missing from the input
  360. and should be automatically generated.
  361. The
  362. .B \-s
  363. option specifies
  364. that the \fIt\fP\^ values should be stripped from the output.
  365. .SH AUTHORS
  366. .B spline
  367. was written by Robert S. Maier (\fBrsm@math.arizona.edu\fP),
  368. starting with an earlier version by Rich Murphey (\fBrich@freebsd.org\fP).
  369. The algorithms for constructing splines under tension are similar
  370. to those used in the FITPACK
  371. subroutine library, and are ultimately due to
  372. Alan K. Cline (\fBcline@cs.utexas.edu\fP).
  373. .SH "SEE ALSO"
  374. "The GNU Plotting Utilities Manual".
  375. .SH BUGS
  376. Email bug reports to
  377. .BR bug\-gnu\-utils@gnu.org .