Task

Write a program to find the sum of squares of a numeric vector.

The program should work on a zero-length vector (with an answer of   0).



Related task

   Mean


*        Sum of squares            27/08/2015
SUMOFSQR CSECT
         USING  SUMOFSQR,R12
         LR     R12,R15
         LA     R7,A               a(1)
         SR     R6,R6              sum=0
         LA     R3,1               i=1
LOOPI    CH     R3,N               do i=1 to hbound(a)
         BH     ELOOPI
         L      R5,0(R7)           a(i)
         M      R4,0(R7)           a(i)*a(i)
         AR     R6,R5              sum=sum+a(i)**2
         LA     R7,4(R7)           next a
         LA     R3,1(R3)           i=i+1
         B      LOOPI              end i
ELOOPI   XDECO  R6,PG+23           edit sum
         XPRNT  PG,80
         XR     R15,R15
         BR     R14
A        DC     F'1',F'2',F'3',F'4',F'5',F'6',F'7',F'8',F'9',F'10'
PG       DC     CL80'The sum of squares is: '
N        DC     AL2((PG-A)/4)
         YREGS
         END    SUMOFSQR