📄 qccmath.3
字号:
.TH QCCMATH 3 "QCCPACK" "".SH NAMEQccMathMax,QccMathMin,QccMathPercent,QccMathModulus,QccMathLog2,QccMathMedian,QccMathRand,QccMathRandNormal,QccMathGaussianDensity,QccMathLaplacianDensity\- various math routines.SH SYNOPSIS.B #include "libQccPack.h".sp.BI "QccMathMax(" x ", " y ).br.BI "QccMathMin(" x ", " y ).br.BI "QccMathPercent(" x ", " y ).br.BI "QccMathModulus(" x ", " y ).br.BI "QccMathLog2(" x ).br.BI "QccMathMedian(" a ", " b ", " c ).br.B double QccMathRand(void);.br.B double QccMathRandNormal(void);.br.BI "double QccMathGaussianDensity(double " x ", double " variance ", double " mean );.br.BI "double QccMathLaplacianDensity(double " x ", double " variance ", double " mean );.SH DESCRIPTION.B QccMathMax()returns the maximum of two numbers. It is a macro defined as.RS.nf#define QccMathMax(x, y) (((x) >= (y)) ? (x) : (y)).fi.RE.LP.B QccMathMin()returns the minimum of two numbers. It is a macro defined as.RS.nf#define QccMathMax(x, y) (((x) <= (y)) ? (x) : (y)).fi.RE.LP.B QccMathPercent()returns the percentage that.I xis of.IR y .It is a macro defined as.RS.nf#define QccMathPercent(x, y) (((double)(x)/(y))*100.0).fi.RE.LP.B QccMathModulus()is a macro that calculates the signed remainder of.I xafter division with.IR y .If .I yis nonzero, .B QccMathModulus()calculates.RS.nfx - y * floor(x/y).fi.REIf.I yis zero, .B QccMathModulus()simply evaluates to.IR x ..IR xand.IR ycan be integers or floating point..LP.B QccMathLog2()is a macro that calculates the logarithm base 2 of.IR x ..LP.B QccMathMedian()is a macro that calculates the median of the three values.IR a ", " b ", and " c ..LP.B QccMathRand()is a wrapper around.BR random (3)that ensures that.BR random (3)is properly seeded (by calling.BR srandom (3)with the current time)the first time that.B QccMathRand()is called.The return value of.B QccMathRand()is approximately uniformly distributed on the interval [0.0, 1.0]..B Warning:Although.BR QccMathRand()is MT-safe if the QccPack library is compiled with thread supportenabled, the underlying.BR random (3)and.BR srandom (3)functions are.I notMT-safe in typical systems. The implication isthat multithreaded application programs must not mix calls to .BR random (3)and.BR srandom (3)with calls to.BR QccMathRand() .Use.BR QccMathRand()exclusively in .I allthreads..LP.BR QccMathRandNormal()returns a random number distributed according to a normaldensity of mean 0 and unit variance.The Box-Muller method is used to transform a pair ofuniformly distributed values (as generated by.BR QccMathRand() )into a normally distributed value..LP.B QccMathGaussianDensity()returns the value of the Gaussian (normal) density functionwith the given.I varianceand .IR mean .It is equivalent to.RS.nfreturn(exp((-(x - mean)*(x - mean))/2/variance)/sqrt(2*M_PI*variance));.fi.RE.LP.B QccMathLaplacianDensity()returns the value of the Laplacian density functionwith the given.I varianceand .IR mean .It is equivalent to.RS.nfreturn(exp((-sqrt(2/variance))*fabs(x - mean))/sqrt(2*variance));.fi.RE.SH "SEE ALSO".BR random (3),.BR srandom (3),.BR QccPack (3).SH AUTHORCopyright (C) 1997-2009 James E. Fowler.\" The programs herein are free software; you can redistribute them an.or.\" modify them under the terms of the GNU General Public License.\" as published by the Free Software Foundation; either version 2.\" of the License, or (at your option) any later version..\" .\" These programs are distributed in the hope that they will be useful,.\" but WITHOUT ANY WARRANTY; without even the implied warranty of.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the.\" GNU General Public License for more details..\" .\" You should have received a copy of the GNU General Public License.\" along with these programs; if not, write to the Free Software.\" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -