Showing posts with label MetaCommunity. Show all posts
Showing posts with label MetaCommunity. Show all posts

Wednesday, December 17, 2014

State of the MetaCommunity McCLIM fork - Apps "OK," fonts "Up in the air"

In my own small efforts in software programming, this year, I've made a fork of McCLIM -- a short overview provided in a previous 'blog entry, here at my DSP42 web log. It's been to nothing too sensational, as yet. I've made simply a few maintenance updates, and have added a dependency onto the mci-cltl-utils software system -- that much, as for applying a DEFCONSTANT* macro within McCLIM. 

Certainly, there are still some more maintenance updates to develop onto the fork, before getting along to any new developments onto McCLIM. In that regards, the last issue that I'd observed of it was that the font selector example is failing. It would appear to be due to something in regards to the interface onto the fonts table in CLX. Perhaps, that may easily resolved, insofar as the the present state of the source tree.  I think it serves to call some broader concerns to mind, however, insofar as developing an application architecture for Common Lisp desktop application development, within a contemporary computing environment.

Broadly, I've been using the Sharplispers CLX fork of Texas Instruments' original CLX codebase, and the CLX backend for McCLIM. I've tested a number of the applications provided in McCLIM, using the CLX backend. Specifically: The McCLIM listener, inspector, and debugger can be verified as running successfully, with that edition of CLX and on SBCL 
1.2.5.76-65a44db. Furthermore, the Scigraph application has been updated to run by-in-large successfully, on that same platform, although again there are some maintenance issues with it.

I've also tested Climacs, on that platform. It runs successfully, too.

I'd tried applying the GTK Cairo backend for McCLIM, but without a lot of success in that port, presently. With some regrets, that may serve to make it more difficult to apply McCLIM onto mobile platforms. I had hoped that the GTK Cairo backend might've made a good component to apply for McCLIM on an Android platform, and well it still may. Presently, if it does not successfully run on so much as a contemporary Ubuntu Linux platform, then there's not much to show for it, at present.

One superficially minor change now developed in McCLIM: In regards to CLIM's multiple-value-setf behaviors, it should now be  portable onto ECL and CCL (ARM architecture), as well as SBCL (amd64) insofar as free/open source Common Lisp implementations. 

With regards to fonts: When adding a set of ASDF system definitions to the fork that I've made of the original Garnet source tree, I'd observed that Garnet is now extended with Truetype font support, such that utilizes CL-Vectors and extensionally, ZPB-TTF for providing a support for TrueType fonts onto CLX . The clx-truetype system may be applied not exclusively onto Garnet, though it is integrated with Garnet as in the gem-font-methods file in the same source tree.  One might hope that it would be fairly trivial, to apply clx-truetype likewise onto the CLX port in McCLIM. Insofar as with regards to fonts and typesetting in CLIM itself, there -- I think -- is one of the broader concerns of the matter. To a few superficially simple questions:

  • How may it be possible to provide functions for denoting superscript or subscript typesetting, in CLIM?
    • If not, then how may such functions be defined effectively onto McCLIM?
    • To what practical ends may such developments be focused?
  • May it be possible to implement the entire Cascading Stylesheets visual formatting model onto CLIM? Specifically, of CSS 2.2?
    • Note: `vertical-align` and related properties in the CSS model for inline blocks
  • Extensionally: How may it be possible to implement an entire MathML interface onto McCLIM?
Such questions might seem trivial, at the outset.

If the CSS 2.2 visual formatting model may be implemented onto McCLIM, perhaps it may be implemented as to extend of MetaObject Protocol. Hypothetically, any one or more metaclasses may be defined as to allow for a modular  implementation of the CSS 2.2 visual formatting model, such that the implementation may also be portable onto XSL Formatting Objects (spec version 1.1). Sure, it would be nothing too conceptually original, to develop an application protocol that may extend of both and that may be integrated with McCLIM, furthermore -- even insofar as for representation of text according to textual formatting specifiers. Historically, there's also DSSSL

XSL-FO and DSSSL may be particularly suited to a page-oriented media, if not specifically a page-oriented model for graphical user interface design. Insofar as page-oriented media in CLIM, of course there's also the McCLIM PostScript backend

Orthogonally, an implementation of SVG onto McCLIM may seem pragmatically "Out of the question," at this time. Though it would serve to keep pace with contemporary widget toolkits defined in C and C++ -- such as Qt, GTK, and Cairo, all of which provide support for rendering of graphics developed in a medium of SVG -- however, it may represent another distinctly non-trivial design issue to approach in any single fork onto McCLIM.

Of course, the design proposed of the Dobelle-App system -- as specifically with regards to development of mobile  applications in Common Lisp -- it would require that McCLIM or any other single graphical user interface toolkit would be suitably applicable in Common Lisp on a mobile platform, as well as on a desktop platform -- furthermore, beyond simple "Proof of concept" implementation. If a framework may be developed and applied for CLIM applications on desktop and mobile platforms -- not only for backing of a thesis article, but furthermore as a framework for commercial application development -- it would well need to be provably applicable in a commercial domain, in every feature of such a framework.

Still, such a matter may seem trivial, at the outset -- and well, there are so many novel things to take to attention, otherwise?

Wednesday, December 10, 2014

Introducing the Mercantile Store of the MetaCommunity Project

I've developed a small aStore storefront at Amazon.com Associates -- the  Mercantile Store of the MetaCommunity Project (presently in its edition 1) -- including a small list of accessories I personally would trust for application in outdoor environments, such as for conservationism or the simple recreations of camping out, if not furthermore for day hikes and so-on.

Of course, with regards to camping stoves, it should be noted: That the same regulations would apply as with regards to campfires. In the US forests, one may consult the nearest, official US Forest Service Ranger Station for more information. Typically, the permits are available for free, and would be accompanied with a wealth of useful information for campfire safety. There are also some digital resources about campfire safety, such as published by the US Forest Service, in California's Sequoia National Forest.

Proceeds from the Mercantile Store will be applied for continued development and maintenance of web resources of MetaCommunity.info There is not, as yet, a 501(C)(3) or other non-profit registration for the development of MetaCommunity.info. Candidly, it may be difficult to register it as a non-profit organization, under any exact specifications in US tax code, though it is essentially a not for profit organization. Pending any further, formal development of the MetaCommunity.info organizational architecture, the author personally will see to it that any proceeds from the aStore will be applied for continued development and maintenance of web resources of MetaCommunity.info.

MetaCommunity.info is a web resource still under development. My own initial idea for the development of MetaCommunity.info was that it may serve as a sort of meta-resource for knowledge sharing, as with regards to concerns of life and lifestyle -- none too aligned to any single social networking platform, however, thus existing as a sort of "Meta-Community." Unfortunately, the development of the web resource has been stalled, pending further resolutions in certain nationalist and quasi-national concerns in the world. Furthermore, the initial design concept has undergone some moderate evolution, in this year.

In the outlook, presently, MetaCommunity.info would be -- in one part -- a projects hub for selected projects about math and engineering, and furthermore a hub for projects developed as towards some humanitarian concerns, and conservationism, and tourism. I've begun to develop a design for a single portal under each such concern. However, I am presently unable to develop any single schedule for such projects. The ink is just dry, on the outline itself, and -- myself -- it seems that I must certainly search for another place of residence, before I may be able to begin to focus about anything so technical and involving.

So, but that's what there is so far, for it --  a web store and a resource for campfire safety.

Please, Tread lightly.

Notes - MetaCommunity.info fork of McCLIM

Towards developing an application framework for supporting a platform-agnostic approach to development of graphical desktop applications in Common Lisp, I've made a fork of the McCLIM codebase, organizing the codebase under the MetaCommunity projects group at Github. Corresponding with so much as the maintenance updates in the fork, I've also begun to keep an issue tracker with YouTrack, under the hosted YouTrack InCloud service, At this time, I would not request contributions about of those endeavors. This is simply a note that I would like to share, regarding such existing work.

Insofar as keeping track of the aims and goals of the development of the MetaCommunity.info (MCi) fork of McCLIM, whereas the project comprised of the fork does not yet "Fit" into any specific heading within the two main MetaCommunity.info projects groups -- respectively, the Clyde projects, named after the Firth of Clyde, directed  mostly towards applications in mathematics and electrical engineering, and the Fourier projects, named after Charles Fourier, those to be focused mostly about literacy, tourism, and ethical conservationism, so far time and focus permit -- so, instead of documenting this small effort, presently, at the MetaCommunity.info work journal,  instead I thought it would be appropriate to publish this outline, here at DSP42.

