Subject: Re: [xsl] How to improve the performance of my matrix addition function? From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 13 Jul 2020 09:19:11 -0000 |
On 12.07.2020 22:47, Dr. Roger L Costello costello@xxxxxxxxx wrote:Hi Folks,
My application uses lots of matrix operations. I used the SAXON Tool Profile (-TP) option to generate a web page that shows the performance of each of my matrix operations. I found that my matrix addition function is taking an appallingly large amount of time. Below is my matrix addition function. Do you have suggestions on ways to improve its performance?B /Roger
And of course in XPath 3/XSLT 3 there is the "for-each-pair" function made for tasks like this but I have no idea whether that would perform better. And to write it solely as a function expression you need XQuery or the XPath 4 extension function introduced in Saxon 10 to create elements.
Here is an XSLT function uses for-each-pair twice together with saxon:new-element to construct the row and col elements:
<xsl:function name="matrix:addition" as="element(Matrix)" visibility="public"> <xsl:param name="M" as="element(Matrix)"/> <xsl:param name="N" as="element(Matrix)"/> <Matrix> <xsl:sequence select=" for-each-pair( $M/row, $N/row, function ($row1, $row2) { saxon:new-element( 'row', for-each-pair( $row1/col, $row2/col, function ($col1, $col2) { saxon:new-element('col', $col1 + $col2) } ) ) } )" /> </Matrix> </xsl:function>
Needs Saxon 10 PE or EE and I haven't tested whether it performs any better than the previous suggestions.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to improve the perfor, Martin Honnen martin | Thread | [xsl] Modeling matrices in an XML e, David Birnbaum djbpi |
[no subject], Unknown | Date | Re: [xsl] JSON to XML using XSLT 3., Martynas Jusevičius |
Month |