[xquery-talk] Matrix Multiplication (JSONiq)

Hermann Stamm-Wilbrandt STAMMW at de.ibm.com
Sat Feb 1 15:33:21 PST 2014

Last Sylvester there was a thread on Matrix Multiplication in XQuery:

The biggest problem identified was that XQuery does not allow for efficient
representation of 2+dimensional arrays.

JSON does provide 2+dimensional arrays for free.

I did not measure performance yet, but this JSONiq script looks very
similar to what would be done in C:

declare variable $A := [
declare variable $B := [

  for $i in 1 to count(jn:members($A)) return
    for $k in 1 to count(jn:members($B(1))) return
        for $j in 1 to count(jn:members($B)) return
          $A($i)($j) * $B($j)($k)

And much simpler than in XSLT:

Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Level 3 support for XML Compiler team and Fixpack team lead
WebSphere DataPower SOA Appliances
IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

More information about the talk mailing list