Recent

Poll

How units should be named in LMath

Keep uSomething for units and lmSomething for packages to maintain compatibility with DMath and make easier DMath -> LMath migration
2 (33.3%)
Name units lmSomething and packages lmpkgSomething to make names unique
2 (33.3%)
Rename units like in (2) and place related functions in one unit to reduce number of units
2 (33.3%)

Total Members Voted: 6

Voting closed: August 19, 2020, 12:15:58 pm

Author Topic: LMath new version (LMath and Components 0.5)  (Read 13026 times)

glorfin

  • Full Member
  • ***
  • Posts: 148
  • LMath supporter
LMath new version (LMath and Components 0.5)
« on: July 17, 2020, 11:26:07 pm »
New version of LMath library (further development of DMath from Jean Debord).
Here are most important changes.
  • Naming of packages and units made more systematic. Now names of all units begin from u (for example, uTypes), while names of all packages begin from lm (for example, lmMathUtil). Hence, you will probably change Requirements in your project inspector.
  • Units uVectorHelper, uVecUtils, uVecFunc and uVecPrn in lmMathUtil package define several handy functions for work with arrays.
  • Unit uMatrix in lmLineAlgebra defines several general operations over vectors and matrices.
  • COBYLA algorithm (Constrained Optimization by Linear Approximation, M. Powell) for tasks of constrained optimization included in lmOptimum package, unit uCobyla.
  • Procedure for constrained non-linear regression ConstrNLFit in the unit uConstrLNFit which uses COBYLA algorithm included in lmRegression package.
  • Procedure LinProgSolve in the unit uLinSimplex, package lmOptimum implements simplex method for solution of linear programming problems.
  • Unit uintPoints in lmGenMath package defines operators over TIntPoint, similar to uRealPoints.
  • Unit uUnitsFormat in lmMathUtils package allows now using of long prefixes (for example, "pico") along with short ("p") ones.
     
This document describes what is new in LMath compared to DMath:
https://sourceforge.net/projects/lmath-library/files/DOC/LMath05/New_in_LMath.pdf/download

The library may be downloaded from Sourceforge:
https://sourceforge.net/projects/lmath-library/files/LMath/lmath_and_components_0_5.zip/download

Note, that this is still beta-version. Bug reports and suggestion for the development will be greatly appreciated.


chenyuchih

  • Jr. Member
  • **
  • Posts: 81
Re: LMath new version (LMath and Components 0.5)
« Reply #1 on: July 18, 2020, 03:23:00 am »
Nice, and thanks for your development/maintenance.

I require math library often, especially in regression, matrix operation and digital signal analysis. About ten years ago I tried ALGLIB, another powerful math library, but the license made me give up and now they even don't provide pascal/delphi source anymore. I did write some functions for my need. Those functions just work correctly but lack of optimization badly, the speed performance is so-so. Maybe LMath is the lamp that could light up my way.

BTW, I am curious about the calculation of fourier transform. Is there any plan to implement the DFT, which doesn't constrain sample number to power of 2, with some high efficieny algorithms such as Cooley-Tukey?

Best Regards,
ChenYuChih

glorfin

  • Full Member
  • ***
  • Posts: 148
  • LMath supporter
Re: LMath new version (LMath and Components 0.5)
« Reply #2 on: July 18, 2020, 04:53:47 am »
Thank you for the interest! I hope, the library will be useful. Look at lmLineAlgebra, lmRegression and maybe lmSpecRegress.
Quote
Is there any plan to implement the DFT...
Well, not in the near future, though I'll mean your request. However, my main interest is electrophysiology, and I work usually in time domain. So, rather one-two new filters can be expected than Fourier transform.

But if somebody would like to implement them, I will gladly include them into the library.
And, speaking about future development, large part of the algorithms for the library was translated from Fortran. Different schema of matrix storage in Pascal (rows first) makes these algorithms fairy slow. One thing which probably should be done, is optimization of them for Pascal. Again, if anybody has interest.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: LMath new version (LMath and Components 0.5)
« Reply #3 on: July 19, 2020, 11:02:45 pm »
Thank you!

I am mostly interested in linear programming, curve fitting, polynomials, path finding and fft/ifft.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: LMath new version (LMath and Components 0.5)
« Reply #4 on: July 20, 2020, 07:45:10 pm »
Many thanks! I have been using dmath for many years, and have recently switched to lmath. I use linear equation solving, eigenvectors, curve fitting, function minimization, some statistics and fourier.

At this point I have written my own library of vector and matrix routines with operator overloading, but they are specific to my needs and may not be optimized. I am therefore very pleased to see that lmath is being developing as a general purpose, and well organized, math library. 

Would be possible to add one package that includes all of lmath? I have, for example, one program that uses 8 of the lmath packages, one that uses 9, and a third that uses 10, all of which I maintain on 3 platforms.

Thanks again.

“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)

glorfin

  • Full Member
  • ***
  • Posts: 148
  • LMath supporter
Re: LMath new version (LMath and Components 0.5)
« Reply #5 on: July 21, 2020, 07:37:54 pm »
Thank you!

