Re: [xsl] Modeling matrices in an XML environment

Subject: Re: [xsl] Modeling matrices in an XML environment
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 13 Jul 2020 21:58:15 -0000
On Mon, 2020-07-13 at 17:26 +0000, David Birnbaum djbpitt@xxxxxxxxx
wrote:
> Dear XSL-list,
> 
> Roger's question invites a tangential one (for which reason I have
> changed
> the subject line): How might we usefully think about representing
> matrices
> in an XML environment?

bit dependsbbfor performance in XPath/XQuery/XSLT/Xcetera ibd probably
use arrays or, for sparse matrices, maps. This is because the
individual elements in mathematical matrices do not have intrinsic
significance beyond the positional.

For situations in which the elements _do_ have significant, there are
obvious (to this crows) benefits to using XML names, or maps with named
components,
   "x" : 4.2, "y" : 7.2, "z" : 9


The benefit to using maps or arrays over elements in XSLT or XQuery is
that element nodes are too heavyweight, and too prone to turning their
content back into strings. In XQuery in particular, constructors by
default do a terrible and dismal thing: <x>3</x> makes a text node
inside an x element. And XDM element nodes have a ton of properties,
such as next, previous, parent, schema type, is_happy, none  of which
are needed for a matrix of numbers.

This is entirely separate from the MathML apprach, of course, whether
content or presentational.

For performance i'd consider also a single flat array,
  [ r0c0 r0c1 .... r1c0.... ]
with accessor functions my:mget($matrix, $row, $col) or whatever.

It depends on the sort of manipulations you do.

Liam

-- 
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org

Current Thread