functions

ABS

 syntax: ABS( x )   ! absolute value,  |x|

 The argument can be a scalar, vector or matrix. The resultant type will be
 the same as the type and shape of its argument. 

AIRY

 syntax: AIRY( x )   ! Airy function of the first kind
         BIRY( x )   ! Airy function of the second kind

 The argument can be a scalar, vector or matrix. The resultant type will be
 the same as the type and shape of its argument.

AREA

 syntax:  AREA( x,y )  ! area enclosed by a polygon

 This function returns a scalar which is the area enclosed in the
 polygon specified by the vertex coordinates given in (x,y), where x
 and y are both vectors of the same length.  The polygon need not be
 closed, i.e., the last point will be assumed to connect to the first
 point.

CHAR

 syntax: CHAR( x )

 The CHAR function accepts either a numeric vector or a numeric scalar as
 argument. It converts these ASCII decimal codes to the equivalent
 characters and returns these characters as a string. The inverse of this
 function is the ICHAR function, which accepts a string as argument. The
 string cannot be a complete array text variable, but it can be an element
 of a array text variable. It returns a numeric vector whose elements are
 the equivalent ASCII decimal codes for the characters. If the string is
 only one character, the resultant vector will be of length one.

ICHAR

 syntax: ICHAR( string )

 The CHAR function accepts either a numeric vector or a numeric scalar as
 argument. It converts these ASCII decimal codes to the equivalent
 characters and returns these characters as a string. The inverse of this
 function is the ICHAR function, which accepts a string as argument. The
 string cannot be a complete array text variable, but it can be an element
 of a array text variable. It returns a numeric vector whose elements are
 the equivalent ASCII decimal codes for the characters. If the string is
 only one character, the resultant vector will be of length one.

Bessel

 syntax: BESJ0( x ) !          Bessel function, first  kind, order 0
         BESJ1( x ) !          Bessel function, first  kind, order 1
         BESY0( x ) !          Bessel function, second kind, order 0
         BESY1( x ) !          Bessel function, second kind, order 1
         BESI0( x ) ! modified Bessel function, first  kind, order 0
         BESI1( x ) ! modified Bessel function, first  kind, order 1
         BESK0( x ) ! modified Bessel function, second kind, order 0
         BESK1( x ) ! modified Bessel function, second kind, order 1

 The argument can be scalar, vector or  matrix. The resultant type will be
 the same as the type and shape of its argument.

beta

 syntax: BETA( a,b )     ! complete beta function
         BETAIN( x,a,b ) ! incomplete beta function

 The arguments can be scalar, vector or matrix. The resultant type will be
 the same as the type and shape of its arguments.

binomial

 syntax: BINOM( n,m )  ! binomial coefficient

 The arguments can be scalar, vector or matrix. The resultant type will be
 the same as the type and shape of its arguments.

