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 13111 times)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: LMath new version (LMath and Components 0.5)
« Reply #45 on: August 17, 2020, 01:26:51 am »
You must be aware that every unit cannot exist in multiple packages. glorfin provided a "summary" package lmath.lpk which requires all the other packages. Therefor you only must add lmath.lpk to the requirements of your projects to have access to all LMath units.

Yes, I did discover that while practicing my package skills.

That is great, it may have been due to a request I made. However, I do not see "lmath.lpk" in "lmath_and_components_0_5". What am I missing?

EDIT: Never mind, I found it in r100. Thanks glorfin!
« Last Edit: August 17, 2020, 01:35:04 am 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)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: LMath new version (LMath and Components 0.5)
« Reply #46 on: August 20, 2020, 04:56:31 pm »
glorfin,

Here is the decreasing exponential fit function I messaged you about. It is a very minor modification of uiexpfit. I needed it to fit some natural time series that show exponential decay.

Feel free to use it in lmath, or not, as you see fit.

Regards,
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)

glorfin

  • Full Member
  • ***
  • Posts: 148
  • LMath supporter
Re: LMath new version (LMath and Components 0.5)
« Reply #47 on: August 20, 2020, 10:03:11 pm »
Thank you!
I will look at udecexpfit in the nearest future.

Meanwhile, as a result of discussion above, I think I will change unit names to lmath.usomeunit. Reasons are that ames like uTypes or, to that end, uComplex are indeed very general and potentially leading to conflicts.

If one uses LMath only, installation is not needed, but LMComponents are design time packages and must be installed. Consequently, they require installation of many LMath units, which may aggravate potential conflicts.
From the other hand, mechanism of name spaces allows to minimize compatibility issues.

Kwadrum

  • New Member
  • *
  • Posts: 17
Re: LMath new version (LMath and Components 0.5)
« Reply #48 on: August 25, 2020, 05:26:56 pm »
Hi,
May I ask about the choice of TVector type used in some (or maybe many) functions of LMath? What are the advantages compared to other more "traditional" arrays/lists/etc? I made some reading on TVector and the only obvious difference seems to be that it can automatically increase its size (which probably makes it quite slow).
I am not trying to challenge this choice, just really unfamiliar with this type and no, I am not a Pascal expert.
Thank you!

glorfin

  • Full Member
  • ***
  • Posts: 148
  • LMath supporter
Re: LMath new version (LMath and Components 0.5)
« Reply #49 on: August 25, 2020, 07:15:52 pm »
May I ask about the choice of TVector type used in some (or maybe many) functions of LMath?
Hi!
TVector is simply dynamic array of Float, and Float by default is double, but depending on compilation key may be single or extended.
In types.pas:
Code: Pascal  [Select][+][-]
  1. type
  2.   {$IFDEF SINGLEREAL}
  3.   Float = Single;
  4. {$ELSE}
  5. {$IFDEF EXTENDEDREAL}
  6.   Float = Extended;
  7. {$ELSE}
  8.   {$DEFINE DOUBLEREAL}
  9.   Float = Double;
  10. {$ENDIF}
  11. {$ENDIF}
  12. ........
  13.   TVector = array of Float;
  14.  
Technically it is a pointer to an array allocated in a heap.
In most cases it must be as efficient, as a usual array.

Kwadrum

  • New Member
  • *
  • Posts: 17
Re: LMath new version (LMath and Components 0.5)
« Reply #50 on: August 25, 2020, 09:57:36 pm »
Thanks for reply!
Does it mean that the same array may be addressed as an array of single or double during run time (depending on the conditions)? If yes, wouldn't conversion between single/double be too time-consuming?

glorfin

  • Full Member
  • ***
  • Posts: 148
  • LMath supporter
Re: LMath new version (LMath and Components 0.5)
« Reply #51 on: August 26, 2020, 01:07:22 pm »
Does it mean that the same array may be addressed as an array of single or double during run time (depending on the conditions)?
No! What is Float is defined when you compile unit uTypes. Look at the code which I have provided: {$IFDEF ...} is a switch for conditional compilation.

So, if you open package lmGenMath, select Options, Custom Options, and write there -dSINGLEREAL, type Float will be equivalent to Single; all TVector will be array of Single.
-dDOUBLEREAL makes Float = double; all TVector are arrays of Double too. This is default option.
-dEXTENDEDREAL makes Float = EXTENDED. (However, see discussions about Extended in Windows 64 bits somewhere in this forum).

So, all these switches are compilation time, not runtime, switches.
« Last Edit: August 26, 2020, 06:19:51 pm by glorfin »

jcbritobr

  • New Member
  • *
  • Posts: 13
Re: LMath new version (LMath and Components 0.5)
« Reply #52 on: September 09, 2020, 01:28:00 am »
Nice library. Always use it for machine learning and linear regression stuffs.

 

TinyPortal © 2005-2018