Question about "?unitsToFundamentalFormCache".

4 views
Skip to first unread message

Ted Kosan

unread,
Jan 28, 2019, 2:50:27 AM1/28/19
to mathpi...@googlegroups.com
Kory,

I noticed that the following code that initializes "?unitsToFundamentalFormCache" is what takes the most time when "src/library_apps/mathpiper4/src/org/mathpiper/scripts4/ proposed/miscellaneous/mpunits_private.mpws" is loaded:

"
ForEach(unit, ?recognizedUnits)
{
    ?unitsToFundamentalFormCache[unit] := UnitsToFundamentalForm(unit);
}
"

Do you see any serious problems that would be caused by just having "?unitsToFundamentalFormCache" be lazily initialized as needed when UnitsToFundamentalForm is called?

Ted

Kory Byrne

unread,
Jan 28, 2019, 12:08:37 PM1/28/19
to mathpiper-dev

I don't believe there would be a problem with lazy initialization. However I think my thought process behind writing the code was I wanted to initialize ?unitsToFundamentalFormCache at compile time, and the code in the repo simulated that.

If there is no easy automatic way to set that up, perhaps assigning ?unitsToFundamentalFormCache with an initial value is a better solution than computing the units dynamically?


As a side note I noticed that the protected variables appear in the Global State plugin in the IDE, is there a way to prevent this so that they cannot be unassigned?

Kory

Ted Kosan

unread,
Jan 28, 2019, 1:03:41 PM1/28/19
to mathpi...@googlegroups.com
Kory,

I have been thinking about a way to initialize ?unitsToFundamentalFormCache in the Java code. However, I have been experimenting with using the lazy initialization method, and it appears to be adequate for now. I will continue to think about faster ways to initialize this variable.

As for the protected variables in the units code being unassigned by the Global State plugin, the ultimate fix may be to make these variables LocalSymbols "instance" variables like what is done with "numericMode" in:

org/mathpiper/scripts4/a_initialization/standard/numeric.mpws

Ted

--
You received this message because you are subscribed to the Google Groups "mathpiper-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathpiper-de...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages