4.95 sqsum - Sum of Squares

Format : sqsum($num_1,num_2,\cdots $)

Calculate the sum of squares of the array of numbers in $num_ i$. NULL values are ignored, if NULL values exist in all numbers in the array, the result will return a NULL value.

Example

Example 1: Basic Example

$ more dat1.csv
id,v1,v2,v3
1,1,2,3
2,-5,2,1
3,1,,3
4,,,
$ mcal c='sqsum(${v1},${v2},${v3})' a=rsl i=dat1.csv o=rsl1.csv
#END# kgcal a=rsl c=sqsum(${v1},${v2},${v3}) i=dat1.csv o=rsl1.csv
$ more rsl1.csv
id,v1,v2,v3,rsl
1,1,2,3,14
2,-5,2,1,30
3,1,,3,10
4,,,,

Example 2: Example using wildcard

Specify fields starting with v (v1,v2,v3) by using wildcard "v*".

$ mcal c='sqsum(${v*})' a=rsl i=dat1.csv o=rsl2.csv
#END# kgcal a=rsl c=sqsum(${v*}) i=dat1.csv o=rsl2.csv
$ more rsl2.csv
id,v1,v2,v3,rsl
1,1,2,3,14
2,-5,2,1,30
3,1,,3,10
4,,,,