So, with that much of adieu, my notes about the MCi McCLIM fork.

The main points of focus in the development of the MCi McCLIM fork are as follows:
  • Maintenance updates
  • Documentation
  • Usage cases
    • Scigraph
    • Extensions: ??? 
      • Usage cases on the BeaglBone Black platform (ARM) in applications of BBB TFT LCDs
        • Application: Multi-headed display for desktop measurement/analysis system
        • Application: Small electrical systems monitor (Solar electrical system)
        • Additional notes:
          • Deterministic timing in RTOS systems
            • Memory locking
            • Process scheduling
            • Garbage collection in the Common Lisp implementation
            • Kernel architectures (onto Linux kernel space)
            • See also: Realtime applications of Java / Realtime JVM implementations
      • Extensions in development of another mathematics platform in Common Lisp
        • Polar coordinate graphing *
        • Graphing for objects on Euclidean and Complex planes *
        • Measurement Units (See also: Igneous-Math)
        • Phasor diagrams *
          • EE Applications (AC systems; signals synthesis; signals analysis)
          • Applications in classical mechanics
        • Linear algebra *
          • Trivial concept: Presentation type for a matrix view of Common Lisp arrays
          • Less than trivial concept: Differential analysis, with corresponding presentation types
      • Extensions for systems modeling and interactive model design, in Common Lisp
        • URIs
        • XSD
        • XMI
        • UML Primitive types)
        • MOF
        • UML metamodel
        • SysML metamodel
        • ODM metamodels (RDF, OWL, Common Logic)
      • Extensions for a CORBA-centric desktop application framework
        • ORB monitor
        • IDL designer (IDE)
        • ??? (TBD)
* See also; Scigraph application, as published in McCLIM (referencing the MCi fork)

Certainly, the development of the fork is focused mostly towards usage cases. Beyond the maintenance updates, there may not be much to add to the McCLIM codebase itself.

Perhaps there may be an opportunity for adding some developer documentation to the codebase, over subsequent changesets in the codebase -- pending development of a suitably comfortable documentation system, perhaps extending of DocBook XML

This, then, would represent the first significant "Note to public" regarding the McCLIM fork developed under MetaCommunity.info.

Thus far, the fork is representative of the source tree cloned from Timothy Moore's original McCLIM source tree, with some changes merged in from Andreas Fuchs' fork, as was developed onto the original McCLIM CVS repository. I've also made a small number of maintenance updates to the source tree, including a short effort for a portable multiple-value setq (needs testing), and a defconstant* form to avoid errors on repeated redefinition of constant values.

Subsequently, the fork may also merge the changes developed under Robert Strandh's McCLIM fork. I'll make a note of that in my own Diigo bookmarks, and here.

This effort is, at the outset, mostly an academic matter. I cannot imagine any immediate commercial applicability about such work. Perhaps it might seem, then, as though it could represent something of a quixotic kind of "lark", in the conformity-oriented social network of "the modern." Regardless, there is the source tree as updated, to-date.

Thursday, November 20, 2014

An Introduction to the MetaCommunity.info fork of McCLIM (Overview - Initial Outline)

Ed. Note: This article represents a preliminary outline for an overview about the MetCommunity.info fork of McCLIM, focusing primarily on the YouTrack InCloud instance presently applied for management of the same fork project.

Pending subsequent revisions of this article,  this initial revision of the article may serve to provide, at least: Some web references onto task lists as created for and of the same project; an overview about YouTrack, in basic outline format; an overview towards the structure of a meta-IDE project developed under the MetaCommunity.info domain.

Items denoted wit {Bracketed Text} will be subject to revision, in subsequent versions of this article.

Overview

{i.e. topical introduction}

{GUI Domain in Common Lisp Application Development}

{McCLIM development}

{MetaCommunity.info (MCi)} {work journal}

{MetaCommunity.info fork of McCLIM}

{Sidebars: Traditional CLtL HCI APIs including: McCLIM; Garnet; Cells GTK; Graphic Forms}

