Recent

Author Topic: How to use this library  (Read 2337 times)

rnfpc

  • Full Member
  • ***
  • Posts: 101
How to use this library
« on: June 23, 2019, 12:42:23 pm »
I want to use this very useful statistics library ( https://wiki.freepascal.org/DMath ) in my programs but I am not sure how to install it to use its functions.

I have downloaded the zip file and unzipped it. Following is the output of tree command showing all files and folders:

Code: Pascal  [Select][+][-]
  1. .
  2. ├── changes.txt
  3. ├── demo
  4. │   ├── bgi
  5. │   │   ├── curfit
  6. │   │   │   ├── mcsim.pas
  7. │   │   │   ├── reglin.pas
  8. │   │   │   ├── regmult.pas
  9. │   │   │   ├── regnlin.pas
  10. │   │   │   ├── regpoly.pas
  11. │   │   │   └── wreglin.pas
  12. │   │   ├── fmath
  13. │   │   │   ├── contour.pas
  14. │   │   │   └── plot.pas
  15. │   │   ├── fourier
  16. │   │   │   ├── filter.pas
  17. │   │   │   └── testfft.pas
  18. │   │   ├── nist
  19. │   │   │   ├── nist.dat
  20. │   │   │   └── nist.pas
  21. │   │   ├── regmodel
  22. │   │   │   ├── exlin.dat
  23. │   │   │   ├── frac.dat
  24. │   │   │   ├── gamma.dat
  25. │   │   │   ├── hill.dat
  26. │   │   │   ├── iexpo.dat
  27. │   │   │   ├── iv2.dat
  28. │   │   │   ├── logist.dat
  29. │   │   │   ├── michael.dat
  30. │   │   │   ├── michint.dat
  31. │   │   │   ├── oral1.dat
  32. │   │   │   ├── oral2.dat
  33. │   │   │   ├── regamma.pas
  34. │   │   │   ├── regexlin.pas
  35. │   │   │   ├── regexpo.pas
  36. │   │   │   ├── regfrac.pas
  37. │   │   │   ├── reghill.pas
  38. │   │   │   ├── regiexpo.pas
  39. │   │   │   ├── reglogi.pas
  40. │   │   │   ├── regmich.pas
  41. │   │   │   ├── regmint.pas
  42. │   │   │   └── regutils.pas
  43. │   │   └── stat
  44. │   │       └── histo.pas
  45. │   ├── console
  46. │   │   ├── complex
  47. │   │   │   └── testcomp.pas
  48. │   │   ├── curfit
  49. │   │   │   └── pcatest.pas
  50. │   │   ├── equation
  51. │   │   │   ├── numjac.inc
  52. │   │   │   ├── testbis.pas
  53. │   │   │   ├── testbrdn.pas
  54. │   │   │   ├── testnr1.pas
  55. │   │   │   ├── testnr.pas
  56. │   │   │   └── testsec.pas
  57. │   │   ├── fmath
  58. │   │   │   ├── eval1.pas
  59. │   │   │   ├── eval2.pas
  60. │   │   │   ├── specfunc.dat
  61. │   │   │   ├── specfunc.pas
  62. │   │   │   ├── speed.pas
  63. │   │   │   ├── testfunc.pas
  64. │   │   │   ├── testmach.pas
  65. │   │   │   ├── testw.pas
  66. │   │   │   └── texdemo.pas
  67. │   │   ├── fourier
  68. │   │   │   └── freq.pas
  69. │   │   ├── integral
  70. │   │   │   ├── conv.pas
  71. │   │   │   ├── convtrap.pas
  72. │   │   │   ├── gauss.pas
  73. │   │   │   ├── test_rkf.pas
  74. │   │   │   └── trap.pas
  75. │   │   ├── matrices
  76. │   │   │   ├── cholesk.pas
  77. │   │   │   ├── detinv.pas
  78. │   │   │   ├── eigensym.pas
  79. │   │   │   ├── eigenval.pas
  80. │   │   │   ├── eigenvec.pas
  81. │   │   │   ├── hilbert.pas
  82. │   │   │   ├── lineq1.pas
  83. │   │   │   ├── lineqm.pas
  84. │   │   │   ├── matrix1.dat
  85. │   │   │   ├── matrix2.dat
  86. │   │   │   ├── matrix3.dat
  87. │   │   │   ├── matrix4.dat
  88. │   │   │   ├── test_lu.pas
  89. │   │   │   ├── test_qr.pas
  90. │   │   │   └── test_svd.pas
  91. │   │   ├── optim
  92. │   │   │   ├── minline.pas
  93. │   │   │   ├── numgrad.inc
  94. │   │   │   ├── numhess.inc
  95. │   │   │   ├── testbfgs.pas
  96. │   │   │   ├── testmarq.pas
  97. │   │   │   ├── testnewt.pas
  98. │   │   │   └── testsimp.pas
  99. │   │   ├── polynom
  100. │   │   │   ├── evalfrac.pas
  101. │   │   │   ├── evalpoly.pas
  102. │   │   │   └── polyroot.pas
  103. │   │   ├── proba
  104. │   │   │   └── binom.pas
  105. │   │   ├── random
  106. │   │   │   ├── mt.txt
  107. │   │   │   ├── randfile.pas
  108. │   │   │   ├── ranmul.dat
  109. │   │   │   ├── ranmull.dat
  110. │   │   │   ├── ranmull.pas
  111. │   │   │   ├── ranmul.pas
  112. │   │   │   ├── test_ga.pas
  113. │   │   │   ├── testmcmc.dat
  114. │   │   │   ├── testmcmc.pas
  115. │   │   │   ├── testmt.pas
  116. │   │   │   ├── testmwc.pas
  117. │   │   │   ├── testnorm.pas
  118. │   │   │   ├── test_sa.pas
  119. │   │   │   ├── testuvag.pas
  120. │   │   │   └── uvag.txt
  121. │   │   └── stat
  122. │   │       ├── av1.pas
  123. │   │       ├── av2a.pas
  124. │   │       ├── av2.pas
  125. │   │       ├── khi2.pas
  126. │   │       ├── stat.pas
  127. │   │       └── student.pas
  128. │   └── gui
  129. │       ├── calc
  130. │       │   ├── calc.dpr
  131. │       │   ├── unit1.dfm
  132. │       │   └── unit1.pas
  133. │       ├── curfit
  134. │       │   ├── curfit.dpr
  135. │       │   ├── graph.gcf
  136. │       │   ├── main.dfm
  137. │       │   ├── main.pas
  138. │       │   ├── reglin.dat
  139. │       │   └── regpol.dat
  140. │       ├── dialogs
  141. │       │   ├── algorith.dfm
  142. │       │   ├── algorith.pas
  143. │       │   ├── aspect.dfm
  144. │       │   ├── aspect.pas
  145. │       │   ├── errfunc.dfm
  146. │       │   ├── errfunc.pas
  147. │       │   ├── format.dfm
  148. │       │   ├── format.pas
  149. │       │   ├── graphopt.dfm
  150. │       │   ├── graphopt.pas
  151. │       │   ├── help.dfm
  152. │       │   ├── help.pas
  153. │       │   ├── param.dfm
  154. │       │   ├── param.pas
  155. │       │   ├── regfunc.dfm
  156. │       │   ├── regfunc.pas
  157. │       │   ├── select.dfm
  158. │       │   └── select.pas
  159. │       ├── fplot
  160. │       │   ├── fplot.dpr
  161. │       │   ├── main.dfm
  162. │       │   └── main.pas
  163. │       ├── hsv_rgb
  164. │       │   ├── hsv_rgb.dpr
  165. │       │   ├── main.dfm
  166. │       │   └── main.pas
  167. │       ├── linsolve
  168. │       │   ├── linsolve.dpr
  169. │       │   ├── main.dfm
  170. │       │   └── main.pas
  171. │       ├── mandel
  172. │       │   ├── julia_2_a.par
  173. │       │   ├── julia_2_b.par
  174. │       │   ├── julia_5.par
  175. │       │   ├── main.dfm
  176. │       │   ├── main.pas
  177. │       │   ├── mandel_2.par
  178. │       │   ├── mandel_3_5.par
  179. │       │   ├── mandel_3_85_a.par
  180. │       │   ├── mandel_3_85.par
  181. │       │   ├── mandel_3.par
  182. │       │   ├── mandel_4.par
  183. │       │   ├── mandel.dpr
  184. │       │   ├── seahorse_01.par
  185. │       │   ├── seahorse_02a.par
  186. │       │   ├── seahorse_02b.par
  187. │       │   ├── seahorse_02.par
  188. │       │   ├── seahorse_03a.par
  189. │       │   ├── seahorse_03.par
  190. │       │   ├── seahorse_04.par
  191. │       │   ├── seahorse_05.par
  192. │       │   ├── seahorse_06.par
  193. │       │   ├── seahorse_07.par
  194. │       │   ├── seahorse_08.par
  195. │       │   ├── seahorse_09.par
  196. │       │   ├── seahorse_10.par
  197. │       │   ├── seahorse_11.par
  198. │       │   └── seahorse_12.par
  199. │       ├── polysolve
  200. │       │   ├── coef.dat
  201. │       │   ├── main.dfm
  202. │       │   ├── main.pas
  203. │       │   └── polysolve.dpr
  204. │       ├── probcalc
  205. │       │   ├── probcalc.dpr
  206. │       │   ├── unit1.dfm
  207. │       │   └── unit1.pas
  208. │       └── quadrit
  209. │           ├── bifur1.dfm
  210. │           ├── bifur1.pas
  211. │           ├── bifur.dpr
  212. │           ├── fft1.dfm
  213. │           ├── fft1.pas
  214. │           ├── fft.dpr
  215. │           ├── orbit1.dfm
  216. │           ├── orbit1.pas
  217. │           └── orbit.dpr
  218. ├── dll
  219. │   ├── dcompil.bat
  220. │   ├── dmath.dpr
  221. │   ├── dmath.pas
  222. │   ├── fpcompil.bat
  223. │   ├── fpcompil.sh
  224. │   ├── lcompil.bat
  225. │   └── lcompil.sh
  226. ├── dmat090_statistics_pas.zip
  227. ├── dmath.pdf
  228. ├── dmath_tree.txt
  229. ├── dmath.txt
  230. ├── lgpl.txt
  231. └── units
  232.     ├── filelist.txt
  233.     ├── types.inc
  234.     ├── uanova1.pas
  235.     ├── uanova2.pas
  236.     ├── ubalance.pas
  237.     ├── ubalbak.pas
  238.     ├── ubartlet.pas
  239.     ├── ubeta.pas
  240.     ├── ubfgs.pas
  241.     ├── ubinom.pas
  242.     ├── ubisect.pas
  243.     ├── ubroyden.pas
  244.     ├── ucholesk.pas
  245.     ├── ucomplex.pas
  246.     ├── ucompvec.pas
  247.     ├── ucorrel.pas
  248.     ├── udigamma.pas
  249.     ├── udistrib.pas
  250.     ├── ueigsym.pas
  251.     ├── ueigval.pas
  252.     ├── ueigvec.pas
  253.     ├── uelmhes.pas
  254.     ├── ueltran.pas
  255.     ├── uevalfit.pas
  256.     ├── ueval.pas
  257.     ├── uexlfit.pas
  258.     ├── uexpdist.pas
  259.     ├── uexpfit.pas
  260.     ├── ufact.pas
  261.     ├── ufft.pas
  262.     ├── ufracfit.pas
  263.     ├── ugamdist.pas
  264.     ├── ugamfit.pas
  265.     ├── ugamma.pas
  266.     ├── ugausjor.pas
  267.     ├── ugausleg.pas
  268.     ├── ugenalg.pas
  269.     ├── ugoldsrc.pas
  270.     ├── uhillfit.pas
  271.     ├── uhqr2.pas
  272.     ├── uhqr.pas
  273.     ├── uhsvrgb.pas
  274.     ├── uhyper.pas
  275.     ├── uibeta.pas
  276.     ├── uibtdist.pas
  277.     ├── uiexpfit.pas
  278.     ├── uigamma.pas
  279.     ├── uigmdist.pas
  280.     ├── uinterv.pas
  281.     ├── uinvbeta.pas
  282.     ├── uinvgam.pas
  283.     ├── uinvnorm.pas
  284.     ├── ujacobi.pas
  285.     ├── ukhi2.pas
  286.     ├── ulambert.pas
  287.     ├── ulineq.pas
  288.     ├── ulinfit.pas
  289.     ├── ulinmin.pas
  290.     ├── ulinminq.pas
  291.     ├── ulogifit.pas
  292.     ├── ulu.pas
  293.     ├── umarq.pas
  294.     ├── umath.pas
  295.     ├── umcmc.pas
  296.     ├── umeansd.pas
  297.     ├── umedian.pas
  298.     ├── umichfit.pas
  299.     ├── uminbrak.pas
  300.     ├── uminmax.pas
  301.     ├── umintfit.pas
  302.     ├── umodels.pas
  303.     ├── umulfit.pas
  304.     ├── unewteq.pas
  305.     ├── unewteqs.pas
  306.     ├── unewton.pas
  307.     ├── unlfit.pas
  308.     ├── unonpar.pas
  309.     ├── unormal.pas
  310.     ├── upca.pas
  311.     ├── upkfit.pas
  312.     ├── uplot.pas
  313.     ├── upoidist.pas
  314.     ├── upolev.pas
  315.     ├── upolfit.pas
  316.     ├── upolutil.pas
  317.     ├── upolynom.pas
  318.     ├── upowfit.pas
  319.     ├── uqr.pas
  320.     ├── uqsort.pas
  321.     ├── urandom.pas
  322.     ├── urangaus.pas
  323.     ├── uranmt.pas
  324.     ├── uranmult.pas
  325.     ├── uranmwc.pas
  326.     ├── uranuvag.pas
  327.     ├── uregtest.pas
  328.     ├── urkf.pas
  329.     ├── urootpol.pas
  330.     ├── uround.pas
  331.     ├── urtpol1.pas
  332.     ├── urtpol2.pas
  333.     ├── urtpol3.pas
  334.     ├── urtpol4.pas
  335.     ├── usecant.pas
  336.     ├── usimann.pas
  337.     ├── usimplex.pas
  338.     ├── uskew.pas
  339.     ├── usnedeco.pas
  340.     ├── ustdpair.pas
  341.     ├── ustrings.pas
  342.     ├── ustudind.pas
  343.     ├── usvdfit.pas
  344.     ├── usvd.pas
  345.     ├── utexplot.pas
  346.     ├── utrapint.pas
  347.     ├── utrigo.pas
  348.     ├── utypes.pas
  349.     ├── uwinplot.pas
  350.     ├── uwinstr.pas
  351.     └── uwoolf.pas
  352.  
  353. 34 directories, 316 files
  354.  


There is a units folder which has all unit .pas files. How do I get this folder in path of my own source files?

There is also a dll folder which has fpcompil.sh and lcompil.sh files for compilation for fp/linux and lazarus/linux, respectively. (I am working on Debian Stable Linux). I think if I run fpcompil.sh, all the units will be installed and be available for fpc command.

I think I will have to put `uses urandom` etc in my source files.  I will appreciate if someone can clarify these issues.
« Last Edit: June 23, 2019, 12:45:34 pm by rnfpc »

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: How to use this library
« Reply #1 on: June 23, 2019, 02:27:51 pm »
I am not sure I understand you well.
Is it that you don't know how to add some path to your project, so that your units can add these units to uses list?

If so, read here: https://wiki.lazarus.freepascal.org/IDE_Window:__Compiler_Options#Paths

rnfpc

  • Full Member
  • ***
  • Posts: 101
Re: How to use this library
« Reply #2 on: June 23, 2019, 02:48:06 pm »
Thanks for the link. I see that it is much easier to add this package through Lazarus though I was thinking of how to use it with fpc on command line. I see that I can get information through command fpc -help.

I am a beginner in Pascal though I have some idea about programming in Python. In Python and I think in many other languages there is a package manager that installs third party packages. Apparently, that is not available here at present. I am not sure if I can use online package manager for this package:  https://wiki.lazarus.freepascal.org/Online_Package_Manager

Also, I am not clear if I should run script files fpcompil.sh and lcompil.sh.  I will appreciate your guidance on that.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: How to use this library
« Reply #3 on: July 21, 2019, 08:23:45 pm »
I use DMath regularly. All I do is add the library path in my project search path, and the file name in my uses clause. This works fine on Mac, Win, and Lin.

Note that DMath has now been extended as LMath by Viatcheslav Nesterov (glorfin):

https://sourceforge.net/projects/lmath-library/

Perhaps someone can update the wiki to show this.

Lazarus has extensive support for packages, you can select and install a package from Lazarus (Package > Open Package File). Package files are included with LMath (not DMath). I do not use the scripts you mention.
« Last Edit: July 21, 2019, 09:03:31 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

rnfpc

  • Full Member
  • ***
  • Posts: 101
Re: How to use this library
« Reply #4 on: July 22, 2019, 04:37:22 am »
Thanks for this very useful information. I hope the wiki gets updated soon. I am trying LMath and will revert with feedback.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: How to use this library
« Reply #5 on: July 22, 2019, 10:53:35 am »
I still use the regression from TPMath, because dmath was buggy (threw unexpected exceptions a lot).

For FFT, I use Nils Haeck's unit.

glorfin

  • Full Member
  • ***
  • Posts: 148
  • LMath supporter
Re: How to use this library
« Reply #6 on: July 22, 2019, 04:40:14 pm »
I want to use this very useful statistics library ( https://wiki.freepascal.org/DMath ) in my programs but I am not sure how to install it to use its functions.

You may look at LMath: https://sourceforge.net/projects/lmath-library/

where units from DMath are organized as a set of Lazarus packages, plus few new procedures and units are added.

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: How to use this library
« Reply #7 on: July 22, 2019, 05:36:00 pm »
I looked at LMath, too. Yes it is well-organized in the Lazarus way. Unlike Delphi it is not necessary to add units manually to the search path. Use the Lazarus package system instead.

Follow these steps:
  • Download the "Snapshot" from https://sourceforge.net/p/lmath-library/code/HEAD/tree/LMath/Trunk/ and unzip to a specific directory, or use svn to get the files.
  • In Lazarus, go to "Package" > "Open Package File (*.lpk...)". Navigate to the folder with the LMath files.
  • Open UGenMath/ugenmath.lpk. Click "Compile". This makes the general math units known to the IDE.
  • Repeat with ULineAlgebra/ulinealgegra.lpk.
  • If you want to do statistics open UMathStat/umathstat.lpk. Click "Compile" again. If you want to do non-linear equations, open UNonLinEq/unonlineq.lpk and compile, etc. Repeat with other packages that you might need. The names are pretty much self-descriptive.
  • In your project, open the project options and click "Add" > "New requirement". Select UMathStat from the list, OK. Now the IDE knows where to find the statistics units (as well as the ugenmath and ulinealgebra units which are implicitely needed by umathstat). No need to modify search paths yourself - in fact, this could cause a lot of trouble.

 

TinyPortal © 2005-2018