[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] How to multiply 2 sequences ?


Subject: RE: [xsl] How to multiply 2 sequences ?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 7 Nov 2007 14:45:27 -0000

> It seems that you are trying to obtain the scalar product of 
> two vectors:
> 
> X = {x1, x2, ... , xn}
> 
> Y = {y1, y2, ... , yn}
> 
> X.Y = x1.y1 + x2.y2 + ... + xn.yn
> 

If that is indeed the requirement (and I wasn't able to work it out from the
posting) then it can be done in XPath 2.0 (without any help from FXSL) as

sum(for $i in 1 to count($x) return $x[$i] * $y[$i])

Michael Kay
http://www.saxonica.com/


Current Thread
Keywords