ISCTxx/IDCTxx/IICTxx/ICCTxx/IZCTxx

Count selected vector elements

Output

i

If n ≤ 0, then i = 0. Otherwise, i is the number of

 

 

elements of x that satisfy the relationship with a

 

 

specified by the subprogram name.

Fortran Equivalent

INTEGER*4 FUNCTION ISCTEQ (N,X,INCX,A) REAL*4 A,X(*)

ISCTEQ = 0

INCXA = ABS ( INCX ) IX = 1

DO 10 I = 1, N

IF ( X(IX) .EQ. A ) ISCTEQ = ISCTEQ + 1

IX = IX + INCXA

10CONTINUE RETURN END

Example Count the number of positive elements of a REAL*8 vector x, where x is a vector 10 elements long stored in a one-dimensional array X of dimension 20.

INTEGER*4

I,IDCTGT,N,INCX

REAL*8

A,X(20)

N =

10

 

INCX = 1

 

A =

0.0D0

 

I = IDCTGT (N,X,INCX,A)

48HP MLIB User’s Guide