{Sidebar: McCLIM' gtkairo backend; FirefoxOS}

{Projects Management Domain in Common Lisp Application Development}

{Concepts for which there are some exacting, conventional "web service bundles"}
  • Repository management (Github; GitLab; ...)
  • Continuous Integration (TeamCity; Travis CI; Jenkins; ...)
  • Issue Tracking (Gnus; RT; Bugzilla; YouTrack; ...)
{Concepts for which there are assorted tools - applied at project managers' own discretion}
  • Documentation development {authoring, editing, publishing, maintenance}
  • Release management {develop=>test=>release=>maintain}
  • Distribution management {binary distributions - archives/packages/installers by platform and version; source distribution available via repository management service}
  • Web presence management {social networking; documentation; resource distribution}
    • {For web hosting, alternatives include}
      • Static-Content Web Site
      • Hybrid Static/Dynamic Content Site
        • PHP
        • Python
        • JSP
        • ...
      • Web Site Published via Java Archive (formats; JAR, WAR, EAR, ... varying by container)
        • Variation of hybrid static/dynamic content site 
        • {JSR-... - Java servlets}
      • Web Portal
        • {In Java} A variation of Web Site Published via Java Archive
          • {JSR-..., formal portal request/response cycle}
          • Alternatives
            • JetSpeed {static portal}
            • ...
            • Liferay
        • {In Other: In programming languages other than Java, portal implementations include Drupal (Python), ...}

 Ed. note: In a sense, "Issue tracking" presents a "Meta-concern," applicable at all phases of a project's formal duration.


{YouTrack} {Stand-alone} {InCloud}

{YouTrack InCloud} {Documentation} {Qiuck Start} {Presently, InCloud is backed by YouTrack 5 [xref]}

{YouTrack License Model}. {10 user limit for 'Free' editions, in stand-alone or InCloud installation}

{MCi instance at YouTrack InCloud (Guest login enabled)}

{An Outline Onto Concepts Implemented in YouTrack}

{Project information structure at YouTrack}
  • Projects
  • Items
    • Swimlanes
    • Issues
    • Tasks
{Conceptual View}
  • Colloquially, Agile Project Management Concepts
    • Scrum
      • Sprints
      • ...
    • ...
  • Project Life Cycle
    • ...
  • ...

{YouTrack Web Interface}

Items of note in MCi McCLIM YouTrack InCloud service:

Article Metadata

Revision History

  • 1.0 (20 Nov 2014) - Basic Outline
  • 1.1 (20 Nov 2014) - Web and Metadata
    • Add details onto web presence management , focusing on web hosting models
    • Add Article Metadata Section
    • Add initial tags to article: MetaCommunity, McCLIM, CLIM, ANSI CL, CLtL2, YouTrack

Monday, October 27, 2014

A Synopsis, at Length, Onto the Decimal Rationalization and Floating-Point Type Coercion Features of the Igneous-Math System

Storage of a Rational Pi 

Last week, after having discovered a rather simple methodology for translating a floating-point computational representation of the irrational number, pi, into a rational number with a decimal exponent, within a fixed-precision floating point implementation, in a software system -- which I denoted, a rational pi, in a previous article, here at my DSP42 web log -- I was all the more cheered, when I discovered that there is also a methodology available for translating pi or any other floating point number, into a rational value, within a machine's respective data space, namely as represented with the ANSI Common Lisp rational and rationalize functions. On having discovered that simple feature of the ANSI Common Lisp standard, I was quite cheered to observe:
(rationalize pi)
=> 245850922/78256779
...as within the Common Lisp implementation in which I had performed that calculation, namely Steel Bank Common Lisp (SBCL)  version 1.2.1 (x86-64) on Microsoft Windows. An equivalent value is produced, with that form, in SBCL 1.2.4 (x86-64) on Linux.

Though the behaviors of the rational and rationalize functions are defined, broadly, in ANSI Common Lisp, but -- of course -- such translation of floating point values into ratio values would be nothing so directly and explicitly standardized as of IEEE floating-point arithmetic. Indirectly, however, given a value of pi calculated to the greatest possible precision of floating point values within a single Common Lisp implementation, one would assume that between two separate  Common Lisp implementations, as such -- both implementing the IEEE standards for floating-point arithmetic -- that the form, (rationalize pi), would return an equivalent rational value, in each respective Common Lisp implementation.

Incidentally, for those of us not having a membership in the IEEE, the article -- i.e [Goldberg1991] -- What Every Computer Scientist Should Know About Floating Point Arithmetic, by David Goldberg (XEROX PARC) (1991) -- that article may serve to explain many of the principles represented in IEEE floating-point arithmetic, candidly whether with or without an accessible draft of the standards defining the IEEE floating-point arithmetic.

Ratio as Rational Number

This might sound like some fairly dry or perhaps droll material to be writing about. Certainly, with so many implementations of IEEE floating-point arithmetic, in computing, one might wish to simply accept the ulps and relative errors of the floating point implementation, and set a software program to  continue, nonetheless, along its axiomatic course. Certainly, by any stretch of arithmetic, 1/3 will always be an irrational number, when reduced to a floating point value.

So, there's "The rub," essentially. The number 1/3 itself is a rational number -- having the corresponding mathematical accuracy of a rational number, per se -- though its floating point representation is not a rational number.

Conveniently, perhaps, ANSI Common Lisp defines a numeric type, ratio, disjunct to the numeric type, integer -- both of which, together, serve to fulfill the set of all types of rational number.

Without making a comprehensive review of ANSI Common Lisp, albeit, one might simply observe that the Common Lisp ratio type is utilized in many mathematical operations within a Common Lisp implementation. For example, in a simple evaluation in SBCL, specifically:
(/ 1 3)
=> 1/3

Rational Magnitude and Degree

This short web log article, presently, will endeavor to illustrate a relevance of rational values as  intermediary values within multi-step mathematical formulas. Rather than preferring a ratio type rationalization of floating-point numbers, however, this article will develop a decimal exponent encoding for rationalization of floating-point numbers.

This article will develop an example onto a methodology for an estimation of net circuit impedance within a single-source AC circuit comprised of resistive, inductive, and capacitive (R,L,C) circuit elements, in which -- namely -- firstly, each of net inductive reactance, net capacitive reactance, and -- if applicable -- net parallel reactance is calculated -- those values deriving from the respective net inductance and net capacitance, and single-source frequency, in the respective circuit being analyzed. Then, one would apply the reactance value together with the resistance in the circuit, for calculating the net circuit impedance and its respective phase angle, through any exacting approach to the computation of those values, dependent on the nature of the exact circuit network -- thus, in a conventional methodology, ultimately estimating  a net circuit impedance, such that may then be applied in estimating a net circuit current, subsequently in estimating the current and voltage at individual circuit elements, within the circuit being analyzed, thusly. At all points, in such calculation, it would be possible for the floating-point implementation to introduce its own natural errors -- whether of a hand-held calculator, or a program system at a desktop computer -- as due to floating point ulps and relative error, such as addressed in [Goldberg1991].

Without venturing to estimate whether such a methodology may be the best or most accurate  methodology available for an estimation of net circuit impedance, presently it may serve as a simple example of a multi-step equation utilizing of floating-point values.

At the outset, in such a calculation, the value pi is encountered, as namely for calculating the net inductive reactance and net capacitive reactance in the circuit. For a series (R,L,C) circuit with a single-source AC power supply operating at a frequency f  Herz, the estimation -- as a calculation onto an imperfect mechanical domain, certainly -- the estimation may begin as follows, axiomatically:
net inductance (series) LT = L1 + L2 + ... Ln

net capacitance (series) CT = 1 / (1/C1 + 1/C2 + ... 1/Cn)

inductive reactance XL = 2 * pi * f * LT

capacitive reactance XC = 1 / (2 * pi * f * CT)
The reader will be spared the details of a further calculation or estimation of net impedance, by any single, known methodology, as would be in an analysis of such types of electrical circuit -- the subject matter of such as the ECT-125 course, at DeVry University Online.

Presently, this article shall focus about: That a concern with regards to floating point contagion is introduced, so soon as at in the calculation of each of XL and XC.

Towards a Methodology for Decimal Scaling in Rationalization of Numeric Input Values

Within the last two of the preceding equations -- those representing, each, an implicit diadic function, accepting of values of f and respectively, LT or CT --  within those functional equations, if  pi is then represented as a floating-point number, or if f, LT, or CT is represented as a floating-point number, then of course each of XC and XL likewise would be calculated as a floating-point number. In a Common Lisp application, the resulting value would be of the greatest precision of the input values -- insofar as measuring the precision of individual floating-point numeric values.

If, instead, each input value, n, to the respective functions would be represented as a numeric object with a rational magnitude, m and an integer decimal degree, d, such that:
n = m * 10^d
...then those  calculations may be performed all within the rational number line, wherein even the intermediary values may be stored as rational, decimal-shifted numeric objects (m, d). The respective calculations for each of inductive reactance and capacitive reactance all rely on the simple mathematical operations of multiplication  and division. In a Common Lisp application, then if those calculations could be conducted with values all of type cl:rational, the result would be, in each, a numeric object of type cl:rational.

Essentially, this methodology applies a decimal shift for integral values -- preferring a decimal base for representation of floating-point values, contrasted to a binary base --  in a manner that serves to ensure that m and d would both be rational values, representative of any floating point value n. This methodology would  serve to ensure that a rational decimal value may be computed for any intermediary real number value, within a mathematical operation.

Furthermore, this methodology  allows for a  manner of scaling of n onto (m,d) into any alternate scale of (m,d) -- as per the decimal prefix values standardized of the Systeme Internationale (SI) -- to any scale for m other than the initial scale, d.For m being of type cl:integer, then, the value (m,d) may be scaled simply by incrementing or decrementing d.

Of course, this in itself does not serve to eliminate the possibility of encountering a floating-point value in an arithmetic computation. For instance, in something of a trivial example, given:
n1 = 100 => (m1, d1) = (1, 2)
n2 = 300 => (m2, d2) = (3, 2)
then:
n1 / n2 = 1/3 => (m3, d3) = (1/3, 0)
The quotient of n1  and  n2 ,in the value's floating point representation, would be an irrational number. In an implementation of the type, ratio, however: The quotient may be stored as a ratio, rather than as a floating point number.

In applying such a methodology -- as here, denoted onto a decimal base, base 10 -- it may be possible to eliminate floating-point values from within the intermediary values of any series of mathematical calculations. Any initial input values to a calculation may be converted into such decimal scalar values -- for each n, initializing a decimal scalar object storing n as a rational magnitude, m, with an integer decimal degree, d. Subsequently, all mathematical operations may be performed onto (m, d)

On a sidebar with regards to base two, ie binary scale encoding for numeric objects: Considering that a numeric value -- even an integer value -- within a software system, would be encoded as a binary value, within the software system's data space, then it may seem more advantageous to perform such a shift onto base 2, in keeping with the natural base of the containing data space . With the numeric value initially provided as a decimal digit, however, the initial precision of the input value may be lost if the shift is not performed onto the input value's base, namely the decimal base, base 10.

Whereas the conventional scalar measurement prefixes standardized in the Systeme Interationale are also defined onto the decimal base, then of course the decimal base scalar value, (m, d), may be effectively re-scaled for any prefix, with simply an adjustment applied onto d, proceeding to any instance in decoding the rationally scaled decimal value.

Inequalities Resulting of Floating-Point Type Inconsistency in Arithmetic Operations

A prototypical example is provided, onto the numeric value, pi, and a fraction of pi, in a comparison onto a value functionally equivalent or ideally equivalent to the fraction of pi, the latter produced of the trigonometric transcendental function, atan:

(typep pi 'double-float)
=> T

(= (/ pi 4) (atan 1d0))
=> T

(= (/ pi 4) (atan 2d0 2d0))
=> T

(= (/ pi 4) (atan 2 2))
=> NIL
In the last instance, the call to atan produces a value of type single-float, such that does not have the same floating-point precision as the  double-float value, pi.

Thus, it might seem well to extrapolate that all values that are input to a mathematical system -- as via read -- should be type coerced -- in a semiotics of programming languages not Common Lisp, essentially to cast a value -- to type coerce all number type values  to double-float -- that being a floating-point type of some precision -- insofar as interacting with functions that accept a value of type float and that consistently produce a floating-point value, i.e. insofar as with regards to floating-point functions.

In coercing every input floating-point type numeric value into a value of a single floating-point numeric type, it may be possible to ensure a greater degree of floating-point accuracy, throughout a program system -- thus, obviating some concerns with regards to floating point contagion.

Notably, there is a feature defined in ANSI Common Lisp, namely the special variable,  cl:*read-default-float-format*. The conclusion of this article, an application of that variable is denoted for an extension to ANSI Common Lisp, in the form of an application of ANSI Common Lisp.

In Search of the Elusive CL:Long-Float Numeric Type

Presently, this article will introduce a sidebar: That if this article may be interpreted as with a perspective towards any Lisp implementations implementing a long-float value type -- assuming that the latter may be implemented to a greater floating-point precision than the double-float numeric type -- then the reader may wish to transpose the term, long-float, into every instance of the term, double-float, denoted in this document, thus implicitly preferring a floating-point numeric type of a greater floating-point precision.

Functions Accepting of Integer Values Only

Of course, not every function in the Common Lisp numbers dictionary would accept a value of type double-float. For instance, the function isqrt accepts values only of type integer. Inasmuch, it may be noted that -- in a prototypical regards -- the double-float value 1.0d0 is equivalent to the integer value, 1. If it would be thought necessary, then a type coercion could be performed onto the double-float 1.0d0 to its integral value 1 -- with measure for accuracy -- as  within an overloaded math functions system, such as provided via Igneous-Math [math-ov], in the specific method dispatching provided by Igneous-Math system, in its present revision (1.3).

Towards a Numeric Equivalence Between Numerically Rationalized Constants and Values Returned of Transcendental Functions

An  ideal fraction of pi, pi/4, represents an ideal angle of exactly 45 degrees -- essentially, one eighth of  the radial angle of 2pi, for 2pi representing the total, singular measure of the radial angles in a unit circle.  

Of course, when pi must be implemented as a measurement within a computational system -- as effectively limited, then, to the precision of the floating point numeric features of the computational system -- then the definition of an ideal angle onto pi  becomes effectively entangled with the definition of the same floating point implementation. Considering that all systems implementing the IEEE floating point standard  would produce equivalent values for pi -- as when provided with a singular, conventionally accepted reference value for pi  --  then one may expect a sense of accuracy between the respective floating point implementations,  for fractions onto pi, as much as onto any  floating-point operations conforming to the IEEE floating point standard. Presently, one might not proceed, at length, to denote any of the possibly nondeterministic qualities of such a relatively simple assertion with regards to floating-point accuracy. 

If the Common Lisp rational and rationalize functions may be applied as, in effect, to limit the number of possible instances of errors resulting of floating point ulps and relative error conditions -- literally, then, to ensure that any single, floating-point value would be type coerced to an appropriate rational value, as soon as a floating-point value would be introduced to a mathematical system --  but such an application may also be met with questions, namely: Whether to apply cl:rational or alternately, to apply cl:rationalize, and whence?

An illustration in applying the functions, cl:rationalize and cl:rational separately, onto each of: (1) pi, (2) a fraction of pi, and (3) a value returned by cl:atan, in an evaluation of cl:atan that produces -- essentially -- a fraction of pi, namely towards an ideal value of pi/4 radians, i.e. 45 angular degrees.
;; double-flat => rationalized rational => equivalent
(= (rationalize (/ pi 4d0)) (rationalize (atan 2d0 2d0)))
=> T

;; double-float=> rationalized rational => equivalent
(= (rationalize (/ pi 4)) (rationalize (atan 2d0 2d0)))
=> T ;; pi being of a double-float type

;; With a rationalized pi applied internal to the
;; fractional form, however, the fractional form   
;; is then unequal to its approximate functional equivalent.
;; Ed. Note: This example was developed with SBCL. ECL presents a different result 
;; than illustrated, certainly as resulting of subtle differences in implementation of
;; the function, cl:rationalize
(= (/ (rationalize pi) 4) (rationalize (atan 2d0 2d0)))
=> NIL

;; In applying cl:rational, as internal to the fractional form,
;; as well as applying cl:rational onto the value returned by
;; the atan function, the two values are then equivalent.
(= (/ (rational pi) 4) (rational (atan 2d0 2d0)))
=> T

With regards to distinctions between the functions, cl:rational and cl:rationalize,  the  wording presented in the Common Lisp Hyperspec (CLHS) may seem somewhat ambiguous, in one regards, as towards a question: What is a completely accurate floating point value?  The question might seem tedious, perhaps, as it may be a difficult question to develop an accurate answer unto. In such regards, of course, one might revert to observing the behaviors of individual Common Lisp implementations.

Original emphasis retained, with emphasis added, in quoting the CLHS dictionary for the functions cl:rational and cl:rationalize:
"If number is a float, rational returns a rational that is mathematically equal in value to the float. rationalize returns a rational that approximates the float to the accuracy of the underlying floating-point representation. 
"rational assumes that the float is completely accurate. 
"rationalize assumes that the float is accurate only to the precision of the floating-point representation."
One might extrapolate, from that summary, that it might be advisable to apply cl:rationalize, throughout. In implementations in which the precision of the Lisp implementation's floating-point number system is governed, effectively, by the IEEE floating-point standard, then certainly one could assume that values produced with cl:rationalize  -- specifically, of cl:rationalize applied onto double-float values --  that the results would be consistent, across all such implementations -- as when the behaviors of cl:rationalize are governed expressly onto the underlying floating-point implementation, and the underlying floating-point implementation is consistent with the IEEE standard for floating-point arithmetic.

To where, then, may one relate the disposition of cl:rational? This article proposes a thesis: That if the IEEE standard for floating-point arithmetic is accepted as the industry standard for floating-point arithmetic, and if the IEEE standard for floating-point arithmetic may represent an implementation of floating-point arithmetic both to an acceptable precision in addition to an acceptable accuracy in computations within and among individual IEEE floating-point implementations,  then -- in a sense -- perhaps the IEEE floating-point standard may be denoted as "The nearest thing possible to a completely accurate floating-point implementation"?  Of course, that might be a mathematically contentious assertion, though it might anyhow represent a pragmatically acceptable assertion, towards assumptions of precision and accuracy within computational systems implementing and extending of Common Lisp.

In a practical regards: Considering the example -- presented in the previous -- as with regards to an ideal fractional value of pi, namely an ideal pi/4 and its representation in a single Common Lisp system, as both (1) via a ratio onto pi and (2) in a numeric rationalization of an ideally equivalent value returned via the transcendental trigonometric function, atan,  then it may seem that it would instead be advisable to apply cl:rational, as consistently and directly onto floating-point values, in all instances of  when a floating-point value is produced -- as whether produced via input or produced via a floating-point calculation -- produced within a Common Lisp program system.

Concerning the Elusive cl:long-float Numeric Type

ANSI Common Lisp defines a type cl:long-float, with a minimum precision and a minimum exponent size equivalent to those qualities of the type, cl:double-float. On a sidebar, if one may wish to develop a further understanding of the relevance of those values, within a floating-point numeric implementation, certainly one may consult any amount of "Existing work", such as, conveniently:  [Goldberg1991]

In a practical regards, it might be assumed that most Common Lisp implementations would implement or would emulate -- respectively -- the C data types, float and double [Wikpedia] for the Common Lisp cl:single-float and cl:double-float types.

Common Lisp implementations might also endeavor to implement or to emulate the C long double numeric type [Wikpedia, ibid.] as extending of the IEEE standards for floating-point arithmetic [Wikipedia]. Conceivably, the C long double numeric type could be implemented or emulated with the elusive cl:long-float numeric type, and then extended with so many compiler-specific optimizations -- such optimizations, perhaps, providing a veritable "Icing on the rational pi" within Common Lisp applications.

Towards Subversion of Floating Point Contagion

Concerning the behaviors of floating-point numeric coercion within implementations of ANSI Common Lisp, it might be advisable for an implementation of a mathematical system to prefer the most precise floating-point implementation available, within a Common Lisp implementation. Conventionally, that would be the type, double-float.

In a simple analysis of possible sources of numeric values within a Common Lisp application, essentially a numeric value may be introduced into an application either via input or via calculation. Concerning calculation of numeric values in Common Lisp, it would be assumed that for any calculation accepting a floating-point value, that the result of the operation would be of the same precision as the highest-precision input value -- with however much for numeric accuracy, as across possible floating point contagion, in instances of floating point coercion.

In regards to how a numeric value may be input into a Common Lisp program, one might denote at least three possible, essentially distinct input sources:
  • REPL - The read/eval/print loop (REPL)
  • Source file
  • Compiled, "Fast loading" i.e. FASL file
In regards to the first two of those input sources, one would assume that the type of any floating-point numeric values would be selected as per the value of cl:*read-default-float-format* . It might seem, then, as if that was sufficient to ensure that all floating-point values introduced via input to a mathematical system would be of an expected floating-point format, perhaps exactly the floating-point format specified in cl:*read-default-float-format*. 

Without venturing into any manner of a lengthy analysis of implementation-specific compiler behaviors and implementation-specific FASL encoding schemes, it might be denoted that a compiler may encode -- as when writing objects into an object form in a FASL file -- that a Lisp implementation may encode a floating-point value, essentially a numeric object, as being of a specific format not functionally equivalent to the value of cl:*read-default-float-format*, in any instantaneous time. Similarly, it may be possible for a Lisp implementation to read a numeric value from a FASL file, without the value being type coerced according to cl:*read-default-float-format*.

Conclusion: Specifications for Floating-Point Type Coercion, Decimal Rationalization, and Default Floating-Point Format for the Lisp Reader

So, if a mathematical system was to endeavor to ensure that all floating-point mathematical operations performed within the system would be performed onto the highest-precision floating point data type available in the implementation, then although it may serve to introduce an additional set of instructions into any functional forms within the same mathematical system,  but the same mathematical system -- in interfacing with any function consistently returning a floating point numeric type -- may endeavor to consistently type coerce  numeric values to the highest precision floating point data type available -- as insofar as in any direct interfaces onto such floating point functions, such as the transcendental trigonometric functions in Common Lisp.  Of course, this might serve to introduce some errors, with regards to floating-point type coercion,  while it would at least serve to address any errors as may occur when comparing values derived of differing floating-point precision.

It would may be a matter of a further design decision, then, as for whether the exacting floating-point format would be specified statically, at compile time, or would default to the value of cl:*read-default-float-format* at time of evaluation. Certainly, both behaviors may be supported -- the exact selection of which could be governed with specific definitions of cl:*features* elements, as may be applied within the source code of the system.

That, in itself, may not serve to obviate some concerns with regards to floating-point ulps and rounding errors, however. So, it might furthermore be specified -- in so much as of an axiomatic regards, certainly -- that in an implementation of a mathematical object system, viz a viz Igneous-Math: That any procedure interfacing directly with floating-point mathematical operations, in Common Lisp,  would return a numeric value directly rationalized with cl:rational -- referencing the example denoted in the previous, as with regards to a rational fraction of pi and a numeric value functionally equivalent or ideally equivalent to a fraction of pi, but as calculated via the transcendental trigonometric function, atan, onto any specific floating point precision, then the return value being numerically rationalized with either cl:rational or cl:rationalize.

Thirdly, for ensuring a manner of type consistency of values input via source files and input via the Common Lisp REPL, the mathematics system may endeavor to apply a floating-point numeric type of the highest available precision in any single Lisp implementation -- as towards the value of cl:*read-default-float-format*. Certainly, an application may endeavor to avoid setting the value of cl:*read-default-float-format* itself, however. An application may signal a continuable error, during application initialization -- as when the user-specified value of cl:*read-default-float-format* would not be of the greatest available numeric precision. That continuable error, then, may be defined as to allow the user to select the highest-precision floating point numeric type and to set the value of cl:*read-default-float-format* oneself, form within any of the continuation forms defined, then, in the single continuable error.

Sidebar in Tangent: Design of the MCi Dobelle-App System

Of course, the previous paragraph may also serve to denote that there would be a definition of an application object, as well as a definition of an initialization phase in the definition of an application object -- towards a sidebar onto the dobelle-app system, in all its colloquial name, within the MetaCommunity group at Github.

For "Later Study," Irregularity in Fractional Rationalized Pi onto a Rationalized, Functionally Equivalent Value Computed By atan 

The following software form presents another interesting example with regards to irregularities in floating point arithmetic and rationalization of floating-point values. A study of the cause of the difference between the values of rpi4 and rtpi4, of course, may be other than trivial. No doubt, such a study may entail a study directly of the implementation of the transcendental trigonometric functions, in GNU LibC.

This example was produced, originally, with SBCL 1.2.4 on Linux (x86-64), and has been tested also with CCL 1.9-r15757 on Linux (x86-64). Considering the consistency of IEEE floating point implementations, an equivalent set of return values is calculated in each implementation.
(let ((fpi4 (/ pi 4d0)) 
      (ftpi4 (atan 2d0 2d0))
      (rpi4 (/ (rationalize pi) 4))
      (rtpi4  (rationalize (atan 2d0 2d0))))
  (values fpi4 ftpi4 
   rpi4 rtpi4 
   (float rpi4 pi) (float rtpi4 pi)
   (= rpi4 rtpi4)))

=> 0.7853981633974483d0,
      0.7853981633974483d0,
      122925461/156513558,
      101534659/129277943,
      0.7853981633974483d0,
      0.7853981633974483d0,
      NIL

Notably, if the function cl:rational is applied instead of cl:rationalize,  the values calculated for each of rpi4 and rtpi4 are, then, exactly equivalent, and the last return value, then, is T.

Appendix: Floating-Point and Non-Floating-Point Functions Defined in ANSI Common Lisp

The following functions, for any input values, will consistently return a floating point return value
  • ffloor
  • fceiling
  • ftruncate
  • fround
The following functions may return a rational value -- as may be tested, in each implementation -- as per the Rule of Float Substitutability, in ANSI Common Lisp. When consistently returning a floating point value, then these functions may be regarded as in the same set as the previous -- this being an implementation-specific quality.
  • sin
  • cos
  • tan
  • asin
  • acos
  • atan
  • sinh
  • cosh
  • tanh
  • asinh
  • acosh
  • atanh
  • exp
  • expt
  • log
  • sqrt

Onto floating-point complex numbers:
  • cis
A set of functions that accept integer values, and would return integer values, exclusively -- this  mathematics system not addressing ash, ldb, or dpb:
  • gcd
  • lcm
  • isqrt
  • evenp
  • oddp
Towards consistency onto the decimal rationalization policy of the the Igneous-Math system: Within  interfaces to those functions that return real numeric values, but that do not  or may not return integer numeric values, those functions' direct return values should be effectively transformed with a call to cl:rational, before return.

Notably, this quality of the Igneous-Math system is designed with an  emphasis towards numeric accuracy before minimization of object system garbage-collection calls -- as with regards to  a consistent discarding of floating point values, in procedural transformation to decimal rationalized integers.

Of course, it may be advantageous towards possible re-use of the software of the Igneous-Math system, if the decimal rationalization policy would be implemented as a compile-time option, in the Igneous-Math system. 

At this point, the author's attention is returned to the documentation toolchain.

Saturday, October 25, 2014

Thoughts about: Electronics, Geometry, Common Lisp, and a Rational Pi within Common Lisp Mathematics

"Once upon a time," when I was a young person, my family had "Gifted me" with an electronics kit, such that I've later learned was developed by Elenco. In fact, my family had "Gifted me" with a number of electronics kits -- an old 60-in-1 kit, later the Elenco 200-in-1 kit, and then a kit somewhat resembling the Elenco Snap Circuits Kit, though the last of those was of a different design, as I recall -- something more designed for carrying an assembled circuit, really. My family had also gifted me with the opportunity to be wary of computer salespersons, but that's another thing.

In studying the manual of the Elenco 200-in-1 kit, specifically, I was able to learn a few things about the simple novelty of electrical circuits. The manual for the Elenco 200-in-1 kit contains a broad range of circuits, onto the domains of each of solid-state and digital electronics. The circuit elements, in the kit, are all firmly fastened into a non-conductive base, each junction attached to a nice spring. The circuit elements, in the kit, may be "wired together" with the set of jumper wires contained in the kit, according to the numbered schematics within the manual. As I remember, today, I'd assembled the radio tuner circuit, the buzzer/oscillator, and something about the multi-segment LED, then  separately, something about the step-up and step-down transformers. Of course, there's a novel analog meter, on the front of the Elenco 200-in-1 kit's form factor case.

Candidly, to my young point of view, the full manual of the Elenco 200-in-1  kit had seemed a little overwhelming, to me. I remember, still, that I'd had a feeling for that I was looking at a broad lot of material when browsing the pages of the manual, but I wasn't particularly certain if I was able to understand the material I was reading. Of course, I could understand something about the circuit assembly instructions, in the manual -- it seemed, to me, much like the "Snap together" airplane models of the hobbyist domain -- but I was not able to analyze the material of those circuits. Inasmuch, I wasn't able to interpret anything about my experiences, in studying of the manual. Certainly, I was able to set a wire between spring 30 and spring 14, to push a button, and to watch an LED glow, but -- beyond the simple, mechanical qualities of such circuit assembly and testing -- it didn't mean so much to me, then. It was a little bewildering to me, too -- there was such a nice manual, with the item, but I was unable to study the manual, beyond the simple circuit assembly instructions. I could not understand any much about it.

Candidly, It was the only electronics book that I knew of, in all of my young views. In that time of my life, I was not whatsoever cognizant about any sense of a relevance of digital circuits -- such as, of the digital logic gates with transistorized circuits, printed in the last pages of the manual. Sure, though, that was only a few years decades after Bell Labs had made their first discoveries about the superconductive properties of germanium [Computer History Museum].  I was a kid, when the decade was 1980, when the 32 bit processor was "New", and when the Nintendo Entertainment System was the hottest thing on the games market. Somehow, I still mark the chronology of my life by those relative metrics.

At that time in my life, I was not aware of there being a digital domain in electrical circuits, beside any concepts particularly of digital/analog interfaces. I had received the Elenco 200-in-1  kit as a gift, at a time before I had ever studied geometry, in school. It was a very novel thing, to me, but there wasn't so much I could do to understand the material of the manual provided with the thing. Candidly, it gathered some dust, and with some regrets, was delivered to a landfill, when I first left California. I wish I had held onto that item -- a reproduction would not be quite the same.

Certainly, the high school geometry class -- in a sense not focused towards any specific, practical or vocational regards -- the class did not present any notes with regards to any applications of geometry, in electrical circuit analysis, so far as I can recall of the primary material of the high school geometry course. There was nothing about the rectangular coordinate plane, almost nothing about the unique, polar coordinate plane, and there was not so much about complex numbers, though certainly the course stayed its track along the standard curriculum.

Sure, though, the geometry class had explained the natures of the unit circle, the pythagorean theorem, and the transcendental functions as defined of a domain of trigonometry -- such as the sine, cosine, and tangent functions, and their functional inverses, asin, acos, and atan. Certainly, it had seemed novel to me that there are the relations of those functions onto objects within a unit circle, but I could not conceive of any applications for such knowledge, beyond any of the no-doubt demanding domains of structural design -- such as of physical architecture or of automotive design, in any manner of mathematical refinement in structural design.

So, it was not until the 38th year of my life that I would learn that those trigonometric transcendental functions may be applied within a methodology of electrical circuit analysis -- and that conventionally, those are denoted as being among the transcendental functions in mathematics. Without begging a discussion with regards to imperfections in measurement systems, personally I think it's a significant thing that there are applications of geometry in electrical circuit analysis, as well as in the broader physics. Candidly, I may only narrowly avoid regressing to a mindset like of a giddy child, to observe that there are more applications for trigonometry, under the nearby sun.


This week, I've begun to define something of an extensional model for application of mathematics, in Common Lisp -- that extending of the set of mathematically relevant functions, defined within the ANSI Common Lisp specification. Today, specifically, I've been developing a model for overloading of mathematical operations in the Common Lisp Object System -- in a manner somewhat extending of a Common Lisp implementation's existing optimizations with regards to numeric computation. While I was endeavoring to make the next day's set of notes, for that "Sprint", I've now learned of a couple of functions defined in ANSI Common Lisp, such that effectively serve to "Obsolete" a page full of code that I had written and tested, earlier this week -- and in that, no doubt with further implementation-specific optimizations, in implementations of the ANSI Common Lisp rational and rationalize functions. The code that I had written, earlier this week, it was something implementing of a decimal-shifted encoding for floating-point numbers -- in a sense, developing a model for decimal shift in measurement values, that onto the base-ten or decimal base measurement prefixes defined of the standard Systeme Internationale measurement system. Of course, there are also the base-eight or octal base prefixes conventionally applied about quantities of digital information.

The code that I had written, earlier this week, it does not completely attain to a model for measurement for "Significant digits" within input values -- not in a sense as I had learned of, when I was a student of the science courses I'd attended in high school, in the mid 1990's. There was not so much about the floating point numeric types, as defined in modern standards for computation -- and neither of so much of a sense of a mantissa, as defined in those specifications -- in a course that described the molar weight of helium.

On discovering the the ANSI Common Lisp rational and rationalize functions, personally I may feel at least a small bit of good cheer that ANSI X3J13 [Franz Inc] had seen fit to develop such a set of functions as would serve to address some inevitable concerns in implementations of conventional models for floating-point arithmetic.

Personally, I think that this -- in a sense -- is the nicest line of code that I've ever written:
(rationalize pi)
=> 245850922/78256779
 It follows, then, that one is also cheered to write:
(defun rad-to-deg (r)
  (* r #.(/ 180 (rationalize pi))))
=> RAD-TO-DEG

(rad-to-deg pi)
=> 180.0D0
So, clearly, it is possible to define an accurate method for transformation of a measurement quantity from onto a unit of radians, then onto a unit of degrees, without one having to go to any gross extent, to extend the ANSI Common Lisp specification.

That being simply the happiest thing that one has seen produced of a computer, of late, but of course one does not wish to make a laurel of the discovery.

Of course, the simple transformation of pi radians  to 180 degrees is not so different if one does not firstly rationalize pi in the equation. In a converse instance, however: What of a transformation of  pi/2 radians?
(/ (rationalize pi) 2)
=> 122925461/78256779
contrasted to:
(/ pi 2)
=> 1.5707963267948966D0
In the first  instance of those two, when the implementation's value for pi is firstly converted to a rational number, then with the computation being made onto another rational number, the real precision of the initial value of pi is neither lost nor folded. In the second instance of those two, it might seem as though the application would simply be venturing along in the implementations' system for floating point arithmetic -- that the application developer, then, must simply accept any matters of  floating-point rounding, and so on, as those being simply matters of the programmed environment. One might think that may not be sufficient, in all regards, though perhaps it might be common, as a matter of practice.

Notably, in applying a rationalized pi value, the calculation of the number of degrees represented of pi/2 radians itself results in a rational number, exactly 90.
(defconstant *rpi* (rationalize pi))
=> *RPI*

(defun rad-to-deg (r)
  (* r #.(/ 180 *rpi*)))
=> RAD-TO-DEG

(rad-to-deg (/ *rpi* 2))
=> 90
In a simple regards: That's both of a mathematical precision, and mathematical accuracy, represented in a conversation of pi/2 radians to 90 degrees.

I'm certain that it may be possible to emulate the CLHS rationalize function, within other object-oriented programming languages -- such a Java, C++, Objective C, and so on. One would like to think that in such an instance, one may also emulate the Common Lisp numeric type, ratio -- that being a subtype of rational, in Common Lisp, disjunct to the numeric type, integer -- then to overload the respective numeric operations, for the new ratio numeric type.

Personally, I would prefer to think of Common Lisp subsuming other programming languages, however, rather than of other programming languages simply emulating Common Lisp. I know that there can be "More than one" -- as far as programming languages, in the industry -- certainly. Personally, I think that it may be as well to address other programming languages if from a Common Lisp baseline, if simply as a matter of at-worst hypothetical efficiency.

An ANSI Common Lisp implementation would already have defined the ratio numeric type, as well as the mathematical operations denoted in the CLHS Mathematics (Numbers) Dictionary, onto the whole set of numeric types defined in ANSI Common Lisp. Implementations might also extend on those functions and types, with any number of implementation-specific extensions such as may be defined for purpose of optimization within Common Lisp programs -- perhaps, towards a metric for deterministic timing in mathematical procedures.

Sure, though, if one would endeavor to extend those numeric operations and types onto more types of mathematical object than those defined in ANSI Common Lisp -- as onto a domain of vector mathematics  and scalar measurements, such as the Igneous-Math project seeks to address, in all of a colloquial character of a source tree (yet unpublished) -- then it would be necessary to extend the mathematical operations, themselves, and to define an object system for the types extension. That's something I was working on developing, today, before I noticed the simply sublime matter of rational and rationalize, as functions standardized in and of ANSI Common Lisp.

Presently, I'm not certain if I should wish to altogether discard the simple decimal-shift code that I'd written, earlier this week -- essentially, that was for developing a rational numeric equivalent of a floating-point representation of a numeric input value, such as pi -- but not only so. In that much, alone, it might be redundant onto the ANSI CL rationalize function.

Also, it was for "Packing" numbers into their least significant digits -- in a sense, to derive value of magnitude and a corresponding decimal scale value, the latter essentially representing a decimal exponent  -- with a thought towards developing some optimized mathematical operations onto rational numeric values, throughout a mathematical system, in seeking to retain something of a sense of mathematical accuracy and precision, if but because it would seem to be appropriate to one's understanding, as such

The decimal shift code, as implemented in Igneous-Math, of course it's nothing too complex, in any sense -- in a simple regards, the "decimal reduction" algorithm uses the Common Lisp truncate function, and correspondingly, the "decimal expansion" algorithm uses the Common Lisp expt function. It's been implemented as part of a system for encoding the Systeme Internationale decimal prefixes as Common Lisp objects, in a system essentially designed to ensure that -- excepting of such rational numeric measurement values as would be input as of the type, ratio -- that other real numeric values in the system would be stored in a manner derived to a base measurement unit, before being applied within such conventional formulae as would be defined around base measurement units -- but allowing for operations onto arbitrary exponents of the base measurement units, in any single measurement system.

While designing so much of those features of the Igneous-Math system, candidly I was not then aware of the simple existence of the ANSI CL rationalize function, as it being a feature available of an ANSI Common Lisp implementation. With some chagrin, I wonder if I would've designed the decimal-shift code any differently, had I been aware of that feature of ANSI Common Lisp, at any time earlier this week.

I think that, henceforward, I'll have to make some consideration about whether the rationalize function should be applied throughout the Igneous-Math system. One matter that I would wish to emphasize about the design of the Igenous-Math system: That a number's printed representation need not be EQ to a number's representation in object storage, within a numeric system. So long as the printed value and the stored value are at least mathematically equivalent -- onto the ANSI Common Lisp '=' function, broadly -- then certainly, the system would have achieved its necessary requirements for storage and printing of numeric values.

That a mathematical system, moreover, may endeavor to apply the rationalize function onto all numeric values input to the system, before applying those values within any mathematical operations -- such a feature would be developed as an extension of ANSI Common Lisp, also. It might seem redundant or simply frivolous, perhaps, but personally I think it's just as well.

Furthermore, I think it's a swell to encode any floating point number as a set of two fixnum type numbers -- assuming that the instances would be few, in which a floating point number would be expanded to a bignum value on a decimal scale -- and only a matter of the nature of an application system, that one would scale a floating point number onto base ten, instead of onto a base eight -- perhaps a matter of developer convenience, in developing a software program for applications of mathematics within a 64-bit Common Lisp implementation.

While beginning to develop a set of overloaded math procedures in the Igneous-Math system, I've begun to wonder of how much work would be required if to optimize an individual mathematical operation onto a microcontroller's own specific hardware -- such as with regards to the Intel SSE extensions [Wikipedia] and the ARM architecture's hard float design, with its corresponding ABI in the Linux application space [Debian Wiki]. The Igneous-Math system has been designed to rely on a Common Lisp implementation's own optimizations, in a portable regards.


Wednesday, September 17, 2014

Towards Reviving the Garnet Source Tree

I've begun developing a fork of Garnet Lisp. Corresponding with the fork, I've also begun developing a few items of documentation, within a journal for the corresponding Genizee Project.

Focusing on the Garnet Lisp fork, this morning I've endeavored to make a git rebase of the garnetlisp branch, such that that branch would be denoted as it  having a head revision proceeding somehow from the last revision of the cvsgarnetlisp branch of the fork. This seems to have resulted in a substantial number of merge conflicts within the local source tree -- a few hundred such conflicts, in fact, which I must now manually merge, to continue with this development task. Towards that effect, I'd begun by using SourceGear DiffMerge as the Git merge tool. For the most part, I've simply been using DiffMerge to set the "local" copy, in the conflict, as it being the preferred copy, in the marge -- though having to do so, manually. Courtesy of an article by Nick Quaranto at git ready, I've been able to determine that it will be possible to automate this process, namely using the shell command "git checkout --ours".

On a related note, the the "git status --short" command can be used within a conflicting merge -- as in the following example --  to display which files are in conflict, after a number of manual merge resolutions, in the merge:

gimbal@granite:garnet$ git status --short | grep '^AA'
AA src/contrib/plotxy.lisp
AA src/contrib/pmop-class-browser.lisp
AA src/contrib/ritter-labeled-box.lisp
AA src/debug/debug-compiler.lisp
AA src/debug/debug-fns.lisp
AA src/debug/debug-loader.lisp
AA src/debug/inspector.lisp
AA src/demos/demo-angle.lisp
AA src/demos/demo-animator.lisp
AA src/demos/demo-arith.lisp
AA src/demos/demo-clock.lisp
AA src/demos/demo-editor.lisp
AA src/demos/demo-gesture.lisp
AA src/demos/demo-graph.lisp
AA src/demos/demo-pixmap.lisp
AA src/demos/demo-schema-browser.lisp
AA src/demos/demo-scrollbar.lisp
AA src/demos/demo-truck.lisp
AA src/demos/demo-unistrokes.lisp
AA src/demos/demo-virtual-agg.lisp
AA src/demos/demo-xasperate.lisp
AA src/demos/demos-compiler.lisp
AA src/demos/demos-controller.lisp
AA src/demos/demos-loader.lisp
AA src/demos/garnet-calculator.lisp
AA src/demos/garnetdraw.lisp
AA src/demos/tour.lisp
AA src/gadgets/GAD-scroll-parts.lisp
AA src/gadgets/arrow-line-loader.lisp
AA src/gadgets/browser-gadget-loader.lisp
AA src/gadgets/error-gadget-loader.lisp
AA src/gadgets/gadgets-compiler.lisp
AA src/gadgets/gadgets-loader.lisp
AA src/gadgets/gauge-loader.lisp
AA src/gadgets/gauge.lisp
AA src/gadgets/graphics-loader.lisp
AA src/gadgets/h-scroll-bar.lisp
AA src/gadgets/h-scroll-loader.lisp
AA src/gadgets/h-slider-loader.lisp
AA src/gadgets/h-slider.lisp
AA src/gadgets/labeled-box-loader.lisp
AA src/gadgets/menu-loader.lisp
AA src/gadgets/menubar-loader.lisp
AA src/gadgets/motif-check-buttons-loader.lisp
AA src/gadgets/motif-error-gadget-loader.lisp
AA src/gadgets/motif-gauge-loader.lisp
AA src/gadgets/motif-gauge.lisp
AA src/gadgets/motif-h-scroll-bar.lisp
AA src/gadgets/motif-h-scroll-loader.lisp
AA src/gadgets/motif-menu-loader.lisp
AA src/gadgets/motif-menu.lisp
AA src/gadgets/motif-menubar-loader.lisp
AA src/gadgets/motif-option-button-loader.lisp
AA src/gadgets/motif-parts.lisp
AA src/gadgets/motif-prop-sheet-win-loader.lisp
AA src/gadgets/motif-radio-buttons-loader.lisp
AA src/gadgets/motif-scrolling-labeled-box.lisp
AA src/gadgets/motif-scrolling-menu-loader.lisp
AA src/gadgets/motif-scrolling-window-loader.lisp
AA src/gadgets/motif-scrolling-window.lisp
AA src/gadgets/motif-slider-loader.lisp
AA src/gadgets/motif-text-buttons-loader.lisp
AA src/gadgets/motif-trill-device-loader.lisp
AA src/gadgets/motif-trill-device.lisp
AA src/gadgets/motif-v-scroll-bar.lisp
AA src/gadgets/motif-v-scroll-loader.lisp
AA src/gadgets/mouseline-loader.lisp
AA src/gadgets/multi-selection-loader.lisp
AA src/gadgets/multifont-gadget-loader.lisp
AA src/gadgets/option-button-loader.lisp
AA src/gadgets/polyline-creator-loader.lisp
AA src/gadgets/popup-menu-button-loader.lisp
AA src/gadgets/popup-menu-button.lisp
AA src/gadgets/prop-sheet-loader.lisp
AA src/gadgets/prop-sheet-win-loader.lisp
AA src/gadgets/prop-value-gadgets.lisp
AA src/gadgets/prop-value-loader.lisp
AA src/gadgets/radio-buttons-loader.lisp
AA src/gadgets/radio-buttons.lisp
AA src/gadgets/save-load-functions.lisp
AA src/gadgets/scrolling-menu-loader.lisp
AA src/gadgets/scrolling-string-loader.lisp
AA src/gadgets/scrolling-unlabeled-box.lisp
AA src/gadgets/scrolling-window-loader.lisp
AA src/gadgets/scrolling-window.lisp
AA src/gadgets/standard-edit-loader.lisp
AA src/gadgets/text-buttons-loader.lisp
AA src/gadgets/trill-device-loader.lisp
AA src/gadgets/v-scroll-bar.lisp
AA src/gadgets/v-scroll-loader.lisp
AA src/gadgets/v-slider-loader.lisp
AA src/gadgets/v-slider.lisp
AA src/gadgets/x-buttons-loader.lisp
AA src/gem/define-methods.lisp
AA src/gem/gem-compiler.lisp
AA src/gem/gem-loader.lisp
AA src/gem/gem.lisp
AA src/gesture/agate.lisp
AA src/gesture/gesture-compiler.lisp
AA src/gesture/gesture-loader.lisp
AA src/gesture/gestureinter.lisp
AA src/gesture/train.lisp
AA src/gilt/filter-functions-loader.lisp
AA src/gilt/gilt-compiler.lisp
AA src/gilt/gilt-functions-loader.lisp
AA src/gilt/gilt-gadget-utils.lisp
AA src/gilt/gilt-gadgets.lisp
AA src/gilt/gilt-loader.lisp
AA src/gilt/gilt.lisp
AA src/gilt/motif-gilt-gadgets.lisp
AA src/gilt/path-functions-loader.lisp
AA src/inter/accelerators.lisp
AA src/inter/angleinter.lisp
AA src/inter/animation-process.lisp
AA src/inter/animatorinter.lisp
AA src/inter/buttoninter.lisp
AA src/inter/define-mouse-keys.lisp
AA src/inter/find-key-symbols.lisp
AA src/inter/focus-multifont-textinter.lisp
AA src/inter/garnet-keytrans.lisp
AA src/inter/i-windows.lisp
AA src/inter/inter-compiler.lisp
AA src/inter/inter-loader.lisp
AA src/inter/interactors.lisp
AA src/inter/lispkeyhandling.lisp
AA src/inter/menuinter.lisp
AA src/inter/movegrowinter.lisp
AA src/inter/multifont-textinter.lisp
AA src/inter/selection-interactor.lisp
AA src/inter/x-define-keys.lisp
AA src/inter/x-inter.lisp
AA src/kr/constraints.lisp
AA src/kr/kr-compiler.lisp
AA src/kr/kr-doc.lisp
AA src/kr/kr-loader.lisp
AA src/kr/kr-macros.lisp
AA src/kr/kr.lisp
AA src/lapidary/constraint-gadget-compiler.lisp
AA src/lapidary/constraint-gadget-loader.lisp
AA src/lapidary/custom.lisp
AA src/lapidary/dialog-parts2.lisp
AA src/lapidary/lap-draw.lisp
AA src/lapidary/lapidary-compiler.lisp
AA src/lapidary/lapidary-loader.lisp
AA src/lapidary/move-grow-box.lisp
AA src/lapidary/new-editor.lisp
AA src/lapidary/query.lisp
AA src/lapidary/save-restore.lisp
AA src/opal/basics.lisp
AA src/opal/clean-up.lisp
AA src/opal/create-instances.lisp
AA src/opal/create-instances2.lisp
AA src/opal/defs.lisp
AA src/opal/fast-redraw.lisp
AA src/opal/halftones.lisp
AA src/opal/macros.lisp
AA src/opal/multifont-loader.lisp
AA src/opal/multifont.lisp
AA src/opal/new-defs.lisp
AA src/opal/objects.lisp
AA src/opal/opal-compiler.lisp
AA src/opal/opal-loader.lisp
AA src/opal/open-and-close.lisp
AA src/opal/pixmaps.lisp
AA src/opal/process.lisp
AA src/opal/roundtangles.lisp
AA src/opal/text-fonts.lisp
AA src/opal/text.lisp
AA src/opal/types.lisp
AA src/opal/update-basics.lisp
AA src/opal/update-constants.lisp
AA src/opal/update-window.lisp
AA src/opal/update.lisp
AA src/opal/utils.lisp
AA src/opal/windows.lisp
AA src/protected-eval/error.lisp
AA src/protected-eval/garnet-errors.lisp
AA src/protected-eval/prompter.lisp
AA src/protected-eval/protected-eval-compiler.lisp
AA src/protected-eval/protected-eval-loader.lisp
AA src/protected-eval/protected-eval.lisp
AA src/protected-eval/protected-process.lisp
AA src/ps/ps-compiler.lisp
AA src/ps/ps-loader.lisp
AA src/utils/general.lisp
AA src/utils/mouse-keys.lisp
AA src/utils/utils-compiler.lisp
AA src/utils/utils-loader.lisp
Together with "awk",there is the following shell command, such that would ensure that every local file would be used 'as is' in completing the merge. Note: This will overwrite any manual changes made to the merge-conflict files, during the merge.
FILES=$(git status --short | grep '^AA' | awk '{print $2}') 
git checkout --ours $FILES
git add $FILES
Note: That short script can also be of use when merging conflicting patches during 'git rebase'

It seems that many of the conflicts are due to changes within the structure and formatting of comments, within the files, as well as the addition of the RCS/CVS '$Id$' tag. I presume that those changes may've been made around the time of the 3.3 branch of the canonical  Garnet Lisp.

As another observation that I'd like to make note of, from during the merge -- as a sidebar to the tedious task of resolving the conflicts in the files: Garnet originally had included support expressly for one Coral Common Lisp (circa 1987-1989) such that is denoted as CCL in the CVS edition of the Garnet source tree. (Web view) (Info).

Reportedly, Coral Common Lisp was part of the origins of Apple's Macintosh Common Lisp (MCL) [BG2013] such that is a part of the development history of Clozure Common Lisp (i.e. contemporary CCL) [Wikipedia]. Evidently, Garnet's support for the original CCL  was removed from the Garnet codebase -- perhaps, sometime around the time of the Garnet 3.3 branch. The original CCL support for Garnet would still be available in the history of the CVS branch, however -- as now mirrored in the cvsgarnetlisp branch of the MetaCommunity fork of Garnet.

Pending a successful merge in the source tree on my laptop -- considering that this merge will be leaving out most of the support made expressly for the original CCL -- then I should try out the Garnet demos, to see how they'll run with the new CCL.

I've made a merged tree of each of the canonical CVS and SVN Garnet source code repositories. That merged tree is published in the branch mergetree, within the MetaCommunity Garnet repository at GitHub.

Presently (19 Sept 2014) I'm developing a set of ASDF system definitions for Garnet -- along with a few corresponding changes in the source tree, as with regards to system dependency resolution -- publishing those in the garnetlisp branch.

For writing the ASDF system definitions for Garnet, largely I've been referencing the original garnet-foo-loader.lisp files. Though tedious, this has been fairly trivial to "Work out". The effort has met with a "Hitch," however, as towards determining how to transpose the files and dependencies from garnet-gadgets.loader.lisp, in avoiding the circular dependency that would result between the derived gadgets and aggregadgets systems, if without moving files from the gadgets system, into the aggregadgets system.

At some point in the revision history of the files in the gadgets system, the source code was revised so as to depend largely on the definition of the opal:aggregadget schema -- thus, making those files and any files depending on those files, in effect, dependent on the aggregadgets system, though contained directly within the gadgets system. Considering that the gadgets system is expressly a dependency of the aggregadgets system, in effect this creates a circular dependency, such that may be observed when the corresponding system definitions are loaded "So far as to that point" with ASDF. There are so many files in the gadgets system, moreover, such that are dependent on the definition of opal:aggregadget, it may effectively seem to require that the gadgets and aggregadgets systems should be merged. However, such a merge would serve to adversely affect the alignment of the Garnet documentation onto both of the gadgets and aggregadgets systems, "As is".

Fortunately, it would not require a revision with regards to the Common Lisp packages in which the respective gadgets are defined, as they are all defined uniformly within the 'opal' package. It would serve to require, however, that the files from the original gadgets system would be annotated, within the resulting aggregadgets system definition, as for the origins of those files in the original 'gadgets' system -- therefore, corresponding to the Garnet Gadgets user manual. Optionally, those files may be annotated, as such, by simply containing all of those files within a unique module in the resulting aggregadgets system definition, the "Gg" module. The majority of the aggregadgets source files could then be contained within a corresponding "Agg" module. "Gg" would then depend on the single source file defining the opal:aggregadget KR schema, and the "Agg" module would then depend on the "Gg" module.