UCASE

 syntax: UCASE( string )  ! convert to upper case

 For example:

 UCASE(`this is a string')   produces   `THIS IS A STRING'
 LCASE(`THIS IS A STRING')   produces   `this is a string'
 TCASE(`ThIs iS A StRiNg')   produces   `tHiS Is a sTrInG'

LCASE

 syntax: LCASE( string )  ! convert to lower case

 For example:

 UCASE(`this is a string')   produces   `THIS IS A STRING'
 LCASE(`THIS IS A STRING')   produces   `this is a string'
 TCASE(`ThIs iS A StRiNg')   produces   `tHiS Is a sTrInG'

TCASE

 syntax: TCASE( string )  ! toggle the case

 For example:

 UCASE(`this is a string')   produces   `THIS IS A STRING'
 LCASE(`THIS IS A STRING')   produces   `this is a string'
 TCASE(`ThIs iS A StRiNg')   produces   `tHiS Is a sTrInG'

STRING

 syntax: STRING( string )  ! produce a quote string

 Examples:

 STRING(test case)   produces  `test case'
 STRING(test)        produces  `test'
 STRING(`test')      produces  `test'

 This function is useful in command scripts, where you want to pass a
 string to the script as a parameter.  For example,   @script test
 where script.pcm is as follows:

 x = string(?1)//` is a quote string'
 display x

 would display    test is a quote string
 Note that the user does not have to supply the quotes around the
 parameter  test.

ICLOSE

 syntax:  ICLOSE( x,s ) ! returns first j where abs(x[j]-s) is a minimum

 This function returns the index of the vector x which corresponds to
 where x is closest to the value of s, a scalar.

IEQUAL

 syntax:  IEQUAL( x,s ) ! returns first j where x[j] = s

 This function returns the index of the vector x which corresponds to
 where x is equal to the value of s, a scalar.

CONVOL

 syntax:  CONVOL( x, y, n ) ! convolute or deconvolute x with y

 This function convolutes or deconvolutes the input vector, x, with
 the specified blurring vector, y.  The result is a vector the same
 length as x. 

Additional Information on:

  • n=0
  • n=1
  • n=-1
  • COSINT

     syntax: COSINT( x )     ! cosine integral
    
     The argument can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument.
    

    DATE

     syntax: DATE  ! returns the current date with the format dd-mmm-yyyy
    
     This function has no arguments, and returns a character string.
    
     For example:      DATE   produces   ` 6-AUG-1995'
                       TIME   produces   `10:36:25'
    

    TIME

     syntax: TIME  ! returns the current time with the format hh:mm:ss
    
     This function has no arguments, and returns a character string.
    
     For example:      DATE   produces   ` 6-AUG-1995'
                       TIME   produces   `10:36:25'
    

    DAWSON

     syntax: DAWSON( x )     ! Dawson integral
    
     The argument can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument.
    

    DERIV

     syntax:  DERIV( x,y{,`keyword'} )
     keyword values:  SMOOTH, INTERP, FC, LAGRANGEn (n=3,5,7,9)
     keyword default: SMOOTH
    
     This function evaluates the first derivatives of the vector y,
     the dependent variable, with respect to vector x, the independent
     variable, at the x locations. The vector x must be strictly
     monotonically increasing. The output of this function is a vector
     with the same length as the vectors x and y.  The algorithm
     that is employed depends on the keyword that is used. The default
     is use smoothing splines.
    

    Additional Information on:

  • SMOOTH
  • INTERP
  • LAGRANGEn
  • FC
  • example
  • DET

     syntax:  DET( m )  ! returns the determinant of matrix m
    
     The function DET(m) returns the determinant of the matrix m, which
     must be a square matrix. The output is a scalar.
    
     Beware: the determinant of a reasonably sized matrix can get very large,
             or very small, leading to over/underflows.  
    

    DIGAMMA

     syntax: DIGAMMA( x )  ! digamma psi function
    
     The argument can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument.
    

    DILOG

     syntax: DILOG( x )  ! dilogarithm function
    
     The argument can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument.
    

    EIGEN

     syntax:  EIGEN( m )  ! returns eigenvectors and eigenvalues
    
     If matrix m is an n by n symmetric matrix, then EIGEN(m) returns a matrix
     with n rows and n+1 columns.  Column n+1 contains the eigenvalues, while
     columns 1 to n are the eigenvectors of the symmetric matrix m. The
     eigenvector x and the eigenvalue s of matrix m satisfy   m<>x = s*x
    

    Additional Information on:

  • check
  • example
  • ELTIME

     syntax: ELTIME( v )
    
     The ELTIME function requires 1 argument, which can be a scalar, vector or
     matrix, but it is intended to have a scalar argument. ELTIME returns the
     elapsed time in seconds. Initialize the time by calling ELTIME(0), which
     return 0, and then subsequent calls of ELTIME(s), with s > 0, will give
     the elapsed time since initialization.  If not initialized, ELTIME(s),
     with s > 0, returns the elapsed time since midnight. ELTIME(s), with
     s < 0, always returns the elapsed time since midnight. 
    
     call       result
     --------------------------------------------------------------------
     ELTIME(0)  returns 0 ( initialization )
     ELTIME(1)  returns elapsed time since initialization, or 
                if not initialized, returns elapsed time since midnight 
     ELTIME(-1) returns elapsed time since midnight
    

    elliptic-integrals

     syntax: FINELLIC( x,p ) ! elliptic integral, first kind
             EINELLIC( x,p ) ! elliptic integral, second kind
    
     The argument can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument.
    

    EXIST

     syntax:  EXIST( string )
    
     This function accepts a string as it argument and returns a 1 if the
     string is an existing variable name, and 0 if not.
    

    EXPAND

     syntax: EXPAND( string )
    
     The EXPAND function accepts a string as argument. The result is also
     a string. It parses the argument, expanding any expression variables
     it finds. If an expression variable, contained in the argument, also
     contains expression variables then they are also expanded, and so on
     until all such expression variables have been expanded.  Syntax
     checking is done during the expansion. The maximum length of a
     completely expanded expression is 2500 characters. For example,
    
     A=2             ! define a scalar A
     B=3             ! define a scalar B
     FC1=`(A+B)/A'   ! define a text variable FC1
     FC2=`SQRT(A/B)' ! define a text variable FC2
     FC3=`FC1*FC2'   ! define a text variable FC3
     FC4=`FC3+4*FC2' ! define a text variable FC4
     =FC4            ! displays `FC3+4*FC2'
     =EXPAND(FC4)    ! displays `(((A+B)/A)*(SQRT(A/B)))+4*(SQRT(A/B))'
     =EVAL(FC4)      ! displays 5.307228
    

    EXP

     syntax: EXP( x )  ! e^(x)
    
     The argument can be a scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument. 
    

    exponential-integrals

             EXPINT( x )     ! exponential integral
             EI( x )         ! = -EXPINT( -x )
             EXPN( x,n )     ! exponential integral, order n
    
     The arguments can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its arguments.
    

    FACTORIAL

     syntax: FACTORIAL( x )  ! factorial,  x!
    
     The argument can be a scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument. 
    

    Fermi-Dirac

     syntax: FERDIRAC( x,p )  ! Fermi-Dirac function
    
     The arguments can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its arguments.
    

    EVAL

     syntax: EVAL( string )
    
     Text variables can be used in numeric expressions, as so called expression
     variables, to shorten or to simplify an expression. Parentheses around the
     expression variable are assumed during numeric evaluation. For example:
     T=`A+B'  followed by  Y=X*T  which is equivalent to Y=X*(A+B). A text
     variable will be numerically evaluated if it is a numeric operand or the
     argument of a numeric function. Otherwise, a text variable is treated as a
     character string. Use the EVAL function to force numeric evaluation. The
     type of result, that is, scalar, vector, or matrix, depends on the
     evaluated expression.
    

    Additional Information on:

  • example
  • FFT

     syntax:  FFT( y{,`keyword'} )
     keyword values:  AMP&PHASE, COS&SIN
     keyword default: AMP&PHASE
    
     This function calculates the discrete fast Fourier transform of the
     input vector y. By default, FFT returns a matrix with the amplitudes in
     the first column and the phases in the second column. The phases are in
     degrees. If the `COS&SIN' keyword is used, FFT returns a matrix
     containing the Fourier coefficients, with the cosine coefficients in the
     first column and the sine coefficients in the second. If the length of
     the y vector is 2N, the output matrix will have N+1 rows.
    

    Additional Information on:

  • COS&SIN
  • restrictions
  • example
  • Fresnel-integrals

     syntax: FREC1( x )    ! Fresnel integral, order 1
             FREC2( x )    ! Fresnel integral, order 2
             FRES1( x )    ! associated Fresnel integral, order 1
             FRES2( x )    ! associated Fresnel integral, order 2
    
     The argument can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument.
    

    gamma

     syntax: GAMMA( x )       ! gamma function
             LOGAM( x )       ! log( gamma(x) )
             GAMMACIN( x,a )  ! incomplete gamma function
             GAMMAIN( x,a )   !      "       "      "
             GAMMATIN( x,a )  !      "       "      "
             GAMMQ( x,a )     !      "       "      "
    
     The arguments can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its arguments.
    

    hypergeometric

     syntax: HYPGEO( a,b,c,x )  ! hypergeometric function
             CHLOGU( a,b,x )    ! logarithmic confluent hypergeometric function
    
     The arguments can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its arguments.
    

    IDENTITY

     syntax:  IDENTITY( n )  ! returns the identity matrix of order n
    
     The function IDENTITY(n) returns the identity matrix of order n. That
     is, the n by n matrix with 1's on the diagonal and zeros elsewhere.
     For example:
                                    | 1 0 0 0 |
                                    | 0 1 0 0 |
     IDENTITY(4) returns the matrix | 0 0 1 0 |
                                    | 0 0 0 1 |
    

    INT

     syntax: INT( x )   ! integer part
    
     The argument can be a scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument. 
    

    NINT

     syntax: NINT( v )  ! nearest integer,  x+sign(1,x)/2
    
     The argument can be a scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument. 
    

    JOIN

     syntax:  JOIN( x, y )
    
     The arguments must both be vectors.  JOIN produces a matrix with 3 columns.
     The first column is the intersection of x and y, that is, if you enter
     m=join(x,y) then m[*,1] is the same as x/&y.  m[i,2] is the index of x from
     which m[i,1] was taken, and m[i,3] is the index of y from which m[i,1] was
     taken.  If the vector arguments are ordered, the JOIN function will proceed
     much faster than if they are unordered.
    

    Additional Information on:

  • example
  • INTEGRAL

     syntax:  INTEGRAL( x,y{,`keyword'} )
     keyword values:  SMOOTH
     keyword default: SMOOTH
    
     This function integrates the vector y, the dependent variable, with
     respect to vector x, the independent variable.  The vector x must be
     strictly monotonically increasing. The output of this function is a 
     vector with the same length as vectors x and y. The last element of
     this output vector is the integral over the full range of x.  The
     method used depends on the keyword. Currently, there is only one type
     of integration available.
    

    Additional Information on:

  • example
  • SMOOTH
  • interpolation

     syntax:  INTERP( x,y,xout )            ! spline (mono. incr. data)
              INTERP( x,y,xout,`FC' )       ! monotone piecewise cubic
              INTERP( x,y,xout,`LINEAR' )   ! linear
              INTERP( x,y,xout,`LAGRANGE' ) ! general Lagrange
              SPLINTERP( x,y,n )            ! spline (no restrictions on x)
    
     Interpolation means that the output will always pass through the original
     data. Smoothing means that the output may not pass through the original
     data. There are two functions for interpolation, INTERP and SPLINTERP.
     With INTERP, you can do linear, Fritsch-Carlson, Lagrange, or spline
     interpolation (which requires strictly monotonically increasing data).
     The SPLINTERP function uses splines, but the data does not need to be
     increasing.
    

    Additional Information on:

  • INTERP
  • SPLINTERP
  • IFFT

     syntax: IFFT( matrix )
             IFFT( matrix,`COS&SIN' )
     keyword values:  AMP&PHASE, COS&SIN
     keyword default: AMP&PHASE
    
     This function calculates the inverse discrete Fourier transform of
     the input 2 column matrix. This matrix is usually calculated by the
     FFT function, thus reconstructing the original vector. By default,
     IFFT expects amplitudes and phases, where the phases are in degrees.
     If the `COS&SIN' keyword is used, IFFT expects the Fourier coefficients.
     If the input matrix has N rows, the function returns a vector with
     length 2*(N-1). The principle usage of IFFT is to modify some of the
     amplitudes and note their effect on the original data. A typical
     application would be data smoothing, in which the user would zero out
     amplitudes of the higher order harmonics before using the IFFT function.
    

    Kelvin

     syntax: BER( x )    ! Kelvin function, first kind
             BEI( x )    !   "        "       "    "  
             KER( x )    ! Kelvin function, second kind
             KEI( x )    !   "        "       "     " 
    
     The argument can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument.
    

    Legendre

     syntax: PLMU( n,m,x )   ! unnormalized assoc. Legendre function, order n
             PLMN( n,m,x )   ! normalized assoc. Legendre function, order n
    
     The arguments can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its arguments.
    

    logarithms

     syntax: LOG( x )    ! logarithm, base e
             LN( v )     ! logarithm, base e
             LOG10( v )  ! logarithm, base 10
    
     The argument can be a scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument. 
    

    LOOP

     syntax: LOOP( f(i), i, range )
    
     The LOOP function accepts a scalar or a vector as its first argument. The
     second argument must be a previously declared dummy variable. A dummy
     variable is declared with the SCALAR\DUMMY command. The third argument is
     the range of the dummy variable, and must be a vector. The first argument
     would normally be some function of the dummy variable, but it is not
     necessary that the dummy variable appear in the first argument.
    
     The LOOP function simply loops over the range of the dummy variable,
     filling the output with the appropriate value from the first argument.
    

    Additional Information on:

  • general
  • 1_example
  • 2_example
  • SUM

     syntax: SUM( f(i), i, range )
    
     The SUM function accepts a scalar, a vector, or a matrix as its first
     argument. The second argument must be a previously declared dummy
     variable. A dummy variable is declared with the SCALAR\DUMMY command.
     The third argument is the range of the dummy variable, and must be a
     vector. The first argument would normally be some function of the dummy
     variable, but it is not necessary that the dummy variable appear in the
     first argument. If f(i) is a scalar, the result is a scalar. If f(i) is
     a vector, the result is a vector. If f(i) is a matrix, the result is a
     matrix.
    

    Additional Information on:

  • general
  • examples
  • PROD

     syntax: PROD( f(i), i, range )
    
     The PROD function accepts a scalar, a vector, or a matrix as its first
     argument. The second argument must be a previously declared dummy
     variable. A dummy variable is declared with the SCALAR\DUMMY command.
     The third argument is the range of the dummy variable, and must be a
     vector. The first argument would normally be some function of the dummy
     variable, but it is not necessary that the dummy variable appear in the
     first argument. If f(i) is a scalar, the result is a scalar. If f(i) is
     a vector, the result is a vector. If f(i) is a matrix, the result is a
     matrix.
    

    Additional Information on:

  • general
  • examples
  • RSUM

     syntax: RSUM( f(i), i, range )
    
     The RSUM function accepts a scalar or a vector as its first argument.
     The second argument must be a previously declared dummy variable. A dummy
     variable is declared with the SCALAR\DUMMY command. The third argument is
     the range of the dummy variable, and must be a vector. The first argument
     would normally be some function of the dummy variable, but it is not
     necessary that the dummy variable appear in the first argument. The RSUM
     function calculates the running sums. If the first argument is a scalar,
     the last element of the RSUM output vector is the total sum. If the first
     argument is a vector, the last column of the RSUM output matrix is the
     total sum.
    

    Additional Information on:

  • general
  • examples
  • RPROD

     syntax: RPROD( f(i), i, range )
    
     The RPROD function accepts a scalar or a vector as its first argument.
     The second argument must be a previously declared dummy variable. A
     dummy variable is declared with the SCALAR\DUMMY command. The third
     argument is the range of the dummy variable, and must be a vector. The
     first argument would normally be some function of the dummy variable, but
     it is not necessary that the dummy variable appear in the first argument.
     The RPROD function calculates the running products. If the first argument
     is a scalar, the last element of the RPROD output vector is the total
     product. If the first argument is a vector, the last column of the RPROD
     output matrix is the total product.
    

    Additional Information on:

  • general
  • examples
  • INVERSE

     syntax:  INVERSE( m )  ! returns the inverse of matrix m
    
     The function INVERSE(m) returns the inverse matrix of the matrix m,
     which must be a square matrix. The output is a matrix the same shape
     as m. The answer can be checked by using the inner product operator,
    
     e.g., invm=INVERSE(m) ! find the inverse of m
           =m<>invm        ! this should be close to the identity matrix
    

    MAX

     syntax: MAX( v1{,v2,...} )
    
     The MAX function accepts from 1 to a maximum of 20 arguments. If only
     one argument is supplied, the maximum element is returned. If two or
     more arguments are supplied, the arguments are compared element by
     element, and the maximum values are returned. The arguments can be
     scalars, vectors or matrices, but cannot be mixed and all arrays must
     be the same size. Vector arguments result in a vector with the same
     length as the arguments, and matrix arguments result in a matrix with
     the same dimensions as the arguments.
    
     arguments   result  example
     -----------------------------------------------------------------------
     one vector  scalar  MAX(x)              = maximum(x[1],x[2],...,x[#])
     one matrix  scalar  MAX(m)              = maximum(m[1,1],...,m[#,#])
     scalars     scalar  MAX(a,b,...)        = maximum(a,b,...)
     vectors     vector  MAX(x,y,...)[j]     = maximum(x[j],y[j],...)
     matrices    matrix  MAX(m1,m2,...)[i,j] = maximum(m1[i,j],m2[i,j],...)
    

    MIN

     syntax: MIN( v1{,v2,...} )
    
     The MIN function accepts from 1 to a maximum of 20 arguments. If only
     one argument is supplied, the minimum element is returned. If two or
     more arguments are supplied, the arguments are compared element by
     element, and the minimum values are returned. The arguments can be
     scalars, vectors or matrices, but cannot be mixed and all arrays must
     be the same size. Vector arguments result in a vector with the same
     length as the arguments, and matrix arguments result in a matrix with
     the same dimensions as the arguments.
    
     arguments   result  example
     -----------------------------------------------------------------------
     one vector  scalar  MIN(x)              = minimum(x[1],x[2],...,x[#])
     one matrix  scalar  MIN(m)              = minimum(m[1,1],...,m[#,#])
     scalars     scalar  MIN(a,b,...)        = minimum(a,b,...)
     vectors     vector  MIN(x,y,...)[j]     = minimum(x[j],y[j],...)
     matrices    matrix  MIN(m1,m2,...)[i,j] = minimum(m1[i,j],m2[i,j],...)
    

    MOD

     syntax: MOD( x,y )
    
     The MOD function requires 2 arguments, which can be a scalar, vector or
     matrix. The resultant type will be the same as the type and shape of its
     argument, for example, a vector argument results in a vector with the
     same length as the argument. 
    
     arg1    arg2    result  example
     -------------------------------------------------------------------
     scalar  scalar  scalar  MOD(a,b) = a-b*INT(a/b)
     vector  vector  vector  MOD(x,y)[j] = x[j]-y[j]*INT(x[j]/y[j])
     scalar  vector  vector  MOD(a,x)[j] = a-x[j]*INT(a/x[j])
     vector  scalar  vector  MOD(x,a)[j] = x[j]-a*INT(x[j]/a)
     matrix  matrix  matrix  MOD(m1,m2)[i,j] =
                                  m1[i,j]-m2[i,j]*INT(m1[i,j]/m2[i,j])
     scalar  matrix  matrix  MOD(a,m)[i,j] = a-m[i,j]*INT(a/m[i,j])
     matrix  scalar  matrix  MOD(m,a)[i,j] = m[i,j]-a*INT(m[i,j]/a)
    

    polynomials

     syntax: CHEBY( n,x )       ! Chebyshev polynomial coefficient
             HERMITE( n,x )     ! Hermite polynomial coefficient
             JACOBI( a,b,n,x )  ! Jacobi polynomial coefficient
             LAGUERRE( n,x )    ! Laguerre polynomial coefficient
             LAGENDRE( n,x )    ! Legendre polynomial coefficient
             POICA( a,n,x )     ! Poisson-Charlier polynomial coefficient
    
     The arguments can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its arguments.
    

    positive-difference

     syntax: DIM( x,y )
    
     The DIM function requires 2 arguments.  The arguments can be scalars,
     vectors or matrices, but vectors and matrices cannot be mixed, and all
     arrays must be the same size. The resultant type will be the same as the
     type and shape of its argument, for example, a vector argument results
     in a vector with the same length as the argument.
    
     arg1    arg2    result  example
     ------------------------------------------------------------------
     scalar  scalar  scalar  DIM(a,b) = max(0,a-b)
     vector  vector  vector  DIM(x,y)[j] = max(0,x[j]-y[j])
     scalar  vector  vector  DIM(a,x)[j] = max(0,a-x[j])
     vector  scalar  vector  DIM(x,a)[j] = max(0,x[j]-a)
     matrix  matrix  matrix  DIM(m1,m2)[i,j] = max(0,m1[i,j]-m2[i,j])
     scalar  matrix  matrix  DIM(a,m)[i,j] = max(0,a-m[i,j])
     matrix  scalar  matrix  DIM(m,a)[i,j] = max(0,m[i,j]-a)
    

    prime-factors

     syntax:  PFACTORS( n ) ! returns the prime factors of n
    
     This function returns a vector containing the prime factors of the
     scalar argument n.  For example, if you enter X=PFACTORS(420) then
     X=[2;2;3;5;7]. This function can be usefull in determining a good
     length for the input vector for the FFT function.
    

    probability

     syntax: BIVARNOR( h,k,r )  ! bivariate normal probability
             CHISQ( x,n )       ! chi-square probability
             CHISQINV( p,n )    ! inverse chi-square probability
             PROB( p,n )        ! probability integral of chi-square dist.
             GAUSS( x )         ! Gaussian, normal, probability
             GAUSSIN( p )       ! inverse Gaussian
             NORMAL( x,a,b )    ! normalized Gaussian distribution
             FISHER( m,n,x )    ! Fisher F-distribution
             STUDENT( t,n )     ! Student t-distribution
             STUDENTI( p,n )    ! inverse Student t-distribution
             ERF( x )           ! error function, integral of Gaussian dist.
             AERF( x )          ! inverse error function
             ERFC( x )          ! complementary  error function
             TINA( x,a,b,c )    ! normalized tina resolution
    
     The arguments can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its arguments.
    

    Additional Information on:

  • NORMAL
  • FISHER
  • TINA
  • Rademacher

     syntax: RADMAC( k,x )  ! Rademacher function
    
     The arguments can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its arguments.
    

    RAN

     syntax: RAN( v )
    
     The RAN function returns a random number(s) and requires 1 argument,
     which can be a scalar, vector or matrix. The resultant type will be the
     same as the type and shape of its argument, for example, a vector
     argument results in a vector with the same length as the argument. RAN
     uses the current value of SEED to generate the next random number,
     0 <= RAN(v) < 1. The initial value for the random number seed is 12345.
     Every time a random number is requested, either from the RAN function or
     from the GENERATE\RANDOM command, the seed is updated. You can change the
     SEED value with the SET SEED command.
    

    RCHAR

     syntax: RCHAR( scalar{,format} )
    
     The RCHAR function accepts a numeric scalar as first argument and
     returns a string. It converts the numeric value to a character string
     using PHYSICA's own format. You can specify your own format string by
     including it as the second optional argument. For example,
    
     function               result
     ------------------------------------
     RCHAR(-1.234)          `-1.234'
     RCHAR(PI)              `3.141593'
     RCHAR(2*PI,`E10.4')    `0.6283E+01'
    

    Additional Information on:

  • example
  • FOLD

     syntax: FOLD( x,n )  ! fold vector x into a matrix with n rows
    
     The FOLD function has two arguments. The first must be a vector, and the
     second a scalar. The result is a matrix formed by folding the data in the
     vector into the columns of a matrix. Suppose that vector x has m
     elements. FOLD(x,n)[i,j] = x[i+(j-1)l]
                         for i = 1,2,...,n and j = 1,2,...,m/n. 
     Note that m must be divisible by n.
    

    Additional Information on:

  • example
  • UNFOLD

     syntax: UNFOLD( m )  ! unfold matrix m into a vector
    
     The UNFOLD function has one argument, which must be a matrix. The
     result is a vector formed by unfolding the data in the rows of
     matrix. Suppose that matrix m has nc columns and nr rows.
     UNFOLD(m)[j+(i-1)n_{c}] = m[i,j]
      for i = 1,2,...,nr; and j = 1,2,...,nc.
    

    Additional Information on:

  • example
  • ROLL

     syntax: ROLL( v,n )     
    
     The ROLL function accepts either a vector or a matrix as its first
     argument, and returns either a vector or a matrix. It shifts the elements
     of a vector or the rows of a matrix by the specified step size, n, which
     should be a scalar.
    
     n>0 -- the last n elements of the vector or the last n rows of the
            matrix are rolled around to the beginning
     n=0 -- the vector or matrix is returned unchanged
     n<0 -- the first n elements of the vector or the first n rows of the
            matrix are rolled around to the end
     If n is non-integral, then linear interpolation is used to generate
     new values. 
    

    Additional Information on:

  • 1-example
  • 2-example
  • STEP

     syntax: STEP( v,n )
    
     The STEP function accepts either a vector or a matrix as its first
     argument, and returns either a vector or a matrix. It shifts the elements
     of a vector or the rows of a matrix by the specified step size, n, which
     should be a scalar.
    
     n>0 -- the last n elements of the vector or the last n rows of the
            matrix are lost
     n=0 -- the vector or matrix is returned unchanged
     n<0 -- the first n elements of the vector or the first n rows of the
            matrix are lost
     If n is non-integral, then linear interpolation is used to generate
     new values.
    

    Additional Information on:

  • 1-example
  • 2-example
  • WRAP

     syntax: WRAP( matrix,n )
    
     The WRAP function accepts a matrix as its first argument, and returns a
     matrix. It wraps the column elements of a matrix by the specified step
     size, n, which should be a scalar.   
    
     n>0 -- the column elements of the matrix are shifted down. The first
            n elements in the first column are zero filled, then the last
            n elements of each column are brought into the next column.
            The last n elements in the last column are lost.
     n=0 -- the matrix is returned unchanged
     n<0 -- the column elements of the matrix are shifted up. The first n
            elements in the first column are lost. The first n elements of
            each column are brought into the preceeding column.  The last
            n elements in the last column are zero filled.
     If n is non-integral, n is truncated to an integer.
    

    Additional Information on:

  • example
  • SIGN

     syntax: SIGN( x,y )
    
     The SIGN function requires 2 arguments, which can be a scalar, vector or
     matrix. The resultant type will be the same as the type and shape of its
     argument, for example, a vector argument results in a vector with the
     same length as the argument. 
    
     arg1    arg2    result  example
     ----------------------------------------------------------------------
     scalar  scalar  scalar  SIGN(a,b) = |a|(sign of b)
     vector  vector  vector  SIGN(x,y)[j] = |x[j]|(sign of y[j])
     scalar  vector  vector  SIGN(a,x)[j] = |a|(sign of x[j])
     vector  scalar  vector  SIGN(x,a)[j] = |x[j]|(sign of a)
     matrix  matrix  matrix  SIGN(m1,m2)[i,j] = |m1[i,j]|(sign of m2[i,j])
     scalar  matrix  matrix  SIGN(a,m)[i,j] = |a|(sign of m[i,j])
     matrix  scalar  matrix  SIGN(m,a)[i,j] = |m[i,j]|(sign of a)
    

    sine-integral

     syntax: SININT( x )     ! sine integral
    
     The argument can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument.
    

    smoothing

     syntax: SMOOTH( x,y,xout{,weights } ) ! x and xout must be mono. incr.
             SPLSMOOTH( x,y,n{,weights } ) ! returns a n by 2 matrix 
             SAVGOL( n,m,y )               ! uses Savitzky-Golay filters
    
     Smoothing means that the output may not pass through the original data.
     Interpolation means that the output will always pass through the original
     data. There are three smoothing functions. SMOOTH and SPLSMOOTH use
     splines under tension, while SAVGOL uses Savitzky-Golay filters.
     SMOOTH requires monotonically increasing data, SPLSMOOTH does not.
     SAVGOL assumes equally spaced data.
    

    Additional Information on:

  • SMOOTH
  • SPLSMOOTH
  • SAVGOL
  • equation-solver

     syntax:  GAUSSJ( matrix, vector )
    
     The function GAUSSJ(m,b) solves the system of equations m<>x = b where
     m is a square matrix and b is a vector, and returns x, the vector of
     solutions. The matrix must be square, and the length of the vector must
     be the row dimension of the matrix.  The output is a vector of the same
     length. The answer can be checked by using the outer product operator,
     e.g., x=GAUSSJ(m,b)  ! to solve the system of equations
           =b-m<>x        ! compare this result with the original b vector
    

    Additional Information on:

  • example
  • SQRT

     syntax: SQRT( x )   ! square root
    
     The argument can be a scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument. 
    

    EQS

     syntax: EQS( str1, str2 )  ! returns 1 if str1=str2, otherwise 0
    
     This function accepts two strings as arguments and returns the scalar
     value 1 if true and 0 if false.
    

    NES

     syntax: NES( str1, str2 )  ! returns 1 if str1~=str2, otherwise 0
    
     This function accepts two strings as arguments and returns the scalar
     value 1 if true and 0 if false.
    

    SUB

     syntax: SUB( str1, str2 )  ! returns 1 if str2 contains str1, otherwise 0
    
     This function accepts two strings as arguments and returns the scalar
     value 1 if true and 0 if false.
    

    SUP

     syntax: SUP( str1, str2 )  ! returns 1 if str1 contains str2, otherwise 0
    
     This function accepts two strings as arguments and returns the scalar
     value 1 if true and 0 if false.
    

    CLEN

     syntax: CLEN( string )  ! returns length of string
    
     The CLEN function accepts only a string as argument. It returns the
     number of characters in the string.  The string can be a literal quote
     string or a scalar text variable. It cannot be an array text variable.
    

    Struve

     syntax: STRUVE0( x )   ! Struve function, first order
             STRUVE1( x )   ! Struve function, second order
    
     The argument can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its argument.
    

    INDEX

     syntax: INDEX( string1,string2 ) ! position of string2 in string1, or 0
    
     The INDEX function accepts two strings as arguments and returns a
     scalar value. If the second string is a subset of the first string
     it returns the substring's starting position. If the second argument
     occurs more than once in the first, the starting position of the first
     (leftmost) occurence is returned. If the second does not occur in the
     first, the value 0 is returned. For example,
    
     function call             result
     ----------------------------------
     INDEX(`abc',`abc')          1
     =INDEX(`abcd',`abc')        1
     =INDEX(`abc',`abcd')        0 
     =INDEX(`xxabcabc',`abc')    3
    

    TRANSLATE

     syntax: TRANSLATE( string )
    
     This function returns:
      VMS:  the translation of the logical name `string'
      UNIX: the translation of the environment variable `string'
    
     If `string' has no translation, TRANSLATE returns `string'.
    

    trigonometric

     Except for the ATAN2 and ATAN2D functions which require 2 arguments, the
     trig functions all require 1 argument, which can be a scalar, vector or
     matrix.  The resultant type of a trig function will be the same as the
     type and shape of its argument. 
    
     function    description         function description
     -----------------------------------------------------------------
     SIN(x)      sine                SINH(x)  hyperbolic sine
     SIND(x)     sine (deg)
     COS(x)      cosine              COSH(x)  hyperbolic cosine
     COSD(x)     cosine (deg)
     TAN(x)      tangent             TANH(x)  hyperbolic tangent
     TAND(x)     tangent (deg) 
     COT(x)      cotangent           COTH(x)  hyperbolic cotangent
     SEC(x)      secant              SECH(x)  hyperbolic secant
     CSC(x)      cosecant            CSCH(x)  hyperbolic cosecant
     ASIN(x)     arcsine             ASINH(x) hyperbolic arcsine
     ASIND(x)    arcsine (deg)
     ACOS(x)     arccosine           ACOSH(x) hyperbolic arccosine
     ACOSD(x)    arccosine (deg)
     ATAN(x)     arctangent          ATANH(x) hyperbolic arctangent
     ATAND(x)    arctangent (deg)
     ACOT(x)     arccotangent        ACOTH(x) hyperbolic arccotangent
     ASEC(x)     arcsecant           ASECH(x) hyperbolic arcsecant
     ACSC(x)     arccosecant         ACSCH(x) hyperbolic arccosecant
    

    Additional Information on:

  • ATAN2
  • ATAN2D
  • variable-length

     syntax: LEN( x )   ! returns a scalar = the length of vector x
             VLEN( v )  ! returns a vector of dimensional sizes
    
     LEN only accepts a vector as argument. It returns the length of the
     vector argument as a scalar. VLEN accepts either a vector or a matrix
     as the argument and returns a vector with length equal to the number of
     dimensions of v. If v is a vector, VLEN(v) will be a vector of length 1,
     and VLEN(v)[1] = the length of v.  If v is a matrix, VLEN(v) will be a
     vector of length 2, and VLEN(v)[1] = the number of rows of v, VLEN(v)[2]
     = the number of columns of v.
    

    VARNAME

     syntax: VARNAME( name )  ! converts variable name into string
    
     The VARNAME function accepts a variable, either text or numeric, as
     its argument, and converts that name into a character string.  This
     function can be useful in macros where a variable is passed to the
     macro as a ? parameter. You could then convert the name to a string
     for display or manipulation. For example, the following macro shows
     one way in which the VARNAME function could be used.
                       t1=varname(?1)
                       t2=varname(?2)
                       graph ?1 ?2
                       text `graph of '//t1//` vs '//t2
    

    vector-coupling

     syntax: CLEBSG( j1,j2,j,m1,m2,m )         ! Clebsch-Gordan coefficient
             CLEBSG( j1,j2,j )                 !        "           " 
             WIGN3J( j1,j2,j,m1,m2,m )         ! Wigner 3-j function
             WIGN3J( j1,j2,j )                 !    "      "     "
             WIGN6J( j1,j2,j,m1,m2,m )         ! Wigner 6-j function
             WIGN9J( j1,j2,j,m1,m2,m,n1,n2,n ) ! Wigner 9-j function
             RACAHC( a,b,c,d,e,f )             ! Racah W-function
             JAHNUF( j1,j2,m2,m1,j,m )         ! Jahn U-function
    
     The arguments can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its arguments.
    

    FIRST

     syntax:  FIRST( x )   ! the starting index 
    
     FIRST returns the starting index for the vector x.  LAST returns the final
     index for the vector x.  The result of either function is a scalar.
     The length of vector x is LAST(x)-FIRST(x)+1 which is equal to LEN(x).
    

    LAST

     syntax:  LAST( x )    ! the final index
    
     FIRST returns the starting index for the vector x.  LAST returns the final
     index for the vector x.  The result of either function is a scalar.
     The length of vector x is LAST(x)-FIRST(x)+1 which is equal to LEN(x).
    

    WALSH

     syntax: WALSH( k,x )   ! Walsh function
    
     The arguments can be scalar, vector or matrix. The resultant type will be
     the same as the type and shape of its arguments.
    

    WHERE

     syntax: WHERE( x )  ! returns indices where x is not zero
    
     The WHERE function accepts a vector as its argument and returns the
     indices where x is not equal to zero. For example,
    
     function                         result
     -------------------------------------------------------------
     WHERE([-5:5]>0)                  [7;8;9;10;11]
     WHERE([-5:5]<=0)                 [1;2;3;4;5;6]
    

    Additional Information on:

  • example