Am 12.07.2020 um 23:53 schrieb Martin Honnen
martin(_dot_)honnen(_at_)gmx(_dot_)de:
On 12.07.2020 22:47, Dr. Roger L Costello costello(_at_)mitre(_dot_)org 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? /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.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--