As for optimization, it is not a strong side of DMath/LMath either. In fact, it is quite slow. In part because many algorithms were transtaled from Fortran and are optimized for "columns first" arrays, in part because clarity was preferred over optimization.

glorfin

  • Full Member
  • ***
  • Posts: 148
  • LMath supporter
Re: LMath new version (LMath and Components 0.5)
« Reply #6 on: August 14, 2020, 01:51:03 am »
Would be possible to add one package that includes all of lmath?

Added LMath-lpk to Trunk. Now it is possible to import LMath.lpk instead of every small package.

In addition, I committed there two missing units from llmMathUtils (thank to bug report from Avra) and corrected a minor error in  uGauss (lmSpecregress).

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: LMath new version (LMath and Components 0.5)
« Reply #7 on: August 14, 2020, 08:10:21 am »
Would be possible to add one package that includes all of lmath?

Added LMath-lpk to Trunk. Now it is possible to import LMath.lpk instead of every small package.

In addition, I committed there two missing units from llmMathUtils (thank to bug report from Avra) and corrected a minor error in  uGauss (lmSpecregress).
Very nice. Thank you! 
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

AlexTP

  • Hero Member
  • *****
  • Posts: 2384
    • UVviewsoft
Re: LMath new version (LMath and Components 0.5)
« Reply #8 on: August 14, 2020, 08:11:27 am »

glorfin

  • Full Member
  • ***
  • Posts: 148
  • LMath supporter
Re: LMath new version (LMath and Components 0.5)
« Reply #9 on: August 14, 2020, 09:24:12 am »
I added a wiki page!
https://wiki.freepascal.org/LMath
Oh, many thanks! I schould have done myself, but was too lazy.


avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: LMath new version (LMath and Components 0.5)
« Reply #10 on: August 14, 2020, 09:47:16 am »
I see that as in dmath, in lmath we also have simple 'u' prefix for many units. I do not think that is enough any more. I have IDE duplicate file conflicts with utypes and usimplex units because I also have these exact named units in code that I use. I will rename my units as a quick fix, but there is a problem if any of the units of all other Lazarus authors contain units with the same names. Since naming was pretty generic, probability for that is quite high. There is also a problem with dmath package having the same named units. Right now, if both lmath and dmath are installed in IDE, which utypes.pas will be used when you use one or the other package? To avoid such confusion, and to let old projects work with dmath without having to uninstall lmath, we will need to differentiate lmath units from dmath. I guess that dotted namespacing for all units could be a solution. Something simple as 'lm' in lm.types.pas, or even finer gradation if needed like lm.integrals.gausleg.pas, lm.integrals.trap.pas, lm.regression.fft.pas lm.regression.spline.pas.

https://www.freepascal.org/docs-html/ref/refse112.html

Just my 2 cents.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: LMath new version (LMath and Components 0.5)
« Reply #11 on: August 14, 2020, 10:06:31 am »
if both lmath and dmath are installed in IDE
Is "installation" needed at all? Do these packages contain designtime code? I don't think so. In the package options mark them as "runtime" so that they cannot be installed.

Also make sure that, if you work with Lazarus trunk, the option "Maximize compatibility of package file" in the package options is set -- otherwise the package is not readable by Laz 2.0.10 and older.

What is the difference between lmath.lpk and lmath_all.lpk?

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: LMath new version (LMath and Components 0.5)
« Reply #12 on: August 14, 2020, 10:25:00 am »
Is "installation" needed at all?

Actually, according to first note in Changes from DMath:
Quote
Naming of packages and units made more systematic. Now names of all units begin from u (for example, uTypes)
the unit names are changed from those in DMath.

Anyway, "utypes" and similar names are too probable to be used in some other package, Avra is probably not the only one who has it in his projects.

So, it would really be better to prefix unit names with "LMath".
« Last Edit: August 14, 2020, 10:27:18 am by Zoran »

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: LMath new version (LMath and Components 0.5)
« Reply #13 on: August 14, 2020, 10:35:08 am »
if both lmath and dmath are installed in IDE
Is "installation" needed at all?
I install no-design-time packages simply to let IDE know where to look for it's units. That is a nice Lazarus improvement over Delphi search path editor. The problem is when I install package A having unit abc in one dir, and then install package B having unit abc with the same name but different content. IDE will not like it, and probably report famous PPU problem. There is also a slim, but existing chance that my project will need both packages A and B, so which abc will be referred? That's why I advocate for unique unit names. At one moment I was even thinking of creating a tool that will scan all fpc, lazarus, and installed components directories and report duplicate names so component authors could be alerted, but did not catch time yet.

What is the difference between lmath.lpk and lmath_all.lpk?
I could not find lmath_all.lpk in trunk.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: LMath new version (LMath and Components 0.5)
« Reply #14 on: August 14, 2020, 10:41:18 am »
according to first note in Changes from DMath:
Quote
Naming of packages and units made more systematic. Now names of all units begin from u (for example, uTypes)
the unit names are changed from those in DMath.
I have just checked and usimplex, uround, unlfit, utypes and many, many other units are in both dmath and lmath. Actually, 118 units out of 122 files in OPM's dmath directory have 'u' prefix.
« Last Edit: August 14, 2020, 10:43:46 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018