math.pp 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Florian Klaempfl
  5. member of the Free Pascal development team
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {
  13. This unit is an equivalent to the Delphi math unit
  14. (with some improvements)
  15. What's to do:
  16. o a lot of function :), search for !!!!
  17. o some statistical functions
  18. o all financial functions
  19. o optimizations
  20. }
  21. unit math;
  22. interface
  23. {$MODE objfpc}
  24. {$ifdef VER1_0}
  25. { we don't assume cross compiling from 1.0.x-m68k ... }
  26. {$define FPC_HAS_TYPE_EXTENDED}
  27. {$endif VER1_0}
  28. uses
  29. sysutils;
  30. { Ranges of the IEEE floating point types, including denormals }
  31. {$ifdef FPC_HAS_TYPE_SINGLE}
  32. const
  33. MinSingle = 1.5e-45;
  34. MaxSingle = 3.4e+38;
  35. {$endif FPC_HAS_TYPE_SINGLE}
  36. {$ifdef FPC_HAS_TYPE_DOUBLE}
  37. const
  38. MinDouble = 5.0e-324;
  39. MaxDouble = 1.7e+308;
  40. {$endif FPC_HAS_TYPE_DOUBLE}
  41. {$ifdef FPC_HAS_TYPE_EXTENDED}
  42. const
  43. MinExtended = 3.4e-4932;
  44. MaxExtended = 1.1e+4932;
  45. {$endif FPC_HAS_TYPE_EXTENDED}
  46. {$ifdef FPC_HAS_TYPE_COMP}
  47. const
  48. MinComp = -9.223372036854775807e+18;
  49. MaxComp = 9.223372036854775807e+18;
  50. {$endif FPC_HAS_TYPE_COMP}
  51. { the original delphi functions use extended as argument, }
  52. { but I would prefer double, because 8 bytes is a very }
  53. { natural size for the processor }
  54. { WARNING : changing float type will }
  55. { break all assembler code PM }
  56. {$ifdef FPC_HAS_TYPE_FLOAT128}
  57. type
  58. float = float128;
  59. const
  60. MinFloat = MinFloat128;
  61. MaxFloat = MaxFloat128;
  62. {$else FPC_HAS_TYPE_FLOAT128}
  63. {$ifdef FPC_HAS_TYPE_EXTENDED}
  64. type
  65. float = extended;
  66. const
  67. MinFloat = MinExtended;
  68. MaxFloat = MaxExtended;
  69. {$else FPC_HAS_TYPE_EXTENDED}
  70. {$ifdef FPC_HAS_TYPE_DOUBLE}
  71. type
  72. float = double;
  73. const
  74. MinFloat = MinDouble;
  75. MaxFloat = MaxDouble;
  76. {$else FPC_HAS_TYPE_DOUBLE}
  77. {$ifdef FPC_HAS_TYPE_SINGLE}
  78. type
  79. float = single;
  80. const
  81. MinFloat = MinSingle;
  82. MaxFloat = MaxSingle;
  83. {$else FPC_HAS_TYPE_SINGLE}
  84. {$fatal At least one floating point type must be supported}
  85. {$endif FPC_HAS_TYPE_SINGLE}
  86. {$endif FPC_HAS_TYPE_DOUBLE}
  87. {$endif FPC_HAS_TYPE_EXTENDED}
  88. {$endif FPC_HAS_TYPE_FLOAT128}
  89. type
  90. PFloat = ^Float;
  91. PInteger = ^Integer;
  92. tpaymenttime = (ptendofperiod,ptstartofperiod);
  93. einvalidargument = class(ematherror);
  94. TValueRelationship = -1..1;
  95. const
  96. EqualsValue = 0;
  97. LessThanValue = Low(TValueRelationship);
  98. GreaterThanValue = High(TValueRelationship);
  99. {$ifndef ver1_0}
  100. {$ifopt R+}
  101. {$define RangeCheckWasOn}
  102. {$R-}
  103. {$endif opt R+}
  104. {$ifopt Q+}
  105. {$define OverflowCheckWasOn}
  106. {$Q-}
  107. {$endif opt Q+}
  108. {$ifdef CPUARM}
  109. { the ARM linux emulator doesn't like 0.0/0.0 }
  110. NaN = ln(-1.0);
  111. {$else CPUARM}
  112. NaN = 0.0/0.0;
  113. {$endif CPUARM}
  114. Infinity = 1.0/0.0;
  115. {$ifdef RangeCheckWasOn}
  116. {$R+}
  117. {$undef RangeCheckWasOn}
  118. {$endif}
  119. {$ifdef OverflowCheckWasOn}
  120. {$Q+}
  121. {$undef OverflowCheckWasOn}
  122. {$endif}
  123. {$endif ver1_0}
  124. { Min/max determination }
  125. function MinIntValue(const Data: array of Integer): Integer;
  126. function MaxIntValue(const Data: array of Integer): Integer;
  127. { Extra, not present in Delphi, but used frequently }
  128. function Min(a, b: Integer): Integer;
  129. function Max(a, b: Integer): Integer;
  130. function Min(a, b: Cardinal): Cardinal;
  131. function Max(a, b: Cardinal): Cardinal;
  132. function Min(a, b: Int64): Int64;
  133. function Max(a, b: Int64): Int64;
  134. {$ifdef FPC_HAS_TYPE_SINGLE}
  135. function Min(a, b: Single): Single;
  136. function Max(a, b: Single): Single;
  137. {$endif FPC_HAS_TYPE_SINGLE}
  138. {$ifdef FPC_HAS_TYPE_DOUBLE}
  139. function Min(a, b: Double): Double;
  140. function Max(a, b: Double): Double;
  141. {$endif FPC_HAS_TYPE_DOUBLE}
  142. {$ifdef FPC_HAS_TYPE_EXTENDED}
  143. function Min(a, b: Extended): Extended;
  144. function Max(a, b: Extended): Extended;
  145. {$endif FPC_HAS_TYPE_EXTENDED}
  146. function InRange(const AValue, AMin, AMax: Integer): Boolean;
  147. function InRange(const AValue, AMin, AMax: Int64): Boolean;
  148. {$ifdef FPC_HAS_TYPE_DOUBLE}
  149. function InRange(const AValue, AMin, AMax: Double): Boolean;
  150. {$endif FPC_HAS_TYPE_DOUBLE}
  151. function EnsureRange(const AValue, AMin, AMax: Integer): Integer;
  152. function EnsureRange(const AValue, AMin, AMax: Int64): Int64;
  153. {$ifdef FPC_HAS_TYPE_DOUBLE}
  154. function EnsureRange(const AValue, AMin, AMax: Double): Double;
  155. {$endif FPC_HAS_TYPE_DOUBLE}
  156. procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: Word);
  157. // Sign functions
  158. Type
  159. TValueSign = -1..1;
  160. const
  161. NegativeValue = Low(TValueSign);
  162. ZeroValue = 0;
  163. PositiveValue = High(TValueSign);
  164. function Sign(const AValue: Integer): TValueSign;
  165. function Sign(const AValue: Int64): TValueSign;
  166. function Sign(const AValue: Double): TValueSign;
  167. function IsZero(const A: Single; Epsilon: Single): Boolean;
  168. function IsZero(const A: Single): Boolean;
  169. {$ifdef FPC_HAS_TYPE_DOUBLE}
  170. function IsZero(const A: Double; Epsilon: Double): Boolean;
  171. function IsZero(const A: Double): Boolean;
  172. {$endif FPC_HAS_TYPE_DOUBLE}
  173. {$ifdef FPC_HAS_TYPE_EXTENDED}
  174. function IsZero(const A: Extended; Epsilon: Extended): Boolean;
  175. function IsZero(const A: Extended): Boolean;
  176. {$endif FPC_HAS_TYPE_EXTENDED}
  177. function IsNan(const d : Double): Boolean;
  178. function IsInfinite(const d : Double): Boolean;
  179. {$ifdef FPC_HAS_TYPE_EXTENDED}
  180. function SameValue(const A, B: Extended): Boolean;
  181. {$endif}
  182. {$ifdef FPC_HAS_TYPE_DOUBLE}
  183. function SameValue(const A, B: Double): Boolean;
  184. {$endif}
  185. function SameValue(const A, B: Single): Boolean;
  186. {$ifdef FPC_HAS_TYPE_EXTENDED}
  187. function SameValue(const A, B: Extended; Epsilon: Extended): Boolean;
  188. {$endif}
  189. {$ifdef FPC_HAS_TYPE_DOUBLE}
  190. function SameValue(const A, B: Double; Epsilon: Double): Boolean;
  191. {$endif}
  192. function SameValue(const A, B: Single; Epsilon: Single): Boolean;
  193. { angle conversion }
  194. function degtorad(deg : float) : float;
  195. function radtodeg(rad : float) : float;
  196. function gradtorad(grad : float) : float;
  197. function radtograd(rad : float) : float;
  198. function degtograd(deg : float) : float;
  199. function gradtodeg(grad : float) : float;
  200. { one cycle are 2*Pi rad }
  201. function cycletorad(cycle : float) : float;
  202. function radtocycle(rad : float) : float;
  203. { trigoniometric functions }
  204. function tan(x : float) : float;
  205. function cotan(x : float) : float;
  206. procedure sincos(theta : float;var sinus,cosinus : float);
  207. { inverse functions }
  208. function arccos(x : float) : float;
  209. function arcsin(x : float) : float;
  210. { calculates arctan(y/x) and returns an angle in the correct quadrant }
  211. function arctan2(y,x : float) : float;
  212. { hyperbolic functions }
  213. function cosh(x : float) : float;
  214. function sinh(x : float) : float;
  215. function tanh(x : float) : float;
  216. { area functions }
  217. { delphi names: }
  218. function arccosh(x : float) : float;
  219. function arcsinh(x : float) : float;
  220. function arctanh(x : float) : float;
  221. { IMHO the function should be called as follows (FK) }
  222. function arcosh(x : float) : float;
  223. function arsinh(x : float) : float;
  224. function artanh(x : float) : float;
  225. { triangle functions }
  226. { returns the length of the hypotenuse of a right triangle }
  227. { if x and y are the other sides }
  228. function hypot(x,y : float) : float;
  229. { logarithm functions }
  230. function log10(x : float) : float;
  231. function log2(x : float) : float;
  232. function logn(n,x : float) : float;
  233. { returns natural logarithm of x+1 }
  234. function lnxp1(x : float) : float;
  235. { exponential functions }
  236. function power(base,exponent : float) : float;
  237. { base^exponent }
  238. function intpower(base : float;const exponent : Integer) : float;
  239. operator ** (bas,expo : float) e: float;
  240. operator ** (bas,expo : int64) i: float;
  241. { number converting }
  242. { rounds x towards positive infinity }
  243. function ceil(x : float) : Integer;
  244. { rounds x towards negative infinity }
  245. function floor(x : float) : Integer;
  246. { misc. functions }
  247. { splits x into mantissa and exponent (to base 2) }
  248. procedure Frexp(X: float; var Mantissa: float; var Exponent: integer);
  249. { returns x*(2^p) }
  250. function ldexp(x : float; const p : Integer) : float;
  251. { statistical functions }
  252. function mean(const data : array of float) : float;
  253. function sum(const data : array of float) : float;
  254. function mean(const data : PFloat; Const N : longint) : float;
  255. function sum(const data : PFloat; Const N : Longint) : float;
  256. function sumofsquares(const data : array of float) : float;
  257. function sumofsquares(const data : PFloat; Const N : Integer) : float;
  258. { calculates the sum and the sum of squares of data }
  259. procedure sumsandsquares(const data : array of float;
  260. var sum,sumofsquares : float);
  261. procedure sumsandsquares(const data : PFloat; Const N : Integer;
  262. var sum,sumofsquares : float);
  263. function minvalue(const data : array of float) : float;
  264. function minvalue(const data : array of integer) : Integer;
  265. function minvalue(const data : PFloat; Const N : Integer) : float;
  266. function MinValue(const Data : PInteger; Const N : Integer): Integer;
  267. function maxvalue(const data : array of float) : float;
  268. function maxvalue(const data : array of integer) : Integer;
  269. function maxvalue(const data : PFloat; Const N : Integer) : float;
  270. function maxvalue(const data : PInteger; Const N : Integer) : Integer;
  271. { calculates the standard deviation }
  272. function stddev(const data : array of float) : float;
  273. function stddev(const data : PFloat; Const N : Integer) : float;
  274. { calculates the mean and stddev }
  275. procedure meanandstddev(const data : array of float;
  276. var mean,stddev : float);
  277. procedure meanandstddev(const data : PFloat;
  278. Const N : Longint;var mean,stddev : float);
  279. function variance(const data : array of float) : float;
  280. function totalvariance(const data : array of float) : float;
  281. function variance(const data : PFloat; Const N : Integer) : float;
  282. function totalvariance(const data : PFloat; Const N : Integer) : float;
  283. { returns random values with gaussian distribution }
  284. function randg(mean,stddev : float) : float;
  285. { I don't know what the following functions do: }
  286. function popnstddev(const data : array of float) : float;
  287. function popnstddev(const data : PFloat; Const N : Integer) : float;
  288. function popnvariance(const data : PFloat; Const N : Integer) : float;
  289. function popnvariance(const data : array of float) : float;
  290. procedure momentskewkurtosis(const data : array of float;
  291. var m1,m2,m3,m4,skew,kurtosis : float);
  292. procedure momentskewkurtosis(const data : PFloat; Const N : Integer;
  293. var m1,m2,m3,m4,skew,kurtosis : float);
  294. { geometrical function }
  295. { returns the euclidean L2 norm }
  296. function norm(const data : array of float) : float;
  297. function norm(const data : PFloat; Const N : Integer) : float;
  298. {$ifndef ver1_0} // default params
  299. function ifthen(val:boolean;const iftrue:integer; const iffalse:integer= 0) :integer; {$ifdef MATHINLINE}inline; {$endif}
  300. function ifthen(val:boolean;const iftrue:int64 ; const iffalse:int64 = 0) :int64; {$ifdef MATHINLINE}inline; {$endif}
  301. function ifthen(val:boolean;const iftrue:double ; const iffalse:double =0.0):double; {$ifdef MATHINLINE}inline; {$endif}
  302. {$endif}
  303. { include cpu specific stuff }
  304. {$i mathuh.inc}
  305. implementation
  306. { include cpu specific stuff }
  307. {$i mathu.inc}
  308. ResourceString
  309. SMathError = 'Math Error : %s';
  310. SInvalidArgument = 'Invalid argument';
  311. Procedure DoMathError(Const S : String);
  312. begin
  313. Raise EMathError.CreateFmt(SMathError,[S]);
  314. end;
  315. Procedure InvalidArgument;
  316. begin
  317. Raise EInvalidArgument.Create(SInvalidArgument);
  318. end;
  319. function Sign(const AValue: Integer): TValueSign;
  320. begin
  321. If Avalue<0 then
  322. Result:=NegativeValue
  323. else If Avalue>0 then
  324. Result:=PositiveValue
  325. else
  326. Result:=ZeroValue;
  327. end;
  328. function Sign(const AValue: Int64): TValueSign;
  329. begin
  330. If Avalue<0 then
  331. Result:=NegativeValue
  332. else If Avalue>0 then
  333. Result:=PositiveValue
  334. else
  335. Result:=ZeroValue;
  336. end;
  337. function Sign(const AValue: Double): TValueSign;
  338. begin
  339. If Avalue<0.0 then
  340. Result:=NegativeValue
  341. else If Avalue>0.0 then
  342. Result:=PositiveValue
  343. else
  344. Result:=ZeroValue;
  345. end;
  346. function degtorad(deg : float) : float;
  347. begin
  348. degtorad:=deg*(pi/180.0);
  349. end;
  350. function radtodeg(rad : float) : float;
  351. begin
  352. radtodeg:=rad*(180.0/pi);
  353. end;
  354. function gradtorad(grad : float) : float;
  355. begin
  356. gradtorad:=grad*(pi/200.0);
  357. end;
  358. function radtograd(rad : float) : float;
  359. begin
  360. radtograd:=rad*(200.0/pi);
  361. end;
  362. function degtograd(deg : float) : float;
  363. begin
  364. degtograd:=deg*(200.0/180.0);
  365. end;
  366. function gradtodeg(grad : float) : float;
  367. begin
  368. gradtodeg:=grad*(180.0/200.0);
  369. end;
  370. function cycletorad(cycle : float) : float;
  371. begin
  372. cycletorad:=(2*pi)*cycle;
  373. end;
  374. function radtocycle(rad : float) : float;
  375. begin
  376. { avoid division }
  377. radtocycle:=rad*(1/(2*pi));
  378. end;
  379. function tan(x : float) : float;
  380. begin
  381. Tan:=Sin(x)/Cos(x)
  382. end;
  383. function cotan(x : float) : float;
  384. begin
  385. cotan:=Cos(X)/Sin(X);
  386. end;
  387. procedure sincos(theta : float;var sinus,cosinus : float);
  388. begin
  389. sinus:=sin(theta);
  390. cosinus:=cos(theta);
  391. end;
  392. { ArcSin and ArcCos from Arjan van Dijk ([email protected]) }
  393. function arcsin(x : float) : float;
  394. begin
  395. if abs(x) > 1 then InvalidArgument
  396. else if abs(x) < 0.5 then
  397. arcsin := arctan(x/sqrt(1-sqr(x)))
  398. else
  399. arcsin := sign(x) * (pi*0.5 - arctan(sqrt(1 / sqr(x) - 1)));
  400. end;
  401. function Arccos(x : Float) : Float;
  402. begin
  403. arccos := pi*0.5 - arcsin(x);
  404. end;
  405. {$ifndef FPC_MATH_HAS_ARCTAN2}
  406. function arctan2(y,x : float) : float;
  407. begin
  408. if (x=0) then
  409. begin
  410. if y=0 then
  411. arctan2:=0.0
  412. else if y>0 then
  413. arctan2:=pi/2
  414. else if y<0 then
  415. arctan2:=-pi/2;
  416. end
  417. else
  418. ArcTan2:=ArcTan(y/x);
  419. if x<0.0 then
  420. ArcTan2:=ArcTan2+pi;
  421. if ArcTan2>pi then
  422. ArcTan2:=ArcTan2-2*pi;
  423. end;
  424. {$endif FPC_MATH_HAS_ARCTAN2}
  425. function cosh(x : float) : float;
  426. var
  427. temp : float;
  428. begin
  429. temp:=exp(x);
  430. cosh:=0.5*(temp+1.0/temp);
  431. end;
  432. function sinh(x : float) : float;
  433. var
  434. temp : float;
  435. begin
  436. temp:=exp(x);
  437. sinh:=0.5*(temp-1.0/temp);
  438. end;
  439. Const MaxTanh = 5678.22249441322; // Ln(MaxExtended)/2
  440. function tanh(x : float) : float;
  441. var Temp : float;
  442. begin
  443. if x>MaxTanh then exit(1.0)
  444. else if x<-MaxTanh then exit (-1.0);
  445. temp:=exp(-2*x);
  446. tanh:=(1-temp)/(1+temp)
  447. end;
  448. function arccosh(x : float) : float;
  449. begin
  450. arccosh:=arcosh(x);
  451. end;
  452. function arcsinh(x : float) : float;
  453. begin
  454. arcsinh:=arsinh(x);
  455. end;
  456. function arctanh(x : float) : float;
  457. begin
  458. if x>1 then InvalidArgument;
  459. arctanh:=artanh(x);
  460. end;
  461. function arcosh(x : float) : float;
  462. begin
  463. if x<1 then InvalidArgument;
  464. arcosh:=Ln(x+Sqrt(x*x-1));
  465. end;
  466. function arsinh(x : float) : float;
  467. begin
  468. arsinh:=Ln(x+Sqrt(1+x*x));
  469. end;
  470. function artanh(x : float) : float;
  471. begin
  472. If abs(x)>1 then InvalidArgument;
  473. artanh:=(Ln((1+x)/(1-x)))*0.5;
  474. end;
  475. function hypot(x,y : float) : float;
  476. begin
  477. hypot:=Sqrt(x*x+y*y)
  478. end;
  479. function log10(x : float) : float;
  480. begin
  481. log10:=ln(x)/ln(10);
  482. end;
  483. function log2(x : float) : float;
  484. begin
  485. log2:=ln(x)/ln(2)
  486. end;
  487. function logn(n,x : float) : float;
  488. begin
  489. if n<0 then InvalidArgument;
  490. logn:=ln(x)/ln(n);
  491. end;
  492. function lnxp1(x : float) : float;
  493. begin
  494. if x<-1 then
  495. InvalidArgument;
  496. lnxp1:=ln(1+x);
  497. end;
  498. function power(base,exponent : float) : float;
  499. begin
  500. if Exponent=0.0 then
  501. if base <> 0.0 then
  502. result:=1.0
  503. else
  504. InvalidArgument
  505. else if (base=0.0) and (exponent>0.0) then
  506. result:=0.0
  507. else if (abs(exponent)<=maxint) and (frac(exponent)=0.0) then
  508. result:=intpower(base,trunc(exponent))
  509. else if base>0.0 then
  510. result:=exp(exponent * ln (base))
  511. else
  512. InvalidArgument;
  513. end;
  514. function intpower(base : float;const exponent : Integer) : float;
  515. var
  516. i : longint;
  517. begin
  518. if (base = 0.0) and (exponent = 0) then
  519. InvalidArgument;
  520. i:=abs(exponent);
  521. intpower:=1.0;
  522. while i>0 do
  523. begin
  524. while (i and 1)=0 do
  525. begin
  526. i:=i shr 1;
  527. base:=sqr(base);
  528. end;
  529. i:=i-1;
  530. intpower:=intpower*base;
  531. end;
  532. if exponent<0 then
  533. intpower:=1.0/intpower;
  534. end;
  535. operator ** (bas,expo : float) e: float;
  536. begin
  537. e:=power(bas,expo);
  538. end;
  539. operator ** (bas,expo : int64) i: float;
  540. begin
  541. i:=intpower(bas,expo);
  542. end;
  543. function ceil(x : float) : integer;
  544. begin
  545. Ceil:=Trunc(x);
  546. If Frac(x)>0 then
  547. Ceil:=Ceil+1;
  548. end;
  549. function floor(x : float) : integer;
  550. begin
  551. Floor:=Trunc(x);
  552. If Frac(x)<0 then
  553. Floor := Floor-1;
  554. end;
  555. procedure Frexp(X: float; var Mantissa: float; var Exponent: integer);
  556. begin
  557. Exponent :=0;
  558. if (abs(x)<0.5) then
  559. While (abs(x)<0.5) do
  560. begin
  561. x := x*2;
  562. Dec(Exponent);
  563. end
  564. else
  565. While (abs(x)>1) do
  566. begin
  567. x := x/2;
  568. Inc(Exponent);
  569. end;
  570. mantissa := x;
  571. end;
  572. function ldexp(x : float;const p : Integer) : float;
  573. begin
  574. ldexp:=x*intpower(2.0,p);
  575. end;
  576. function mean(const data : array of float) : float;
  577. begin
  578. Result:=Mean(@data[0],High(Data)+1);
  579. end;
  580. function mean(const data : PFloat; Const N : longint) : float;
  581. begin
  582. mean:=sum(Data,N);
  583. mean:=mean/N;
  584. end;
  585. function sum(const data : array of float) : float;
  586. begin
  587. Result:=Sum(@Data[0],High(Data)+1);
  588. end;
  589. function sum(const data : PFloat;Const N : longint) : float;
  590. var
  591. i : longint;
  592. begin
  593. sum:=0.0;
  594. for i:=0 to N-1 do
  595. sum:=sum+data[i];
  596. end;
  597. function sumofsquares(const data : array of float) : float;
  598. begin
  599. Result:=sumofsquares(@data[0],High(Data)+1);
  600. end;
  601. function sumofsquares(const data : PFloat; Const N : Integer) : float;
  602. var
  603. i : longint;
  604. begin
  605. sumofsquares:=0.0;
  606. for i:=0 to N-1 do
  607. sumofsquares:=sumofsquares+sqr(data[i]);
  608. end;
  609. procedure sumsandsquares(const data : array of float;
  610. var sum,sumofsquares : float);
  611. begin
  612. sumsandsquares (@Data[0],High(Data)+1,Sum,sumofsquares);
  613. end;
  614. procedure sumsandsquares(const data : PFloat; Const N : Integer;
  615. var sum,sumofsquares : float);
  616. var
  617. i : Integer;
  618. temp : float;
  619. begin
  620. sumofsquares:=0.0;
  621. sum:=0.0;
  622. for i:=0 to N-1 do
  623. begin
  624. temp:=data[i];
  625. sumofsquares:=sumofsquares+sqr(temp);
  626. sum:=sum+temp;
  627. end;
  628. end;
  629. function stddev(const data : array of float) : float;
  630. begin
  631. Result:=Stddev(@Data[0],High(Data)+1)
  632. end;
  633. function stddev(const data : PFloat; Const N : Integer) : float;
  634. begin
  635. StdDev:=Sqrt(Variance(Data,N));
  636. end;
  637. procedure meanandstddev(const data : array of float;
  638. var mean,stddev : float);
  639. begin
  640. Meanandstddev(@Data[0],High(Data)+1,Mean,stddev);
  641. end;
  642. procedure meanandstddev(const data : PFloat;
  643. Const N : Longint;var mean,stddev : float);
  644. Var I : longint;
  645. begin
  646. Mean:=0;
  647. StdDev:=0;
  648. For I:=0 to N-1 do
  649. begin
  650. Mean:=Mean+Data[i];
  651. StdDev:=StdDev+Sqr(Data[i]);
  652. end;
  653. Mean:=Mean/N;
  654. StdDev:=(StdDev-N*Sqr(Mean));
  655. If N>1 then
  656. StdDev:=Sqrt(Stddev/(N-1))
  657. else
  658. StdDev:=0;
  659. end;
  660. function variance(const data : array of float) : float;
  661. begin
  662. Variance:=Variance(@Data[0],High(Data)+1);
  663. end;
  664. function variance(const data : PFloat; Const N : Integer) : float;
  665. begin
  666. If N=1 then
  667. Result:=0
  668. else
  669. Result:=TotalVariance(Data,N)/(N-1);
  670. end;
  671. function totalvariance(const data : array of float) : float;
  672. begin
  673. Result:=TotalVariance(@Data[0],High(Data)+1);
  674. end;
  675. function totalvariance(const data : Pfloat;Const N : Integer) : float;
  676. var S,SS : Float;
  677. begin
  678. If N=1 then
  679. Result:=0
  680. else
  681. begin
  682. SumsAndSquares(Data,N,S,SS);
  683. Result := SS-Sqr(S)/N;
  684. end;
  685. end;
  686. function randg(mean,stddev : float) : float;
  687. Var U1,S2 : Float;
  688. begin
  689. repeat
  690. u1:= 2*random-1;
  691. S2:=Sqr(U1)+sqr(2*random-1);
  692. until s2<1;
  693. randg:=Sqrt(-2*ln(S2)/S2)*u1*stddev+Mean;
  694. end;
  695. function popnstddev(const data : array of float) : float;
  696. begin
  697. PopnStdDev:=Sqrt(PopnVariance(@Data[0],High(Data)+1));
  698. end;
  699. function popnstddev(const data : PFloat; Const N : Integer) : float;
  700. begin
  701. PopnStdDev:=Sqrt(PopnVariance(Data,N));
  702. end;
  703. function popnvariance(const data : array of float) : float;
  704. begin
  705. popnvariance:=popnvariance(@data[0],high(Data)+1);
  706. end;
  707. function popnvariance(const data : PFloat; Const N : Integer) : float;
  708. begin
  709. PopnVariance:=TotalVariance(Data,N)/N;
  710. end;
  711. procedure momentskewkurtosis(const data : array of float;
  712. var m1,m2,m3,m4,skew,kurtosis : float);
  713. begin
  714. momentskewkurtosis(@Data[0],High(Data)+1,m1,m2,m3,m4,skew,kurtosis);
  715. end;
  716. procedure momentskewkurtosis(const data : PFloat; Const N : Integer;
  717. var m1,m2,m3,m4,skew,kurtosis : float);
  718. Var S,SS,SC,SQ,invN,Acc,M1S,S2N,S3N,temp : Float;
  719. I : Longint;
  720. begin
  721. invN:=1.0/N;
  722. s:=0;
  723. ss:=0;
  724. sq:=0;
  725. sc:=0;
  726. for i:=0 to N-1 do
  727. begin
  728. temp:=Data[i]; { faster }
  729. S:=S+temp;
  730. acc:=temp*temp;
  731. ss:=ss+acc;
  732. Acc:=acc*temp;
  733. Sc:=sc+acc;
  734. acc:=acc*temp;
  735. sq:=sq+acc;
  736. end;
  737. M1:=s*invN;
  738. M1S:=M1*M1;
  739. S2N:=SS*invN;
  740. S3N:=SC*invN;
  741. M2:=S2N-M1S;
  742. M3:=S3N-(M1*3*S2N) + 2*M1S*M1;
  743. M4:=SQ*invN - (M1 * 4 * S3N) + (M1S*6*S2N-3*Sqr(M1S));
  744. Skew:=M3*power(M2,-3/2);
  745. Kurtosis:=M4 / Sqr(M2);
  746. end;
  747. function norm(const data : array of float) : float;
  748. begin
  749. norm:=Norm(@data[0],High(Data)+1);
  750. end;
  751. function norm(const data : PFloat; Const N : Integer) : float;
  752. begin
  753. norm:=sqrt(sumofsquares(data,N));
  754. end;
  755. function MinIntValue(const Data: array of Integer): Integer;
  756. var
  757. I: Integer;
  758. begin
  759. Result := Data[Low(Data)];
  760. For I := Succ(Low(Data)) To High(Data) Do
  761. If Data[I] < Result Then Result := Data[I];
  762. end;
  763. function MinValue(const Data: array of Integer): Integer;
  764. begin
  765. Result:=MinValue(Pinteger(@Data[0]),High(Data)+1)
  766. end;
  767. function MinValue(const Data: PInteger; Const N : Integer): Integer;
  768. var
  769. I: Integer;
  770. begin
  771. Result := Data[0];
  772. For I := 1 To N-1 do
  773. If Data[I] < Result Then Result := Data[I];
  774. end;
  775. function minvalue(const data : array of float) : float;
  776. begin
  777. Result:=minvalue(PFloat(@data[0]),High(Data)+1);
  778. end;
  779. function minvalue(const data : PFloat; Const N : Integer) : float;
  780. var
  781. i : longint;
  782. begin
  783. { get an initial value }
  784. minvalue:=data[0];
  785. for i:=1 to N-1 do
  786. if data[i]<minvalue then
  787. minvalue:=data[i];
  788. end;
  789. function MaxIntValue(const Data: array of Integer): Integer;
  790. var
  791. I: Integer;
  792. begin
  793. Result := Data[Low(Data)];
  794. For I := Succ(Low(Data)) To High(Data) Do
  795. If Data[I] > Result Then Result := Data[I];
  796. end;
  797. function maxvalue(const data : array of float) : float;
  798. begin
  799. Result:=maxvalue(PFloat(@data[0]),High(Data)+1);
  800. end;
  801. function maxvalue(const data : PFloat; Const N : Integer) : float;
  802. var
  803. i : longint;
  804. begin
  805. { get an initial value }
  806. maxvalue:=data[0];
  807. for i:=1 to N-1 do
  808. if data[i]>maxvalue then
  809. maxvalue:=data[i];
  810. end;
  811. function MaxValue(const Data: array of Integer): Integer;
  812. begin
  813. Result:=MaxValue(PInteger(@Data[0]),High(Data)+1)
  814. end;
  815. function maxvalue(const data : PInteger; Const N : Integer) : Integer;
  816. var
  817. i : longint;
  818. begin
  819. { get an initial value }
  820. maxvalue:=data[0];
  821. for i:=1 to N-1 do
  822. if data[i]>maxvalue then
  823. maxvalue:=data[i];
  824. end;
  825. function Min(a, b: Integer): Integer;
  826. begin
  827. if a < b then
  828. Result := a
  829. else
  830. Result := b;
  831. end;
  832. function Max(a, b: Integer): Integer;
  833. begin
  834. if a > b then
  835. Result := a
  836. else
  837. Result := b;
  838. end;
  839. function Min(a, b: Cardinal): Cardinal;
  840. begin
  841. if a < b then
  842. Result := a
  843. else
  844. Result := b;
  845. end;
  846. function Max(a, b: Cardinal): Cardinal;
  847. begin
  848. if a > b then
  849. Result := a
  850. else
  851. Result := b;
  852. end;
  853. function Min(a, b: Int64): Int64;
  854. begin
  855. if a < b then
  856. Result := a
  857. else
  858. Result := b;
  859. end;
  860. function Max(a, b: Int64): Int64;
  861. begin
  862. if a > b then
  863. Result := a
  864. else
  865. Result := b;
  866. end;
  867. {$ifdef FPC_HAS_TYPE_SINGLE}
  868. function Min(a, b: Single): Single;
  869. begin
  870. if a < b then
  871. Result := a
  872. else
  873. Result := b;
  874. end;
  875. function Max(a, b: Single): Single;
  876. begin
  877. if a > b then
  878. Result := a
  879. else
  880. Result := b;
  881. end;
  882. {$endif FPC_HAS_TYPE_SINGLE}
  883. {$ifdef FPC_HAS_TYPE_DOUBLE}
  884. function Min(a, b: Double): Double;
  885. begin
  886. if a < b then
  887. Result := a
  888. else
  889. Result := b;
  890. end;
  891. function Max(a, b: Double): Double;
  892. begin
  893. if a > b then
  894. Result := a
  895. else
  896. Result := b;
  897. end;
  898. {$endif FPC_HAS_TYPE_DOUBLE}
  899. {$ifdef FPC_HAS_TYPE_EXTENDED}
  900. function Min(a, b: Extended): Extended;
  901. begin
  902. if a < b then
  903. Result := a
  904. else
  905. Result := b;
  906. end;
  907. function Max(a, b: Extended): Extended;
  908. begin
  909. if a > b then
  910. Result := a
  911. else
  912. Result := b;
  913. end;
  914. {$endif FPC_HAS_TYPE_EXTENDED}
  915. function InRange(const AValue, AMin, AMax: Integer): Boolean;
  916. begin
  917. Result:=(AValue>=AMin) and (AValue<=AMax);
  918. end;
  919. function InRange(const AValue, AMin, AMax: Int64): Boolean;
  920. begin
  921. Result:=(AValue>=AMin) and (AValue<=AMax);
  922. end;
  923. {$ifdef FPC_HAS_TYPE_DOUBLE}
  924. function InRange(const AValue, AMin, AMax: Double): Boolean;
  925. begin
  926. Result:=(AValue>=AMin) and (AValue<=AMax);
  927. end;
  928. {$endif FPC_HAS_TYPE_DOUBLE}
  929. function EnsureRange(const AValue, AMin, AMax: Integer): Integer;
  930. begin
  931. Result:=AValue;
  932. If Result<AMin then
  933. Result:=AMin
  934. else if Result>AMax then
  935. Result:=AMax;
  936. end;
  937. function EnsureRange(const AValue, AMin, AMax: Int64): Int64;
  938. begin
  939. Result:=AValue;
  940. If Result<AMin then
  941. Result:=AMin
  942. else if Result>AMax then
  943. Result:=AMax;
  944. end;
  945. {$ifdef FPC_HAS_TYPE_DOUBLE}
  946. function EnsureRange(const AValue, AMin, AMax: Double): Double;
  947. begin
  948. Result:=AValue;
  949. If Result<AMin then
  950. Result:=AMin
  951. else if Result>AMax then
  952. Result:=AMax;
  953. end;
  954. {$endif FPC_HAS_TYPE_DOUBLE}
  955. Const
  956. EZeroResolution = 1E-16;
  957. DZeroResolution = 1E-12;
  958. SZeroResolution = 1E-4;
  959. function IsZero(const A: Single; Epsilon: Single): Boolean;
  960. begin
  961. if (Epsilon=0) then
  962. Epsilon:=SZeroResolution;
  963. Result:=Abs(A)<=Epsilon;
  964. end;
  965. function IsZero(const A: Single): Boolean;
  966. begin
  967. Result:=IsZero(A,single(SZeroResolution));
  968. end;
  969. {$ifdef FPC_HAS_TYPE_DOUBLE}
  970. function IsZero(const A: Double; Epsilon: Double): Boolean;
  971. begin
  972. if (Epsilon=0) then
  973. Epsilon:=DZeroResolution;
  974. Result:=Abs(A)<=Epsilon;
  975. end;
  976. function IsZero(const A: Double): Boolean;
  977. begin
  978. Result:=IsZero(A,DZeroResolution);
  979. end;
  980. {$endif FPC_HAS_TYPE_DOUBLE}
  981. {$ifdef FPC_HAS_TYPE_EXTENDED}
  982. function IsZero(const A: Extended; Epsilon: Extended): Boolean;
  983. begin
  984. if (Epsilon=0) then
  985. Epsilon:=EZeroResolution;
  986. Result:=Abs(A)<=Epsilon;
  987. end;
  988. function IsZero(const A: Extended): Boolean;
  989. begin
  990. Result:=IsZero(A,EZeroResolution);
  991. end;
  992. {$endif FPC_HAS_TYPE_EXTENDED}
  993. type
  994. TSplitDouble = packed record
  995. cards: Array[0..1] of cardinal;
  996. end;
  997. function IsNan(const d : Double): Boolean;
  998. var
  999. fraczero, expMaximal: boolean;
  1000. begin
  1001. {$if defined(FPC_BIG_ENDIAN) or (defined(CPUARM) and defined(FPUFPA))}
  1002. expMaximal := ((TSplitDouble(d).cards[0] shr 20) and $7ff) = 2047;
  1003. fraczero:= (TSplitDouble(d).cards[0] and $fffff = 0) and
  1004. (TSplitDouble(d).cards[1] = 0);
  1005. {$else FPC_BIG_ENDIAN}
  1006. expMaximal := ((TSplitDouble(d).cards[1] shr 20) and $7ff) = 2047;
  1007. fraczero := (TSplitDouble(d).cards[1] and $fffff = 0) and
  1008. (TSplitDouble(d).cards[0] = 0);
  1009. {$endif FPC_BIG_ENDIAN}
  1010. Result:=expMaximal and not(fraczero);
  1011. end;
  1012. function IsInfinite(const d : Double): Boolean;
  1013. var
  1014. fraczero, expMaximal: boolean;
  1015. begin
  1016. {$if defined(FPC_BIG_ENDIAN) or (defined(CPUARM) and defined(FPUFPA))}
  1017. expMaximal := ((TSplitDouble(d).cards[0] shr 20) and $7ff) = 2047;
  1018. fraczero:= (TSplitDouble(d).cards[0] and $fffff = 0) and
  1019. (TSplitDouble(d).cards[1] = 0);
  1020. {$else FPC_BIG_ENDIAN}
  1021. expMaximal := ((TSplitDouble(d).cards[1] shr 20) and $7ff) = 2047;
  1022. fraczero := (TSplitDouble(d).cards[1] and $fffff = 0) and
  1023. (TSplitDouble(d).cards[0] = 0);
  1024. {$endif FPC_BIG_ENDIAN}
  1025. Result:=expMaximal and fraczero;
  1026. end;
  1027. {$ifdef FPC_HAS_TYPE_EXTENDED}
  1028. function SameValue(const A, B: Extended; Epsilon: Extended): Boolean;
  1029. begin
  1030. if (Epsilon=0) then
  1031. Epsilon:=Max(Min(Abs(A),Abs(B))*EZeroResolution,EZeroResolution);
  1032. if (A>B) then
  1033. Result:=((A-B)<=Epsilon)
  1034. else
  1035. Result:=((B-A)<=Epsilon);
  1036. end;
  1037. function SameValue(const A, B: Extended): Boolean;
  1038. begin
  1039. Result:=SameValue(A,B,0);
  1040. end;
  1041. {$endif FPC_HAS_TYPE_EXTENDED}
  1042. {$ifdef FPC_HAS_TYPE_DOUBLE}
  1043. function SameValue(const A, B: Double): Boolean;
  1044. begin
  1045. Result:=SameValue(A,B,0);
  1046. end;
  1047. function SameValue(const A, B: Double; Epsilon: Double): Boolean;
  1048. begin
  1049. if (Epsilon=0) then
  1050. Epsilon:=Max(Min(Abs(A),Abs(B))*DZeroResolution,DZeroResolution);
  1051. if (A>B) then
  1052. Result:=((A-B)<=Epsilon)
  1053. else
  1054. Result:=((B-A)<=Epsilon);
  1055. end;
  1056. {$endif FPC_HAS_TYPE_DOUBLE}
  1057. function SameValue(const A, B: Single): Boolean;
  1058. begin
  1059. Result:=SameValue(A,B,0);
  1060. end;
  1061. function SameValue(const A, B: Single; Epsilon: Single): Boolean;
  1062. begin
  1063. if (Epsilon=0) then
  1064. Epsilon:=Max(Min(Abs(A),Abs(B))*SZeroResolution,SZeroResolution);
  1065. if (A>B) then
  1066. Result:=((A-B)<=Epsilon)
  1067. else
  1068. Result:=((B-A)<=Epsilon);
  1069. end;
  1070. // Some CPUs probably allow a faster way of doing this in a single operation...
  1071. // There weshould define CPUDIVMOD in the header mathuh.inc and implement it using asm.
  1072. {$ifndef CPUDIVMOD}
  1073. procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: Word);
  1074. begin
  1075. Result:=Dividend Div Divisor;
  1076. Remainder:=Dividend Mod Divisor;
  1077. end;
  1078. {$endif}
  1079. {$ifndef ver1_0} // default params
  1080. function ifthen(val:boolean;const iftrue:integer; const iffalse:integer= 0) :integer;
  1081. begin
  1082. if val then result:=iftrue else result:=iffalse;
  1083. end;
  1084. function ifthen(val:boolean;const iftrue:int64 ; const iffalse:int64 = 0) :int64;
  1085. begin
  1086. if val then result:=iftrue else result:=iffalse;
  1087. end;
  1088. function ifthen(val:boolean;const iftrue:double ; const iffalse:double =0.0):double;
  1089. begin
  1090. if val then result:=iftrue else result:=iffalse;
  1091. end;
  1092. {$endif}
  1093. end.
  1094. {
  1095. $Log$
  1096. Revision 1.30 2005-02-08 20:25:28 florian
  1097. - killed power from system unit
  1098. * move operator ** to math unit
  1099. Revision 1.29 2005/01/31 13:59:23 marco
  1100. * fixed
  1101. Revision 1.28 2005/01/12 20:17:39 florian
  1102. * generic arctan2 for 3rd and 4th quadrand fixed
  1103. Revision 1.27 2005/01/04 16:47:05 florian
  1104. * compilation on ARM fixed
  1105. Revision 1.26 2004/12/05 16:52:34 jonas
  1106. * also invalid argument if trying to calculate 0^0 with intpower()
  1107. Revision 1.25 2004/12/05 16:43:57 jonas
  1108. * fixed power() in genmath.inc (code duplication from math.pp for **
  1109. support!)
  1110. * fixed power() in math.pp to give an error from 0^0
  1111. Revision 1.24 2004/12/04 23:38:59 florian
  1112. * fixed power(float,float) for negative exponents
  1113. Revision 1.23 2004/07/25 16:46:08 michael
  1114. + Implemented DivMod
  1115. Revision 1.22 2004/05/29 12:28:59 florian
  1116. * fixed IsNan and IsInf for big endian systems
  1117. Revision 1.21 2004/04/08 16:37:08 peter
  1118. * disable range,overflow check when generating Nan/Inf
  1119. Revision 1.20 2004/02/20 20:10:44 florian
  1120. + added Inf/Nan stuff
  1121. Revision 1.19 2004/02/09 18:53:09 florian
  1122. * compilation on ppc fixed
  1123. Revision 1.18 2004/02/09 17:21:04 marco
  1124. * 1.0 compilation fixes
  1125. Revision 1.17 2004/02/09 09:11:46 michael
  1126. + Implemented SameValue
  1127. Revision 1.16 2004/02/09 08:55:45 michael
  1128. + Missing functions IsZero,InRange,EnsureRange implemented
  1129. Revision 1.15 2003/11/09 21:52:54 michael
  1130. + Added missing sign functions
  1131. Revision 1.14 2003/10/29 19:10:07 jonas
  1132. * fixed arctan2
  1133. Revision 1.13 2003/10/26 15:58:05 florian
  1134. * fixed arctan2 to handle x=0 correctly as well
  1135. Revision 1.12 2003/09/01 20:46:59 peter
  1136. * small fixes for sparc
  1137. Revision 1.11 2003/04/24 09:38:12 florian
  1138. * min/max must check the compiler capabilities
  1139. Revision 1.10 2003/04/24 09:21:59 florian
  1140. + moved cpu dependend code to mathuh.inc and mathu.inc
  1141. Revision 1.9 2003/01/03 20:34:02 peter
  1142. * i386 fpu controlword functions added
  1143. Revision 1.8 2002/09/07 21:06:12 carl
  1144. * cleanup of parameters
  1145. - remove assembler code
  1146. Revision 1.7 2002/09/07 16:01:22 peter
  1147. * old logs removed and tabs fixed
  1148. }