Manuals >Reference >Parameter Extraction Language
Print version of this Book (PDF file)
prevnext

Expressions

As explained in the Data Types section, each type of data can be considered a simple expression. The primitive data types can make up more complex expressions by applying functions (such as log, or operators such as + ). In this section, expr denotes an expression; string_expr denotes a string expression.

(expr)     expr + expr      expr - expr     expr * expr

 

Parentheses force precedence and group expressions.

expr / expr     expr//expr

 

IC-CAP objects, including data sets, can be named using a slash (/). These same data sets can be used as arguments in a divide operation. To ensure the slash is understood as the divide operator, surround it with white space, or enter  a double slash (//). If  the slash is followed by a digit, divide is also understood, because a data set name in IC-CAP cannot start with a digit. The expression (ic)/(ib) is an example of another technique.

expr ^ expr     expr ** expr

 

These operators express exponentiation, and are equivalents.

string_expr & string_expr

 

As in HP BASIC, this operator performs string concatenation.

log(expr)

Performs a natural log function. For more information, refer to Built-in Functions and Calls to the Function Library.

To complete a computation, most operations make reasonable attempts to promote certain operands. For example, ib + 2e-6 promotes the scalar number 2e-6 to be a data set that, in turn, can be added to the data set ib.

For most arithmetic operations performed on a data set, the function or operator is applied point-by-point, producing a data set. The behavior of individual functions in this regard is clarified in their individual descriptions in Built-in Functions.

There are some limitations in the usage of the 5 basic arithmetic operators in working with data sets. For example:

    • If ic is a data set, re-write 3//ic as 3*ic^ -1.
    • The expression ic^ib is not supported when both operands are data sets.
    • None of the binary operators * / + - ^ support an operation between a matrix and a data set.

The arithmetic in Programs is generally a complex floating point. Therefore, it is possible to see unexpected residue from integer or real arithmetic. For example:

 print (0+j)^2

may produce

 -1+j*1.22461E-16

rather than

 -1+j*0

This is due to finite precision in the library function that handles exponentiation of complex quantities.

Because complex arithmetic is used, success can occur where a function would be expected to fail in real arithmetic. For example

 acsh(.5)

yields

 0+j*1.05

The complex arithmetic provides a wider domain of valid inputs, but in cases where a real input should produce a real output, the complex arithmetic is indistinguishable from real arithmetic.


Caution


Using the binary operators + and - (which have a higher precedence when used with the j notation) will produce unexpected results.

       -1+j2 == -1-j*2
     (-1)+j2 == -1+j*2

Boolean Expressions

The expressions in this section can be used in the branching constructs (IF, IF...ENDIF, and WHILE...ENDWHILE), or can be used to generate the quantities 0 and 1. The abbreviation bool_expr denotes a boolean expression.


Note


There is a distinction between the = operator (used for assignment) and the == operator. BASIC uses = for both assignment and comparison.

In some circumstances, == may not behave as expected. For example, if you repeatedly increment the quantity 0.3 by the amount 0.025, the results may be slightly less (in the 15th decimal place) than the expected sequence of values: 0.325, 0.350, ... , 0.4. Under these circumstances, == may yield FALSE unexpectedly. This is an inherent problem of expressing decimal numbers in binary floating point format.


expr == expr

This operator tests for equality and can be used with string, integer, double, complex, and matrix types.

expr <> expr

This operator tests for inequality and can be used with string, integer, double, complex, and matrix types.

expr > expr     expr >= expr     expr < expr     expr <= expr

 

These operators designate the standard comparison operation found in BASIC languages and can be used with integers, doubles, and complex quantities. With complex quantities, imaginary parts are discarded. (You can apply the mag function to each quantity to compare magnitudes of complex quantities.)

bool_expr AND bool_expr bool_expr OR bool_expr NOT boolean_expr

 

Any non-zero integer, double, or complex number is considered TRUE. For example:

 IF 2 THEN PRINT 'hi' ! this always prints

A string with length >0 is TRUE. For example:

 IF "Hello world" THEN PRINT "HI TO YOU TOO"

prints the second expression in the string

 HI TO YOU TOO

Operators Precedence

The following is a list of operators in decreasing order of precedence. Operators listed on the same line have equal precedence.

( )    [ ]

Function calls, and array indexing, respectively

^    **

Exponentiation

+    -    &

The ampersand (&) is for string concatenation

==  <>  <  <=  >  >=

Comparison operators

NOT

AND

OR                      

=

Assignment

For example, it is TRUE that:

 -2^4 == -16 

because the precedence of  ^  exceeds that of  -  .

Calls to the Function Library

Any function in IC-CAP's Function Browser can be called, such as sin, cos, and RMSerror. This greatly expands the availability of functions in expressions, Programs, and Macros. Some examples are:

 x = sin(pi/4)   ! x takes on the value .707... 
x = linfit(ic,vc,0)   
! x becomes a temporary data set with 2 points
print x[0] , x[1]   ! slope and intercept are printed 

To review the arguments used in a function, refer to Chapter 8, "IC-CAP Functions," or create a stand-alone transform that uses the desired function and look at the resulting transform editor. For details on this procedure, refer to the section "Defining Transforms" in the User's Guide. To call the library function in a Program, Macro, or table element, supply arguments in the same order shown in the editor.

The functions may expect some data set arguments, some real number arguments, and some strings or Model or DUT parameter names. Expressions can be used for the data set arguments and real number arguments. For the parameter names, use actual parameter names, IC-CAP system variable names, or quoted strings, string variables, or string expressions. If a function requires a string as a flag or switch of some sort, quote it. Otherwise the system thinks you are referring to an identifier such as a Model parameter, a system variable, or a temporary variable in a Program or Macro. The following example might clarify this point:

 ! TwoPort requires strings as second and third arguments 
! string argument dictates what type conversion to do 
x = TwoPort(S_out,"S","Y")   ! this is OK 
x = TwoPort(S_out,S,Y)   ! this is not, although... 
S = "S"   ! initialize local variables S and Y 
Y = "Y" 
x = TwoPort(S_out,S,Y)   ! now this is OK 

This point is mentioned because the quotation marks are not necessary if you use TwoPort as the function in a simple stand-alone Transform. The only other function that is like TwoPort in this regard is USERC_system, which requires a string to use as an operating system command.

Spell calls to functions contained in IC-CAP's Function List must be spelled exactly as in the Function List.

The result from a call to a function in the library is usually a data set. For example:

 x = linfit(vc:log(ic.m),0)
! get slope and intercept for log(ic.m)
print x[0]   ! print the slope of log(ic.m)

On the other hand, there are 2 cases in which the result of a library function is a single number or matrix, and not a data set. This makes library function calls more convenient, or usable within expressions in table elements. For example:

 x = sin(pi/4)   ! x is now .70711 ...
x = mean(ic.s)   ! x is the average current value in ic.s

In the first example, sin is a function that can sometimes return a data set, if a data set is provided. In this example though, the input is a scalar number. Therefore, the system initializes x with a scalar number. A number of other functions behave like sin in this respect. They can be identified in the IC-CAP Functions List, because the Output of these functions is said to be a single number or an array, dependent on the Input Arguments.

In the second example, mean receives a data set as input. However, by definition it always produces a scalar, so x is initialized as a single number, and not a data set. A call to the variance, correlation, or RMSerror functions also produces a single number, and not a data set.

Some library functions, particularly extractions, yield null data sets; they do not appear to generate data, but they set parameters to new values.


prevnext