| Subject: [xsl] A super-efficient way to compute the sum of A[i] * B[i]  for i=1 to n? From: "Costello, Roger L. costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 9 May 2020 11:59:16 -0000 | 
Hi Folks,
I need a super-efficient way to compute the sum of A[i] * B[i] for i=1 to n.
For example, suppose A is this:
<row>
    <col>0.9</col>
    <col>0.3</col>
</row>
and B is this:
<row>
    <col>0.2</col>
    <col>0.8</col>
</row>
I want to compute:
(0.9 * 0.2) + (0.3 * 0.8)
Here's one way to do it:
sum(for $i in 1 to count($A/col) return number($A/col[$i]) *
number($B/col[$i]))
I suspect that is not the most efficient approach.
What is the most efficient approach? I will be doing hundreds of thousands of
these computations, so I want to use the most efficient approach.
/Roger
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: [xsl] [ANN] Balisage 2020 Goes , Debbie Lapeyre dalap | Thread | Re: [xsl] A super-efficient way to , Martin Honnen martin | 
| Re: [xsl] [ANN] Balisage 2020 Goes , Debbie Lapeyre dalap | Date | Re: [xsl] A super-efficient way to , Martin Honnen martin | 
| Month |